Skip to content

go: strict tier runs staticcheck's full set, forvar, and SA as errors (#14655) - #14716

Merged
TrapsterDK merged 1 commit into
mainfrom
issue-14655-go-strict
Nov 23, 2026
Merged

TrapsterDK merged 1 commit into
mainfrom
issue-14655-go-strict

Conversation

@TrapsterDK

@TrapsterDK TrapsterDK commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Part of #14655

  • Strict staticcheck runs every check except SA9003, ST1000, ST1003, ST1016 and ST1020 to ST1023. The exclusions are listed as -NAME, and core/quality/tiers/gopls/gen.rs writes them as false, because gopls's staticcheck switch would otherwise turn them on.
  • Strict govet adds forvar, x/tools' successor to copyloopvar. The other analyzers the issue names already run by default.
  • staticcheck SA findings are errors. S, ST and U1000 findings stay warnings. The tool moves from known to supported.
  • The docs say what each tier runs.
  • New real-result cases cover SA4006, errcheck type assertions, forvar on and off, and opt-in ST1003. A unit test pins strict to all checks minus the exclusions.

The third-party analyzers from the issue (errorlint, exhaustive, noctx, bodyclose, sqlclosecheck, contextcheck, gosec, forbidigo/nolintlint) are tracked in #14714.

Tested

  • tools/dx test on the touched packages, real-result cases and gopls drift tests: 248 passed. //tools/ci:prose_rules_test fails on design pages this PR does not touch. 121 passed again after rebasing on main.
  • tools/dx format/lint/typecheck on the touched packages: format and typecheck pass. Lint reports warnings only in files this PR does not change.
  • tools/dx check --affected: generate fails on gate: full dx generate fails on ambiguous Kotlin grades imports after #14343 (part of #9216) #14500 (Kotlin grades ambiguous imports, Flutter locks), so the gate skips the later phases.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xut2hxcqqAoDeuSr83mscS

…#14655)

Strict staticcheck now runs every check except SA9003, ST1000, ST1003,
ST1016 and ST1020-ST1023, listed as -NAME so gopls turns them off too.
Strict govet adds forvar, x/tools' successor to copyloopvar. staticcheck
SA findings are errors and the tool is supported. New real-result cases
cover SA4006, errcheck type assertions, forvar and the opt-in ST1003.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Xut2hxcqqAoDeuSr83mscS
@TrapsterDK TrapsterDK added the needs-review Touches review paths; needs a second-session Review: comment label Nov 23, 2026
@TrapsterDK

Copy link
Copy Markdown
Collaborator Author

Review: approved

I found nothing that blocks merge. Checked against #14655 and the PR head (84d407b).

What I checked:

  • core/quality/tiers/staticcheck/strict.conf: strict and standard now enable exactly the same checks. The only difference between the files is the eight -NAME entries, which do nothing in an explicit list. This follows the issue: its exclusions (SA9003, ST1000, ST1003, ST1016, ST1020-ST1023) are the checks staticcheck marks non-default, so "all minus the exclusions" works out to the default set. Compared with main, strict users lose those eight checks, ST1003 included. That is intended, and docs/cli/commands/quality.md:244 says so.
  • core/quality/tiers/gopls/gen.rs:23-35: I re-ran the generator logic on the PR's tier files. Both gopls_standard.json and gopls_strict.json match byte for byte.
  • core/quality/adapter/src/severity.rs:25-27: the longest prefix wins, so SA (error) takes precedence over S (warning), and ST still resolves to warning. --fail-on defaults to warning, so moving SA to error does not change pass/fail for standard-tier runs on repo code.
  • go/private/tools/analysis/staticcheck/checks_test.go:127-142: selectAnalyzers handles -NAME correctly, and the test pins strict to every analyzer except the exclusions. Registry, severity_gen.rs and go_tools.bzl agree, and row() defaults state to supported.
  • Docs paragraph: plain, describes behavior only, no rationale or issue numbers.

Non-blocking notes:

  1. go/private/tools/analysis/govet/govet.go:96: modernize.ForVarAnalyzer checks only range loops (x/tools v0.52 forvar.go:27-44). It does not flag for i := 0; i < n; i++ { i := i }, which copyloopvar does. The comment calls forvar the copyloopvar successor, which overstates the coverage.
  2. core/quality/tiers/gopls/gopls_standard.json:166: "forvar": false explicitly turns off a check gopls enables by default (v0.20+), so standard-tier editors lose that hint compared with main. This is a side effect of gen.rs writing every strict-only name as false.

🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-review Touches review paths; needs a second-session Review: comment train Tested; land via merge train

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant