Skip to content

Commit d4ec1a1

Browse files
authored
linting update (#539)
1 parent 8c381ea commit d4ec1a1

File tree

11 files changed

+509
-841
lines changed

11 files changed

+509
-841
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ jobs:
2626

2727
strategy:
2828
matrix:
29-
go: [ '1.23', '1.22' ]
29+
go: [ '1.24', '1.23' ]
3030
include:
31-
- go: '1.23'
31+
- go: '1.24'
3232
lint: true
3333

3434
# Steps represent a sequence of tasks that will be executed as part of the job
@@ -39,9 +39,9 @@ jobs:
3939
# Running golangci-lint
4040
- name: Linting
4141
if: matrix.lint
42-
uses: golangci/golangci-lint-action@v6.5.2
42+
uses: golangci/golangci-lint-action@v8.0.0
4343
with:
44-
version: v1.56.2
44+
version: v2.1.6
4545
only-new-issues: true
4646

4747
# Install Go

.golangci.bck.yml

Lines changed: 288 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,288 @@
1+
run:
2+
# default concurrency is a available CPU number
3+
concurrency: 4
4+
5+
# timeout for analysis, e.g. 30s, 5m, default is 1m
6+
timeout: 1m
7+
8+
# exit code when at least one issue was found, default is 1
9+
issues-exit-code: 1
10+
11+
# include test files or not, default is true
12+
tests: true
13+
14+
# all available settings of specific linters
15+
linters-settings:
16+
errcheck:
17+
# report about not checking of errors in type assetions: `a := b.(MyStruct)`;
18+
# default is false: such cases aren't reported by default.
19+
check-type-assertions: false
20+
21+
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
22+
# default is false: such cases aren't reported by default.
23+
check-blank: false
24+
25+
funlen:
26+
lines: 80
27+
statements: 40
28+
29+
govet:
30+
# settings per analyzer
31+
settings:
32+
printf: # analyzer name, run `go tool vet help` to see all analyzers
33+
funcs: # run `go tool vet help printf` to see available settings for `printf` analyzer
34+
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
35+
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
36+
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
37+
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
38+
39+
# enable or disable analyzers by name
40+
enable:
41+
- atomicalign
42+
- shadow
43+
# - fieldalignment
44+
enable-all: false
45+
disable: []
46+
disable-all: false
47+
gofmt:
48+
# simplify code: gofmt with `-s` option, true by default
49+
simplify: true
50+
goimports:
51+
# put imports beginning with prefix after 3rd-party packages;
52+
# it's a comma-separated list of prefixes
53+
local-prefixes: github.com/fclairamb/ftpserverlib
54+
gocyclo:
55+
# minimal code complexity to report, 30 by default (but we recommend 10-20)
56+
min-complexity: 15
57+
gocognit:
58+
# minimal code complexity to report, 30 by default (but we recommend 10-20)
59+
min-complexity: 30
60+
dupl:
61+
# tokens count to trigger issue, 150 by default
62+
threshold: 100
63+
goconst:
64+
# minimal length of string constant, 3 by default
65+
min-len: 3
66+
# minimal occurrences count to trigger, 3 by default
67+
min-occurrences: 3
68+
misspell:
69+
# Correct spellings using locale preferences for US or UK.
70+
# Default is to use a neutral variety of English.
71+
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
72+
locale: US
73+
ignore-words:
74+
- someword
75+
lll:
76+
# max line length, lines longer will be reported. Default is 120.
77+
# '\t' is counted as 1 character by default, and can be changed with the tab-width option
78+
line-length: 120
79+
# tab width in spaces. Default to 1.
80+
tab-width: 1
81+
unparam:
82+
# Inspect exported functions, default is false. Set to true if no external program/library imports your code.
83+
# XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
84+
# if it's called for subdir of a project it can't find external interfaces. All text editor integrations
85+
# with golangci-lint call it on a directory with the changed file.
86+
check-exported: false
87+
nakedret:
88+
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
89+
max-func-lines: 30
90+
prealloc:
91+
# XXX: we don't recommend using this linter before doing performance profiling.
92+
# For most programs usage of prealloc will be a premature optimization.
93+
94+
# Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
95+
# True by default.
96+
simple: true
97+
range-loops: true # Report preallocation suggestions on range loops, true by default
98+
for-loops: false # Report preallocation suggestions on for loops, false by default
99+
gocritic:
100+
# Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.
101+
# Empty list by default. See https://github.com/go-critic/go-critic#usage -> section "Tags".
102+
enabled-tags:
103+
- performance
104+
105+
settings: # settings passed to gocritic
106+
captLocal: # must be valid enabled check name
107+
paramsOnly: true
108+
rangeValCopy:
109+
sizeThreshold: 32
110+
godox:
111+
# report any comments starting with keywords, this is useful for TODO or FIXME comments that
112+
# might be left in the code accidentally and should be resolved before merging
113+
keywords: # default keywords are TODO, BUG, and FIXME, these can be overwritten by this setting
114+
- NOTE
115+
- OPTIMIZE # marks code that should be optimized before merging
116+
- HACK # marks hack-arounds that should be removed before merging
117+
dogsled:
118+
# checks assignments with too many blank identifiers; default is 2
119+
max-blank-identifiers: 2
120+
121+
whitespace:
122+
multi-if: false # Enforces newlines (or comments) after every multi-line if statement
123+
multi-func: false # Enforces newlines (or comments) after every multi-line function signature
124+
wsl:
125+
# If true append is only allowed to be cuddled if appending value is
126+
# matching variables, fields or types on line above. Default is true.
127+
strict-append: true
128+
# Allow calls and assignments to be cuddled as long as the lines have any
129+
# matching variables, fields or types. Default is true.
130+
allow-assign-and-call: true
131+
# Allow multiline assignments to be cuddled. Default is true.
132+
allow-multiline-assign: true
133+
# Allow declarations (var) to be cuddled.
134+
allow-cuddle-declarations: true
135+
# Allow trailing comments in ending of blocks
136+
allow-trailing-comment: false
137+
# Force newlines in end of case at this limit (0 = never).
138+
force-case-trailing-whitespace: 0
139+
depguard:
140+
rules:
141+
prevent_unmaintained_packages:
142+
list-mode: lax # allow unless explicitely denied
143+
files:
144+
- $all
145+
- "!$test"
146+
allow:
147+
- $gostd
148+
deny:
149+
- pkg: io/ioutil
150+
desc: "replaced by io and os packages since Go 1.16: https://tip.golang.org/doc/go1.16#ioutil"
151+
linters:
152+
disable-all: true
153+
enable:
154+
# https://golangci-lint.run/usage/linters/
155+
- asciicheck
156+
- asasalint
157+
- bidichk
158+
- bodyclose
159+
# - deadcode -> unused
160+
- containedctx
161+
# - contextcheck -> creates an odd error here: https://github.com/fclairamb/ftpserverlib/blob/4d7c663e9e0b2650673fc2e0fcdb443895f2a1b9/server.go#L234
162+
# - copyloopvar -> unknown in v1.56.2 ???
163+
# - cyclop -> Delaying it for now (too much work)
164+
- decorder
165+
- depguard
166+
- dogsled
167+
- dupl
168+
- dupword
169+
- durationcheck
170+
- errcheck
171+
- exhaustive
172+
- errchkjson
173+
- errname
174+
- errorlint
175+
- execinquery
176+
- exhaustive
177+
# - exhaustruct --> Not convinced it's useful
178+
# - exhaustivestruct
179+
- exportloopref
180+
- funlen
181+
- forbidigo
182+
- forcetypeassert
183+
- gci
184+
- ginkgolinter
185+
- gochecknoinits
186+
- gochecksumtype
187+
- gochecknoglobals
188+
- gocognit
189+
- goconst
190+
- gocritic
191+
- gocyclo
192+
# - godot --> lots of not so useful changes
193+
- godox
194+
- goerr113
195+
- gofmt
196+
# - gofumpt -> conflicts with wsl
197+
- goimports
198+
- gosimple
199+
# - golint --> revive
200+
- revive
201+
# - gomnd --> too much work
202+
# - gomoddirectives
203+
# - gomodguard
204+
- goprintffuncname
205+
- gosec
206+
- gosmopolitan
207+
- gosimple
208+
- govet
209+
- grouper
210+
- ineffassign
211+
- importas
212+
- inamedparam
213+
# - intrange --> upcoming
214+
# - interfacebloat
215+
# - interfacer --> (deprecated)
216+
# - ireturn --> I can't even see how to fix those like ClientHandler::getFileHandle
217+
- lll
218+
- loggercheck
219+
- maintidx
220+
- makezero
221+
- mirror
222+
# - maligned --> govet:fieldalignment
223+
- megacheck
224+
- misspell
225+
- musttag
226+
- nakedret
227+
# - nestif
228+
- nlreturn
229+
- prealloc
230+
- nestif
231+
- nilerr
232+
- nilnil
233+
- nolintlint
234+
- nlreturn
235+
- rowserrcheck
236+
- noctx
237+
- nonamedreturns
238+
# - scopelint --> exportloopref
239+
- nosprintfhostport
240+
- exportloopref
241+
- staticcheck
242+
# - structcheck -> unused
243+
- stylecheck
244+
# - paralleltest -> buggy, doesn't work with subtests
245+
- typecheck
246+
- perfsprint
247+
- prealloc
248+
- predeclared
249+
- reassign
250+
- promlinter
251+
- protogetter
252+
- rowserrcheck
253+
- sloglint
254+
- spancheck
255+
- sqlclosecheck
256+
- stylecheck
257+
- tagalign
258+
- tagliatelle
259+
- tenv
260+
- testableexamples
261+
- testifylint
262+
# - testpackage -> too late for that
263+
- thelper
264+
- tparallel
265+
- unconvert
266+
- unparam
267+
- unused
268+
- usestdlibvars
269+
- varnamelen
270+
- wastedassign
271+
# - varcheck -> unused
272+
- whitespace
273+
# - wrapcheck -> too much effort for now
274+
- wsl
275+
# - zerologlint -> Will most probably never use it
276+
fast: false
277+
278+
issues:
279+
# Independently from option `exclude` we use default exclude patterns,
280+
# it can be disabled by this option. To list all
281+
# excluded by default patterns execute `golangci-lint run --help`.
282+
# Default value for this option is true.
283+
exclude-use-default: false
284+
285+
exclude-rules:
286+
- path: _test\.go
287+
linters:
288+
- gochecknoglobals

0 commit comments

Comments
 (0)