Align threshold linters with sibling analyzer behavior#40740
Merged
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix excessivefuncparams linter to skip test files and honor nolint directives
Align threshold linters with sibling analyzer behavior
Jun 22, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because no GitHub Actions runner was available. Make sure your repository has a runner available to run Copilot's review, or add a copilot-setup-steps.yml file specifying one with the runs-on attribute. See the docs for more details.
Aligns the excessivefuncparams and largefunc threshold linters with other FuncDecl-based analyzers by reducing noise in _test.go and enabling per-declaration //nolint suppression.
Changes:
- Skip
_test.gofiles inexcessivefuncparamsto match sibling analyzers’ behavior. - Add
//nolint:<linter>directive support for bothexcessivefuncparamsandlargefuncvia sharedinternal/nolinthelpers. - Extend analysistest fixtures to cover
_test.goskipping and suppression behavior.
Show a summary per file
| File | Description |
|---|---|
| pkg/linters/largefunc/largefunc.go | Adds nolint directive handling and uses source positions for suppression and test-file skipping. |
| pkg/linters/largefunc/testdata/src/a/a.go | Adds a suppressed large function fixture to validate //nolint:largefunc. |
| pkg/linters/excessivefuncparams/excessivefuncparams.go | Skips _test.go and adds nolint suppression for excessive parameter diagnostics. |
| pkg/linters/excessivefuncparams/testdata/src/a/a.go | Adds a suppressed excessive-params fixture to validate //nolint:excessivefuncparams. |
| pkg/linters/excessivefuncparams/testdata/src/a/a_test.go | Adds a _test.go fixture to ensure the analyzer ignores test helpers. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 5/5 changed files
- Comments generated: 2
Comment on lines
+68
to
71
| position := pass.Fset.PositionFor(reportNode.Pos(), false) | ||
| if filecheck.IsTestFile(position.Filename) { | ||
| return | ||
| } |
Comment on lines
+55
to
+58
| position := pass.Fset.PositionFor(fn.Name.Pos(), false) | ||
| if filecheck.IsTestFile(position.Filename) { | ||
| return | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
excessivefuncparamswas the onlyFuncDecl-based linter still analyzing_test.go, and neitherexcessivefuncparamsnorlargefuncsupported per-site//nolintsuppression. That made both threshold linters noisy in tests and hard to enforce without weakening global limits.Analyzer behavior
excessivefuncparamsnow skips_test.go, matching the existing behavior of siblingFuncDecllinters.excessivefuncparamsnow honors//nolint:excessivefuncparams.largefuncnow honors//nolint:largefunc.Implementation shape
internal/nolinthelpers (BuildLineIndex/HasDirective) used elsewhere inpkg/linters.Analysistest coverage
_test.gofixture forexcessivefuncparamsto assert test helpers are ignored.//nolintprevents diagnostics while unsuppressed cases still report.