Skip to content

Commit 81d0074

Browse files
authored
CI: golangci-lint v2 (#181)
1 parent 4bbc3e8 commit 81d0074

File tree

2 files changed

+186
-2
lines changed

2 files changed

+186
-2
lines changed

.github/workflows/lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ jobs:
3737
make build
3838
3939
- name: golangci-lint
40-
uses: golangci/golangci-lint-action@v6
40+
uses: golangci/golangci-lint-action@v7
4141
with:
42-
version: v1.61
42+
version: v2.0
4343
args: --issues-exit-code=1 --timeout 10m
4444
only-new-issues: false
4545

.golangci.yml

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
version: "2"
2+
3+
linters:
4+
default: all
5+
disable:
6+
- depguard
7+
- recvcheck
8+
- dupl
9+
- misspell
10+
- nolintlint
11+
- forbidigo
12+
- interfacebloat
13+
- perfsprint
14+
- unparam
15+
- maintidx
16+
- containedctx
17+
- promlinter
18+
- predeclared
19+
- nestif
20+
- ireturn
21+
- cyclop # revive
22+
- funlen # revive
23+
- gocognit # revive
24+
- gocyclo # revive
25+
- lll # revive
26+
- godot # Check if comments end in a period
27+
- gosec # (gas): Inspects source code for security problems
28+
- wrapcheck # Checks that errors returned from external packages are wrapped
29+
- mnd # An analyzer to detect magic numbers.
30+
- nlreturn # nlreturn checks for a new line before return and branch statements to increase code clarity
31+
- whitespace # Whitespace is a linter that checks for unnecessary newlines at the start and end of functions, if, for, etc.
32+
- wsl # add or remove empty lines
33+
- godox # Tool for detection of FIXME, TODO and other comment keywords
34+
- err113 # Go linter to check the errors handling expressions
35+
- paralleltest # Detects missing usage of t.Parallel() method in your Go test
36+
- testpackage # linter that makes you use a separate _test package
37+
- exhaustruct # Checks if all structure fields are initialized
38+
- gochecknoglobals # Check that no global variables exist.
39+
- goconst # Finds repeated strings that could be replaced by a constant
40+
- tagliatelle # Checks the struct tags.
41+
- varnamelen # checks that the length of a variable's name matches its scope
42+
43+
settings:
44+
45+
errcheck:
46+
check-type-assertions: false
47+
48+
gocritic:
49+
enable-all: true
50+
disabled-checks:
51+
- builtinShadow
52+
- captLocal
53+
- commentedOutCode
54+
- deferInLoop #
55+
- emptyStringTest
56+
- hugeParam
57+
- ifElseChain
58+
- octalLiteral
59+
- paramTypeCombine
60+
- rangeValCopy
61+
- sprintfQuotedString
62+
- typeUnparen
63+
- unnamedResult
64+
- whyNoLint
65+
66+
govet:
67+
disable:
68+
- fieldalignment
69+
enable-all: true
70+
71+
maintidx:
72+
# raise this after refactoring
73+
under: 17
74+
75+
misspell:
76+
locale: US
77+
78+
nlreturn:
79+
block-size: 5
80+
81+
nolintlint:
82+
require-explanation: false # don't require an explanation for nolint directives
83+
require-specific: false # don't require nolint directives to be specific about which linter is being skipped
84+
allow-unused: false # report any unused nolint directives
85+
86+
revive:
87+
severity: error
88+
enable-all-rules: true
89+
rules:
90+
- name: add-constant
91+
disabled: true
92+
- name: cognitive-complexity
93+
arguments:
94+
# lower this after refactoring
95+
- 84
96+
- name: defer
97+
disabled: true
98+
- name: confusing-results
99+
disabled: true
100+
- name: cyclomatic
101+
arguments:
102+
# lower this after refactoring
103+
- 40
104+
- name: empty-lines
105+
disabled: true
106+
- name: flag-parameter
107+
disabled: true
108+
- name: function-length
109+
arguments:
110+
# lower this after refactoring
111+
- 88
112+
- 211
113+
- name: indent-error-flow
114+
disabled: true
115+
- name: line-length-limit
116+
arguments:
117+
# lower this after refactoring
118+
- 213
119+
- name: max-public-structs
120+
disabled: true
121+
- name: redefines-builtin-id
122+
disabled: true
123+
- name: superfluous-else
124+
disabled: true
125+
- name: unexported-naming
126+
disabled: true
127+
- name: unexported-return
128+
disabled: true
129+
- name: var-naming
130+
disabled: true
131+
- name: unused-parameter
132+
disabled: true
133+
- name: unused-receiver
134+
disabled: true
135+
- name: use-errors-new
136+
disabled: true
137+
- name: var-declaration
138+
disabled: true
139+
140+
staticcheck:
141+
checks:
142+
- all
143+
- -ST1003
144+
145+
wsl:
146+
# Allow blocks to end with comments
147+
allow-trailing-comment: true
148+
149+
exclusions:
150+
presets:
151+
- comments
152+
- common-false-positives
153+
- legacy
154+
- std-error-handling
155+
rules:
156+
157+
# `err` is often shadowed, we may continue to do it
158+
- linters:
159+
- govet
160+
text: 'shadow: declaration of "(err|ctx)" shadows declaration'
161+
162+
paths:
163+
- third_party$
164+
- builtin$
165+
- examples$
166+
167+
issues:
168+
max-issues-per-linter: 0
169+
max-same-issues: 0
170+
171+
formatters:
172+
settings:
173+
gci:
174+
sections:
175+
- standard
176+
- default
177+
- prefix(github.com/crowdsecurity)
178+
- prefix(github.com/crowdsecurity/cs-cloudflare-bouncer)
179+
180+
exclusions:
181+
paths:
182+
- third_party$
183+
- builtin$
184+
- examples$

0 commit comments

Comments
 (0)