@@ -72,13 +72,43 @@ linters:
7272 # Formatting only, useful in IDE but should not be forced on CI
7373 #
7474
75- - godot # Check if comments end in a period
76- - nlreturn # nlreturn checks for a new line before return and branch statements to increase code clarity
77- - whitespace # Whitespace is a linter that checks for unnecessary newlines at the start and end of functions, if, for, etc.
78- - wsl_v5 # add or remove empty lines
75+ - godot # Check if comments end in a period
76+ - nlreturn # nlreturn checks for a new line before return and branch statements to increase code clarity
77+ - whitespace # Whitespace is a linter that checks for unnecessary newlines at the start and end of functions, if, for, etc.
78+ - wsl_v5 # add or remove empty lines
7979
8080 settings :
8181
82+ decorder :
83+ # Required order of `type`, `const`, `var` and `func` declarations inside a file.
84+ # Default: types before constants before variables before functions.
85+ dec-order :
86+ - type
87+ - const
88+ - var
89+ - func
90+ # If true, underscore vars (vars with "_" as the name) will be ignored at all checks.
91+ # Default: false (underscore vars are not ignored)
92+ ignore-underscore-vars : false
93+ # If true, order of declarations is not checked at all.
94+ # Default: true (disabled)
95+ disable-dec-order-check : true
96+ # If true, `init` func can be anywhere in file (does not have to be declared before all other functions).
97+ # Default: true (disabled)
98+ disable-init-func-first-check : true
99+ # If true, multiple global `type`, `const` and `var` declarations are allowed.
100+ # Default: true (disabled)
101+ disable-dec-num-check : true
102+ # If true, type declarations will be ignored for dec num check.
103+ # Default: false (type statements are not ignored)
104+ disable-type-dec-num-check : false
105+ # If true, const declarations will be ignored for dec num check.
106+ # Default: false (const statements are not ignored)
107+ disable-const-dec-num-check : false
108+ # If true, var declarations will be ignored for dec num check.
109+ # Default: false (var statements are not ignored)
110+ disable-var-dec-num-check : false
111+
82112 depguard :
83113 rules :
84114 wrap :
@@ -103,6 +133,10 @@ linters:
103133 - pkg : gopkg.in/yaml.v2
104134 desc : yaml.v2 is deprecated for new code in favor of yaml.v3
105135
136+ embeddedstructfieldcheck :
137+ empty-line : false
138+ forbid-mutex : true
139+
106140 errcheck :
107141 # Report about not checking of errors in type assertions: `a := b.(MyStruct)`.
108142 # Such cases aren't reported by default.
@@ -135,6 +169,37 @@ linters:
135169 asserts : true
136170 comparison : true
137171
172+ exhaustive :
173+ # Program elements to check for exhaustiveness.
174+ # Default: [ switch ]
175+ check :
176+ - switch
177+ - map
178+ # Presence of "default" case in switch statements satisfies exhaustiveness,
179+ # even if all enum members are not listed.
180+ # Default: false
181+ default-signifies-exhaustive : true
182+ # Enum members matching the supplied regex do not have to be listed in
183+ # switch statements to satisfy exhaustiveness.
184+ # Default: ""
185+ ignore-enum-members : " Example.+"
186+ # Enum types matching the supplied regex do not have to be listed in
187+ # switch statements to satisfy exhaustiveness.
188+ # Default: ""
189+ ignore-enum-types : " Example.+"
190+ # Consider enums only in package scopes, not in inner scopes.
191+ # Default: false
192+ package-scope-only : true
193+ # Only run exhaustive check on switches with "//exhaustive:enforce" comment.
194+ # Default: false
195+ explicit-exhaustive-switch : true
196+ # Only run exhaustive check on map literals with "//exhaustive:enforce" comment.
197+ # Default: false
198+ explicit-exhaustive-map : true
199+ # Switch statement requires default case even if exhaustive.
200+ # Default: false
201+ default-case-required : true
202+
138203 gocritic :
139204 enable-all : true
140205 disabled-checks :
@@ -158,46 +223,6 @@ linters:
158223 ifElseChain :
159224 minThreshold : 4
160225
161- modernize :
162- disable :
163- - any
164- - fmtappendf
165- - forvar
166- - omitzero
167- - slicessort
168- - stringsbuilder
169- - stringsseq
170- - waitgroup
171-
172- perfsprint :
173- concat-loop : false
174- hex-format : false
175- integer-format : false
176- string-format : false
177-
178- unused :
179- # Mark all struct fields that have been written to as used.
180- # Default: true
181- field-writes-are-uses : false
182- # Treat IncDec statement (e.g. `i++` or `i--`) as both read and write operation instead of just write.
183- # Default: false
184- post-statements-are-reads : false
185- # Mark all exported identifiers as used.
186- # Default: true
187- # exported-is-used: false
188- # Mark all exported fields as used.
189- # default: true
190- exported-fields-are-used : false
191- # Mark all function parameters as used.
192- # default: true
193- parameters-are-used : true
194- # Mark all local variables as used.
195- # default: true
196- local-variables-are-used : false
197- # Mark all identifiers inside generated files as used.
198- # Default: true
199- generated-is-used : false
200-
201226 gomoddirectives :
202227 replace-allow-list :
203228 - golang.org/x/time
@@ -208,6 +233,17 @@ linters:
208233 - fieldalignment
209234 enable-all : true
210235
236+ iface :
237+ enable :
238+ # Identifies interfaces in the same package that have identical method sets.
239+ - identical
240+ # Identifies interfaces that are not used anywhere in the same package where the interface is defined.
241+ # - unused
242+ # Identifies functions that return interfaces, but the actual returned value is always a single concrete implementation.
243+ - opaque
244+ # Identifies interfaces that are not exported but are used in exported functions or methods.
245+ # - unexported
246+
211247 interfacebloat :
212248 max : 7
213249
@@ -218,6 +254,17 @@ linters:
218254 misspell :
219255 locale : US
220256
257+ modernize :
258+ disable :
259+ - any
260+ - fmtappendf
261+ - forvar
262+ - omitzero
263+ - slicessort
264+ - stringsbuilder
265+ - stringsseq
266+ - waitgroup
267+
221268 nestif :
222269 # lower this after refactoring
223270 min-complexity : 15
@@ -233,6 +280,59 @@ linters:
233280 # report any unused nolint directives
234281 allow-unused : false
235282
283+ perfsprint :
284+ # Enable/disable optimization of integer formatting.
285+ # Default: true
286+ integer-format : false
287+ # Optimizes even if it requires an int or uint type cast.
288+ # Default: true
289+ int-conversion : false
290+ # Enable/disable optimization of error formatting.
291+ # Default: true
292+ error-format : true
293+ # Optimizes into `err.Error()` even if it is only equivalent for non-nil errors.
294+ # Default: false
295+ err-error : true
296+ # Optimizes `fmt.Errorf`.
297+ # Default: true
298+ errorf : true
299+ # Enable/disable optimization of string formatting.
300+ # Default: true
301+ string-format : false
302+ # Optimizes `fmt.Sprintf` with only one argument.
303+ # Default: true
304+ sprintf1 : true
305+ # Optimizes into strings concatenation.
306+ # Default: true
307+ strconcat : false
308+ # Enable/disable optimization of bool formatting.
309+ # Default: true
310+ bool-format : true
311+ # Enable/disable optimization of hex formatting.
312+ # Default: true
313+ hex-format : false
314+ # Enable/disable optimization of concat loop.
315+ # Default: true
316+ concat-loop : false
317+ # Optimization of `concat-loop` even with other operations.
318+ # Default: false
319+ loop-other-ops : false
320+
321+ recvcheck :
322+ # Disables the built-in method exclusions:
323+ # - `MarshalText`
324+ # - `MarshalJSON`
325+ # - `MarshalYAML`
326+ # - `MarshalXML`
327+ # - `MarshalBinary`
328+ # - `GobEncode`
329+ disable-builtin : false
330+ # User-defined method exclusions.
331+ # The format is `struct_name.method_name` (ex: `Foo.MethodName`).
332+ # A wildcard `*` can use as a struct name (ex: `*.MethodName`).
333+ exclusions :
334+ - " HCLogAdapter.SetLevel"
335+
236336 revive :
237337 severity : error
238338 enable-all-rules : true
@@ -339,6 +439,64 @@ linters:
339439 - -QF1003 # could use tagged switch on ...
340440 - -QF1012 # QF1012: Use fmt.Fprintf(...) instead of ...
341441
442+ unused :
443+ # Mark all struct fields that have been written to as used.
444+ # Default: true
445+ field-writes-are-uses : false
446+ # Treat IncDec statement (e.g. `i++` or `i--`) as both read and write operation instead of just write.
447+ # Default: false
448+ post-statements-are-reads : false
449+ # Mark all exported identifiers as used.
450+ # Default: true
451+ # exported-is-used: false
452+ # Mark all exported fields as used.
453+ # default: true
454+ exported-fields-are-used : false
455+ # Mark all function parameters as used.
456+ # default: true
457+ parameters-are-used : true
458+ # Mark all local variables as used.
459+ # default: true
460+ local-variables-are-used : false
461+ # Mark all identifiers inside generated files as used.
462+ # Default: true
463+ generated-is-used : false
464+
465+ usestdlibvars :
466+ # Suggest the use of http.MethodXX.
467+ # Default: true
468+ http-method : true
469+ # Suggest the use of http.StatusXX.
470+ # Default: true
471+ http-status-code : true
472+ # Suggest the use of time.Month in time.Date.
473+ # Default: false
474+ time-date-month : false
475+ # Suggest the use of time.Weekday.String().
476+ # Default: true
477+ time-weekday : false
478+ # Suggest the use of time.Month.String().
479+ # Default: false
480+ time-month : false
481+ # Suggest the use of time.Layout.
482+ # Default: false
483+ time-layout : false
484+ # Suggest the use of crypto.Hash.String().
485+ # Default: false
486+ crypto-hash : true
487+ # Suggest the use of rpc.DefaultXXPath.
488+ # Default: false
489+ default-rpc-path : true
490+ # Suggest the use of sql.LevelXX.String().
491+ # Default: false
492+ sql-isolation-level : true
493+ # Suggest the use of tls.SignatureScheme.String().
494+ # Default: false
495+ tls-signature-scheme : true
496+ # Suggest the use of constant.Kind.String().
497+ # Default: false
498+ constant-kind : true
499+
342500 usetesting :
343501 os-temp-dir : false
344502 context-background : true
@@ -437,17 +595,6 @@ linters:
437595 path : cmd/crowdsec/flags.go
438596 text : ' deep-exit: .*'
439597
440- - linters :
441- - recvcheck
442- path : pkg/csplugin/hclog_adapter.go
443- text : the methods of "HCLogAdapter" use pointer receiver and non-pointer receiver.
444-
445- # encoding to json/yaml requires value receivers
446- - linters :
447- - recvcheck
448- path : pkg/cwhub/item.go
449- text : the methods of "Item" use pointer receiver and non-pointer receiver.
450-
451598 - linters :
452599 - gocritic
453600 path : cmd/crowdsec-cli
@@ -505,6 +652,10 @@ linters:
505652 path : pkg/exprhelpers/helpers.go
506653 text : " net.LookupHost must not be called"
507654
655+ - linters :
656+ - embeddedstructfieldcheck
657+ text : " embedded fields should be listed before regular fields"
658+
508659 paths :
509660 - third_party$
510661 - builtin$
0 commit comments