Skip to content

Add //nolint suppression support to seenmapbool and tolowerequalfold#37255

Merged
pelikhan merged 2 commits into
mainfrom
copilot/add-nolint-buildlineindex-support
Jun 6, 2026
Merged

Add //nolint suppression support to seenmapbool and tolowerequalfold#37255
pelikhan merged 2 commits into
mainfrom
copilot/add-nolint-buildlineindex-support

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 6, 2026

The linter set currently relies on an enforcement invariant: CI-blocking analyzers support //nolint suppression. seenmapbool and tolowerequalfold were missing this integration, blocking seenmapbool enforcement readiness and creating parity drift for another enforcement candidate.

  • Analyzer parity: seenmapbool

    • Integrates pkg/linters/internal/nolint in run.
    • Builds line index once via nolint.BuildLineIndex(pass, "seenmapbool").
    • Skips diagnostics when nolint.HasDirective(...) matches the declaration site.
  • Analyzer parity: tolowerequalfold

    • Integrates pkg/linters/internal/nolint in run.
    • Builds line index once via nolint.BuildLineIndex(pass, "tolowerequalfold").
    • Skips diagnostics when nolint.HasDirective(...) matches the comparison expression.
  • Suppression fixtures

    • Adds //nolint:seenmapbool case in pkg/linters/seenmapbool/testdata/....
    • Adds //nolint:tolowerequalfold case in pkg/linters/tolowerequalfold/testdata/....
    • Existing unsuppressed fixture coverage remains intact.
noLintLinesByFile := nolint.BuildLineIndex(pass, "seenmapbool")

if nolint.HasDirective(pass.Fset.PositionFor(declNode.Pos(), false), noLintLinesByFile) {
    continue
}
pass.ReportRangef(declNode, "map[string]bool %q used as a set; use map[string]struct{} ...", obj.Name())

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add nolint.BuildLineIndex support to enforce-candidate linters Add //nolint suppression support to seenmapbool and tolowerequalfold Jun 6, 2026
Copilot AI requested a review from pelikhan June 6, 2026 05:29
@pelikhan pelikhan marked this pull request as ready for review June 6, 2026 05:32
Copilot AI review requested due to automatic review settings June 6, 2026 05:32
@pelikhan pelikhan merged commit d48bc59 into main Jun 6, 2026
@pelikhan pelikhan deleted the copilot/add-nolint-buildlineindex-support branch June 6, 2026 05:32
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR brings //nolint suppression parity to two analyzers (seenmapbool and tolowerequalfold) by integrating the shared pkg/linters/internal/nolint helpers and adding suppressed test fixtures, aligning them with the project’s CI-blocking analyzer invariant.

Changes:

  • Add nolint.BuildLineIndex(...) + nolint.HasDirective(...) checks to tolowerequalfold and seenmapbool so diagnostics can be suppressed via //nolint:<linter>.
  • Thread the computed nolint line index into seenmapbool’s inspectBody helper to suppress diagnostics at the declaration reporting site.
  • Add new suppressed fixtures in both linters’ analysistest testdata to validate suppression behavior.
Show a summary per file
File Description
pkg/linters/tolowerequalfold/tolowerequalfold.go Build nolint line index once and skip reporting when the comparison expression line is suppressed.
pkg/linters/tolowerequalfold/testdata/src/tolowerequalfold/tolowerequalfold.go Add a //nolint:tolowerequalfold fixture that should not emit diagnostics.
pkg/linters/seenmapbool/seenmapbool.go Build nolint line index once and skip reporting when the declaration site is suppressed.
pkg/linters/seenmapbool/testdata/src/seenmapbool/seenmapbool.go Add a //nolint:seenmapbool fixture that should not emit diagnostics.

Copilot's findings

Tip

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

  • Files reviewed: 4/4 changed files
  • Comments generated: 0

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.

Linter (nolint/redacted) parity: add nolint.BuildLineIndex support to enforce-candidate linters (seenmapbool, tolowerequalfold)

3 participants