Skip to content

Commit 4202054

Browse files
authored
Update golangci-lint to v2 (#4037)
Signed-off-by: Joshua Kim <20001595+joshua-kim@users.noreply.github.com>
1 parent 05fc315 commit 4202054

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+390
-439
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ jobs:
146146
runs-on: ubuntu-latest
147147
steps:
148148
- uses: actions/checkout@v4
149-
- uses: umbrelladocs/action-linkspector@a0567ce1c7c13de4a2358587492ed43cab5d0102 #v1.3.4
149+
- uses: umbrelladocs/action-linkspector@de84085e0f51452a470558693d7d308fbb2fa261 #v1.2.5
150150
with:
151151
fail_level: any
152152
check_generated_protobuf:

.golangci.yml

Lines changed: 158 additions & 150 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# https://golangci-lint.run/usage/configuration/
2+
version: "2"
23
run:
3-
timeout: 10m
4-
54
# If set we pass it to "go list -mod={option}". From "go help modules":
65
# If invoked with -mod=readonly, the go command is disallowed from the implicit
76
# automatic updating of go.mod described above. Instead, it fails when any changes
@@ -22,26 +21,16 @@ run:
2221

2322
issues:
2423
# Make issues output unique by line.
25-
# Default: true
2624
uniq-by-line: false
2725

2826
# Maximum issues count per one linter.
29-
# Set to 0 to disable.
30-
# Default: 50
3127
max-issues-per-linter: 0
3228

3329
# Maximum count of issues with the same text.
34-
# Set to 0 to disable.
35-
# Default: 3
3630
max-same-issues: 0
3731

38-
# Enables skipping of directories:
39-
# - vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
40-
# Default: true
41-
exclude-dirs-use-default: false
42-
4332
linters:
44-
disable-all: true
33+
default: none
4534
enable:
4635
- asciicheck
4736
- bodyclose
@@ -51,20 +40,13 @@ linters:
5140
- errcheck
5241
- errorlint
5342
- forbidigo
54-
- gci
5543
- goconst
5644
- gocritic
57-
# - goerr113
58-
- gofmt
59-
- gofumpt
60-
# - gomnd
6145
- goprintffuncname
6246
- gosec
63-
- gosimple
6447
- govet
6548
- importas
6649
- ineffassign
67-
# - lll
6850
- misspell
6951
- nakedret
7052
- nilerr
@@ -76,133 +58,135 @@ linters:
7658
- revive
7759
- spancheck
7860
- staticcheck
79-
- stylecheck
8061
- tagalign
8162
- testifylint
82-
- typecheck
8363
- unconvert
8464
- unparam
8565
- unused
8666
- usestdlibvars
8767
- whitespace
88-
89-
linters-settings:
90-
depguard:
91-
rules:
92-
packages:
93-
deny:
94-
- pkg: "container/list"
95-
desc: github.com/ava-labs/avalanchego/utils/linked should be used instead.
96-
- pkg: "github.com/golang/mock/gomock"
97-
desc: go.uber.org/mock/gomock should be used instead.
98-
- pkg: "github.com/stretchr/testify/assert"
99-
desc: github.com/stretchr/testify/require should be used instead.
100-
- pkg: "io/ioutil"
101-
desc: io/ioutil is deprecated. Use package io or os instead.
102-
errorlint:
103-
# Check for plain type assertions and type switches.
104-
asserts: false
105-
# Check for plain error comparisons.
106-
comparison: false
107-
forbidigo:
108-
# Forbid the following identifiers (list of regexp).
109-
forbid:
110-
- 'require\.Error$(# ErrorIs should be used instead)?'
111-
- 'require\.ErrorContains$(# ErrorIs should be used instead)?'
112-
- 'require\.EqualValues$(# Equal should be used instead)?'
113-
- 'require\.NotEqualValues$(# NotEqual should be used instead)?'
114-
- '^(t|b|tb|f)\.(Fatal|Fatalf|Error|Errorf)$(# the require library should be used instead)?'
115-
- '^sort\.(Slice|Strings)$(# the slices package should be used instead)?'
116-
# Exclude godoc examples from forbidigo checks.
117-
exclude_godoc_examples: false
118-
gci:
119-
sections:
120-
- standard
121-
- default
122-
- blank
123-
- prefix(github.com/ava-labs/avalanchego)
124-
- alias
125-
- dot
126-
skip-generated: true
127-
custom-order: true
128-
gosec:
129-
excludes:
130-
- G107 # Url provided to HTTP request as taint input https://securego.io/docs/rules/g107
131-
- G115 # TODO(marun) Enable this ruleset in a follow-up PR
132-
importas:
133-
# Do not allow unaliased imports of aliased packages.
134-
no-unaliased: false
135-
# Do not allow non-required aliases.
136-
no-extra-aliases: false
137-
# List of aliases
138-
alias:
139-
- pkg: github.com/ava-labs/avalanchego/utils/math
140-
alias: safemath
141-
- pkg: github.com/ava-labs/avalanchego/utils/json
142-
alias: avajson
143-
revive:
144-
rules:
145-
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#bool-literal-in-expr
146-
- name: bool-literal-in-expr
147-
disabled: false
148-
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#early-return
149-
- name: early-return
150-
disabled: false
151-
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#empty-lines
152-
- name: empty-lines
153-
disabled: false
154-
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#string-format
155-
- name: string-format
156-
disabled: false
157-
arguments:
158-
- ["b.Logf[0]", "/.*%.*/", "no format directive, use b.Log instead"]
159-
- ["fmt.Errorf[0]", "/.*%.*/", "no format directive, use errors.New instead"]
160-
- ["fmt.Fprintf[1]", "/.*%.*/", "no format directive, use fmt.Fprint instead"]
161-
- ["fmt.Printf[0]", "/.*%.*/", "no format directive, use fmt.Print instead"]
162-
- ["fmt.Sprintf[0]", "/.*%.*/", "no format directive, use fmt.Sprint instead"]
163-
- ["log.Fatalf[0]", "/.*%.*/", "no format directive, use log.Fatal instead"]
164-
- ["log.Printf[0]", "/.*%.*/", "no format directive, use log.Print instead"]
165-
- ["t.Logf[0]", "/.*%.*/", "no format directive, use t.Log instead"]
166-
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#struct-tag
167-
- name: struct-tag
168-
disabled: false
169-
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unexported-naming
170-
- name: unexported-naming
171-
disabled: false
172-
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unhandled-error
173-
- name: unhandled-error
174-
# prefer the errcheck linter since it can be disabled directly with nolint directive
175-
# but revive's disable directive (e.g. //revive:disable:unhandled-error) is not
176-
# supported when run under golangci_lint
177-
disabled: true
178-
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-parameter
179-
- name: unused-parameter
180-
disabled: false
181-
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-receiver
182-
- name: unused-receiver
183-
disabled: false
184-
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#useless-break
185-
- name: useless-break
186-
disabled: false
187-
spancheck:
188-
# https://github.com/jjti/go-spancheck#checks
189-
checks:
190-
- end
191-
# - record-error # check that `span.RecordError(err)` is called when an error is returned
192-
# - set-status # check that `span.SetStatus(codes.Error, msg)` is called when an error is returned
193-
staticcheck:
194-
# https://staticcheck.io/docs/options#checks
195-
checks:
196-
- "all"
197-
- "-SA6002" # Storing non-pointer values in sync.Pool allocates memory
198-
- "-SA1019" # Using a deprecated function, variable, constant or field
199-
tagalign:
200-
align: true
201-
sort: true
202-
strict: true
203-
order:
204-
- serialize
205-
testifylint:
68+
settings:
69+
depguard:
70+
rules:
71+
packages:
72+
deny:
73+
- pkg: container/list
74+
desc: github.com/ava-labs/avalanchego/utils/linked should be used instead.
75+
- pkg: github.com/golang/mock/gomock
76+
desc: go.uber.org/mock/gomock should be used instead.
77+
- pkg: github.com/stretchr/testify/assert
78+
desc: github.com/stretchr/testify/require should be used instead.
79+
- pkg: io/ioutil
80+
desc: io/ioutil is deprecated. Use package io or os instead.
81+
errorlint:
82+
# Check for plain type assertions and type switches.
83+
asserts: false
84+
# Check for plain error comparisons.
85+
comparison: false
86+
forbidigo:
87+
# Forbid the following identifiers (list of regexp).
88+
forbid:
89+
- pattern: require\.Error$(# ErrorIs should be used instead)?
90+
- pattern: require\.ErrorContains$(# ErrorIs should be used instead)?
91+
- pattern: require\.EqualValues$(# Equal should be used instead)?
92+
- pattern: require\.NotEqualValues$(# NotEqual should be used instead)?
93+
- pattern: ^(t|b|tb|f)\.(Fatal|Fatalf|Error|Errorf)$(# the require library should be used instead)?
94+
- pattern: ^sort\.(Slice|Strings)$(# the slices package should be used instead)?
95+
# Exclude godoc examples from forbidigo checks.
96+
exclude-godoc-examples: false
97+
gosec:
98+
excludes:
99+
- G107 # Url provided to HTTP request as taint input https://securego.io/docs/rules/g107
100+
- G115 # TODO(marun) Enable this ruleset in a follow-up PR
101+
importas:
102+
# Do not allow unaliased imports of aliased packages.
103+
no-unaliased: false
104+
# Do not allow non-required aliases.
105+
no-extra-aliases: false
106+
# List of aliases
107+
alias:
108+
- pkg: github.com/ava-labs/avalanchego/utils/math
109+
alias: safemath
110+
- pkg: github.com/ava-labs/avalanchego/utils/json
111+
alias: avajson
112+
revive:
113+
rules:
114+
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#bool-literal-in-expr
115+
- name: bool-literal-in-expr
116+
disabled: false
117+
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#early-return
118+
- name: early-return
119+
disabled: false
120+
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#empty-lines
121+
- name: empty-lines
122+
disabled: false
123+
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#string-format
124+
- name: string-format
125+
disabled: false
126+
arguments:
127+
- - b.Logf[0]
128+
- /.*%.*/
129+
- no format directive, use b.Log instead
130+
- - fmt.Errorf[0]
131+
- /.*%.*/
132+
- no format directive, use errors.New instead
133+
- - fmt.Fprintf[1]
134+
- /.*%.*/
135+
- no format directive, use fmt.Fprint instead
136+
- - fmt.Printf[0]
137+
- /.*%.*/
138+
- no format directive, use fmt.Print instead
139+
- - fmt.Sprintf[0]
140+
- /.*%.*/
141+
- no format directive, use fmt.Sprint instead
142+
- - log.Fatalf[0]
143+
- /.*%.*/
144+
- no format directive, use log.Fatal instead
145+
- - log.Printf[0]
146+
- /.*%.*/
147+
- no format directive, use log.Print instead
148+
- - t.Logf[0]
149+
- /.*%.*/
150+
- no format directive, use t.Log instead
151+
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#struct-tag
152+
- name: struct-tag
153+
disabled: false
154+
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unexported-naming
155+
- name: unexported-naming
156+
disabled: false
157+
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unhandled-error
158+
- name: unhandled-error
159+
# prefer the errcheck linter since it can be disabled directly with nolint directive
160+
# but revive's disable directive (e.g. //revive:disable:unhandled-error) is not
161+
# supported when run under golangci_lint
162+
disabled: true
163+
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-parameter
164+
- name: unused-parameter
165+
disabled: false
166+
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-receiver
167+
- name: unused-receiver
168+
disabled: false
169+
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#useless-break
170+
- name: useless-break
171+
disabled: false
172+
spancheck:
173+
# https://github.com/jjti/go-spancheck#checks
174+
checks:
175+
- end
176+
staticcheck:
177+
# https://staticcheck.io/docs/options#checks
178+
checks:
179+
- all
180+
- -SA6002A # Storing non-pointer values in sync.Pool allocates memory
181+
- -SA1019 # Using a deprecated function, variable, constant or field
182+
- -QF1008 # Unnecessary embedded expressions
183+
tagalign:
184+
align: true
185+
sort: true
186+
order:
187+
- serialize
188+
strict: true
189+
testifylint:
206190
# Enable all checkers (https://github.com/Antonboom/testifylint#checkers).
207191
# Default: false
208192
enable-all: true
@@ -213,13 +197,37 @@ linters-settings:
213197
disable:
214198
- go-require
215199
- float-compare
216-
unused:
217-
# Mark all struct fields that have been written to as used.
218-
# Default: true
219-
field-writes-are-uses: false
220-
# Treat IncDec statement (e.g. `i++` or `i--`) as both read and write operation instead of just write.
221-
# Default: false
222-
post-statements-are-reads: true
223-
# Mark all local variables as used.
224-
# default: true
225-
local-variables-are-used: false
200+
unused:
201+
# Mark all struct fields that have been written to as used.
202+
# Default: true
203+
field-writes-are-uses: false
204+
# Treat IncDec statement (e.g. `i++` or `i--`) as both read and write operation instead of just write.
205+
# Default: false
206+
post-statements-are-reads: true
207+
# Mark all local variables as used.
208+
# default: true
209+
local-variables-are-used: false
210+
exclusions:
211+
generated: lax
212+
presets:
213+
- comments
214+
- common-false-positives
215+
- legacy
216+
- std-error-handling
217+
formatters:
218+
enable:
219+
- gci
220+
- gofmt
221+
- gofumpt
222+
settings:
223+
gci:
224+
sections:
225+
- standard
226+
- default
227+
- blank
228+
- prefix(github.com/ava-labs/avalanchego)
229+
- alias
230+
- dot
231+
custom-order: true
232+
exclusions:
233+
generated: lax

api/admin/service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ type DBGetReply struct {
391391
ErrorCode rpcdbpb.Error `json:"errorCode"`
392392
}
393393

394-
//nolint:stylecheck // renaming this method to DBGet would change the API method from "dbGet" to "dBGet"
394+
//nolint:staticcheck // renaming this method to DBGet would change the API method from "dbGet" to "dBGet"
395395
func (a *Admin) DbGet(_ *http.Request, args *DBGetArgs, reply *DBGetReply) error {
396396
a.Log.Debug("API called",
397397
zap.String("service", "admin"),

0 commit comments

Comments
 (0)