1
0
Fork 0
golang-github-nicholas-fedo.../.golangci.yaml
Daniel Baumann c0c4addb85
Adding upstream version 0.8.9.
Signed-off-by: Daniel Baumann <daniel@debian.org>
2025-05-22 10:16:14 +02:00

634 lines
30 KiB
YAML

######################################################################################################
# #
# Shoutrrr golangci-lint Configuration #
# #
# Shoutrrr: https://github.com/nicholas-fedor/shoutrrr/ #
# Golangci-lint: https://golangci-lint.run/ #
# #
######################################################################################################
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.
- 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.
- revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint.
- 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 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 # 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.
- 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`.
- exhaustive # Check exhaustiveness of enum switch statements.
- forbidigo # Forbids identifiers.
- forcetypeassert # Finds forced type assertions.
- 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.
- 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.
- grouper # Analyze expression groups.
- iface # Detect the incorrect use of interfaces, helping developers avoid interface pollution.
- inamedparam # Reports interfaces with unnamed method parameters.
- 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.
- 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.
- 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.
- spancheck # Checks for mistakes with OpenTelemetry/Census spans.
- sqlclosecheck # Checks that sql.Rows, sql.Stmt, sqlx.NamedStmt, pgx.Query are closed.
- 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.
- 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.
disable:
- cyclop # Checks function and package cyclomatic complexity.
- depguard # Checks if package imports are in a list of acceptable packages.
- exhaustruct # Checks if all structure fields are initialized.
- funlen # Checks for long functions.
- gochecknoinits # Checks that no init functions are present in Go code.
- gochecknoglobals # Check that no global variables exist.
- gocognit # Computes and checks the cognitive complexity of functions.
- gocyclo # Computes and checks the cyclomatic complexity of functions. [fast]
- gomodguard # Allow and block list linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations. [fast]
- gosmopolitan # Report certain i18n/l10n anti-patterns in your Go codebase.
- 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. [fast]
- nestif # Reports deeply nested if statements.
- rowserrcheck # Checks whether Rows.Err of rows is checked successfully.
- paralleltest # Detects missing usage of t.Parallel() method in your Go test.
- protogetter # Reports direct reads from proto message fields when getters should be used. [auto-fix]
- sloglint # Ensure consistent code style when using log/slog.
- tagliatelle # Checks the struct tags.
- testableexamples # Linter checks if examples are testable (have an expected output). [fast]
- testpackage # Linter that makes you use a separate _test package.
- zerologlint # Detects the wrong usage of `zerolog` that a user forgets to dispatch with `Send` or `Msg`.
######################################################################################################
# Linter Settings Configuration
######################################################################################################
settings:
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
- c
- ctx
- i
- j
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
######################################################################################################
# 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
- forcetypeassert
- gocyclo
- gosec
- promlinter
- wrapcheck
- varnamelen
# 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:
- gci
- gofmt
- gofumpt
- goimports
- golines
####################################################################################################
# Formatters settings.
settings:
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/watchtower) # 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
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:
- pattern: "interface{}"
replacement: "any"
- pattern: "a[b:len(a)]"
replacement: "a[b:]"
####################################################################################################
# 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
# 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: ""
####################################################################################################
# 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
######################################################################################################