Repository navigation
fix(lint): work around nolintlint false positives from cache bug - #10136
Merged
Merged
Conversation
Contributor
|
❗ By default, the pull request is configured to backport to all release branches.
|
Set allow-unused: true for nolintlint to prevent flaky CI failures caused by golangci-lint's internal cache losing staticcheck SA1019 deprecation facts across runs. Signed-off-by: Marco Nenciarini <[email protected]>
mnencia
force-pushed
the
dev/fix-nolintlint-false-positives
branch
from
March 5, 2026 09:32
428e5f4 to
5bdb21a
Compare
sxd
approved these changes
Mar 5, 2026
Member
Author
|
/ok-to-merge |
leonardoce
approved these changes
Mar 5, 2026
cnpg-bot
pushed a commit
that referenced
this pull request
Mar 5, 2026
) Set allow-unused: true for nolintlint to prevent flaky CI failures caused by a known golangci-lint bug (golangci/golangci-lint#3228) where the internal cache loses staticcheck SA1019 deprecation facts across runs, causing nolintlint to falsely report `//nolint:staticcheck` directives as unused. Signed-off-by: Marco Nenciarini <[email protected]> (cherry picked from commit e7d6db3)
cnpg-bot
pushed a commit
that referenced
this pull request
Mar 5, 2026
) Set allow-unused: true for nolintlint to prevent flaky CI failures caused by a known golangci-lint bug (golangci/golangci-lint#3228) where the internal cache loses staticcheck SA1019 deprecation facts across runs, causing nolintlint to falsely report `//nolint:staticcheck` directives as unused. Signed-off-by: Marco Nenciarini <[email protected]> (cherry picked from commit e7d6db3)
cnpg-bot
pushed a commit
that referenced
this pull request
Mar 5, 2026
) Set allow-unused: true for nolintlint to prevent flaky CI failures caused by a known golangci-lint bug (golangci/golangci-lint#3228) where the internal cache loses staticcheck SA1019 deprecation facts across runs, causing nolintlint to falsely report `//nolint:staticcheck` directives as unused. Signed-off-by: Marco Nenciarini <[email protected]> (cherry picked from commit e7d6db3)
clement0010
added a commit
to Twingate/gateway
that referenced
this pull request
May 21, 2026
…cache bug (#298) Issue: #300 ## Changes - Set `allow-unused: true` for `nolintlint` in `.golangci.yml` to prevent flaky CI failures ## Notes ### Problem The `lint-go` CI job intermittently fails with errors like: ``` directive `//nolint:ireturn` is unused for linter "ireturn" (nolintlint) ``` **Evidence**: [Failed CI run](https://github.com/Twingate/gateway/actions/runs/26206509968/job/77107441411?pr=296) ### Root Cause This is a [known golangci-lint bug](golangci/golangci-lint#3228) where the internal linter cache loses analysis facts (in our case, `ireturn` violations) across runs. When this happens: 1. `ireturn` violations become invisible due to stale/partial cache 2. `nolintlint` checks whether each `//nolint` directive suppresses a real violation 3. With the cached facts missing, `nolintlint` concludes the directive is "unused" and flags it 4. With `--fix` enabled (as in `make lint`), these "unused" directives get silently deleted 5. The next clean run sees the real violations again and fails The bug is flaky — it depends on which cache entries are evicted, so it affects a different subset of directives each time. It is more likely in CI where the GitHub Actions cache is restored from previous runs against different code states. ### Fix Following the same [workaround adopted by cloudnative-pg](cloudnative-pg/cloudnative-pg#10136), we set `allow-unused: true` for `nolintlint` to tolerate potentially "unused" nolint directives rather than falsely flagging them. Co-authored-by: Claude Opus 4.6 <[email protected]>
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.
Set allow-unused: true for nolintlint to prevent flaky CI failures caused by a known golangci-lint bug (golangci/golangci-lint#3228) where the internal cache loses staticcheck SA1019 deprecation facts across runs, causing nolintlint to falsely report
//nolint:staticcheckdirectives as unused.