-
Notifications
You must be signed in to change notification settings - Fork 17
chore: update golangci-lint config #3306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,65 +1,52 @@ | ||||||||||||||||||
| # Originally copied from github.com/stackrox/stackrox, and regularly kept in-sync manually. | ||||||||||||||||||
|
|
||||||||||||||||||
| version: "2" | ||||||||||||||||||
| run: | ||||||||||||||||||
| timeout: 16m | ||||||||||||||||||
| modules-download-mode: readonly | ||||||||||||||||||
| go: "1.23" | ||||||||||||||||||
|
|
||||||||||||||||||
| modules-download-mode: readonly | ||||||||||||||||||
| output: | ||||||||||||||||||
| formats: | ||||||||||||||||||
| - format: colored-line-number | ||||||||||||||||||
| - format: junit-xml | ||||||||||||||||||
| text: | ||||||||||||||||||
| path: stdout | ||||||||||||||||||
| junit-xml: | ||||||||||||||||||
| path: report.xml | ||||||||||||||||||
|
|
||||||||||||||||||
| issues: | ||||||||||||||||||
| exclude-use-default: false | ||||||||||||||||||
|
|
||||||||||||||||||
| exclude-rules: | ||||||||||||||||||
| - linters: | ||||||||||||||||||
| - revive | ||||||||||||||||||
| text: "should have a package comment, unless it's in another file for this package" | ||||||||||||||||||
| - linters: | ||||||||||||||||||
| - revive | ||||||||||||||||||
| text: "should not use dot imports" | ||||||||||||||||||
| - linters: | ||||||||||||||||||
| - revive | ||||||||||||||||||
| text: "returns unexported type .* which can be annoying to use" | ||||||||||||||||||
| - linters: | ||||||||||||||||||
| - revive | ||||||||||||||||||
| text: "error strings should not be capitalized or end with punctuation or a newline" | ||||||||||||||||||
| - linters: | ||||||||||||||||||
| - revive | ||||||||||||||||||
| text: "should omit type int from declaration" | ||||||||||||||||||
| - linters: | ||||||||||||||||||
| - revive | ||||||||||||||||||
| text: "don't use leading k in Go names" | ||||||||||||||||||
| - linters: | ||||||||||||||||||
| - revive | ||||||||||||||||||
| text: "package-comments: should have a package comment" | ||||||||||||||||||
| - linters: | ||||||||||||||||||
| - gocritic | ||||||||||||||||||
| path: _test\.go | ||||||||||||||||||
|
|
||||||||||||||||||
| linters-settings: | ||||||||||||||||||
| gosec: | ||||||||||||||||||
| includes: | ||||||||||||||||||
| - G601 # Implicit memory aliasing of items from a range statement | ||||||||||||||||||
| revive: | ||||||||||||||||||
| rules: | ||||||||||||||||||
| - name: package-comments | ||||||||||||||||||
| disabled: true | ||||||||||||||||||
| - name: error-strings | ||||||||||||||||||
| disabled: true | ||||||||||||||||||
| - name: unexported-return | ||||||||||||||||||
| disabled: true | ||||||||||||||||||
| govet: | ||||||||||||||||||
| enable-all: true | ||||||||||||||||||
| disable: | ||||||||||||||||||
| linters: | ||||||||||||||||||
| # please, do not use `enable-all`: it's deprecated and will be removed soon. | ||||||||||||||||||
| # inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint | ||||||||||||||||||
| default: none | ||||||||||||||||||
| enable: | ||||||||||||||||||
| - asciicheck | ||||||||||||||||||
| - copyloopvar | ||||||||||||||||||
| # - errcheck | ||||||||||||||||||
| # - forbidigo | ||||||||||||||||||
| - gocritic | ||||||||||||||||||
| # - exptostd | ||||||||||||||||||
| - gosec | ||||||||||||||||||
| - govet | ||||||||||||||||||
| - ineffassign | ||||||||||||||||||
| # - modernize | ||||||||||||||||||
| - nolintlint | ||||||||||||||||||
| # - protogetter | ||||||||||||||||||
| - revive # replaces golint | ||||||||||||||||||
| - rowserrcheck | ||||||||||||||||||
| - staticcheck | ||||||||||||||||||
| # - wrapcheck | ||||||||||||||||||
| # - nakedret TODO: add in follow-up | ||||||||||||||||||
| - unconvert | ||||||||||||||||||
| # - unparam TODO: add in follow-up | ||||||||||||||||||
| settings: | ||||||||||||||||||
| gosec: | ||||||||||||||||||
| includes: | ||||||||||||||||||
| - G601 | ||||||||||||||||||
| govet: | ||||||||||||||||||
| disable: | ||||||||||||||||||
| - shadow | ||||||||||||||||||
| - fieldalignment | ||||||||||||||||||
| settings: | ||||||||||||||||||
| printf: # analyzer name, run `go tool vet help` to see all analyzers | ||||||||||||||||||
| funcs: # run `go tool vet help printf` to see available settings for `printf` analyzer | ||||||||||||||||||
| enable-all: true | ||||||||||||||||||
| settings: | ||||||||||||||||||
| printf: | ||||||||||||||||||
| funcs: | ||||||||||||||||||
| - Printf | ||||||||||||||||||
| - Println | ||||||||||||||||||
|
|
@@ -71,69 +58,72 @@ linters-settings: | |||||||||||||||||
| - Warnf | ||||||||||||||||||
| - Error | ||||||||||||||||||
| - Errorf | ||||||||||||||||||
| gocritic: | ||||||||||||||||||
| enabled-checks: | ||||||||||||||||||
| - commentFormatting | ||||||||||||||||||
| nolintlint: | ||||||||||||||||||
| allow-leading-space: false # require machine-readable nolint directives (i.e. with no leading space) | ||||||||||||||||||
| allow-unused: false # report any unused nolint directives | ||||||||||||||||||
| require-explanation: false # don't require an explanation for nolint directives | ||||||||||||||||||
| require-specific: true # require nolint directives to be specific about which linter is being skipped | ||||||||||||||||||
| staticcheck: | ||||||||||||||||||
| checks: [ all,-ST1000,-ST1001,-ST1003,-ST1005,-SA1019,-SA4001,-ST1016 ] | ||||||||||||||||||
|
|
||||||||||||||||||
| linters: | ||||||||||||||||||
| # please, do not use `enable-all`: it's deprecated and will be removed soon. | ||||||||||||||||||
| # inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint | ||||||||||||||||||
| disable-all: true | ||||||||||||||||||
| nolintlint: | ||||||||||||||||||
| require-explanation: false | ||||||||||||||||||
| require-specific: true | ||||||||||||||||||
| allow-unused: false | ||||||||||||||||||
| revive: | ||||||||||||||||||
| rules: | ||||||||||||||||||
| - name: package-comments | ||||||||||||||||||
| disabled: true | ||||||||||||||||||
| - name: error-strings | ||||||||||||||||||
| disabled: true | ||||||||||||||||||
| - name: unexported-return | ||||||||||||||||||
| disabled: true | ||||||||||||||||||
| staticcheck: | ||||||||||||||||||
| checks: | ||||||||||||||||||
| - all | ||||||||||||||||||
| - -QF1001 | ||||||||||||||||||
| - -QF1002 | ||||||||||||||||||
| - -QF1003 | ||||||||||||||||||
| - -QF1008 | ||||||||||||||||||
| - -SA1019 | ||||||||||||||||||
| - -SA4001 | ||||||||||||||||||
| - -ST1000 | ||||||||||||||||||
| - -ST1001 | ||||||||||||||||||
| - -ST1003 | ||||||||||||||||||
| - -ST1005 | ||||||||||||||||||
| exclusions: | ||||||||||||||||||
| generated: lax | ||||||||||||||||||
| rules: | ||||||||||||||||||
| - linters: | ||||||||||||||||||
| - revive | ||||||||||||||||||
| text: should have a package comment, unless it's in another file for this package | ||||||||||||||||||
| - linters: | ||||||||||||||||||
| - revive | ||||||||||||||||||
| text: should not use dot imports | ||||||||||||||||||
| - linters: | ||||||||||||||||||
| - revive | ||||||||||||||||||
| text: returns unexported type .* which can be annoying to use | ||||||||||||||||||
| - linters: | ||||||||||||||||||
| - revive | ||||||||||||||||||
| text: error strings should not be capitalized or end with punctuation or a newline | ||||||||||||||||||
| - linters: | ||||||||||||||||||
| - revive | ||||||||||||||||||
| text: should omit type int from declaration | ||||||||||||||||||
| - linters: | ||||||||||||||||||
| - revive | ||||||||||||||||||
| text: don't use leading k in Go names | ||||||||||||||||||
| - linters: | ||||||||||||||||||
| - revive | ||||||||||||||||||
| text: 'package-comments: should have a package comment' | ||||||||||||||||||
| - linters: | ||||||||||||||||||
| - gocritic | ||||||||||||||||||
| path: _test\.go | ||||||||||||||||||
| paths: | ||||||||||||||||||
| - third_party$ | ||||||||||||||||||
| - builtin$ | ||||||||||||||||||
| - examples$ | ||||||||||||||||||
|
Comment on lines
+113
to
+116
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
python - <<'PY'
import re
current = [r"third_party$", r"builtin$", r"examples$"]
proposed = [r"(^|/)third_party(/|$)", r"(^|/)builtin(/|$)", r"(^|/)examples(/|$)"]
paths = [
"third_party/foo.go",
"pkg/third_party/foo.go",
"builtin/foo.go",
"examples/foo.go",
]
for path in paths:
print(path)
print(" current:", any(re.search(p, path) for p in current))
print(" proposed:", any(re.search(p, path) for p in proposed))
PY
for d in third_party builtin examples; do
echo
echo "Sample files under $d, if present:"
fd . "$d" -t f -d 2 2>/dev/null | head -5 || true
doneRepository: stackrox/scanner Length of output: 491 Fix path exclusions to correctly exclude directory trees The current regex patterns Update the patterns in both locations (lines 113–116 and 126–129) to match the directory as a path component. Suggested update paths:
- - third_party$
- - builtin$
- - examples$
+ - '(^|/)third_party(/|$)'
+ - '(^|/)builtin(/|$)'
+ - '(^|/)examples(/|$)'
@@
paths:
- - third_party$
- - builtin$
- - examples$
+ - '(^|/)third_party(/|$)'
+ - '(^|/)builtin(/|$)'
+ - '(^|/)examples(/|$)'📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
| issues: | ||||||||||||||||||
| max-issues-per-linter: 0 | ||||||||||||||||||
| max-same-issues: 0 | ||||||||||||||||||
| formatters: | ||||||||||||||||||
| enable: | ||||||||||||||||||
| - asciicheck | ||||||||||||||||||
| # - bodyclose | ||||||||||||||||||
| - copyloopvar | ||||||||||||||||||
| # - deadcode | ||||||||||||||||||
| # - depguard | ||||||||||||||||||
| # - dogsled | ||||||||||||||||||
| # - dupl | ||||||||||||||||||
| # - errcheck | ||||||||||||||||||
| # - funlen | ||||||||||||||||||
| # - forbidigo | ||||||||||||||||||
| # - gochecknoglobals | ||||||||||||||||||
| # - gochecknoinits | ||||||||||||||||||
| # - gocognit | ||||||||||||||||||
| # - goconst | ||||||||||||||||||
| - gocritic | ||||||||||||||||||
| # - gocyclo | ||||||||||||||||||
| # - godot | ||||||||||||||||||
| # - godox | ||||||||||||||||||
| # - goerr113 | ||||||||||||||||||
| - gofmt | ||||||||||||||||||
| - goimports | ||||||||||||||||||
| - revive # replaces golint | ||||||||||||||||||
| # - gomnd | ||||||||||||||||||
| # - goprintffuncname | ||||||||||||||||||
| - gosec | ||||||||||||||||||
| - gosimple | ||||||||||||||||||
| - govet | ||||||||||||||||||
| - ineffassign | ||||||||||||||||||
| # - interfacer | ||||||||||||||||||
| # - lll | ||||||||||||||||||
| # - maligned | ||||||||||||||||||
| # - misspell | ||||||||||||||||||
| # - nakedret TODO: add in follow-up | ||||||||||||||||||
| # - nestif | ||||||||||||||||||
| - nolintlint | ||||||||||||||||||
| # - prealloc | ||||||||||||||||||
| - rowserrcheck | ||||||||||||||||||
| # - scopelint | ||||||||||||||||||
| - staticcheck | ||||||||||||||||||
| # - structcheck | ||||||||||||||||||
| # - stylecheck | ||||||||||||||||||
| # - testpackage | ||||||||||||||||||
| # - typecheck | ||||||||||||||||||
| # - unconvert TODO: add in follow-up | ||||||||||||||||||
| # - unparam TODO: add in follow-up | ||||||||||||||||||
| # - unused | ||||||||||||||||||
| # - varcheck | ||||||||||||||||||
| # - whitespace | ||||||||||||||||||
| # - wrapcheck TODO: add in follow-up | ||||||||||||||||||
| # - wsl | ||||||||||||||||||
| - gofmt | ||||||||||||||||||
| - goimports | ||||||||||||||||||
| exclusions: | ||||||||||||||||||
| generated: lax | ||||||||||||||||||
| paths: | ||||||||||||||||||
| - third_party$ | ||||||||||||||||||
| - builtin$ | ||||||||||||||||||
| - examples$ | ||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor
🧩 Analysis chain
🏁 Script executed:
Repository: stackrox/scanner
Length of output: 1251
🏁 Script executed:
Repository: stackrox/scanner
Length of output: 201
Update exclusion path patterns and migrate to the v2 toolchain.
The configuration uses
version: "2", but theMakefileinstallsgolangci-lintfrom the v1 module path (github.com/golangci/golangci-lintatv1.64.8). While v1.64.8 detects v2 configs, consistency requires migrating the tool installation togithub.com/golangci/golangci-lint/v2.More critically, the exclusion patterns (e.g.,
third_party$) use a trailing$anchor, which fails to exclude files inside those directories. Ingolangci-lint, thepathsexclusion list treats trailing slashes as directory prefixes. Update the patterns (lines 114–116 and 127–129) to:- third_party/- builtin/- examples/Also update the
v1install command in theMakefileandtools/linters/go.modto use the/v2module path.🤖 Prompt for AI Agents