Skip to content

Commit b00b902

Browse files
committed
chore: update golangci-lint config (#3306)
Updates .golangci.yml with stackrox/stackrox@d5fcd2f/.golangci.yml. The impetus for this change is the OOM failures during some GitHub Actions.
1 parent fb6bef4 commit b00b902

5 files changed

Lines changed: 469 additions & 430 deletions

File tree

.golangci.yml

Lines changed: 107 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,52 @@
11
# Originally copied from github.com/stackrox/stackrox, and regularly kept in-sync manually.
22

3+
version: "2"
34
run:
45
timeout: 16m
5-
modules-download-mode: readonly
66
go: "1.23"
7-
7+
modules-download-mode: readonly
88
output:
99
formats:
10-
- format: colored-line-number
11-
- format: junit-xml
10+
text:
11+
path: stdout
12+
junit-xml:
1213
path: report.xml
13-
14-
issues:
15-
exclude-use-default: false
16-
17-
exclude-rules:
18-
- linters:
19-
- revive
20-
text: "should have a package comment, unless it's in another file for this package"
21-
- linters:
22-
- revive
23-
text: "should not use dot imports"
24-
- linters:
25-
- revive
26-
text: "returns unexported type .* which can be annoying to use"
27-
- linters:
28-
- revive
29-
text: "error strings should not be capitalized or end with punctuation or a newline"
30-
- linters:
31-
- revive
32-
text: "should omit type int from declaration"
33-
- linters:
34-
- revive
35-
text: "don't use leading k in Go names"
36-
- linters:
37-
- revive
38-
text: "package-comments: should have a package comment"
39-
- linters:
40-
- gocritic
41-
path: _test\.go
42-
43-
linters-settings:
44-
gosec:
45-
includes:
46-
- G601 # Implicit memory aliasing of items from a range statement
47-
revive:
48-
rules:
49-
- name: package-comments
50-
disabled: true
51-
- name: error-strings
52-
disabled: true
53-
- name: unexported-return
54-
disabled: true
55-
govet:
56-
enable-all: true
57-
disable:
14+
linters:
15+
# please, do not use `enable-all`: it's deprecated and will be removed soon.
16+
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
17+
default: none
18+
enable:
19+
- asciicheck
20+
- copyloopvar
21+
# - errcheck
22+
# - forbidigo
23+
- gocritic
24+
# - exptostd
25+
- gosec
26+
- govet
27+
- ineffassign
28+
# - modernize
29+
- nolintlint
30+
# - protogetter
31+
- revive # replaces golint
32+
- rowserrcheck
33+
- staticcheck
34+
# - wrapcheck
35+
# - nakedret TODO: add in follow-up
36+
- unconvert
37+
# - unparam TODO: add in follow-up
38+
settings:
39+
gosec:
40+
includes:
41+
- G601
42+
govet:
43+
disable:
5844
- shadow
5945
- fieldalignment
60-
settings:
61-
printf: # analyzer name, run `go tool vet help` to see all analyzers
62-
funcs: # run `go tool vet help printf` to see available settings for `printf` analyzer
46+
enable-all: true
47+
settings:
48+
printf:
49+
funcs:
6350
- Print
6451
- Printf
6552
- Println
@@ -71,69 +58,72 @@ linters-settings:
7158
- Warnf
7259
- Error
7360
- Errorf
74-
gocritic:
75-
enabled-checks:
76-
- commentFormatting
77-
nolintlint:
78-
allow-leading-space: false # require machine-readable nolint directives (i.e. with no leading space)
79-
allow-unused: false # report any unused nolint directives
80-
require-explanation: false # don't require an explanation for nolint directives
81-
require-specific: true # require nolint directives to be specific about which linter is being skipped
82-
staticcheck:
83-
checks: [ all,-ST1000,-ST1001,-ST1003,-ST1005,-SA1019,-SA4001,-ST1016 ]
84-
85-
linters:
86-
# please, do not use `enable-all`: it's deprecated and will be removed soon.
87-
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
88-
disable-all: true
61+
nolintlint:
62+
require-explanation: false
63+
require-specific: true
64+
allow-unused: false
65+
revive:
66+
rules:
67+
- name: package-comments
68+
disabled: true
69+
- name: error-strings
70+
disabled: true
71+
- name: unexported-return
72+
disabled: true
73+
staticcheck:
74+
checks:
75+
- all
76+
- -QF1001
77+
- -QF1002
78+
- -QF1003
79+
- -QF1008
80+
- -SA1019
81+
- -SA4001
82+
- -ST1000
83+
- -ST1001
84+
- -ST1003
85+
- -ST1005
86+
exclusions:
87+
generated: lax
88+
rules:
89+
- linters:
90+
- revive
91+
text: should have a package comment, unless it's in another file for this package
92+
- linters:
93+
- revive
94+
text: should not use dot imports
95+
- linters:
96+
- revive
97+
text: returns unexported type .* which can be annoying to use
98+
- linters:
99+
- revive
100+
text: error strings should not be capitalized or end with punctuation or a newline
101+
- linters:
102+
- revive
103+
text: should omit type int from declaration
104+
- linters:
105+
- revive
106+
text: don't use leading k in Go names
107+
- linters:
108+
- revive
109+
text: 'package-comments: should have a package comment'
110+
- linters:
111+
- gocritic
112+
path: _test\.go
113+
paths:
114+
- third_party$
115+
- builtin$
116+
- examples$
117+
issues:
118+
max-issues-per-linter: 0
119+
max-same-issues: 0
120+
formatters:
89121
enable:
90-
- asciicheck
91-
# - bodyclose
92-
- copyloopvar
93-
# - deadcode
94-
# - depguard
95-
# - dogsled
96-
# - dupl
97-
# - errcheck
98-
# - funlen
99-
# - forbidigo
100-
# - gochecknoglobals
101-
# - gochecknoinits
102-
# - gocognit
103-
# - goconst
104-
- gocritic
105-
# - gocyclo
106-
# - godot
107-
# - godox
108-
# - goerr113
109-
- gofmt
110-
- goimports
111-
- revive # replaces golint
112-
# - gomnd
113-
# - goprintffuncname
114-
- gosec
115-
- gosimple
116-
- govet
117-
- ineffassign
118-
# - interfacer
119-
# - lll
120-
# - maligned
121-
# - misspell
122-
# - nakedret TODO: add in follow-up
123-
# - nestif
124-
- nolintlint
125-
# - prealloc
126-
- rowserrcheck
127-
# - scopelint
128-
- staticcheck
129-
# - structcheck
130-
# - stylecheck
131-
# - testpackage
132-
# - typecheck
133-
# - unconvert TODO: add in follow-up
134-
# - unparam TODO: add in follow-up
135-
# - unused
136-
# - varcheck
137-
# - whitespace
138-
# - wrapcheck TODO: add in follow-up
139-
# - wsl
122+
- gofmt
123+
- goimports
124+
exclusions:
125+
generated: lax
126+
paths:
127+
- third_party$
128+
- builtin$
129+
- examples$

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ $(EASYJSON_BIN): deps
9191
GOLANGCILINT_BIN := $(GOBIN)/golangci-lint
9292
$(GOLANGCILINT_BIN): deps
9393
@echo "+ $@"
94-
@cd tools/linters/ && $(GOINSTALL) github.com/golangci/golangci-lint/cmd/golangci-lint
94+
@cd tools/linters/ && $(GOINSTALL) github.com/golangci/golangci-lint/v2/cmd/golangci-lint
9595

9696
OSSLS_BIN := $(GOBIN)/ossls
9797
$(OSSLS_BIN): deps

0 commit comments

Comments
 (0)