Debian Codegraph @

build/golangci-lint/golangci.yaml

raw
1 ######################################################################################################
2 # #
3 # Shoutrrr golangci-lint Configuration #
4 # #
5 # Shoutrrr: https://github.com/nicholas-fedor/shoutrrr/ #
6 # Golangci-lint: https://golangci-lint.run/ #
7 # yaml-language-server: $schema=https://golangci-lint.run/jsonschema/golangci.jsonschema.json #
8 # #
9 ######################################################################################################
10
11 ######################################################################################################
12 # Version Configuration
13 # https://golangci-lint.run/docs/configuration/file/#version-configuration
14 ######################################################################################################
15 version: "2"
16
17 ######################################################################################################
18 # Linters Configuration
19 # https://golangci-lint.run/usage/linters/
20 ######################################################################################################
21 linters:
22 ####################################################################################################
23 # Default set of linters.
24 # The value can be: `standard`, `all`, `none`, or `fast`.
25 # Default: standard
26 # default: all
27
28 ####################################################################################################
29 enable:
30 ##################################################################################################
31 # Enabled linters that automatically resolve issues
32 ##################################################################################################
33 - canonicalheader # Canonicalheader checks whether net/http.Header uses canonical header.
34 - copyloopvar # A linter detects places where loop variables are copied.
35 - dupword # Checks for duplicate words in the source code.
36 - err113 # Go linter to check the errors handling expressions.
37 - errorlint # Errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13.
38 - exptostd # Detects functions from golang.org/x/exp/ that can be replaced by std functions.
39 - fatcontext # Detects nested contexts in loops and function literals.
40 - ginkgolinter # Enforces standards of using ginkgo and gomega.
41 - gocritic # Provides diagnostics that check for bugs, performance and style issues.
42 - godot # Check if comments end in a period.
43 - goheader # Checks if file header matches to pattern.
44 - govet # Vet examines Go source code and reports suspicious constructs. It is roughly the same as 'go vet' and uses its passes.
45 - iface # Detect the incorrect use of interfaces, helping developers avoid interface pollution.
46 - importas # Enforces consistent import aliases.
47 - intrange # Intrange is a linter to find places where for loops could make use of an integer range.
48 - mirror # Reports wrong mirror patterns of bytes/strings usage.
49 - misspell # Finds commonly misspelled English words.
50 - nakedret # Checks that functions with naked returns are not longer than a maximum size (can be zero).
51 - nlreturn # Nlreturn checks for a new line before return and branch statements to increase code clarity.
52 - nolintlint # Reports ill-formed or insufficient nolint directives.
53 - perfsprint # Checks that fmt.Sprintf can be replaced with a faster alternative.
54 - protogetter # Reports direct reads from proto message fields when getters should be used. [auto-fix]
55 - revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint.
56 - sloglint # Ensure consistent code style when using log/slog.
57 - staticcheck # It's a set of rules from staticcheck. It's not the same thing as the staticcheck binary. The author of staticcheck doesn't support or approve the use of the staticcheck as a library inside golangci-lint.
58 - tagalign # Check that struct tags are well aligned.
59 - testifylint # Checks usage of github.com/stretchr/testify.
60 - usestdlibvars # A linter that detect the possibility to use variables/constants from the Go standard library.
61 - usetesting # Reports uses of functions with replacement inside the testing package.
62 - whitespace # Whitespace is a linter that checks for unnecessary newlines at the start and end of functions, if, for, etc.
63 - wsl_v5 # Add or remove empty lines.
64 ##################################################################################################
65 # Enabled linters that require manual issue resolution
66 ##################################################################################################
67 - asasalint # Check for pass []any as any in variadic func(...any).
68 - asciicheck # Checks that all code identifiers does not have non-ASCII symbols in the name.
69 - bidichk # Checks for dangerous unicode character sequences.
70 - bodyclose # Checks whether HTTP response body is closed successfully.
71 - containedctx # Containedctx is a linter that detects struct contained context.Context field.
72 - contextcheck # Check whether the function uses a non-inherited context.
73 - decorder # Check declaration order and count of types, constants, variables and functions.
74 - dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f()).
75 - dupl # Detects duplicate fragments of code.
76 - durationcheck # Check for two durations multiplied together.
77 - embeddedstructfieldcheck # Embedded types should be at the top of the field list of a struct, and there must be an empty line separating embedded fields from regular fields.
78 - errchkjson # Checks types passed to the json encoding functions. Reports unsupported types and reports occurrences where the check for the returned error can be omitted.
79 - errname # Checks that sentinel errors are prefixed with the `Err` and error types are suffixed with the `Error`.
80 - errcheck # Errcheck is a program for checking for unchecked errors in Go code. These unchecked errors can be critical bugs in some cases.
81 - exhaustive # Check exhaustiveness of enum switch statements.
82 - exhaustruct # Checks if all structure fields are initialized.
83 - forbidigo # Forbids identifiers.
84 - forcetypeassert # Finds forced type assertions.
85 - funcorder # Checks the order of functions, methods, and constructors.
86 - gocheckcompilerdirectives # Checks that go compiler directive comments (//go:) are valid.
87 - gochecksumtype # Run exhaustiveness checks on Go "sum types".
88 - goconst # Finds repeated strings that could be replaced by a constant.
89 - godoclint # Checks Golang's documentation practice (godoc).
90 - godox # Detects usage of FIXME, TODO and other keywords inside comments.
91 - gomoddirectives # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod.
92 - goprintffuncname # Checks that printf-like functions are named with `f` at the end.
93 - gosec # Inspects source code for security problems.
94 - gosmopolitan # Report certain i18n/l10n anti-patterns in your Go codebase.
95 - grouper # Analyze expression groups.
96 - inamedparam # Reports interfaces with unnamed method parameters.
97 - ineffassign # Detects when assignments to existing variables are not used.
98 - iotamixing # Checks if iotas are being used in const blocks with other non-iota declarations.
99 - loggercheck # Checks key value pairs for common logger libraries (kitlog,klog,logr,zap).
100 - makezero # Finds slice declarations with non-zero initial length.
101 - mnd # An analyzer to detect magic numbers.
102 - modernize # A suite of analyzers that suggest simplifications to Go code, using modern language and library features.
103 - musttag # Enforce field tags in (un)marshaled structs.
104 - nilerr # Finds the code that returns nil even if it checks that the error is not nil.
105 - nilnesserr # Reports constructs that checks for err != nil, but returns a different nil value error.
106 - nilnil # Checks that there is no simultaneous return of `nil` error and an invalid value.
107 - noctx # Finds sending http request without context.Context.
108 - nonamedreturns # Reports all named returns.
109 - nosprintfhostport # Checks for misuse of Sprintf to construct a host with port in a URL.
110 - paralleltest # Detects missing usage of t.Parallel() method in your Go test.
111 - prealloc # Finds slice declarations that could potentially be pre-allocated.
112 - predeclared # Find code that shadows one of Go's predeclared identifiers.
113 - promlinter # Check Prometheus metrics naming via promlint.
114 - reassign # Checks that package variables are not reassigned.
115 - recvcheck # Checks for receiver type consistency.
116 - testableexamples # Linter checks if examples are testable (have an expected output). [fast]
117 - thelper # Thelper detects tests helpers which is not start with t.Helper() method.
118 - tparallel # Tparallel detects inappropriate usage of t.Parallel() method in your Go test codes.
119 - unconvert # Remove unnecessary type conversions.
120 - unparam # Reports unused function parameters.
121 - unqueryvet # Detects SELECT \* in SQL queries and SQL builders, preventing performance issues and encouraging explicit column selection.
122 - unused # Checks Go code for unused constants, variables, functions and types.
123 - varnamelen # Checks that the length of a variable's name matches its scope.
124 - wastedassign # Finds wasted assignment statements.
125 - wrapcheck # Checks that errors returned from external packages are wrapped.
126 - zerologlint # Detects the wrong usage of zerolog that a user forgets to dispatch with Send or Msg.
127 ####################################################################################################
128 disable:
129 - arangolint # Opinionated best practices for arangodb client.
130 - cyclop # Checks function and package cyclomatic complexity.
131 - depguard # Checks if package imports are in a list of acceptable packages.
132 - funlen # Checks for long functions.
133 - gochecknoglobals # Check that no global variables exist.
134 - gochecknoinits # Checks that no init functions are present in Go code.
135 - gocognit # Computes and checks the cognitive complexity of functions.
136 - gocyclo # Computes and checks the cyclomatic complexity of functions. [fast]
137 - gomodguard # Allow and blocklist linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations.
138 - interfacebloat # A linter that checks the number of methods inside an interface. [fast]
139 - ireturn # Accept Interfaces, Return Concrete Types.
140 - lll # Reports long lines.
141 - maintidx # Maintidx measures the maintainability index of each function.
142 - nestif # Reports deeply nested if statements.
143 - noinlineerr # Disallows inline error handling
144 - rowserrcheck # Checks whether Rows.Err of rows is checked successfully.
145 - spancheck # Checks for mistakes with OpenTelemetry/Census spans.
146 - sqlclosecheck # Checks that sql.Rows, sql.Stmt, sqlx.NamedStmt, pgx.Query are closed.
147 - tagliatelle # Checks the struct tags.
148 - testpackage # Linter that makes you use a separate _test package.
149 - wsl # deprecated, replaced by wsl_v5 (whitespace linter)
150
151 ######################################################################################################
152 # Linter Settings Configuration
153 ######################################################################################################
154 settings:
155 ####################################################################################################
156 # https://golangci-lint.run/docs/linters/configuration/#copyloopvar
157 copyloopvar:
158 # Check all assigning the loop variable to another variable.
159 # Default: false
160 check-alias: true
161
162 ####################################################################################################
163 # https://golangci-lint.run/docs/linters/configuration/#decorder
164 decorder:
165 # Required order of `type`, `const`, `var` and `func` declarations inside a file.
166 # Default: types before constants before variables before functions.
167 dec-order:
168 - type
169 - const
170 - var
171 - func
172 # If true, underscore vars (vars with "_" as the name) will be ignored at all checks.
173 # Default: false (underscore vars are not ignored)
174 ignore-underscore-vars: false
175 # If true, order of declarations is not checked at all.
176 # Default: true (disabled)
177 disable-dec-order-check: false
178 # If true, `init` func can be anywhere in file (does not have to be declared before all other functions).
179 # Default: true (disabled)
180 disable-init-func-first-check: false
181 # If true, multiple global `type`, `const` and `var` declarations are allowed.
182 # Default: true (disabled)
183 disable-dec-num-check: true
184 # If true, type declarations will be ignored for dec num check.
185 # Default: false (type statements are not ignored)
186 disable-type-dec-num-check: false
187 # If true, const declarations will be ignored for dec num check.
188 # Default: false (const statements are not ignored)
189 disable-const-dec-num-check: false
190 # If true, var declarations will be ignored for dec num check.
191 # Default: false (var statements are not ignored)
192 disable-var-dec-num-check: false
193
194 ####################################################################################################
195 # https://golangci-lint.run/docs/linters/configuration/#errcheck
196 errcheck:
197 # Report about not checking of errors in type assertions: `a := b.(MyStruct)`.
198 # Such cases aren't reported by default.
199 # Default: false
200 check-type-assertions: true
201 # report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`.
202 # Such cases aren't reported by default.
203 # Default: false
204 check-blank: true
205 # To disable the errcheck built-in exclude list.
206 # See `-excludeonly` option in https://github.com/kisielk/errcheck#excluding-functions for details.
207 # Default: false
208 # disable-default-exclusions: true
209 # List of functions to exclude from checking, where each entry is a single function to exclude.
210 # See https://github.com/kisielk/errcheck#excluding-functions for details.
211 exclude-functions:
212 - (*strings.Builder).Write
213 - (*strings.Builder).WriteString
214 - (*bytes.Buffer).Write
215 - (*bytes.Buffer).WriteString
216 - fmt.Fprintf
217 - fmt.Fprint
218 # Display function signature instead of selector.
219 # Default: false
220 verbose: true
221
222 ####################################################################################################
223 # https://golangci-lint.run/docs/linters/configuration/#exhaustruct
224 exhaustruct:
225 # List of regular expressions to match type names that should be processed.
226 # Anonymous structs can be matched by '<anonymous>' alias.
227 #
228 # Each regular expression must match the full type name, including package path.
229 # For example, to match type `net/http.Cookie` regular expression should be `.*/http\.Cookie`,
230 # but not `http\.Cookie`.
231 # Default: []
232 # include:
233 # - '.+\.Test'
234 # - 'example\.com/package\.ExampleStruct[\d]{1,2}'
235 # List of regular expressions to match type names that should be excluded from processing.
236 # Anonymous structs can be matched by '<anonymous>' alias.
237 # Has precedence over `include`.
238 # Each regular expression must match the full type name, including package path.
239 # For example, to match type `net/http.Cookie` regular expression should be `.*/http\.Cookie`,
240 # but not `http\.Cookie`.
241 # Default: []
242 exclude:
243 # Exclude test files - pattern matches type names from test files
244 - '.*_test\.\w+$'
245 # Exclude cobra.Command - typically used with partial initialization
246 - '.+/cobra\.Command$'
247 # Exclude internal/testutils package - test utilities
248 - 'github\.com/nicholas-fedor/shoutrrr/internal/testutils/.*'
249 # Exclude service types - initialized via factory functions
250 - 'github\.com/nicholas-fedor/shoutrrr/pkg/services/.+\.Service'
251 # Exclude config types - initialized via URL parsing (setURL method)
252 - 'github\.com/nicholas-fedor/shoutrrr/pkg/services/.+\.Config'
253 # Exclude payload types - initialized via URL parsing (setURL method)
254 - 'github\.com/nicholas-fedor/shoutrrr/pkg/services/.+Payload'
255 # Exclude message/body types - partially initialized with fields set conditionally
256 - 'github\.com/nicholas-fedor/shoutrrr/pkg/services/.+\.(TextContent|RequestBody|Message)$'
257 # Exclude standard library types that don't require full initialization
258 - '.*/url\.URL$'
259 - '.*/http\.Client$'
260 - '.*/http\.Transport$'
261 - '.*/http\.Request$'
262 - '.*/http\.Response$'
263 - '.*/tls\.Config$'
264 # Exclude third-party OAuth types
265 - '.*/oauth2\.Endpoint'
266 - '.*/oauth2\.Config'
267 # Exclude tls.Dialer - embedded net.Dialer with zero-value defaults
268 - '.*/tls\.Dialer'
269 # Allows empty structures, effectively excluding them from the check.
270 # Default: false
271 allow-empty: true
272 # List of regular expressions to match type names that should be allowed to be empty.
273 # Anonymous structs can be matched by '<anonymous>' alias.
274 # Each regular expression must match the full type name, including package path.
275 # For example, to match type `net/http.Cookie` regular expression should be `.*/http\.Cookie`,
276 # but not `http\.Cookie`.
277 # Default: []
278 # allow-empty-rx:
279 # - '.*/http\.Cookie'
280 # Allows empty structures in return statements.
281 # Default: false
282 allow-empty-returns: true
283 # Allows empty structures in variable declarations.
284 # Default: false
285 allow-empty-declarations: true
286
287 ####################################################################################################
288 # https://golangci-lint.run/docs/linters/configuration/#forbidigo
289 forbidigo:
290 # Forbid the following identifiers (list of regexp).
291 # Default: ["^(fmt\\.Print(|f|ln)|print|println)$"]
292 forbid:
293 # Default
294 - pattern: ^(fmt\\.Print(|f|ln)|print|println)$
295 # Use new https://pkg.go.dev/math/rand/v2
296 - pattern: math/rand\.
297 msg: Use math/rand/v2 instead
298 # Prevent use of deprecated https://pkg.go.dev/io/ioutil
299 - pattern: io/ioutil
300 msg: Use io or os packages instead
301 # Prevent use of syscall package https://go.googlesource.com/proposal/+/refs/heads/master/design/freeze-syscall.md
302 - pattern: syscall\.
303 msg: Use golang.org/x/sys instead
304 # Exclude godoc examples from forbidigo checks.
305 # Default: true
306 # exclude-godoc-examples: false
307 # Instead of matching the literal source code,
308 # use type information to replace expressions with strings that contain the package name
309 # and (for methods and fields) the type name.
310 # This makes it possible to handle import renaming and forbid struct fields and methods.
311 # Default: false
312 # analyze-types: true
313
314 ####################################################################################################
315 # https://golangci-lint.run/docs/linters/configuration/#funcorder
316 funcorder:
317 # Checks that constructors are placed after the structure declaration.
318 # Default: true
319 constructor: true
320 # Checks if the exported methods of a structure are placed before the non-exported ones.
321 # Default: true
322 struct-method: true
323 # Checks if the constructors and/or structure methods are sorted alphabetically.
324 # Default: false
325 alphabetical: true
326
327 ####################################################################################################
328 # https://golangci-lint.run/docs/linters/configuration/#goconst
329 goconst:
330 # Minimal length of string constant.
331 # Default: 3
332 min-len: 3
333 # Minimum occurrences of constant string count to trigger issue.
334 # Default: 3
335 min-occurrences: 5
336 # Look for existing constants matching the values.
337 # Default: true
338 match-constant: false
339 # Search also for duplicated numbers.
340 # Default: false
341 numbers: false
342 # Minimum value, only works with `goconst.numbers`.
343 # Default: 3
344 min: 3
345 # Maximum value, only works with `goconst.numbers`.
346 # Default: 3
347 max: 3
348 # Ignore when constant is not used as function argument.
349 # Default: true
350 ignore-calls: false
351 # Exclude strings matching the given regular expression.
352 # Default: ""
353 ignore-string-values:
354 - ""
355 # Detects constants with identical values.
356 # Default: false
357 find-duplicates: true
358 # Evaluates of constant expressions like Prefix + "suffix".
359 # Default: false
360 eval-const-expressions: false
361 # Ignore strings from test files.
362 # Default: false
363 ignore-tests: true
364 # Ignore string literals in calls to these functions
365 # Default: empty list
366 ignore-functions:
367 - "log.*"
368 - "slog.*"
369 - "fmt.Printf"
370 - "fmt.Errorf"
371 - "errors.New"
372
373 ####################################################################################################
374 # https://golangci-lint.run/docs/linters/configuration/#gocritic
375 gocritic:
376 # Enable all checks.
377 # Default: false
378 enable-all: true
379 # Disable checks that conflict with nonamedreturns linter
380 # Default: []
381 disabled-checks:
382 - unnamedResult
383
384 ####################################################################################################
385 # https://golangci-lint.run/docs/linters/configuration/#gosec
386 gosec:
387 # To select a subset of rules to run.
388 # Available rules: https://github.com/securego/gosec#available-rules
389 # Default: [] - means include all rules
390 # includes:
391 # - G101 # Look for hardcoded credentials
392 # To specify a set of rules to explicitly exclude.
393 # Available rules: https://github.com/securego/gosec#available-rules
394 # Default: []
395 excludes:
396 - G402 # TLS InsecureSkipVerify - intentional for dev/testing/internal networks
397 - G704 # SSRF via taint analysis - this is a http client library
398 - G705 # XSS via taint analysis - false positives for CLI console output
399
400 ####################################################################################################
401 # https://golangci-lint.run/docs/linters/configuration/#misspell
402 misspell:
403 locale: US
404
405 ####################################################################################################
406 # https://golangci-lint.run/docs/linters/configuration/#nakedret
407 nakedret:
408 # Make an issue if func has more lines of code than this setting, and it has naked returns.
409 # Default: 30
410 max-func-lines: 10
411
412 ####################################################################################################
413 # https://golangci-lint.run/docs/linters/configuration/#revive
414 revive:
415 enable-all-rules: false
416 # Configure rules
417 rules:
418 # Rule to check for meaningless package names
419 # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#var-naming
420 - name: var-naming
421 severity: warning
422 disabled: false
423 exclude: [""]
424 arguments:
425 - [""] # AllowList
426 - [""] # DenyList
427 - - skip-initialism-name-checks: false
428 upper-case-const: true
429 skip-package-name-checks: true
430 skip-package-name-collision-with-go-std: true
431 extra-bad-package-names:
432 - helpers
433 - models
434 # Rule to check for package name conflicts
435 # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#package-comments
436 - name: package-comments
437 severity: warning
438 disabled: false
439 exclude:
440 - ".*pkg/api/metrics/.*"
441 - ".*pkg/metrics/.*"
442
443 ####################################################################################################
444 # https://golangci-lint.run/docs/linters/configuration/#paralleltest
445 paralleltest:
446 # Ignore missing calls to `t.Parallel()` and only report incorrect uses of it.
447 # Default: false
448 # ignore-missing: true
449 # Ignore missing calls to `t.Parallel()` in subtests. Top-level tests are
450 # still required to have `t.Parallel`, but subtests are allowed to skip it.
451 # Default: false
452 ignore-missing-subtests: true
453
454 ####################################################################################################
455 # https://golangci-lint.run/docs/linters/configuration/#testifylint
456 testifylint:
457 enable-all: true
458
459 ####################################################################################################
460 # https://golangci-lint.run/docs/linters/configuration/#wrapcheck
461 wrapcheck:
462 # An array of strings specifying additional substrings of signatures to ignore.
463 # Unlike 'ignore-sigs', this option extends the default set (or the set specified in 'ignore-sigs') without replacing it entirely.
464 # This allows you to add specific signatures to the ignore list
465 # while retaining the defaults or any items in 'ignore-sigs'.
466 # Default: []
467 # extra-ignore-sigs:
468 # - .CustomError(
469 # - .SpecificWrap(
470 # An array of strings that specify substrings of signatures to ignore.
471 # If this set, it will override the default set of ignored signatures.
472 # See https://github.com/tomarrell/wrapcheck#configuration for more information.
473 # Default: [".Errorf(", "errors.New(", "errors.Unwrap(", "errors.Join(", ".Wrap(", ".Wrapf(", ".WithMessage(", ".WithMessagef(", ".WithStack("]
474 # ignore-sigs:
475 # - .Errorf(
476 # - errors.New(
477 # - errors.Unwrap(
478 # - errors.Join(
479 # - .Wrap(
480 # - .Wrapf(
481 # - .WithMessage(
482 # - .WithMessagef(
483 # - .WithStack(
484 # An array of strings that specify regular expressions of signatures to ignore.
485 # Default: []
486 # ignore-sig-regexps:
487 # - \.New.*Error\(
488 # An array of strings that specify globs of packages to ignore.
489 # Default: []
490 ignore-package-globs:
491 - github.com/nicholas-fedor/shoutrrr/internal/*
492 - github.com/nicholas-fedor/shoutrrr/pkg/*
493 # An array of strings that specify regular expressions of interfaces to ignore.
494 # Default: []
495 # ignore-interface-regexps:
496 # - ^(?i)c(?-i)ach(ing|e)
497 # Determines whether wrapcheck should report errors returned from inside the package.
498 # Default: false
499 # report-internal-errors: true
500
501 ####################################################################################################
502 # https://golangci-lint.run/docs/linters/configuration/#varnamelen
503 varnamelen:
504 max-distance: 5
505 min-name-length: 3
506 check-return: true
507 check-type-param: true
508 ignore-type-assert-ok: true
509 ignore-map-index-ok: true
510 ignore-chan-recv-ok: true
511 ignore-names:
512 - err
513 - b
514 - c
515 - ctx
516 - i
517 - j
518 - tt
519 ignore-decls:
520 - c echo.Context
521 - t testing.T
522 - f *foo.Bar
523 - e error
524 - i int
525 - j int
526 - const C
527 - T any
528 - m map[string]int
529 - w http.ResponseWriter
530 - r *http.Request
531 - r http.Request
532 - r *net/http/Request
533 - r *mux.Router
534 - b strings.Builder{}
535 - c echo.Context
536 - t testing.T
537 - f *foo.Bar
538 - e error
539 - i int
540 - const C
541 - T any
542 - m map[string]int
543 - w http.ResponseWriter
544 - r *http.Request
545 - r http.Request
546 - r *http.Request
547 - r http.Request
548 - r *mux.Router
549 - r *mux.Router
550
551 ######################################################################################################
552 # Defines a set of rules to ignore issues.
553 # It does not skip the analysis, and so does not ignore "typecheck" errors.
554 exclusions:
555 # Mode of the generated files analysis.
556 #
557 # - `strict`: sources are excluded by strictly following the Go generated file convention.
558 # Source files that have lines matching only the following regular expression will be excluded: `^// Code generated .* DO NOT EDIT\.$`
559 # This line must appear before the first non-comment, non-blank text in the file.
560 # https://go.dev/s/generatedcode
561 # - `lax`: sources are excluded if they contain lines like `autogenerated file`, `code generated`, `do not edit`, etc.
562 # - `disable`: disable the generated files exclusion.
563 #
564 # Default: lax
565 # generated: strict
566
567 ####################################################################################################
568 # Log a warning if an exclusion rule is unused.
569 # Default: false
570 warn-unused: true
571
572 ####################################################################################################
573 # Predefined exclusion rules.
574 # Default: []
575 presets:
576 - comments
577 - std-error-handling
578 - common-false-positives
579 - legacy
580
581 ####################################################################################################
582 # Excluding configuration per-path, per-linter, per-text and per-source.
583 rules:
584 # Exclude some linters from running on tests files.
585 - path: ".*_test.go$"
586 linters:
587 - dupl
588 - err113
589 - errcheck
590 - errorlint
591 - exhaustive
592 - exhaustruct
593 - forcetypeassert
594 - funlen
595 - gocyclo
596 - gosec
597 - promlinter
598 - usetesting
599 - varnamelen
600 - wrapcheck
601 - bodyclose
602 # Exclude dupword from running on doc.go files.
603 - path: "doc.go$"
604 linters:
605 - dupword
606 # Exclude revive from flagging the internal/util package's name.
607 - path: "internal/util/.*"
608 linters:
609 - revive
610 text: "avoid meaningless package names"
611
612 # Run some linter only for test files by excluding its issues for everything else.
613 # - path-except: _test\.go
614 # linters:
615 # - forbidigo
616
617 # Exclude known linters from partially hard-vendored code,
618 # which is impossible to exclude via `nolint` comments.
619 # `/` will be replaced by the current OS file path separator to properly work on Windows.
620 # - path: internal/hmac/
621 # text: "weak cryptographic primitive"
622 # linters:
623 # - gosec
624
625 # Exclude some `staticcheck` messages.
626 # - linters:
627 # - staticcheck
628 # text: "SA9003:"
629
630 # Exclude `lll` issues for long lines with `go:generate`.
631 # - linters:
632 # - lll
633 # source: "^//go:generate "
634
635 ####################################################################################################
636 # Which file paths to exclude: they will be analyzed, but issues from them won't be reported.
637 # "/" will be replaced by the current OS file path separator to properly work on Windows.
638 # Default: []
639 paths:
640 # - ".*\\.my\\.go$"
641 # - lib/bad.go
642 - ".*/mocks/.*"
643 # - third_party$
644 # - builtin$
645 # - examples$
646
647 ####################################################################################################
648 # Which file paths to not exclude.
649 # Default: []
650 # paths-except:
651 # - ".*\\.my\\.go$"
652 # - lib/bad.go
653
654 ######################################################################################################
655 # Formatters Configuration
656 # https://golangci-lint.run/usage/configuration/#formatters-configuration
657 ######################################################################################################
658
659 formatters:
660 # Enable specific formatter.
661 # Default: []
662 enable:
663 ##################################################################################################
664 # Check if code and import statements are formatted, with additional rules.
665 - gci
666 ##################################################################################################
667 # Check if the code is formatted according to 'gofmt' command.
668 - gofmt
669 ##################################################################################################
670 # Check if code and import statements are formatted, with additional rules.
671 - gofumpt
672 ##################################################################################################
673 # Checks if the code and import statements are formatted according to the 'goimports' command.
674 - goimports
675 ##################################################################################################
676 # Checks if code is formatted, and fixes long lines.
677 - golines
678
679 ####################################################################################################
680 # Formatters settings.
681 # https://golangci-lint.run/docs/configuration/file/#formatters-configuration
682 ####################################################################################################
683 settings:
684 ##################################################################################################
685 # https://golangci-lint.run/docs/formatters/configuration/#gci
686 gci:
687 # Section configuration to compare against.
688 # Section names are case-insensitive and may contain parameters in ().
689 # The default order of sections is `standard > default > custom > blank > dot > alias > localmodule`,
690 # If `custom-order` is `true`, it follows the order of `sections` option.
691 # Default: ["standard", "default"]
692 sections:
693 - standard # Standard section: captures all standard packages.
694 - default # Default section: contains all imports that could not be matched to another section type.
695 - prefix(github.com/nicholas-fedor/shoutrrr) # Custom section: groups all imports with the specified Prefix.
696 - blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled.
697 - dot # Dot section: contains all dot imports. This section is not present unless explicitly enabled.
698 - alias # Alias section: contains all alias imports. This section is not present unless explicitly enabled.
699 - localmodule # Local module section: contains all local packages. This section is not present unless explicitly enabled.
700 # Checks that no inline comments are present.
701 # Default: false
702 # no-inline-comments: true
703 # Checks that no prefix comments (comment lines above an import) are present.
704 # Default: false
705 # no-prefix-comments: true
706 # Enable custom order of sections.
707 # If `true`, make the section order the same as the order of `sections`.
708 # Default: false
709 # custom-order: true
710 # Drops lexical ordering for custom sections.
711 # Default: false
712 # no-lex-order: true
713 ##################################################################################################
714 # https://golangci-lint.run/docs/formatters/configuration/#gofmt
715 gofmt:
716 # Simplify code: gofmt with `-s` option.
717 # Default: true
718 # simplify: false
719 # Apply the rewrite rules to the source before reformatting.
720 # https://pkg.go.dev/cmd/gofmt
721 # Default: []
722 rewrite-rules:
723 # Go 1.18+: replace interface{} with any
724 - pattern: "interface{}"
725 replacement: "any"
726 # Slice expressions: a[b:len(a)] → a[b:]
727 - pattern: "a[b:len(a)]"
728 replacement: "a[b:]"
729 # a[:len(a)] → a[:] (full slice)
730 - pattern: "a[:len(a)]"
731 replacement: "a[:]"
732 # Go 1.21+: use slices.Clone instead of append(make([]T, len(s)), s...)
733 - pattern: "append(make([]T, len(s)), s...)"
734 replacement: "slices.Clone(s)"
735 # Go 1.21+: use slices.Delete instead of manual delete patterns
736 # i:j+1 where j = i + k, common delete pattern
737 - pattern: "a[:i+i+k:k+i+k]"
738 replacement: "slices.Delete(a, i, i+k)"
739 # strings.Clone (Go 1.20+)
740 - pattern: "string([]byte(s))"
741 replacement: "strings.Clone(s)"
742 # bytes.Clone (Go 1.20+)
743 - pattern: "append([]byte(nil), b...)"
744 replacement: "bytes.Clone(b)"
745 - pattern: "append(make([]byte, 0, len(b)), b...)"
746 replacement: "bytes.Clone(b)"
747 # Remove redundant type conversions in append
748 - pattern: "append([]T(nil), x)"
749 replacement: "append(make([]T, 0), x)"
750 # or better: just "[]T{x}" if building a new slice
751 ##################################################################################################
752 # https://golangci-lint.run/docs/formatters/configuration/#gofumpt
753 gofumpt:
754 module-path: "github.com/nicholas-fedor/shoutrrr"
755 extra-rules: true
756 ##################################################################################################
757 # https://golangci-lint.run/docs/formatters/configuration/#goimports
758 goimports:
759 # A list of prefixes, which, if set, checks import paths
760 # with the given prefixes are grouped after 3rd-party packages.
761 # Default: []
762 local-prefixes:
763 - github.com/nicholas-fedor/shoutrrr
764 ##################################################################################################
765 # https://golangci-lint.run/docs/formatters/configuration/#golines
766 golines:
767 # Target maximum line length.
768 # Default: 100
769 max-len: 200
770 # Length of a tabulation.
771 # Default: 4
772 tab-len: 4
773 # Shorten single-line comments.
774 # Default: false
775 shorten-comments: true
776 # Default: true
777 reformat-tags: true
778 # Split chained methods on the dots as opposed to the arguments.
779 # Default: true
780 chain-split-dots: true
781
782 ####################################################################################################
783 exclusions:
784 ##################################################################################################
785 # Log a warning if an exclusion path is unused.
786 # Default: false
787 warn-unused: true
788 ##################################################################################################
789 # Mode of the generated files analysis.
790 #
791 # - `strict`: sources are excluded by strictly following the Go generated file convention.
792 # Source files that have lines matching only the following regular expression will be excluded: `^// Code generated .* DO NOT EDIT\.$`
793 # This line must appear before the first non-comment, non-blank text in the file.
794 # https://go.dev/s/generatedcode
795 # - `lax`: sources are excluded if they contain lines like `autogenerated file`, `code generated`, `do not edit`, etc.
796 # - `disable`: disable the generated files exclusion.
797 #
798 # Default: lax
799 # generated: strict
800 ##################################################################################################
801 # Which file paths to exclude.
802 # Default: []
803 paths:
804 - ".*mocks$"
805 # - third_party$
806 # - builtin$
807 # - examples$
808
809 ######################################################################################################
810 # Issues Configuration
811 # https://golangci-lint.run/usage/configuration/#issues-configuration
812 ######################################################################################################
813 issues:
814 # Maximum issues count per one linter.
815 # Set to 0 to disable.
816 # Default: 50
817 max-issues-per-linter: 0
818
819 ####################################################################################################
820 # Maximum count of issues with the same text.
821 # Set to 0 to disable.
822 # Default: 3
823 max-same-issues: 0
824
825 ####################################################################################################
826 # Make issues output unique by line.
827 # Default: true
828 # uniq-by-line: false
829
830 ####################################################################################################
831 # Show only new issues: if there are unstaged changes or untracked files,
832 # only those changes are analyzed, else only changes in HEAD~ are analyzed.
833 # It's a super-useful option for integration of golangci-lint into existing large codebase.
834 # It's not practical to fix all existing issues at the moment of integration:
835 # much better don't allow issues in new code.
836 #
837 # Default: false
838 # new: true
839
840 ####################################################################################################
841 # Show only new issues created after the best common ancestor (merge-base against HEAD).
842 # Default: ""
843 # new-from-merge-base: main
844
845 ####################################################################################################
846 # Show only new issues created after git revision `REV`.
847 # Default: ""
848 # new-from-rev: HEAD
849
850 ####################################################################################################
851 # Show only new issues created in git patch with set file path.
852 # Default: ""
853 # new-from-patch: path/to/patch/file
854
855 ####################################################################################################
856 # Show issues in any part of update files (requires new-from-rev or new-from-patch).
857 # Default: false
858 whole-files: true
859
860 ####################################################################################################
861 # Fix found issues (if it's supported by the linter).
862 # Default: false
863 fix: true
864
865 ######################################################################################################
866 # Output Configuration
867 # https://golangci-lint.run/usage/configuration/#output-configuration
868 ######################################################################################################
869 output:
870 ####################################################################################################
871 # The formats used to render issues.
872 formats:
873 ##################################################################################################
874 # Prints issues in a text format with colors, line number, and linter name.
875 # This format is the default format.
876 text:
877 # Output path can be either `stdout`, `stderr` or path to the file to write to.
878 # Default: stdout
879 # path: ./path/to/output.txt
880
881 # Print linter name in the end of issue text.
882 # Default: true
883 # print-linter-name: false
884 print-linter-name: true
885
886 # Print lines of code with issue.
887 # Default: true
888 # print-issued-lines: false
889 print-issued-lines: true
890
891 # Use colors.
892 # Default: true
893 # colors: false
894 colors: true
895
896 ##################################################################################################
897 # Prints issues in a JSON representation.
898 # json:
899 # Output path can be either `stdout`, `stderr` or path to the file to write to.
900 # Default: stdout
901 # path: ./path/to/output.json
902 # path: stderr
903
904 ##################################################################################################
905 # Prints issues in columns representation separated by tabulations.
906 tab:
907 # Output path can be either `stdout`, `stderr` or path to the file to write to.
908 # Default: stdout
909 # path: ./path/to/output.txt
910 # Print linter name in the end of issue text.
911 # Default: true
912 print-linter-name: true
913 # Use colors.
914 # Default: true
915 # colors: false
916 colors: true
917
918 ##################################################################################################
919 # Prints issues in an HTML page.
920 # It uses the Cloudflare CDN (cdnjs) and React.
921 # html:
922 # Output path can be either `stdout`, `stderr` or path to the file to write to.
923 # Default: stdout
924 # path: ./path/to/output.html
925
926 ##################################################################################################
927 # Prints issues in the Checkstyle format.
928 # checkstyle:
929 # Output path can be either `stdout`, `stderr` or path to the file to write to.
930 # Default: stdout
931 # path: ./path/to/output.xml
932
933 ##################################################################################################
934 # Prints issues in the Code Climate format.
935 # code-climate:
936 # Output path can be either `stdout`, `stderr` or path to the file to write to.
937 # Default: stdout
938 # path: ./path/to/output.json
939
940 ##################################################################################################
941 # Prints issues in the JUnit XML format.
942 # junit-xml:
943 # Output path can be either `stdout`, `stderr` or path to the file to write to.
944 # Default: stdout
945 # path: ./path/to/output.xml
946 # Support extra JUnit XML fields.
947 # Default: false
948 # extended: true
949
950 ##################################################################################################
951 # Prints issues in the TeamCity format.
952 # teamcity:
953 # Output path can be either `stdout`, `stderr` or path to the file to write to.
954 # Default: stdout
955 # path: ./path/to/output.txt
956
957 ##################################################################################################
958 # Prints issues in the SARIF format.
959 # sarif:
960 # Output path can be either `stdout`, `stderr` or path to the file to write to.
961 # Default: stdout
962 # path: ./path/to/output.json
963
964 ####################################################################################################
965 # Add a prefix to the output file references.
966 # Default: ""
967 # path-prefix: ""
968
969 ####################################################################################################
970 # By default, the report are related to the path obtained by `run.relative-path-mode`.
971 # The mode `abs` allows to show absolute file paths instead of relative file paths.
972 # The option `output.path-prefix` is ignored when using `abs` mode.
973 # Default: ""
974 path-mode: "abs"
975
976 ####################################################################################################
977 # Order to use when sorting results.
978 # Possible values: `file`, `linter`, and `severity`.
979 #
980 # If the severity values are inside the following list, they are ordered in this order:
981 # 1. error
982 # 2. warning
983 # 3. high
984 # 4. medium
985 # 5. low
986 # Either they are sorted alphabetically.
987 #
988 # Default: ["linter", "file"]
989 sort-order:
990 - file # filepath, line, and column.
991 - severity
992 - linter
993
994 ####################################################################################################
995 # Show statistics per linter.
996 # Default: true
997 # show-stats: false
998
999 ######################################################################################################
1000 # Run Configuration
1001 # Options for analysis running.
1002 # https://golangci-lint.run/usage/configuration/#run-configuration
1003 ######################################################################################################
1004 run:
1005 ####################################################################################################
1006 # Timeout for analysis, e.g. 30s, 5m, 5m30s.
1007 # If the value is lower or equal to 0, the timeout is disabled.
1008 # Default: 1m
1009 # timeout: 5m
1010
1011 ####################################################################################################
1012 # The mode used to evaluate relative paths.
1013 # It's used by exclusions, Go plugins, and some linters.
1014 # The value can be:
1015 # - `gomod`: the paths will be relative to the directory of the `go.mod` file.
1016 # - `gitroot`: the paths will be relative to the git root (the parent directory of `.git`).
1017 # - `cfg`: the paths will be relative to the configuration file.
1018 # - `wd` (NOT recommended): the paths will be relative to the place where golangci-lint is run.
1019 # Default: wd
1020 # relative-path-mode: gomod
1021
1022 ####################################################################################################
1023 # Exit code when at least one issue was found.
1024 # Default: 1
1025 # issues-exit-code: 2
1026
1027 ####################################################################################################
1028 # Include test files or not.
1029 # Default: true
1030 # tests: false
1031
1032 ####################################################################################################
1033 # List of build tags, all linters use it.
1034 # Default: []
1035 # build-tags:
1036 # - mytag
1037
1038 ####################################################################################################
1039 # If set, we pass it to "go list -mod={option}". From "go help modules":
1040 # If invoked with -mod=readonly, the go command is disallowed from the implicit
1041 # automatic updating of go.mod described above. Instead, it fails when any changes
1042 # to go.mod are needed. This setting is most useful to check that go.mod does
1043 # not need updates, such as in a continuous integration and testing system.
1044 # If invoked with -mod=vendor, the go command assumes that the vendor
1045 # directory holds the correct copies of dependencies and ignores
1046 # the dependency descriptions in go.mod.
1047 #
1048 # Allowed values: readonly|vendor|mod
1049 # Default: ""
1050 # modules-download-mode: readonly
1051
1052 ####################################################################################################
1053 # Allow multiple parallel golangci-lint instances running.
1054 # If false, golangci-lint acquires file lock on start.
1055 # Default: false
1056 allow-parallel-runners: true
1057
1058 ####################################################################################################
1059 # Allow multiple golangci-lint instances running, but serialize them around a lock.
1060 # If false, golangci-lint exits with an error if it fails to acquire file lock on start.
1061 # Default: false
1062 allow-serial-runners: true
1063
1064 ####################################################################################################
1065 # Define the Go version limit.
1066 # Mainly related to generics support since go1.18.
1067 # Default: use Go version from the go.mod file, fallback on the env var `GOVERSION`, fallback on 1.22.
1068 # go: "1.24"
1069
1070 ####################################################################################################
1071 # Number of operating system threads (`GOMAXPROCS`) that can execute golangci-lint simultaneously.
1072 # If it is explicitly set to 0 (i.e. not the default) then golangci-lint will automatically set the value to match Linux container CPU quota.
1073 # Default: the number of logical CPUs in the machine
1074 # concurrency: 4
1075 ######################################################################################################
1076 # Severity Configuration
1077 # https://golangci-lint.run/usage/configuration/#severity-configuration
1078 ######################################################################################################
1079 # severity:
1080 ####################################################################################################
1081 # Set the default severity for issues.
1082 #
1083 # If severity rules are defined and the issues do not match or no severity is provided to the rule
1084 # this will be the default severity applied.
1085 # Severities should match the supported severity names of the selected out format.
1086 # - Code climate: https://docs.codeclimate.com/docs/issues#issue-severity
1087 # - Checkstyle: https://checkstyle.sourceforge.io/property_types.html#SeverityLevel
1088 # - GitHub: https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-error-message
1089 # - TeamCity: https://www.jetbrains.com/help/teamcity/service-messages.html#Inspection+Instance
1090 #
1091 # `@linter` can be used as severity value to keep the severity from linters (e.g. revive, gosec, ...)
1092 #
1093 # Default: ""
1094 # default: error
1095
1096 ####################################################################################################
1097 # If set to true `severity-rules` regular expressions become case-sensitive.
1098 # Default: false
1099 # case-sensitive: true
1100
1101 ####################################################################################################
1102 # When a list of severity rules are provided, severity information will be added to lint issues.
1103 # Severity rules have the same filtering capability as exclude rules
1104 # except you are allowed to specify one matcher per severity rule.
1105 #
1106 # `@linter` can be used as severity value to keep the severity from linters (e.g. revive, gosec, ...)
1107 #
1108 # Only affects out formats that support setting severity information.
1109 #
1110 # Default: []
1111 # rules:
1112 # - linters:
1113 # - dupl
1114 # severity: info
1115 ######################################################################################################
1116 # End of golangci-lint Configuration
1117 ######################################################################################################