Skip to content

golangci: enable modernize linter#22197

Merged
yperbasis merged 4 commits into
mainfrom
yperbasis/enable-modernize-lint
Jul 4, 2026
Merged

golangci: enable modernize linter#22197
yperbasis merged 4 commits into
mainfrom
yperbasis/enable-modernize-lint

Conversation

@yperbasis

@yperbasis yperbasis commented Jul 3, 2026

Copy link
Copy Markdown
Member

Enables the modernize linter — the gopls modernize analyzer suite shipped with the pinned golangci-lint (v2.12.2) — so these modernizations are enforced mechanically instead of by periodic manual cleanup passes.

  • The 17 analyzers with an existing backlog on main are disabled via settings.modernize.disable, keeping this PR config-only. Each gets enabled in its own PR once its backlog is cleared — tracked in lint: enable the remaining modernize analyzers #22199, which carries the per-analyzer finding counts, the workflow, and the autofix caveats.
  • The analyzers that are already clean are enforced from now on: stringsseq, embedlit, errorsastype, newexpr, plusbuild, unsafefuncs.
  • One stringsseq site sits behind //go:build leak (execution/engineapi/engineapitester/engine_x_leak_test.go), invisible to the linter, and is converted manually (typechecked with go vet -tags leak).

TDD note: mechanical change (lint config plus a behavior-preserving loop rewrite); no new tests — existing tests and the linter itself are the safety net.

Enable the gopls modernize suite; disable the analyzers with an
existing backlog (enable each once its findings are cleared). Clear
the stringsseq backlog: convert the remaining strings.Split range
loops to strings.SplitSeq, including the leak-tagged site the linter
cannot see.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Enables golangci-lint’s modernize analyzer suite to mechanically enforce select Go “modernization” patterns going forward (notably strings.Split-in-loop → strings.SplitSeq), reducing recurring manual churn across the codebase.

Changes:

  • Enabled the modernize linter in .golangci.yml and configured it to disable analyzers with existing backlog findings.
  • Rewrote the remaining strings.Split(... )-in-range loops to use strings.SplitSeq(... ) in several packages (including one //go:build leak test).
  • Kept behavior equivalent by preserving trimming/empty-token handling and loop control flow.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
.golangci.yml Enables modernize and disables backlog analyzers so CI remains manageable while enforcing newly-clean checks.
execution/engineapi/engineapitester/engine_x_leak_test.go Switches /proc parsing loop to strings.SplitSeq in the leak-tagged test.
db/state/commitment_convert.go Uses strings.SplitSeq when reading restore manifest lines to avoid allocating a full slice.
cmd/evm/enginexrunner.go Uses strings.SplitSeq for path component scanning in isUnderPreAlloc.
cl/sentinel/httpreqresp/server.go Uses strings.SplitSeq for comma-separated protocol topic parsing.
cl/beacon/beaconhttp/api.go Uses strings.SplitSeq when iterating Accept header media types.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@yperbasis yperbasis marked this pull request as draft July 3, 2026 09:18
SonarCloud stopped treating git-submodule contents as SCM-ignored
(server-side change on 2026-07-03), so the vendored ethereum/tests
fixtures (~38.5k files) entered PR analyses as new code and their
Dockerfile/JS findings fail the quality gate's security rating on
every PR.
@yperbasis yperbasis changed the title golangci: enable modernize linter golangci, sonar: enable modernize linter, exclude legacy-tests from analysis Jul 3, 2026
@yperbasis yperbasis changed the title golangci, sonar: enable modernize linter, exclude legacy-tests from analysis golangci: enable modernize linter Jul 4, 2026
@yperbasis yperbasis marked this pull request as ready for review July 4, 2026 07:43
@yperbasis yperbasis enabled auto-merge July 4, 2026 07:44
@yperbasis yperbasis added this pull request to the merge queue Jul 4, 2026
Merged via the queue into main with commit 35a93b7 Jul 4, 2026
93 of 95 checks passed
@yperbasis yperbasis deleted the yperbasis/enable-modernize-lint branch July 4, 2026 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants