###################################################################################################### # # # Shoutrrr golangci-lint Configuration # # # # Shoutrrr: https://github.com/nicholas-fedor/shoutrrr/ # # Golangci-lint: https://golangci-lint.run/ # # yaml-language-server: $schema=https://golangci-lint.run/jsonschema/golangci.jsonschema.json # # # ###################################################################################################### ###################################################################################################### # Version Configuration # https://golangci-lint.run/docs/configuration/file/#version-configuration ###################################################################################################### version: "2" ###################################################################################################### # Linters Configuration # https://golangci-lint.run/usage/linters/ ###################################################################################################### linters: #################################################################################################### # Default set of linters. # The value can be: `standard`, `all`, `none`, or `fast`. # Default: standard # default: all #################################################################################################### enable: ################################################################################################## # Enabled linters that automatically resolve issues ################################################################################################## - canonicalheader # Canonicalheader checks whether net/http.Header uses canonical header. - copyloopvar # A linter detects places where loop variables are copied. - dupword # Checks for duplicate words in the source code. - err113 # Go linter to check the errors handling expressions. - 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. - exptostd # Detects functions from golang.org/x/exp/ that can be replaced by std functions. - fatcontext # Detects nested contexts in loops and function literals. - ginkgolinter # Enforces standards of using ginkgo and gomega. - gocritic # Provides diagnostics that check for bugs, performance and style issues. - godot # Check if comments end in a period. - goheader # Checks if file header matches to pattern. - govet # Vet examines Go source code and reports suspicious constructs. It is roughly the same as 'go vet' and uses its passes. - iface # Detect the incorrect use of interfaces, helping developers avoid interface pollution. - importas # Enforces consistent import aliases. - intrange # Intrange is a linter to find places where for loops could make use of an integer range. - mirror # Reports wrong mirror patterns of bytes/strings usage. - misspell # Finds commonly misspelled English words. - nakedret # Checks that functions with naked returns are not longer than a maximum size (can be zero). - nlreturn # Nlreturn checks for a new line before return and branch statements to increase code clarity. - nolintlint # Reports ill-formed or insufficient nolint directives. - perfsprint # Checks that fmt.Sprintf can be replaced with a faster alternative. - protogetter # Reports direct reads from proto message fields when getters should be used. [auto-fix] - revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint. - sloglint # Ensure consistent code style when using log/slog. - 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. - tagalign # Check that struct tags are well aligned. - testifylint # Checks usage of github.com/stretchr/testify. - usestdlibvars # A linter that detect the possibility to use variables/constants from the Go standard library. - usetesting # Reports uses of functions with replacement inside the testing package. - whitespace # Whitespace is a linter that checks for unnecessary newlines at the start and end of functions, if, for, etc. - wsl_v5 # Add or remove empty lines. ################################################################################################## # Enabled linters that require manual issue resolution ################################################################################################## - asasalint # Check for pass []any as any in variadic func(...any). - asciicheck # Checks that all code identifiers does not have non-ASCII symbols in the name. - bidichk # Checks for dangerous unicode character sequences. - bodyclose # Checks whether HTTP response body is closed successfully. - containedctx # Containedctx is a linter that detects struct contained context.Context field. - contextcheck # Check whether the function uses a non-inherited context. - decorder # Check declaration order and count of types, constants, variables and functions. - dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f()). - dupl # Detects duplicate fragments of code. - durationcheck # Check for two durations multiplied together. - 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. - 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. - errname # Checks that sentinel errors are prefixed with the `Err` and error types are suffixed with the `Error`. - errcheck # Errcheck is a program for checking for unchecked errors in Go code. These unchecked errors can be critical bugs in some cases. - exhaustive # Check exhaustiveness of enum switch statements. - exhaustruct # Checks if all structure fields are initialized. - forbidigo # Forbids identifiers. - forcetypeassert # Finds forced type assertions. - funcorder # Checks the order of functions, methods, and constructors. - gocheckcompilerdirectives # Checks that go compiler directive comments (//go:) are valid. - gochecksumtype # Run exhaustiveness checks on Go "sum types". - goconst # Finds repeated strings that could be replaced by a constant. - godoclint # Checks Golang's documentation practice (godoc). - godox # Detects usage of FIXME, TODO and other keywords inside comments. - gomoddirectives # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod. - goprintffuncname # Checks that printf-like functions are named with `f` at the end. - gosec # Inspects source code for security problems. - gosmopolitan # Report certain i18n/l10n anti-patterns in your Go codebase. - grouper # Analyze expression groups. - inamedparam # Reports interfaces with unnamed method parameters. - ineffassign # Detects when assignments to existing variables are not used. - iotamixing # Checks if iotas are being used in const blocks with other non-iota declarations. - loggercheck # Checks key value pairs for common logger libraries (kitlog,klog,logr,zap). - makezero # Finds slice declarations with non-zero initial length. - mnd # An analyzer to detect magic numbers. - modernize # A suite of analyzers that suggest simplifications to Go code, using modern language and library features. - musttag # Enforce field tags in (un)marshaled structs. - nilerr # Finds the code that returns nil even if it checks that the error is not nil. - nilnesserr # Reports constructs that checks for err != nil, but returns a different nil value error. - nilnil # Checks that there is no simultaneous return of `nil` error and an invalid value. - noctx # Finds sending http request without context.Context. - nonamedreturns # Reports all named returns. - nosprintfhostport # Checks for misuse of Sprintf to construct a host with port in a URL. - paralleltest # Detects missing usage of t.Parallel() method in your Go test. - prealloc # Finds slice declarations that could potentially be pre-allocated. - predeclared # Find code that shadows one of Go's predeclared identifiers. - promlinter # Check Prometheus metrics naming via promlint. - reassign # Checks that package variables are not reassigned. - recvcheck # Checks for receiver type consistency. - testableexamples # Linter checks if examples are testable (have an expected output). [fast] - thelper # Thelper detects tests helpers which is not start with t.Helper() method. - tparallel # Tparallel detects inappropriate usage of t.Parallel() method in your Go test codes. - unconvert # Remove unnecessary type conversions. - unparam # Reports unused function parameters. - unqueryvet # Detects SELECT \* in SQL queries and SQL builders, preventing performance issues and encouraging explicit column selection. - unused # Checks Go code for unused constants, variables, functions and types. - varnamelen # Checks that the length of a variable's name matches its scope. - wastedassign # Finds wasted assignment statements. - wrapcheck # Checks that errors returned from external packages are wrapped. - zerologlint # Detects the wrong usage of zerolog that a user forgets to dispatch with Send or Msg. #################################################################################################### disable: - arangolint # Opinionated best practices for arangodb client. - cyclop # Checks function and package cyclomatic complexity. - depguard # Checks if package imports are in a list of acceptable packages. - funlen # Checks for long functions. - gochecknoglobals # Check that no global variables exist. - gochecknoinits # Checks that no init functions are present in Go code. - gocognit # Computes and checks the cognitive complexity of functions. - gocyclo # Computes and checks the cyclomatic complexity of functions. [fast] - 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. - interfacebloat # A linter that checks the number of methods inside an interface. [fast] - ireturn # Accept Interfaces, Return Concrete Types. - lll # Reports long lines. - maintidx # Maintidx measures the maintainability index of each function. - nestif # Reports deeply nested if statements. - noinlineerr # Disallows inline error handling - rowserrcheck # Checks whether Rows.Err of rows is checked successfully. - spancheck # Checks for mistakes with OpenTelemetry/Census spans. - sqlclosecheck # Checks that sql.Rows, sql.Stmt, sqlx.NamedStmt, pgx.Query are closed. - tagliatelle # Checks the struct tags. - testpackage # Linter that makes you use a separate _test package. - wsl # deprecated, replaced by wsl_v5 (whitespace linter) ###################################################################################################### # Linter Settings Configuration ###################################################################################################### settings: #################################################################################################### # https://golangci-lint.run/docs/linters/configuration/#copyloopvar copyloopvar: # Check all assigning the loop variable to another variable. # Default: false check-alias: true #################################################################################################### # https://golangci-lint.run/docs/linters/configuration/#decorder decorder: # Required order of `type`, `const`, `var` and `func` declarations inside a file. # Default: types before constants before variables before functions. dec-order: - type - const - var - func # If true, underscore vars (vars with "_" as the name) will be ignored at all checks. # Default: false (underscore vars are not ignored) ignore-underscore-vars: false # If true, order of declarations is not checked at all. # Default: true (disabled) disable-dec-order-check: false # If true, `init` func can be anywhere in file (does not have to be declared before all other functions). # Default: true (disabled) disable-init-func-first-check: false # If true, multiple global `type`, `const` and `var` declarations are allowed. # Default: true (disabled) disable-dec-num-check: true # If true, type declarations will be ignored for dec num check. # Default: false (type statements are not ignored) disable-type-dec-num-check: false # If true, const declarations will be ignored for dec num check. # Default: false (const statements are not ignored) disable-const-dec-num-check: false # If true, var declarations will be ignored for dec num check. # Default: false (var statements are not ignored) disable-var-dec-num-check: false #################################################################################################### # https://golangci-lint.run/docs/linters/configuration/#errcheck errcheck: # Report about not checking of errors in type assertions: `a := b.(MyStruct)`. # Such cases aren't reported by default. # Default: false check-type-assertions: true # report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`. # Such cases aren't reported by default. # Default: false check-blank: true # To disable the errcheck built-in exclude list. # See `-excludeonly` option in https://github.com/kisielk/errcheck#excluding-functions for details. # Default: false # disable-default-exclusions: true # List of functions to exclude from checking, where each entry is a single function to exclude. # See https://github.com/kisielk/errcheck#excluding-functions for details. exclude-functions: - (*strings.Builder).Write - (*strings.Builder).WriteString - (*bytes.Buffer).Write - (*bytes.Buffer).WriteString - fmt.Fprintf - fmt.Fprint # Display function signature instead of selector. # Default: false verbose: true #################################################################################################### # https://golangci-lint.run/docs/linters/configuration/#exhaustruct exhaustruct: # List of regular expressions to match type names that should be processed. # Anonymous structs can be matched by '' alias. # # Each regular expression must match the full type name, including package path. # For example, to match type `net/http.Cookie` regular expression should be `.*/http\.Cookie`, # but not `http\.Cookie`. # Default: [] # include: # - '.+\.Test' # - 'example\.com/package\.ExampleStruct[\d]{1,2}' # List of regular expressions to match type names that should be excluded from processing. # Anonymous structs can be matched by '' alias. # Has precedence over `include`. # Each regular expression must match the full type name, including package path. # For example, to match type `net/http.Cookie` regular expression should be `.*/http\.Cookie`, # but not `http\.Cookie`. # Default: [] exclude: # Exclude test files - pattern matches type names from test files - '.*_test\.\w+$' # Exclude cobra.Command - typically used with partial initialization - '.+/cobra\.Command$' # Exclude internal/testutils package - test utilities - 'github\.com/nicholas-fedor/shoutrrr/internal/testutils/.*' # Exclude service types - initialized via factory functions - 'github\.com/nicholas-fedor/shoutrrr/pkg/services/.+\.Service' # Exclude config types - initialized via URL parsing (setURL method) - 'github\.com/nicholas-fedor/shoutrrr/pkg/services/.+\.Config' # Exclude payload types - initialized via URL parsing (setURL method) - 'github\.com/nicholas-fedor/shoutrrr/pkg/services/.+Payload' # Exclude message/body types - partially initialized with fields set conditionally - 'github\.com/nicholas-fedor/shoutrrr/pkg/services/.+\.(TextContent|RequestBody|Message)$' # Exclude standard library types that don't require full initialization - '.*/url\.URL$' - '.*/http\.Client$' - '.*/http\.Transport$' - '.*/http\.Request$' - '.*/http\.Response$' - '.*/tls\.Config$' # Exclude third-party OAuth types - '.*/oauth2\.Endpoint' - '.*/oauth2\.Config' # Exclude tls.Dialer - embedded net.Dialer with zero-value defaults - '.*/tls\.Dialer' # Allows empty structures, effectively excluding them from the check. # Default: false allow-empty: true # List of regular expressions to match type names that should be allowed to be empty. # Anonymous structs can be matched by '' alias. # Each regular expression must match the full type name, including package path. # For example, to match type `net/http.Cookie` regular expression should be `.*/http\.Cookie`, # but not `http\.Cookie`. # Default: [] # allow-empty-rx: # - '.*/http\.Cookie' # Allows empty structures in return statements. # Default: false allow-empty-returns: true # Allows empty structures in variable declarations. # Default: false allow-empty-declarations: true #################################################################################################### # https://golangci-lint.run/docs/linters/configuration/#forbidigo forbidigo: # Forbid the following identifiers (list of regexp). # Default: ["^(fmt\\.Print(|f|ln)|print|println)$"] forbid: # Default - pattern: ^(fmt\\.Print(|f|ln)|print|println)$ # Use new https://pkg.go.dev/math/rand/v2 - pattern: math/rand\. msg: Use math/rand/v2 instead # Prevent use of deprecated https://pkg.go.dev/io/ioutil - pattern: io/ioutil msg: Use io or os packages instead # Prevent use of syscall package https://go.googlesource.com/proposal/+/refs/heads/master/design/freeze-syscall.md - pattern: syscall\. msg: Use golang.org/x/sys instead # Exclude godoc examples from forbidigo checks. # Default: true # exclude-godoc-examples: false # Instead of matching the literal source code, # use type information to replace expressions with strings that contain the package name # and (for methods and fields) the type name. # This makes it possible to handle import renaming and forbid struct fields and methods. # Default: false # analyze-types: true #################################################################################################### # https://golangci-lint.run/docs/linters/configuration/#funcorder funcorder: # Checks that constructors are placed after the structure declaration. # Default: true constructor: true # Checks if the exported methods of a structure are placed before the non-exported ones. # Default: true struct-method: true # Checks if the constructors and/or structure methods are sorted alphabetically. # Default: false alphabetical: true #################################################################################################### # https://golangci-lint.run/docs/linters/configuration/#goconst goconst: # Minimal length of string constant. # Default: 3 min-len: 3 # Minimum occurrences of constant string count to trigger issue. # Default: 3 min-occurrences: 5 # Look for existing constants matching the values. # Default: true match-constant: false # Search also for duplicated numbers. # Default: false numbers: false # Minimum value, only works with `goconst.numbers`. # Default: 3 min: 3 # Maximum value, only works with `goconst.numbers`. # Default: 3 max: 3 # Ignore when constant is not used as function argument. # Default: true ignore-calls: false # Exclude strings matching the given regular expression. # Default: "" ignore-string-values: - "" # Detects constants with identical values. # Default: false find-duplicates: true # Evaluates of constant expressions like Prefix + "suffix". # Default: false eval-const-expressions: false # Ignore strings from test files. # Default: false ignore-tests: true # Ignore string literals in calls to these functions # Default: empty list ignore-functions: - "log.*" - "slog.*" - "fmt.Printf" - "fmt.Errorf" - "errors.New" #################################################################################################### # https://golangci-lint.run/docs/linters/configuration/#gocritic gocritic: # Enable all checks. # Default: false enable-all: true # Disable checks that conflict with nonamedreturns linter # Default: [] disabled-checks: - unnamedResult #################################################################################################### # https://golangci-lint.run/docs/linters/configuration/#gosec gosec: # To select a subset of rules to run. # Available rules: https://github.com/securego/gosec#available-rules # Default: [] - means include all rules # includes: # - G101 # Look for hardcoded credentials # To specify a set of rules to explicitly exclude. # Available rules: https://github.com/securego/gosec#available-rules # Default: [] excludes: - G402 # TLS InsecureSkipVerify - intentional for dev/testing/internal networks - G704 # SSRF via taint analysis - this is a http client library - G705 # XSS via taint analysis - false positives for CLI console output #################################################################################################### # https://golangci-lint.run/docs/linters/configuration/#misspell misspell: locale: US #################################################################################################### # https://golangci-lint.run/docs/linters/configuration/#nakedret nakedret: # Make an issue if func has more lines of code than this setting, and it has naked returns. # Default: 30 max-func-lines: 10 #################################################################################################### # https://golangci-lint.run/docs/linters/configuration/#revive revive: enable-all-rules: false # Configure rules rules: # Rule to check for meaningless package names # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#var-naming - name: var-naming severity: warning disabled: false exclude: [""] arguments: - [""] # AllowList - [""] # DenyList - - skip-initialism-name-checks: false upper-case-const: true skip-package-name-checks: true skip-package-name-collision-with-go-std: true extra-bad-package-names: - helpers - models # Rule to check for package name conflicts # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#package-comments - name: package-comments severity: warning disabled: false exclude: - ".*pkg/api/metrics/.*" - ".*pkg/metrics/.*" #################################################################################################### # https://golangci-lint.run/docs/linters/configuration/#paralleltest paralleltest: # Ignore missing calls to `t.Parallel()` and only report incorrect uses of it. # Default: false # ignore-missing: true # Ignore missing calls to `t.Parallel()` in subtests. Top-level tests are # still required to have `t.Parallel`, but subtests are allowed to skip it. # Default: false ignore-missing-subtests: true #################################################################################################### # https://golangci-lint.run/docs/linters/configuration/#testifylint testifylint: enable-all: true #################################################################################################### # https://golangci-lint.run/docs/linters/configuration/#wrapcheck wrapcheck: # An array of strings specifying additional substrings of signatures to ignore. # Unlike 'ignore-sigs', this option extends the default set (or the set specified in 'ignore-sigs') without replacing it entirely. # This allows you to add specific signatures to the ignore list # while retaining the defaults or any items in 'ignore-sigs'. # Default: [] # extra-ignore-sigs: # - .CustomError( # - .SpecificWrap( # An array of strings that specify substrings of signatures to ignore. # If this set, it will override the default set of ignored signatures. # See https://github.com/tomarrell/wrapcheck#configuration for more information. # Default: [".Errorf(", "errors.New(", "errors.Unwrap(", "errors.Join(", ".Wrap(", ".Wrapf(", ".WithMessage(", ".WithMessagef(", ".WithStack("] # ignore-sigs: # - .Errorf( # - errors.New( # - errors.Unwrap( # - errors.Join( # - .Wrap( # - .Wrapf( # - .WithMessage( # - .WithMessagef( # - .WithStack( # An array of strings that specify regular expressions of signatures to ignore. # Default: [] # ignore-sig-regexps: # - \.New.*Error\( # An array of strings that specify globs of packages to ignore. # Default: [] ignore-package-globs: - github.com/nicholas-fedor/shoutrrr/internal/* - github.com/nicholas-fedor/shoutrrr/pkg/* # An array of strings that specify regular expressions of interfaces to ignore. # Default: [] # ignore-interface-regexps: # - ^(?i)c(?-i)ach(ing|e) # Determines whether wrapcheck should report errors returned from inside the package. # Default: false # report-internal-errors: true #################################################################################################### # https://golangci-lint.run/docs/linters/configuration/#varnamelen varnamelen: max-distance: 5 min-name-length: 3 check-return: true check-type-param: true ignore-type-assert-ok: true ignore-map-index-ok: true ignore-chan-recv-ok: true ignore-names: - err - b - c - ctx - i - j - tt ignore-decls: - c echo.Context - t testing.T - f *foo.Bar - e error - i int - j int - const C - T any - m map[string]int - w http.ResponseWriter - r *http.Request - r http.Request - r *net/http/Request - r *mux.Router - b strings.Builder{} - c echo.Context - t testing.T - f *foo.Bar - e error - i int - const C - T any - m map[string]int - w http.ResponseWriter - r *http.Request - r http.Request - r *http.Request - r http.Request - r *mux.Router - r *mux.Router ###################################################################################################### # Defines a set of rules to ignore issues. # It does not skip the analysis, and so does not ignore "typecheck" errors. exclusions: # Mode of the generated files analysis. # # - `strict`: sources are excluded by strictly following the Go generated file convention. # Source files that have lines matching only the following regular expression will be excluded: `^// Code generated .* DO NOT EDIT\.$` # This line must appear before the first non-comment, non-blank text in the file. # https://go.dev/s/generatedcode # - `lax`: sources are excluded if they contain lines like `autogenerated file`, `code generated`, `do not edit`, etc. # - `disable`: disable the generated files exclusion. # # Default: lax # generated: strict #################################################################################################### # Log a warning if an exclusion rule is unused. # Default: false warn-unused: true #################################################################################################### # Predefined exclusion rules. # Default: [] presets: - comments - std-error-handling - common-false-positives - legacy #################################################################################################### # Excluding configuration per-path, per-linter, per-text and per-source. rules: # Exclude some linters from running on tests files. - path: ".*_test.go$" linters: - dupl - err113 - errcheck - errorlint - exhaustive - exhaustruct - forcetypeassert - funlen - gocyclo - gosec - promlinter - usetesting - varnamelen - wrapcheck - bodyclose # Exclude dupword from running on doc.go files. - path: "doc.go$" linters: - dupword # Exclude revive from flagging the internal/util package's name. - path: "internal/util/.*" linters: - revive text: "avoid meaningless package names" # Run some linter only for test files by excluding its issues for everything else. # - path-except: _test\.go # linters: # - forbidigo # Exclude known linters from partially hard-vendored code, # which is impossible to exclude via `nolint` comments. # `/` will be replaced by the current OS file path separator to properly work on Windows. # - path: internal/hmac/ # text: "weak cryptographic primitive" # linters: # - gosec # Exclude some `staticcheck` messages. # - linters: # - staticcheck # text: "SA9003:" # Exclude `lll` issues for long lines with `go:generate`. # - linters: # - lll # source: "^//go:generate " #################################################################################################### # Which file paths to exclude: they will be analyzed, but issues from them won't be reported. # "/" will be replaced by the current OS file path separator to properly work on Windows. # Default: [] paths: # - ".*\\.my\\.go$" # - lib/bad.go - ".*/mocks/.*" # - third_party$ # - builtin$ # - examples$ #################################################################################################### # Which file paths to not exclude. # Default: [] # paths-except: # - ".*\\.my\\.go$" # - lib/bad.go ###################################################################################################### # Formatters Configuration # https://golangci-lint.run/usage/configuration/#formatters-configuration ###################################################################################################### formatters: # Enable specific formatter. # Default: [] enable: ################################################################################################## # Check if code and import statements are formatted, with additional rules. - gci ################################################################################################## # Check if the code is formatted according to 'gofmt' command. - gofmt ################################################################################################## # Check if code and import statements are formatted, with additional rules. - gofumpt ################################################################################################## # Checks if the code and import statements are formatted according to the 'goimports' command. - goimports ################################################################################################## # Checks if code is formatted, and fixes long lines. - golines #################################################################################################### # Formatters settings. # https://golangci-lint.run/docs/configuration/file/#formatters-configuration #################################################################################################### settings: ################################################################################################## # https://golangci-lint.run/docs/formatters/configuration/#gci gci: # Section configuration to compare against. # Section names are case-insensitive and may contain parameters in (). # The default order of sections is `standard > default > custom > blank > dot > alias > localmodule`, # If `custom-order` is `true`, it follows the order of `sections` option. # Default: ["standard", "default"] sections: - standard # Standard section: captures all standard packages. - default # Default section: contains all imports that could not be matched to another section type. - prefix(github.com/nicholas-fedor/shoutrrr) # Custom section: groups all imports with the specified Prefix. - blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled. - dot # Dot section: contains all dot imports. This section is not present unless explicitly enabled. - alias # Alias section: contains all alias imports. This section is not present unless explicitly enabled. - localmodule # Local module section: contains all local packages. This section is not present unless explicitly enabled. # Checks that no inline comments are present. # Default: false # no-inline-comments: true # Checks that no prefix comments (comment lines above an import) are present. # Default: false # no-prefix-comments: true # Enable custom order of sections. # If `true`, make the section order the same as the order of `sections`. # Default: false # custom-order: true # Drops lexical ordering for custom sections. # Default: false # no-lex-order: true ################################################################################################## # https://golangci-lint.run/docs/formatters/configuration/#gofmt gofmt: # Simplify code: gofmt with `-s` option. # Default: true # simplify: false # Apply the rewrite rules to the source before reformatting. # https://pkg.go.dev/cmd/gofmt # Default: [] rewrite-rules: # Go 1.18+: replace interface{} with any - pattern: "interface{}" replacement: "any" # Slice expressions: a[b:len(a)] → a[b:] - pattern: "a[b:len(a)]" replacement: "a[b:]" # a[:len(a)] → a[:] (full slice) - pattern: "a[:len(a)]" replacement: "a[:]" # Go 1.21+: use slices.Clone instead of append(make([]T, len(s)), s...) - pattern: "append(make([]T, len(s)), s...)" replacement: "slices.Clone(s)" # Go 1.21+: use slices.Delete instead of manual delete patterns # i:j+1 where j = i + k, common delete pattern - pattern: "a[:i+i+k:k+i+k]" replacement: "slices.Delete(a, i, i+k)" # strings.Clone (Go 1.20+) - pattern: "string([]byte(s))" replacement: "strings.Clone(s)" # bytes.Clone (Go 1.20+) - pattern: "append([]byte(nil), b...)" replacement: "bytes.Clone(b)" - pattern: "append(make([]byte, 0, len(b)), b...)" replacement: "bytes.Clone(b)" # Remove redundant type conversions in append - pattern: "append([]T(nil), x)" replacement: "append(make([]T, 0), x)" # or better: just "[]T{x}" if building a new slice ################################################################################################## # https://golangci-lint.run/docs/formatters/configuration/#gofumpt gofumpt: module-path: "github.com/nicholas-fedor/shoutrrr" extra-rules: true ################################################################################################## # https://golangci-lint.run/docs/formatters/configuration/#goimports goimports: # A list of prefixes, which, if set, checks import paths # with the given prefixes are grouped after 3rd-party packages. # Default: [] local-prefixes: - github.com/nicholas-fedor/shoutrrr ################################################################################################## # https://golangci-lint.run/docs/formatters/configuration/#golines golines: # Target maximum line length. # Default: 100 max-len: 200 # Length of a tabulation. # Default: 4 tab-len: 4 # Shorten single-line comments. # Default: false shorten-comments: true # Default: true reformat-tags: true # Split chained methods on the dots as opposed to the arguments. # Default: true chain-split-dots: true #################################################################################################### exclusions: ################################################################################################## # Log a warning if an exclusion path is unused. # Default: false warn-unused: true ################################################################################################## # Mode of the generated files analysis. # # - `strict`: sources are excluded by strictly following the Go generated file convention. # Source files that have lines matching only the following regular expression will be excluded: `^// Code generated .* DO NOT EDIT\.$` # This line must appear before the first non-comment, non-blank text in the file. # https://go.dev/s/generatedcode # - `lax`: sources are excluded if they contain lines like `autogenerated file`, `code generated`, `do not edit`, etc. # - `disable`: disable the generated files exclusion. # # Default: lax # generated: strict ################################################################################################## # Which file paths to exclude. # Default: [] paths: - ".*mocks$" # - third_party$ # - builtin$ # - examples$ ###################################################################################################### # Issues Configuration # https://golangci-lint.run/usage/configuration/#issues-configuration ###################################################################################################### issues: # Maximum issues count per one linter. # Set to 0 to disable. # Default: 50 max-issues-per-linter: 0 #################################################################################################### # Maximum count of issues with the same text. # Set to 0 to disable. # Default: 3 max-same-issues: 0 #################################################################################################### # Make issues output unique by line. # Default: true # uniq-by-line: false #################################################################################################### # Show only new issues: if there are unstaged changes or untracked files, # only those changes are analyzed, else only changes in HEAD~ are analyzed. # It's a super-useful option for integration of golangci-lint into existing large codebase. # It's not practical to fix all existing issues at the moment of integration: # much better don't allow issues in new code. # # Default: false # new: true #################################################################################################### # Show only new issues created after the best common ancestor (merge-base against HEAD). # Default: "" # new-from-merge-base: main #################################################################################################### # Show only new issues created after git revision `REV`. # Default: "" # new-from-rev: HEAD #################################################################################################### # Show only new issues created in git patch with set file path. # Default: "" # new-from-patch: path/to/patch/file #################################################################################################### # Show issues in any part of update files (requires new-from-rev or new-from-patch). # Default: false whole-files: true #################################################################################################### # Fix found issues (if it's supported by the linter). # Default: false fix: true ###################################################################################################### # Output Configuration # https://golangci-lint.run/usage/configuration/#output-configuration ###################################################################################################### output: #################################################################################################### # The formats used to render issues. formats: ################################################################################################## # Prints issues in a text format with colors, line number, and linter name. # This format is the default format. text: # Output path can be either `stdout`, `stderr` or path to the file to write to. # Default: stdout # path: ./path/to/output.txt # Print linter name in the end of issue text. # Default: true # print-linter-name: false print-linter-name: true # Print lines of code with issue. # Default: true # print-issued-lines: false print-issued-lines: true # Use colors. # Default: true # colors: false colors: true ################################################################################################## # Prints issues in a JSON representation. # json: # Output path can be either `stdout`, `stderr` or path to the file to write to. # Default: stdout # path: ./path/to/output.json # path: stderr ################################################################################################## # Prints issues in columns representation separated by tabulations. tab: # Output path can be either `stdout`, `stderr` or path to the file to write to. # Default: stdout # path: ./path/to/output.txt # Print linter name in the end of issue text. # Default: true print-linter-name: true # Use colors. # Default: true # colors: false colors: true ################################################################################################## # Prints issues in an HTML page. # It uses the Cloudflare CDN (cdnjs) and React. # html: # Output path can be either `stdout`, `stderr` or path to the file to write to. # Default: stdout # path: ./path/to/output.html ################################################################################################## # Prints issues in the Checkstyle format. # checkstyle: # Output path can be either `stdout`, `stderr` or path to the file to write to. # Default: stdout # path: ./path/to/output.xml ################################################################################################## # Prints issues in the Code Climate format. # code-climate: # Output path can be either `stdout`, `stderr` or path to the file to write to. # Default: stdout # path: ./path/to/output.json ################################################################################################## # Prints issues in the JUnit XML format. # junit-xml: # Output path can be either `stdout`, `stderr` or path to the file to write to. # Default: stdout # path: ./path/to/output.xml # Support extra JUnit XML fields. # Default: false # extended: true ################################################################################################## # Prints issues in the TeamCity format. # teamcity: # Output path can be either `stdout`, `stderr` or path to the file to write to. # Default: stdout # path: ./path/to/output.txt ################################################################################################## # Prints issues in the SARIF format. # sarif: # Output path can be either `stdout`, `stderr` or path to the file to write to. # Default: stdout # path: ./path/to/output.json #################################################################################################### # Add a prefix to the output file references. # Default: "" # path-prefix: "" #################################################################################################### # By default, the report are related to the path obtained by `run.relative-path-mode`. # The mode `abs` allows to show absolute file paths instead of relative file paths. # The option `output.path-prefix` is ignored when using `abs` mode. # Default: "" path-mode: "abs" #################################################################################################### # Order to use when sorting results. # Possible values: `file`, `linter`, and `severity`. # # If the severity values are inside the following list, they are ordered in this order: # 1. error # 2. warning # 3. high # 4. medium # 5. low # Either they are sorted alphabetically. # # Default: ["linter", "file"] sort-order: - file # filepath, line, and column. - severity - linter #################################################################################################### # Show statistics per linter. # Default: true # show-stats: false ###################################################################################################### # Run Configuration # Options for analysis running. # https://golangci-lint.run/usage/configuration/#run-configuration ###################################################################################################### run: #################################################################################################### # Timeout for analysis, e.g. 30s, 5m, 5m30s. # If the value is lower or equal to 0, the timeout is disabled. # Default: 1m # timeout: 5m #################################################################################################### # The mode used to evaluate relative paths. # It's used by exclusions, Go plugins, and some linters. # The value can be: # - `gomod`: the paths will be relative to the directory of the `go.mod` file. # - `gitroot`: the paths will be relative to the git root (the parent directory of `.git`). # - `cfg`: the paths will be relative to the configuration file. # - `wd` (NOT recommended): the paths will be relative to the place where golangci-lint is run. # Default: wd # relative-path-mode: gomod #################################################################################################### # Exit code when at least one issue was found. # Default: 1 # issues-exit-code: 2 #################################################################################################### # Include test files or not. # Default: true # tests: false #################################################################################################### # List of build tags, all linters use it. # Default: [] # build-tags: # - mytag #################################################################################################### # If set, we pass it to "go list -mod={option}". From "go help modules": # If invoked with -mod=readonly, the go command is disallowed from the implicit # automatic updating of go.mod described above. Instead, it fails when any changes # to go.mod are needed. This setting is most useful to check that go.mod does # not need updates, such as in a continuous integration and testing system. # If invoked with -mod=vendor, the go command assumes that the vendor # directory holds the correct copies of dependencies and ignores # the dependency descriptions in go.mod. # # Allowed values: readonly|vendor|mod # Default: "" # modules-download-mode: readonly #################################################################################################### # Allow multiple parallel golangci-lint instances running. # If false, golangci-lint acquires file lock on start. # Default: false allow-parallel-runners: true #################################################################################################### # Allow multiple golangci-lint instances running, but serialize them around a lock. # If false, golangci-lint exits with an error if it fails to acquire file lock on start. # Default: false allow-serial-runners: true #################################################################################################### # Define the Go version limit. # Mainly related to generics support since go1.18. # Default: use Go version from the go.mod file, fallback on the env var `GOVERSION`, fallback on 1.22. # go: "1.24" #################################################################################################### # Number of operating system threads (`GOMAXPROCS`) that can execute golangci-lint simultaneously. # 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. # Default: the number of logical CPUs in the machine # concurrency: 4 ###################################################################################################### # Severity Configuration # https://golangci-lint.run/usage/configuration/#severity-configuration ###################################################################################################### # severity: #################################################################################################### # Set the default severity for issues. # # If severity rules are defined and the issues do not match or no severity is provided to the rule # this will be the default severity applied. # Severities should match the supported severity names of the selected out format. # - Code climate: https://docs.codeclimate.com/docs/issues#issue-severity # - Checkstyle: https://checkstyle.sourceforge.io/property_types.html#SeverityLevel # - GitHub: https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-error-message # - TeamCity: https://www.jetbrains.com/help/teamcity/service-messages.html#Inspection+Instance # # `@linter` can be used as severity value to keep the severity from linters (e.g. revive, gosec, ...) # # Default: "" # default: error #################################################################################################### # If set to true `severity-rules` regular expressions become case-sensitive. # Default: false # case-sensitive: true #################################################################################################### # When a list of severity rules are provided, severity information will be added to lint issues. # Severity rules have the same filtering capability as exclude rules # except you are allowed to specify one matcher per severity rule. # # `@linter` can be used as severity value to keep the severity from linters (e.g. revive, gosec, ...) # # Only affects out formats that support setting severity information. # # Default: [] # rules: # - linters: # - dupl # severity: info ###################################################################################################### # End of golangci-lint Configuration ######################################################################################################