1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634
|
######################################################################################################
# #
# 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
######################################################################################################
|