From bb9708b49d2752815df0c267c9d97f6951ac16c9 Mon Sep 17 00:00:00 2001 From: Anuj Chaudhari Date: Fri, 3 Jan 2025 06:10:26 -0800 Subject: [PATCH] Fix linter errors flagged with latest golanglint Signed-off-by: Anuj Chaudhari --- .golangci.yaml | 3 ++- command/deprecate_test.go | 4 ++-- component/output.go | 2 +- component/reader_test.go | 4 ++-- config/contexts_test.go | 2 +- log/logger.go | 6 +++--- .../testplugins/runtime-test-plugin-latest/cmd/test.go | 2 +- .../testplugins/runtime-test-plugin-v0_11_6/cmd/test.go | 2 +- .../testplugins/runtime-test-plugin-v0_25_4/cmd/test.go | 2 +- .../testplugins/runtime-test-plugin-v0_28_0/cmd/test.go | 2 +- .../testplugins/runtime-test-plugin-v0_90/cmd/test.go | 2 +- .../testplugins/runtime-test-plugin-v1_0_2/cmd/test.go | 2 +- test/plugin_e2e_test.go | 4 ++-- 13 files changed, 19 insertions(+), 18 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index 0e93d8ef6..ccba5b966 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -104,6 +104,7 @@ issues: - 'declaration of "(err|ctx)" shadows declaration at' - 'unnamedResult: consider giving a name to these results' - '(Expect directory permissions to be 0750 or less|Expect (WriteFile|file) permissions to be 0600 or less)' + - 'dot-imports: should not use dot imports' exclude-rules: - path: _test\.go @@ -164,4 +165,4 @@ run: # golangci.com configuration # https://github.com/golangci/golangci/wiki/Configuration service: - golangci-lint-version: 1.46.0 # use the fixed version to not introduce new linters unexpectedly + golangci-lint-version: 1.63.3 # use the fixed version to not introduce new linters unexpectedly diff --git a/command/deprecate_test.go b/command/deprecate_test.go index fce29730e..a5d371de0 100644 --- a/command/deprecate_test.go +++ b/command/deprecate_test.go @@ -9,8 +9,8 @@ import ( "github.com/spf13/cobra" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" + . "github.com/onsi/ginkgo/v2" //nolint:revive // Using dot import for readability in test files + . "github.com/onsi/gomega" //nolint:revive // Using dot import for readability in test files ) func TestCommand(t *testing.T) { diff --git a/component/output.go b/component/output.go index b15537544..d70417230 100644 --- a/component/output.go +++ b/component/output.go @@ -196,7 +196,7 @@ func (obw *objectwriter) SetKeys(_ ...string) { } // MarkDynamicKeys marks the headers as dynamic -func (obw *objectwriter) MarkDynamicKeys(dynamicKeys ...string) { +func (obw *objectwriter) MarkDynamicKeys(_ ...string) { // Object writer does not have the concept of dynamic keys fmt.Fprintln(obw.out, "Programming error, attempt to mark dynamic headers to object output") } diff --git a/component/reader_test.go b/component/reader_test.go index bd166aa88..51f89a9ae 100644 --- a/component/reader_test.go +++ b/component/reader_test.go @@ -7,8 +7,8 @@ import ( "os" "testing" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" + . "github.com/onsi/ginkgo/v2" //nolint:revive // Using dot import for readability in test files + . "github.com/onsi/gomega" //nolint:revive // Using dot import for readability in test files ) func TestComponent(t *testing.T) { diff --git a/config/contexts_test.go b/config/contexts_test.go index 866e95011..108cfa193 100644 --- a/config/contexts_test.go +++ b/config/contexts_test.go @@ -7,7 +7,7 @@ import ( "fmt" "testing" - . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/ginkgo/v2" //nolint:revive // Using dot import for readability in test files "github.com/onsi/gomega" "github.com/stretchr/testify/assert" diff --git a/log/logger.go b/log/logger.go index 6bc98eed4..3cc9a02ca 100644 --- a/log/logger.go +++ b/log/logger.go @@ -46,7 +46,7 @@ func getLogThreshold() int32 { if reqLogLevelStr != "" { requestedLogLevel, err := strconv.ParseUint(reqLogLevelStr, 10, 32) if err == nil { - return int32(requestedLogLevel) + return int32(requestedLogLevel) //nolint:gosec // overflow conversion does not apply } fmt.Fprintf(os.Stderr, "invalid value %q for %s\n", reqLogLevelStr, EnvTanzuCLILogLevel) } @@ -145,7 +145,7 @@ func (l *logger) Outputf(format string, args ...interface{}) { // V returns an InfoLogger value for a specific verbosity level. func (l *logger) V(level int) LoggerImpl { nl := l.clone() - nl.level = int32(level) + nl.level = int32(level) //nolint:gosec // overflow conversion does not apply return nl } @@ -184,7 +184,7 @@ func (l *logger) Clone() LoggerImpl { func (l *logger) CloneWithLevel(level int) LoggerImpl { return &logger{ threshold: l.threshold, - level: int32(level), + level: int32(level), //nolint:gosec // overflow conversion does not apply prefix: l.prefix, values: copySlice(l.values), callDepth: l.callDepth, diff --git a/test/compatibility/testplugins/runtime-test-plugin-latest/cmd/test.go b/test/compatibility/testplugins/runtime-test-plugin-latest/cmd/test.go index 0e87d2e5b..8c286d0cf 100644 --- a/test/compatibility/testplugins/runtime-test-plugin-latest/cmd/test.go +++ b/test/compatibility/testplugins/runtime-test-plugin-latest/cmd/test.go @@ -18,7 +18,7 @@ var ( testCmd = &cobra.Command{ Use: "test", Short: "A test command that parse the file and trigger the runtime apis", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { // Parse the file into array of apis struct apis, err := compatibilitytestingcore.ParseRuntimeAPIsFromFile(filepath) if err != nil { diff --git a/test/compatibility/testplugins/runtime-test-plugin-v0_11_6/cmd/test.go b/test/compatibility/testplugins/runtime-test-plugin-v0_11_6/cmd/test.go index 3ba6de349..565363cf6 100644 --- a/test/compatibility/testplugins/runtime-test-plugin-v0_11_6/cmd/test.go +++ b/test/compatibility/testplugins/runtime-test-plugin-v0_11_6/cmd/test.go @@ -19,7 +19,7 @@ var ( testCmd = &cobra.Command{ Use: "test", Short: "A test command that parse the apis file and trigger the runtime library apis", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { apis, err := core.ParseRuntimeAPIsFromFile(filepath) if err != nil { fmt.Println(err) diff --git a/test/compatibility/testplugins/runtime-test-plugin-v0_25_4/cmd/test.go b/test/compatibility/testplugins/runtime-test-plugin-v0_25_4/cmd/test.go index d40ef0f97..9084f9b3c 100644 --- a/test/compatibility/testplugins/runtime-test-plugin-v0_25_4/cmd/test.go +++ b/test/compatibility/testplugins/runtime-test-plugin-v0_25_4/cmd/test.go @@ -18,7 +18,7 @@ var ( testCmd = &cobra.Command{ Use: "test", Short: "A test command that parse the file and trigger the runtime apis", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { apis, err := core.ParseRuntimeAPIsFromFile(filepath) if err != nil { fmt.Println(err) diff --git a/test/compatibility/testplugins/runtime-test-plugin-v0_28_0/cmd/test.go b/test/compatibility/testplugins/runtime-test-plugin-v0_28_0/cmd/test.go index 23c94a168..72349e5f4 100644 --- a/test/compatibility/testplugins/runtime-test-plugin-v0_28_0/cmd/test.go +++ b/test/compatibility/testplugins/runtime-test-plugin-v0_28_0/cmd/test.go @@ -18,7 +18,7 @@ var ( testCmd = &cobra.Command{ Use: "test", Short: "A test command that parse the file and trigger the runtime apis", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { // Parse the file into array of apis struct apis, err := core.ParseRuntimeAPIsFromFile(filepath) if err != nil { diff --git a/test/compatibility/testplugins/runtime-test-plugin-v0_90/cmd/test.go b/test/compatibility/testplugins/runtime-test-plugin-v0_90/cmd/test.go index 0e87d2e5b..8c286d0cf 100644 --- a/test/compatibility/testplugins/runtime-test-plugin-v0_90/cmd/test.go +++ b/test/compatibility/testplugins/runtime-test-plugin-v0_90/cmd/test.go @@ -18,7 +18,7 @@ var ( testCmd = &cobra.Command{ Use: "test", Short: "A test command that parse the file and trigger the runtime apis", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { // Parse the file into array of apis struct apis, err := compatibilitytestingcore.ParseRuntimeAPIsFromFile(filepath) if err != nil { diff --git a/test/compatibility/testplugins/runtime-test-plugin-v1_0_2/cmd/test.go b/test/compatibility/testplugins/runtime-test-plugin-v1_0_2/cmd/test.go index 0e87d2e5b..8c286d0cf 100644 --- a/test/compatibility/testplugins/runtime-test-plugin-v1_0_2/cmd/test.go +++ b/test/compatibility/testplugins/runtime-test-plugin-v1_0_2/cmd/test.go @@ -18,7 +18,7 @@ var ( testCmd = &cobra.Command{ Use: "test", Short: "A test command that parse the file and trigger the runtime apis", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { // Parse the file into array of apis struct apis, err := compatibilitytestingcore.ParseRuntimeAPIsFromFile(filepath) if err != nil { diff --git a/test/plugin_e2e_test.go b/test/plugin_e2e_test.go index 1da4e9625..664cf01e9 100644 --- a/test/plugin_e2e_test.go +++ b/test/plugin_e2e_test.go @@ -10,8 +10,8 @@ import ( "path/filepath" "testing" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" + . "github.com/onsi/ginkgo/v2" //nolint:revive // Using dot import for readability in test files + . "github.com/onsi/gomega" //nolint:revive // Using dot import for readability in test files executil "github.com/vmware-tanzu/tanzu-plugin-runtime/test/exec" )