From 924fe4de987cfa85f6cf49f229ab9074d4495bb4 Mon Sep 17 00:00:00 2001 From: terence Date: Thu, 25 Sep 2025 10:01:22 -0700 Subject: [PATCH] Restructure golangci-lint config: explicit opt-in (#15744) * update golangci-lint configuration to enable basic linters only * Add back formatter * feedback * Add nolint --- .github/workflows/go.yml | 1 - .golangci.yml | 72 ++------------------- changelog/ttsao_simplify-golangci-config.md | 3 + validator/client/runner.go | 7 +- 4 files changed, 14 insertions(+), 69 deletions(-) create mode 100644 changelog/ttsao_simplify-golangci-config.md diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 0b75d9cf64..8df59cc54a 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -56,7 +56,6 @@ jobs: uses: golangci/golangci-lint-action@v8 with: version: v2.4 - only-new-issues: true build: name: Build diff --git a/.golangci.yml b/.golangci.yml index 8c9264ef2d..0d57624210 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -2,72 +2,13 @@ version: "2" run: go: 1.23.5 linters: - default: all - disable: - - asasalint - - bodyclose - - containedctx - - contextcheck - - cyclop - - depguard - - dogsled - - dupl - - durationcheck - - err113 - - errname - - exhaustive - - exhaustruct - - forbidigo - - forcetypeassert - - funlen - - gochecknoglobals - - gochecknoinits - - goconst - - gocritic - - gocyclo - - godot - - godox - - gomoddirectives - - gosec + enable: + - errcheck + - ineffassign - govet - - inamedparam - - interfacebloat - - intrange - - ireturn - - lll - - maintidx - - makezero - - mnd - - musttag - - nakedret - - nestif - - nilnil - - nlreturn - - noctx - - noinlineerr - - nolintlint - - nonamedreturns - - nosprintfhostport - - perfsprint - - prealloc - - predeclared - - promlinter - - protogetter - - recvcheck - - revive - - spancheck + disable: - staticcheck - - tagalign - - tagliatelle - - thelper - - unparam - - usetesting - - varnamelen - - wrapcheck - - wsl - settings: - gocognit: - min-complexity: 65 + - unused exclusions: generated: lax presets: @@ -83,6 +24,7 @@ linters: - third_party$ - builtin$ - examples$ + formatters: enable: - gofmt @@ -96,4 +38,4 @@ formatters: - tools/analyzers - third_party$ - builtin$ - - examples$ + - examples$ \ No newline at end of file diff --git a/changelog/ttsao_simplify-golangci-config.md b/changelog/ttsao_simplify-golangci-config.md new file mode 100644 index 0000000000..515f3a7a79 --- /dev/null +++ b/changelog/ttsao_simplify-golangci-config.md @@ -0,0 +1,3 @@ +### Ignored + +- Update golangci-lint config to enable only basic linters that currently pass diff --git a/validator/client/runner.go b/validator/client/runner.go index f57810c3b7..63f6066d19 100644 --- a/validator/client/runner.go +++ b/validator/client/runner.go @@ -90,6 +90,7 @@ func (r *runner) run(ctx context.Context) { select { case <-ctx.Done(): log.Info("Context canceled, stopping validator") + //nolint:govet return // Exit if context is canceled. case slot := <-v.NextSlot(): if !r.healthMonitor.IsHealthy() { @@ -98,7 +99,7 @@ func (r *runner) run(ctx context.Context) { } deadline := v.SlotDeadline(slot) - slotCtx, cancel := context.WithDeadline(ctx, deadline) + slotCtx, cancel := context.WithDeadline(ctx, deadline) //nolint:govet var span trace.Span slotCtx, span = prysmTrace.StartSpan(slotCtx, "validator.processSlot") @@ -131,7 +132,7 @@ func (r *runner) run(ctx context.Context) { // Start fetching domain data for the next epoch. if slots.IsEpochEnd(slot) { - domainCtx, _ := context.WithDeadline(ctx, deadline) + domainCtx, _ := context.WithDeadline(ctx, deadline) //nolint:govet go v.UpdateDomainDataCaches(domainCtx, slot+1) } @@ -145,7 +146,7 @@ func (r *runner) run(ctx context.Context) { continue } // performRoles calls span.End() - rolesCtx, _ := context.WithDeadline(ctx, deadline) + rolesCtx, _ := context.WithDeadline(ctx, deadline) //nolint:govet performRoles(rolesCtx, allRoles, v, slot, &wg, span) case e := <-v.EventsChan(): v.ProcessEvent(ctx, e)