From b0d47022fcf762212a421a1a84224e88e61fbcd1 Mon Sep 17 00:00:00 2001 From: Shyamsundar Ranganathan Date: Sun, 24 Nov 2024 08:57:41 -0500 Subject: [PATCH] Move to golangci 1.62.0 Moving to the latest version errors out on inactivated linters (that were deprecated earlier). This required commenting out these linters till we ensure we have enabled the required replacements correctly. The linters that are inacivated (and hence commented out) are: deadcode, execinquery, golint, ifshort, maligned, scopelint, strutcheck, varcheck gomnd is replaced by mnd exportloopref is replaced by copyloopvar, but not enabled in this commit to address linter issues in code. Signed-off-by: Shyamsundar Ranganathan --- .github/workflows/ramen.yaml | 2 +- .golangci.yaml | 22 +++++++++---------- hack/install-golangci-lint.sh | 2 +- .../controller/drclusterconfig_controller.go | 2 +- internal/controller/util/drpolicy_util.go | 2 +- .../volumereplicationgroup_controller.go | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ramen.yaml b/.github/workflows/ramen.yaml index 071888627..c2f464b94 100644 --- a/.github/workflows/ramen.yaml +++ b/.github/workflows/ramen.yaml @@ -93,7 +93,7 @@ jobs: - name: GolangCI Lint uses: golangci/golangci-lint-action@v6 with: - version: v1.55.2 + version: v1.62.0 working-directory: ${{ matrix.directory }} unit-test: diff --git a/.golangci.yaml b/.golangci.yaml index 0336789c3..1488b0a82 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -103,8 +103,9 @@ linters: - asciicheck - bidichk - bodyclose + # - copyloopvar // Additional new replacement for go 1.22 (https://go.dev/blog/loopvar-preview) (deprecating exportloopref) - cyclop - - deadcode + # - deadcode // Fully deprecated, remove this line once an alternative is enabled for the same - decorder # - depguard - dogsled @@ -113,9 +114,8 @@ linters: - errcheck - errchkjson # - errorlint - - execinquery + # - execinquery // Fully deprecated, remove this line once an alternative is enabled for the same - exhaustive - - exportloopref - forbidigo - funlen - gocognit @@ -124,24 +124,24 @@ linters: - gocyclo - gofmt - gofumpt - - golint - - gomnd + # - golint // Fully deprecated, remove this line once an alternative is enabled for the same - gomodguard - goprintffuncname - gosec - gosimple - govet - grouper - - ifshort + # - ifshort // Fully deprecated, remove this line once an alternative is enabled for the same - importas - ineffassign - interfacebloat - lll - - logrlint + - loggercheck - maintidx - makezero - - maligned + # - maligned // Fully deprecated, remove this line once an alternative is enabled for the same - misspell + - mnd # - nakedret - nestif - nilerr @@ -155,9 +155,9 @@ linters: - reassign - revive - rowserrcheck - - scopelint + # - scopelint // Fully deprecated, remove this line once an alternative is enabled for the same - sqlclosecheck - - structcheck + # - structcheck // Fully deprecated, remove this line once an alternative is enabled for the same - stylecheck - tenv - testpackage @@ -168,7 +168,7 @@ linters: - unparam - unused - usestdlibvars - - varcheck + # - varcheck // Fully deprecated, remove this line once an alternative is enabled for the same - wastedassign - whitespace - wsl diff --git a/hack/install-golangci-lint.sh b/hack/install-golangci-lint.sh index 02f4dafa2..fad048a25 100755 --- a/hack/install-golangci-lint.sh +++ b/hack/install-golangci-lint.sh @@ -4,7 +4,7 @@ set -e script_dir="$(cd "$(dirname "$0")" && pwd)" source_url="https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh" -required_version="1.55.2" +required_version="1.62.0" target_dir="${script_dir}/../testbin" target_path="${target_dir}/golangci-lint" tool="golangci-lint" diff --git a/internal/controller/drclusterconfig_controller.go b/internal/controller/drclusterconfig_controller.go index abed094c6..571539ed7 100644 --- a/internal/controller/drclusterconfig_controller.go +++ b/internal/controller/drclusterconfig_controller.go @@ -356,7 +356,7 @@ func (r *DRClusterConfigReconciler) SetupWithManager(mgr ctrl.Manager) error { rateLimiter := workqueue.NewTypedMaxOfRateLimiter( workqueue.NewTypedItemExponentialFailureRateLimiter[reconcile.Request](1*time.Second, maxReconcileBackoff), // defaults from client-go - //nolint: gomnd + //nolint: mnd &workqueue.TypedBucketRateLimiter[reconcile.Request]{Limiter: rate.NewLimiter(rate.Limit(10), 100)}, ) diff --git a/internal/controller/util/drpolicy_util.go b/internal/controller/util/drpolicy_util.go index 0eb1606d0..48eddc61f 100644 --- a/internal/controller/util/drpolicy_util.go +++ b/internal/controller/util/drpolicy_util.go @@ -90,7 +90,7 @@ func DRPolicyS3Profiles(drpolicy *rmn.DRPolicy, drclusters []rmn.DRCluster) sets return mustHaveS3Profiles } -//nolint:gomnd +//nolint:mnd func GetSecondsFromSchedulingInterval(drpolicy *rmn.DRPolicy) (float64, error) { schedulingInterval := drpolicy.Spec.SchedulingInterval if schedulingInterval == "" { diff --git a/internal/controller/volumereplicationgroup_controller.go b/internal/controller/volumereplicationgroup_controller.go index e8e1f965e..66de6d356 100644 --- a/internal/controller/volumereplicationgroup_controller.go +++ b/internal/controller/volumereplicationgroup_controller.go @@ -70,7 +70,7 @@ func (r *VolumeReplicationGroupReconciler) SetupWithManager( rateLimiter := workqueue.NewTypedMaxOfRateLimiter( workqueue.NewTypedItemExponentialFailureRateLimiter[reconcile.Request](1*time.Second, 1*time.Minute), // defaults from client-go - //nolint: gomnd + //nolint: mnd &workqueue.TypedBucketRateLimiter[reconcile.Request]{Limiter: rate.NewLimiter(rate.Limit(10), 100)}, ) if r.RateLimiter != nil {