From 8d23d7d42dbd8a52b8a9b9848a074e8c3d577dec Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Sat, 22 Feb 2025 18:09:07 +0100 Subject: [PATCH 1/8] chore: remove linter presets --- .golangci.next.reference.yml | 18 - assets/linters-info.json | 383 -------------------- jsonschema/golangci.next.jsonschema.json | 21 -- pkg/commands/flagsets.go | 28 -- pkg/commands/help.go | 40 +- pkg/config/linters.go | 2 +- pkg/config/loader.go | 1 - pkg/lint/linter/config.go | 22 -- pkg/lint/lintersdb/builder_linter.go | 114 +----- pkg/lint/lintersdb/manager.go | 53 --- pkg/lint/lintersdb/manager_test.go | 57 ++- pkg/lint/lintersdb/validator.go | 20 - pkg/lint/lintersdb/validator_test.go | 74 ---- scripts/website/dump_info/main.go | 1 - scripts/website/expand_templates/linters.go | 7 +- test/run_test.go | 11 - 16 files changed, 35 insertions(+), 817 deletions(-) diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index 5c445cbd2bd5..02c03baa1866 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -239,24 +239,6 @@ linters: - wsl - zerologlint - # Enable presets. - # https://golangci-lint.run/usage/linters - # Default: [] - presets: - - bugs - - comment - - complexity - - error - - format - - import - - metalinter - - module - - performance - - sql - - style - - test - - unused - # Enable only fast linters from enabled linters set (first run won't be fast) # Default: false fast: true diff --git a/assets/linters-info.json b/assets/linters-info.json index 6142f725cae0..d00191939a47 100644 --- a/assets/linters-info.json +++ b/assets/linters-info.json @@ -3,9 +3,6 @@ "name": "asasalint", "desc": "check for pass []any as any in variadic func(...any)", "loadMode": 8767, - "inPresets": [ - "bugs" - ], "originalURL": "https://github.com/alingse/asasalint", "internal": false, "isSlow": true, @@ -15,10 +12,6 @@ "name": "asciicheck", "desc": "checks that all code identifiers does not have non-ASCII symbols in the name", "loadMode": 8199, - "inPresets": [ - "bugs", - "style" - ], "originalURL": "https://github.com/tdakkota/asciicheck", "internal": false, "isSlow": false, @@ -28,9 +21,6 @@ "name": "bidichk", "desc": "Checks for dangerous unicode character sequences", "loadMode": 8199, - "inPresets": [ - "bugs" - ], "originalURL": "https://github.com/breml/bidichk", "internal": false, "isSlow": false, @@ -40,10 +30,6 @@ "name": "bodyclose", "desc": "checks whether HTTP response body is closed successfully", "loadMode": 8767, - "inPresets": [ - "performance", - "bugs" - ], "originalURL": "https://github.com/timakin/bodyclose", "internal": false, "isSlow": true, @@ -53,9 +39,6 @@ "name": "canonicalheader", "desc": "canonicalheader checks whether net/http.Header uses canonical header", "loadMode": 8767, - "inPresets": [ - "style" - ], "originalURL": "https://github.com/lasiar/canonicalheader", "internal": false, "canAutoFix": true, @@ -66,9 +49,6 @@ "name": "containedctx", "desc": "containedctx is a linter that detects struct contained context.Context field", "loadMode": 8767, - "inPresets": [ - "style" - ], "originalURL": "https://github.com/sivchari/containedctx", "internal": false, "isSlow": true, @@ -78,9 +58,6 @@ "name": "contextcheck", "desc": "check whether the function uses a non-inherited context", "loadMode": 8767, - "inPresets": [ - "bugs" - ], "originalURL": "https://github.com/kkHAIKE/contextcheck", "internal": false, "isSlow": true, @@ -90,9 +67,6 @@ "name": "copyloopvar", "desc": "a linter detects places where loop variables are copied", "loadMode": 8199, - "inPresets": [ - "style" - ], "originalURL": "https://github.com/karamaru-alpha/copyloopvar", "internal": false, "canAutoFix": true, @@ -103,9 +77,6 @@ "name": "cyclop", "desc": "checks function and package cyclomatic complexity", "loadMode": 8199, - "inPresets": [ - "complexity" - ], "originalURL": "https://github.com/bkielbasa/cyclop", "internal": false, "isSlow": false, @@ -115,9 +86,6 @@ "name": "decorder", "desc": "check declaration order and count of types, constants, variables and functions", "loadMode": 8199, - "inPresets": [ - "style" - ], "originalURL": "https://gitlab.com/bosi/decorder", "internal": false, "isSlow": false, @@ -127,11 +95,6 @@ "name": "depguard", "desc": "Go linter that checks if package imports are in a list of acceptable packages", "loadMode": 8199, - "inPresets": [ - "style", - "import", - "module" - ], "originalURL": "https://github.com/OpenPeeDeeP/depguard", "internal": false, "isSlow": false, @@ -141,9 +104,6 @@ "name": "dogsled", "desc": "Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f())", "loadMode": 8199, - "inPresets": [ - "style" - ], "originalURL": "https://github.com/alexkohler/dogsled", "internal": false, "isSlow": false, @@ -153,9 +113,6 @@ "name": "dupl", "desc": "Tool for code clone detection", "loadMode": 8199, - "inPresets": [ - "style" - ], "originalURL": "https://github.com/mibk/dupl", "internal": false, "isSlow": false, @@ -165,9 +122,6 @@ "name": "dupword", "desc": "checks for duplicate words in the source code", "loadMode": 8199, - "inPresets": [ - "comment" - ], "originalURL": "https://github.com/Abirdcfly/dupword", "internal": false, "canAutoFix": true, @@ -178,9 +132,6 @@ "name": "durationcheck", "desc": "check for two durations multiplied together", "loadMode": 8767, - "inPresets": [ - "bugs" - ], "originalURL": "https://github.com/charithe/durationcheck", "internal": false, "isSlow": true, @@ -191,10 +142,6 @@ "desc": "errcheck is a program for checking for unchecked errors in Go code. These unchecked errors can be critical bugs in some cases", "enabledByDefault": true, "loadMode": 8767, - "inPresets": [ - "bugs", - "error" - ], "originalURL": "https://github.com/kisielk/errcheck", "internal": false, "isSlow": true, @@ -204,9 +151,6 @@ "name": "errchkjson", "desc": "Checks types passed to the json encoding functions. Reports unsupported types and reports occurrences where the check for the returned error can be omitted.", "loadMode": 8767, - "inPresets": [ - "bugs" - ], "originalURL": "https://github.com/breml/errchkjson", "internal": false, "isSlow": true, @@ -216,9 +160,6 @@ "name": "errname", "desc": "Checks that sentinel errors are prefixed with the `Err` and error types are suffixed with the `Error`.", "loadMode": 8767, - "inPresets": [ - "style" - ], "originalURL": "https://github.com/Antonboom/errname", "internal": false, "isSlow": true, @@ -228,10 +169,6 @@ "name": "errorlint", "desc": "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.", "loadMode": 8767, - "inPresets": [ - "bugs", - "error" - ], "originalURL": "https://github.com/polyfloyd/go-errorlint", "internal": false, "canAutoFix": true, @@ -242,9 +179,6 @@ "name": "exhaustive", "desc": "check exhaustiveness of enum switch statements", "loadMode": 8767, - "inPresets": [ - "bugs" - ], "originalURL": "https://github.com/nishanths/exhaustive", "internal": false, "isSlow": true, @@ -254,10 +188,6 @@ "name": "exhaustruct", "desc": "Checks if all structure fields are initialized", "loadMode": 8767, - "inPresets": [ - "style", - "test" - ], "originalURL": "https://github.com/GaijinEntertainment/go-exhaustruct", "internal": false, "isSlow": true, @@ -267,9 +197,6 @@ "name": "exptostd", "desc": "Detects functions from golang.org/x/exp/ that can be replaced by std functions.", "loadMode": 8767, - "inPresets": [ - "style" - ], "originalURL": "https://github.com/ldez/exptostd", "internal": false, "canAutoFix": true, @@ -280,9 +207,6 @@ "name": "forbidigo", "desc": "Forbids identifiers", "loadMode": 8767, - "inPresets": [ - "style" - ], "originalURL": "https://github.com/ashanbrown/forbidigo", "internal": false, "isSlow": true, @@ -292,9 +216,6 @@ "name": "forcetypeassert", "desc": "finds forced type assertions", "loadMode": 8767, - "inPresets": [ - "style" - ], "originalURL": "https://github.com/gostaticanalysis/forcetypeassert", "internal": false, "isSlow": true, @@ -304,9 +225,6 @@ "name": "fatcontext", "desc": "detects nested contexts in loops and function literals", "loadMode": 8767, - "inPresets": [ - "performance" - ], "originalURL": "https://github.com/Crocmagnon/fatcontext", "internal": false, "canAutoFix": true, @@ -317,9 +235,6 @@ "name": "funlen", "desc": "Checks for long functions.", "loadMode": 8199, - "inPresets": [ - "complexity" - ], "originalURL": "https://github.com/ultraware/funlen", "internal": false, "isSlow": false, @@ -329,10 +244,6 @@ "name": "gci", "desc": "Checks if code and import statements are formatted, with additional rules.", "loadMode": 8199, - "inPresets": [ - "format", - "import" - ], "originalURL": "https://github.com/daixiang0/gci", "internal": false, "canAutoFix": true, @@ -343,9 +254,6 @@ "name": "ginkgolinter", "desc": "enforces standards of using ginkgo and gomega", "loadMode": 8767, - "inPresets": [ - "style" - ], "originalURL": "https://github.com/nunnatsa/ginkgolinter", "internal": false, "canAutoFix": true, @@ -356,9 +264,6 @@ "name": "gocheckcompilerdirectives", "desc": "Checks that go compiler directive comments (//go:) are valid.", "loadMode": 8199, - "inPresets": [ - "bugs" - ], "originalURL": "https://github.com/leighmcculloch/gocheckcompilerdirectives", "internal": false, "isSlow": false, @@ -368,9 +273,6 @@ "name": "gochecknoglobals", "desc": "Check that no global variables exist.", "loadMode": 8767, - "inPresets": [ - "style" - ], "originalURL": "https://github.com/leighmcculloch/gochecknoglobals", "internal": false, "isSlow": true, @@ -380,9 +282,6 @@ "name": "gochecknoinits", "desc": "Checks that no init functions are present in Go code", "loadMode": 8199, - "inPresets": [ - "style" - ], "internal": false, "isSlow": false, "since": "v1.12.0" @@ -391,9 +290,6 @@ "name": "gochecksumtype", "desc": "Run exhaustiveness checks on Go \"sum types\"", "loadMode": 8767, - "inPresets": [ - "bugs" - ], "originalURL": "https://github.com/alecthomas/go-check-sumtype", "internal": false, "isSlow": true, @@ -403,9 +299,6 @@ "name": "gocognit", "desc": "Computes and checks the cognitive complexity of functions", "loadMode": 8199, - "inPresets": [ - "complexity" - ], "originalURL": "https://github.com/uudashr/gocognit", "internal": false, "isSlow": false, @@ -415,9 +308,6 @@ "name": "goconst", "desc": "Finds repeated strings that could be replaced by a constant", "loadMode": 8199, - "inPresets": [ - "style" - ], "originalURL": "https://github.com/jgautheron/goconst", "internal": false, "isSlow": false, @@ -427,10 +317,6 @@ "name": "gocritic", "desc": "Provides diagnostics that check for bugs, performance and style issues.\nExtensible without recompilation through dynamic rules.\nDynamic rules are written declaratively with AST patterns, filters, report message and optional suggestion.", "loadMode": 8767, - "inPresets": [ - "style", - "metalinter" - ], "originalURL": "https://github.com/go-critic/go-critic", "internal": false, "canAutoFix": true, @@ -441,9 +327,6 @@ "name": "gocyclo", "desc": "Computes and checks the cyclomatic complexity of functions", "loadMode": 8199, - "inPresets": [ - "complexity" - ], "originalURL": "https://github.com/fzipp/gocyclo", "internal": false, "isSlow": false, @@ -453,10 +336,6 @@ "name": "godot", "desc": "Check if comments end in a period", "loadMode": 8199, - "inPresets": [ - "style", - "comment" - ], "originalURL": "https://github.com/tetafro/godot", "internal": false, "canAutoFix": true, @@ -467,10 +346,6 @@ "name": "godox", "desc": "Detects usage of FIXME, TODO and other keywords inside comments", "loadMode": 8199, - "inPresets": [ - "style", - "comment" - ], "originalURL": "https://github.com/matoous/godox", "internal": false, "isSlow": false, @@ -480,13 +355,6 @@ "name": "err113", "desc": "Go linter to check the errors handling expressions", "loadMode": 8767, - "inPresets": [ - "style", - "error" - ], - "alternativeNames": [ - "goerr113" - ], "originalURL": "https://github.com/Djarvur/go-err113", "internal": false, "canAutoFix": true, @@ -497,9 +365,6 @@ "name": "gofmt", "desc": "Checks if the code is formatted according to 'gofmt' command.", "loadMode": 8199, - "inPresets": [ - "format" - ], "originalURL": "https://pkg.go.dev/cmd/gofmt", "internal": false, "canAutoFix": true, @@ -510,9 +375,6 @@ "name": "gofumpt", "desc": "Checks if code and import statements are formatted, with additional rules.", "loadMode": 8199, - "inPresets": [ - "format" - ], "originalURL": "https://github.com/mvdan/gofumpt", "internal": false, "canAutoFix": true, @@ -523,9 +385,6 @@ "name": "golines", "desc": "Checks if code is formatted, and fixes long lines", "loadMode": 8199, - "inPresets": [ - "format" - ], "originalURL": "https://github.com/segmentio/golines", "internal": false, "canAutoFix": true, @@ -536,9 +395,6 @@ "name": "goheader", "desc": "Checks if file header matches to pattern", "loadMode": 8199, - "inPresets": [ - "style" - ], "originalURL": "https://github.com/denis-tingaikin/go-header", "internal": false, "canAutoFix": true, @@ -549,10 +405,6 @@ "name": "goimports", "desc": "Checks if the code and import statements are formatted according to the 'goimports' command.", "loadMode": 8199, - "inPresets": [ - "format", - "import" - ], "originalURL": "https://pkg.go.dev/golang.org/x/tools/cmd/goimports", "internal": false, "canAutoFix": true, @@ -563,9 +415,6 @@ "name": "mnd", "desc": "An analyzer to detect magic numbers.", "loadMode": 8199, - "inPresets": [ - "style" - ], "originalURL": "https://github.com/tommy-muehle/go-mnd", "internal": false, "isSlow": false, @@ -575,10 +424,6 @@ "name": "gomoddirectives", "desc": "Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod.", "loadMode": 8199, - "inPresets": [ - "style", - "module" - ], "originalURL": "https://github.com/ldez/gomoddirectives", "internal": false, "isSlow": false, @@ -588,11 +433,6 @@ "name": "gomodguard", "desc": "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.", "loadMode": 8199, - "inPresets": [ - "style", - "import", - "module" - ], "originalURL": "https://github.com/ryancurrah/gomodguard", "internal": false, "isSlow": false, @@ -602,9 +442,6 @@ "name": "goprintffuncname", "desc": "Checks that printf-like functions are named with `f` at the end.", "loadMode": 8199, - "inPresets": [ - "style" - ], "originalURL": "https://github.com/golangci/go-printf-func-name", "internal": false, "isSlow": false, @@ -614,12 +451,6 @@ "name": "gosec", "desc": "Inspects source code for security problems", "loadMode": 8767, - "inPresets": [ - "bugs" - ], - "alternativeNames": [ - "gas" - ], "originalURL": "https://github.com/securego/gosec", "internal": false, "isSlow": true, @@ -630,12 +461,6 @@ "desc": "Linter for Go source code that specializes in simplifying code", "enabledByDefault": true, "loadMode": 8767, - "inPresets": [ - "style" - ], - "alternativeNames": [ - "megacheck" - ], "originalURL": "https://github.com/dominikh/go-tools/tree/HEAD/simple", "internal": false, "canAutoFix": true, @@ -646,9 +471,6 @@ "name": "gosmopolitan", "desc": "Report certain i18n/l10n anti-patterns in your Go codebase", "loadMode": 8767, - "inPresets": [ - "bugs" - ], "originalURL": "https://github.com/xen0n/gosmopolitan", "internal": false, "isSlow": true, @@ -659,14 +481,6 @@ "desc": "Vet examines Go source code and reports suspicious constructs. It is roughly the same as 'go vet' and uses its passes.", "enabledByDefault": true, "loadMode": 8767, - "inPresets": [ - "bugs", - "metalinter" - ], - "alternativeNames": [ - "vet", - "vetshadow" - ], "originalURL": "https://pkg.go.dev/cmd/vet", "internal": false, "canAutoFix": true, @@ -677,9 +491,6 @@ "name": "grouper", "desc": "Analyze expression groups.", "loadMode": 8199, - "inPresets": [ - "style" - ], "originalURL": "https://github.com/leonklingele/grouper", "internal": false, "isSlow": false, @@ -689,9 +500,6 @@ "name": "iface", "desc": "Detect the incorrect use of interfaces, helping developers avoid interface pollution.", "loadMode": 8767, - "inPresets": [ - "style" - ], "originalURL": "https://github.com/uudashr/iface", "internal": false, "canAutoFix": true, @@ -702,9 +510,6 @@ "name": "importas", "desc": "Enforces consistent import aliases", "loadMode": 8767, - "inPresets": [ - "style" - ], "originalURL": "https://github.com/julz/importas", "internal": false, "canAutoFix": true, @@ -715,9 +520,6 @@ "name": "inamedparam", "desc": "reports interfaces with unnamed method parameters", "loadMode": 8199, - "inPresets": [ - "style" - ], "originalURL": "https://github.com/macabu/inamedparam", "internal": false, "isSlow": false, @@ -728,9 +530,6 @@ "desc": "Detects when assignments to existing variables are not used", "enabledByDefault": true, "loadMode": 8199, - "inPresets": [ - "unused" - ], "originalURL": "https://github.com/gordonklaus/ineffassign", "internal": false, "isSlow": false, @@ -740,9 +539,6 @@ "name": "interfacebloat", "desc": "A linter that checks the number of methods inside an interface.", "loadMode": 8199, - "inPresets": [ - "style" - ], "originalURL": "https://github.com/sashamelentyev/interfacebloat", "internal": false, "isSlow": false, @@ -752,9 +548,6 @@ "name": "intrange", "desc": "intrange is a linter to find places where for loops could make use of an integer range.", "loadMode": 8199, - "inPresets": [ - "style" - ], "originalURL": "https://github.com/ckaznocha/intrange", "internal": false, "canAutoFix": true, @@ -765,9 +558,6 @@ "name": "ireturn", "desc": "Accept Interfaces, Return Concrete Types", "loadMode": 8767, - "inPresets": [ - "style" - ], "originalURL": "https://github.com/butuzov/ireturn", "internal": false, "isSlow": true, @@ -777,9 +567,6 @@ "name": "lll", "desc": "Reports long lines", "loadMode": 8199, - "inPresets": [ - "style" - ], "internal": false, "isSlow": false, "since": "v1.8.0" @@ -788,13 +575,6 @@ "name": "loggercheck", "desc": "Checks key value pairs for common logger libraries (kitlog,klog,logr,zap).", "loadMode": 8767, - "inPresets": [ - "style", - "bugs" - ], - "alternativeNames": [ - "logrlint" - ], "originalURL": "https://github.com/timonwong/loggercheck", "internal": false, "isSlow": true, @@ -804,9 +584,6 @@ "name": "maintidx", "desc": "maintidx measures the maintainability index of each function.", "loadMode": 8199, - "inPresets": [ - "complexity" - ], "originalURL": "https://github.com/yagipy/maintidx", "internal": false, "isSlow": false, @@ -816,10 +593,6 @@ "name": "makezero", "desc": "Finds slice declarations with non-zero initial length", "loadMode": 8767, - "inPresets": [ - "style", - "bugs" - ], "originalURL": "https://github.com/ashanbrown/makezero", "internal": false, "isSlow": true, @@ -829,9 +602,6 @@ "name": "mirror", "desc": "reports wrong mirror patterns of bytes/strings usage", "loadMode": 8767, - "inPresets": [ - "style" - ], "originalURL": "https://github.com/butuzov/mirror", "internal": false, "canAutoFix": true, @@ -842,10 +612,6 @@ "name": "misspell", "desc": "Finds commonly misspelled English words", "loadMode": 8199, - "inPresets": [ - "style", - "comment" - ], "originalURL": "https://github.com/client9/misspell", "internal": false, "canAutoFix": true, @@ -856,10 +622,6 @@ "name": "musttag", "desc": "enforce field tags in (un)marshaled structs", "loadMode": 8767, - "inPresets": [ - "style", - "bugs" - ], "originalURL": "https://github.com/go-simpler/musttag", "internal": false, "isSlow": true, @@ -869,9 +631,6 @@ "name": "nakedret", "desc": "Checks that functions with naked returns are not longer than a maximum size (can be zero).", "loadMode": 8199, - "inPresets": [ - "style" - ], "originalURL": "https://github.com/alexkohler/nakedret", "internal": false, "canAutoFix": true, @@ -882,9 +641,6 @@ "name": "nestif", "desc": "Reports deeply nested if statements", "loadMode": 8199, - "inPresets": [ - "complexity" - ], "originalURL": "https://github.com/nakabonne/nestif", "internal": false, "isSlow": false, @@ -894,9 +650,6 @@ "name": "nilerr", "desc": "Finds the code that returns nil even if it checks that the error is not nil.", "loadMode": 8767, - "inPresets": [ - "bugs" - ], "originalURL": "https://github.com/gostaticanalysis/nilerr", "internal": false, "isSlow": true, @@ -906,9 +659,6 @@ "name": "nilnesserr", "desc": "Reports constructs that checks for err != nil, but returns a different nil value error.\nPowered by nilness and nilerr.", "loadMode": 8767, - "inPresets": [ - "bugs" - ], "originalURL": "https://github.com/alingse/nilnesserr", "internal": false, "isSlow": true, @@ -918,9 +668,6 @@ "name": "nilnil", "desc": "Checks that there is no simultaneous return of `nil` error and an invalid value.", "loadMode": 8767, - "inPresets": [ - "style" - ], "originalURL": "https://github.com/Antonboom/nilnil", "internal": false, "isSlow": true, @@ -930,9 +677,6 @@ "name": "nlreturn", "desc": "nlreturn checks for a new line before return and branch statements to increase code clarity", "loadMode": 8199, - "inPresets": [ - "style" - ], "originalURL": "https://github.com/ssgreg/nlreturn", "internal": false, "canAutoFix": true, @@ -943,10 +687,6 @@ "name": "noctx", "desc": "Finds sending http request without context.Context", "loadMode": 8767, - "inPresets": [ - "performance", - "bugs" - ], "originalURL": "https://github.com/sonatard/noctx", "internal": false, "isSlow": true, @@ -956,9 +696,6 @@ "name": "nonamedreturns", "desc": "Reports all named returns", "loadMode": 8767, - "inPresets": [ - "style" - ], "originalURL": "https://github.com/firefart/nonamedreturns", "internal": false, "isSlow": true, @@ -968,9 +705,6 @@ "name": "nosprintfhostport", "desc": "Checks for misuse of Sprintf to construct a host with port in a URL.", "loadMode": 8199, - "inPresets": [ - "style" - ], "originalURL": "https://github.com/stbenjam/no-sprintf-host-port", "internal": false, "isSlow": false, @@ -980,10 +714,6 @@ "name": "paralleltest", "desc": "Detects missing usage of t.Parallel() method in your Go test", "loadMode": 8767, - "inPresets": [ - "style", - "test" - ], "originalURL": "https://github.com/kunwardeep/paralleltest", "internal": false, "isSlow": true, @@ -993,9 +723,6 @@ "name": "perfsprint", "desc": "Checks that fmt.Sprintf can be replaced with a faster alternative.", "loadMode": 8767, - "inPresets": [ - "performance" - ], "originalURL": "https://github.com/catenacyber/perfsprint", "internal": false, "canAutoFix": true, @@ -1006,9 +733,6 @@ "name": "prealloc", "desc": "Finds slice declarations that could potentially be pre-allocated", "loadMode": 8199, - "inPresets": [ - "performance" - ], "originalURL": "https://github.com/alexkohler/prealloc", "internal": false, "isSlow": false, @@ -1018,9 +742,6 @@ "name": "predeclared", "desc": "find code that shadows one of Go's predeclared identifiers", "loadMode": 8199, - "inPresets": [ - "style" - ], "originalURL": "https://github.com/nishanths/predeclared", "internal": false, "isSlow": false, @@ -1030,9 +751,6 @@ "name": "promlinter", "desc": "Check Prometheus metrics naming via promlint", "loadMode": 8199, - "inPresets": [ - "style" - ], "originalURL": "https://github.com/yeya24/promlinter", "internal": false, "isSlow": false, @@ -1042,9 +760,6 @@ "name": "protogetter", "desc": "Reports direct reads from proto message fields when getters should be used", "loadMode": 8767, - "inPresets": [ - "bugs" - ], "originalURL": "https://github.com/ghostiam/protogetter", "internal": false, "canAutoFix": true, @@ -1055,9 +770,6 @@ "name": "reassign", "desc": "Checks that package variables are not reassigned", "loadMode": 8767, - "inPresets": [ - "bugs" - ], "originalURL": "https://github.com/curioswitch/go-reassign", "internal": false, "isSlow": true, @@ -1067,9 +779,6 @@ "name": "recvcheck", "desc": "checks for receiver type consistency", "loadMode": 8767, - "inPresets": [ - "bugs" - ], "originalURL": "https://github.com/raeperd/recvcheck", "internal": false, "isSlow": true, @@ -1079,10 +788,6 @@ "name": "revive", "desc": "Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint.", "loadMode": 8199, - "inPresets": [ - "style", - "metalinter" - ], "originalURL": "https://github.com/mgechev/revive", "internal": false, "canAutoFix": true, @@ -1093,10 +798,6 @@ "name": "rowserrcheck", "desc": "checks whether Rows.Err of rows is checked successfully", "loadMode": 8767, - "inPresets": [ - "bugs", - "sql" - ], "originalURL": "https://github.com/jingyugao/rowserrcheck", "internal": false, "isSlow": true, @@ -1106,9 +807,6 @@ "name": "sloglint", "desc": "ensure consistent code style when using log/slog", "loadMode": 8767, - "inPresets": [ - "style" - ], "originalURL": "https://github.com/go-simpler/sloglint", "internal": false, "isSlow": true, @@ -1118,10 +816,6 @@ "name": "sqlclosecheck", "desc": "Checks that sql.Rows, sql.Stmt, sqlx.NamedStmt, pgx.Query are closed.", "loadMode": 8767, - "inPresets": [ - "bugs", - "sql" - ], "originalURL": "https://github.com/ryanrolds/sqlclosecheck", "internal": false, "isSlow": true, @@ -1131,9 +825,6 @@ "name": "spancheck", "desc": "Checks for mistakes with OpenTelemetry/Census spans.", "loadMode": 8767, - "inPresets": [ - "bugs" - ], "originalURL": "https://github.com/jjti/go-spancheck", "internal": false, "isSlow": true, @@ -1144,13 +835,6 @@ "desc": "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.", "enabledByDefault": true, "loadMode": 8767, - "inPresets": [ - "bugs", - "metalinter" - ], - "alternativeNames": [ - "megacheck" - ], "originalURL": "https://staticcheck.dev/", "internal": false, "canAutoFix": true, @@ -1161,9 +845,6 @@ "name": "stylecheck", "desc": "Stylecheck is a replacement for golint", "loadMode": 8767, - "inPresets": [ - "style" - ], "originalURL": "https://github.com/dominikh/go-tools/tree/HEAD/stylecheck", "internal": false, "canAutoFix": true, @@ -1174,9 +855,6 @@ "name": "tagalign", "desc": "check that struct tags are well aligned", "loadMode": 8199, - "inPresets": [ - "style" - ], "originalURL": "https://github.com/4meepo/tagalign", "internal": false, "canAutoFix": true, @@ -1187,9 +865,6 @@ "name": "tagliatelle", "desc": "Checks the struct tags.", "loadMode": 8767, - "inPresets": [ - "style" - ], "originalURL": "https://github.com/ldez/tagliatelle", "internal": false, "isSlow": true, @@ -1199,9 +874,6 @@ "name": "testableexamples", "desc": "linter checks if examples are testable (have an expected output)", "loadMode": 8199, - "inPresets": [ - "test" - ], "originalURL": "https://github.com/maratori/testableexamples", "internal": false, "isSlow": false, @@ -1211,10 +883,6 @@ "name": "testifylint", "desc": "Checks usage of github.com/stretchr/testify.", "loadMode": 8767, - "inPresets": [ - "test", - "bugs" - ], "originalURL": "https://github.com/Antonboom/testifylint", "internal": false, "canAutoFix": true, @@ -1225,10 +893,6 @@ "name": "testpackage", "desc": "linter that makes you use a separate _test package", "loadMode": 8199, - "inPresets": [ - "style", - "test" - ], "originalURL": "https://github.com/maratori/testpackage", "internal": false, "isSlow": false, @@ -1238,9 +902,6 @@ "name": "thelper", "desc": "thelper detects tests helpers which is not start with t.Helper() method.", "loadMode": 8767, - "inPresets": [ - "test" - ], "originalURL": "https://github.com/kulti/thelper", "internal": false, "isSlow": true, @@ -1250,10 +911,6 @@ "name": "tparallel", "desc": "tparallel detects inappropriate usage of t.Parallel() method in your Go test codes.", "loadMode": 8767, - "inPresets": [ - "style", - "test" - ], "originalURL": "https://github.com/moricho/tparallel", "internal": false, "isSlow": true, @@ -1272,9 +929,6 @@ "name": "unconvert", "desc": "Remove unnecessary type conversions", "loadMode": 8767, - "inPresets": [ - "style" - ], "originalURL": "https://github.com/mdempsky/unconvert", "internal": false, "isSlow": true, @@ -1284,9 +938,6 @@ "name": "unparam", "desc": "Reports unused function parameters", "loadMode": 8767, - "inPresets": [ - "unused" - ], "originalURL": "https://github.com/mvdan/unparam", "internal": false, "isSlow": true, @@ -1297,12 +948,6 @@ "desc": "Checks Go code for unused constants, variables, functions and types", "enabledByDefault": true, "loadMode": 8767, - "inPresets": [ - "unused" - ], - "alternativeNames": [ - "megacheck" - ], "originalURL": "https://github.com/dominikh/go-tools/tree/HEAD/unused", "internal": false, "isSlow": true, @@ -1313,9 +958,6 @@ "name": "usestdlibvars", "desc": "A linter that detect the possibility to use variables/constants from the Go standard library.", "loadMode": 8199, - "inPresets": [ - "style" - ], "originalURL": "https://github.com/sashamelentyev/usestdlibvars", "internal": false, "canAutoFix": true, @@ -1326,9 +968,6 @@ "name": "usetesting", "desc": "Reports uses of functions with replacement inside the testing package.", "loadMode": 8767, - "inPresets": [ - "test" - ], "originalURL": "https://github.com/ldez/usetesting", "internal": false, "canAutoFix": true, @@ -1339,9 +978,6 @@ "name": "varnamelen", "desc": "checks that the length of a variable's name matches its scope", "loadMode": 8767, - "inPresets": [ - "style" - ], "originalURL": "https://github.com/blizzy78/varnamelen", "internal": false, "isSlow": true, @@ -1351,9 +987,6 @@ "name": "wastedassign", "desc": "Finds wasted assignment statements", "loadMode": 8767, - "inPresets": [ - "style" - ], "originalURL": "https://github.com/sanposhiho/wastedassign", "internal": false, "isSlow": true, @@ -1363,9 +996,6 @@ "name": "whitespace", "desc": "Whitespace is a linter that checks for unnecessary newlines at the start and end of functions, if, for, etc.", "loadMode": 8199, - "inPresets": [ - "style" - ], "originalURL": "https://github.com/ultraware/whitespace", "internal": false, "canAutoFix": true, @@ -1376,10 +1006,6 @@ "name": "wrapcheck", "desc": "Checks that errors returned from external packages are wrapped", "loadMode": 8767, - "inPresets": [ - "style", - "error" - ], "originalURL": "https://github.com/tomarrell/wrapcheck", "internal": false, "isSlow": true, @@ -1389,9 +1015,6 @@ "name": "wsl", "desc": "add or remove empty lines", "loadMode": 8199, - "inPresets": [ - "style" - ], "originalURL": "https://github.com/bombsimon/wsl", "internal": false, "canAutoFix": true, @@ -1402,9 +1025,6 @@ "name": "zerologlint", "desc": "Detects the wrong usage of `zerolog` that a user forgets to dispatch with `Send` or `Msg`", "loadMode": 8767, - "inPresets": [ - "bugs" - ], "originalURL": "https://github.com/ykadowak/zerologlint", "internal": false, "isSlow": true, @@ -1414,9 +1034,6 @@ "name": "nolintlint", "desc": "Reports ill-formed or insufficient nolint directives", "loadMode": 8199, - "inPresets": [ - "style" - ], "originalURL": "https://github.com/golangci/golangci-lint/tree/HEAD/pkg/golinters/nolintlint/internal", "internal": false, "canAutoFix": true, diff --git a/jsonschema/golangci.next.jsonschema.json b/jsonschema/golangci.next.jsonschema.json index 65a1a31b7b65..9574412be29d 100644 --- a/jsonschema/golangci.next.jsonschema.json +++ b/jsonschema/golangci.next.jsonschema.json @@ -4176,27 +4176,6 @@ "type": "boolean", "default": false }, - "presets": { - "description": "Allow to use different presets of linters", - "type": "array", - "items": { - "enum": [ - "bugs", - "comment", - "complexity", - "error", - "format", - "import", - "metalinter", - "module", - "performance", - "sql", - "style", - "test", - "unused" - ] - } - }, "fast": { "description": "Enable run of fast linters.", "type": "boolean", diff --git a/pkg/commands/flagsets.go b/pkg/commands/flagsets.go index 4081501eb28d..bc39d755b7de 100644 --- a/pkg/commands/flagsets.go +++ b/pkg/commands/flagsets.go @@ -1,16 +1,12 @@ package commands import ( - "fmt" - "strings" - "github.com/fatih/color" "github.com/spf13/pflag" "github.com/spf13/viper" "github.com/golangci/golangci-lint/pkg/commands/internal" "github.com/golangci/golangci-lint/pkg/exitcodes" - "github.com/golangci/golangci-lint/pkg/lint/lintersdb" ) const defaultMaxIssuesPerLinter = 50 @@ -25,13 +21,6 @@ func setupLintersFlagSet(v *viper.Viper, fs *pflag.FlagSet) { internal.AddFlagAndBind(v, fs, fs.Bool, "fast", "linters.fast", false, color.GreenString("Enable only fast linters from enabled linters set (first run won't be fast)")) - internal.AddHackedStringSliceP(fs, "presets", "p", - formatList("Enable presets of linters:", lintersdb.AllPresets(), - "Run 'golangci-lint help linters' to see them.", - "This option implies option --disable-all", - ), - ) - fs.StringSlice("enable-only", nil, color.GreenString("Override linters configuration section to only run the specific linter(s)")) // Flags only. } @@ -148,20 +137,3 @@ func setupIssuesFlagSet(v *viper.Viper, fs *pflag.FlagSet) { internal.AddFlagAndBind(v, fs, fs.Bool, "fix", "issues.fix", false, color.GreenString("Fix found issues (if it's supported by the linter)")) } - -func formatList(head string, items []string, foot ...string) string { - parts := []string{color.GreenString(head)} - for _, p := range items { - parts = append(parts, fmt.Sprintf(" - %s", color.YellowString(p))) - } - - for _, s := range foot { - parts = append(parts, color.GreenString(s)) - } - - if len(foot) == 0 { - parts = append(parts, "") - } - - return strings.Join(parts, "\n") -} diff --git a/pkg/commands/help.go b/pkg/commands/help.go index de4a9998fb8f..94af684bf736 100644 --- a/pkg/commands/help.go +++ b/pkg/commands/help.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" "slices" - "sort" "strings" "unicode" "unicode/utf8" @@ -19,15 +18,14 @@ import ( ) type linterHelp struct { - Name string `json:"name"` - Desc string `json:"description"` - Fast bool `json:"fast"` - AutoFix bool `json:"autoFix"` - Presets []string `json:"presets"` - EnabledByDefault bool `json:"enabledByDefault"` - Deprecated bool `json:"deprecated"` - Since string `json:"since"` - OriginalURL string `json:"originalURL,omitempty"` + Name string `json:"name"` + Desc string `json:"description"` + Fast bool `json:"fast"` + AutoFix bool `json:"autoFix"` + EnabledByDefault bool `json:"enabledByDefault"` + Deprecated bool `json:"deprecated"` + Since string `json:"since"` + OriginalURL string `json:"originalURL,omitempty"` } type helpOptions struct { @@ -113,7 +111,6 @@ func (c *helpCommand) printJSON() error { Desc: formatDescription(lc.Linter.Desc()), Fast: !lc.IsSlowLinter(), AutoFix: lc.CanAutoFix, - Presets: lc.InPresets, EnabledByDefault: lc.EnabledByDefault, Deprecated: lc.IsDeprecated(), Since: lc.Since, @@ -143,27 +140,6 @@ func (c *helpCommand) print() { color.Red("\nDisabled by default linters:\n") printLinters(disabledLCs) - - color.Green("\nLinters presets:") - c.printPresets() -} - -func (c *helpCommand) printPresets() { - for _, p := range lintersdb.AllPresets() { - linters := c.dbManager.GetAllLinterConfigsForPreset(p) - - var linterNames []string - for _, lc := range linters { - if lc.Internal { - continue - } - - linterNames = append(linterNames, lc.Name()) - } - sort.Strings(linterNames) - - _, _ = fmt.Fprintf(logutils.StdOut, "%s: %s\n", color.YellowString(p), strings.Join(linterNames, ", ")) - } } func printLinters(lcs []*linter.Config) { diff --git a/pkg/config/linters.go b/pkg/config/linters.go index 6c5125052934..72ac14360708 100644 --- a/pkg/config/linters.go +++ b/pkg/config/linters.go @@ -39,7 +39,7 @@ func (l *Linters) validateAllDisableEnableOptions() error { } if l.DisableAll { - if len(l.Enable) == 0 && len(l.Presets) == 0 { + if len(l.Enable) == 0 { return errors.New("all linters were disabled, but no one linter was enabled: must enable at least one") } diff --git a/pkg/config/loader.go b/pkg/config/loader.go index efd777775336..f6e846a00f64 100644 --- a/pkg/config/loader.go +++ b/pkg/config/loader.go @@ -280,7 +280,6 @@ func (l *Loader) applyStringSliceHack() { l.appendStringSlice("enable", &l.cfg.Linters.Enable) l.appendStringSlice("disable", &l.cfg.Linters.Disable) - l.appendStringSlice("presets", &l.cfg.Linters.Presets) l.appendStringSlice("build-tags", &l.cfg.Run.BuildTags) } diff --git a/pkg/lint/linter/config.go b/pkg/lint/linter/config.go index 20bed6a71168..63f664829e42 100644 --- a/pkg/lint/linter/config.go +++ b/pkg/lint/linter/config.go @@ -8,22 +8,6 @@ import ( "github.com/golangci/golangci-lint/pkg/config" ) -const ( - PresetBugs = "bugs" // Related to bugs detection. - PresetComment = "comment" // Related to comments analysis. - PresetComplexity = "complexity" // Related to code complexity analysis. - PresetError = "error" // Related to error handling analysis. - PresetFormatting = "format" // Related to code formatting. - PresetImport = "import" // Related to imports analysis. - PresetMetaLinter = "metalinter" // Related to linter that contains multiple rules or multiple linters. - PresetModule = "module" // Related to Go modules analysis. - PresetPerformance = "performance" // Related to performance. - PresetSQL = "sql" // Related to SQL. - PresetStyle = "style" // Related to coding style. - PresetTest = "test" // Related to the analysis of the code of the tests. - PresetUnused = "unused" // Related to the detection of unused code. -) - // LastLinter nolintlint must be last because it looks at the results of all the previous linters for unused nolint directives. const LastLinter = "nolintlint" @@ -48,7 +32,6 @@ type Config struct { LoadMode packages.LoadMode - InPresets []string AlternativeNames []string OriginalURL string // URL of original (not forked) repo, needed for autogenerated README @@ -92,11 +75,6 @@ func (lc *Config) WithLoadForGoAnalysis() *Config { return lc } -func (lc *Config) WithPresets(presets ...string) *Config { - lc.InPresets = presets - return lc -} - func (lc *Config) WithURL(url string) *Config { lc.OriginalURL = url return lc diff --git a/pkg/lint/lintersdb/builder_linter.go b/pkg/lint/lintersdb/builder_linter.go index a3a0cdb358a1..25892ae3a5a6 100644 --- a/pkg/lint/lintersdb/builder_linter.go +++ b/pkg/lint/lintersdb/builder_linter.go @@ -136,29 +136,24 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { return []*linter.Config{ linter.NewConfig(asasalint.New(&cfg.LintersSettings.Asasalint)). WithSince("v1.47.0"). - WithPresets(linter.PresetBugs). WithLoadForGoAnalysis(). WithURL("https://github.com/alingse/asasalint"), linter.NewConfig(asciicheck.New()). WithSince("v1.26.0"). - WithPresets(linter.PresetBugs, linter.PresetStyle). WithURL("https://github.com/tdakkota/asciicheck"), linter.NewConfig(bidichk.New(&cfg.LintersSettings.BiDiChk)). WithSince("v1.43.0"). - WithPresets(linter.PresetBugs). WithURL("https://github.com/breml/bidichk"), linter.NewConfig(bodyclose.New()). WithSince("v1.18.0"). WithLoadForGoAnalysis(). - WithPresets(linter.PresetPerformance, linter.PresetBugs). WithURL("https://github.com/timakin/bodyclose"), linter.NewConfig(canonicalheader.New()). WithSince("v1.58.0"). - WithPresets(linter.PresetStyle). WithLoadForGoAnalysis(). WithAutoFix(). WithURL("https://github.com/lasiar/canonicalheader"), @@ -166,56 +161,46 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { linter.NewConfig(containedctx.New()). WithSince("v1.44.0"). WithLoadForGoAnalysis(). - WithPresets(linter.PresetStyle). WithURL("https://github.com/sivchari/containedctx"), linter.NewConfig(contextcheck.New()). WithSince("v1.43.0"). - WithPresets(linter.PresetBugs). WithLoadForGoAnalysis(). WithURL("https://github.com/kkHAIKE/contextcheck"), linter.NewConfig(copyloopvar.New(&cfg.LintersSettings.CopyLoopVar)). WithSince("v1.57.0"). - WithPresets(linter.PresetStyle). WithAutoFix(). WithURL("https://github.com/karamaru-alpha/copyloopvar"). WithNoopFallback(cfg, linter.IsGoLowerThanGo122()), linter.NewConfig(cyclop.New(&cfg.LintersSettings.Cyclop)). WithSince("v1.37.0"). - WithPresets(linter.PresetComplexity). WithURL("https://github.com/bkielbasa/cyclop"), linter.NewConfig(decorder.New(&cfg.LintersSettings.Decorder)). WithSince("v1.44.0"). - WithPresets(linter.PresetStyle). WithURL("https://gitlab.com/bosi/decorder"), linter.NewConfig(depguard.New(&cfg.LintersSettings.Depguard, cfg.GetBasePath())). WithSince("v1.4.0"). - WithPresets(linter.PresetStyle, linter.PresetImport, linter.PresetModule). WithURL("https://github.com/OpenPeeDeeP/depguard"), linter.NewConfig(dogsled.New(&cfg.LintersSettings.Dogsled)). WithSince("v1.19.0"). - WithPresets(linter.PresetStyle). WithURL("https://github.com/alexkohler/dogsled"), linter.NewConfig(dupl.New(&cfg.LintersSettings.Dupl)). WithSince("v1.0.0"). - WithPresets(linter.PresetStyle). WithURL("https://github.com/mibk/dupl"), linter.NewConfig(dupword.New(&cfg.LintersSettings.DupWord)). WithSince("v1.50.0"). - WithPresets(linter.PresetComment). WithAutoFix(). WithURL("https://github.com/Abirdcfly/dupword"), linter.NewConfig(durationcheck.New()). WithSince("v1.37.0"). - WithPresets(linter.PresetBugs). WithLoadForGoAnalysis(). WithURL("https://github.com/charithe/durationcheck"), @@ -223,50 +208,42 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithEnabledByDefault(). WithSince("v1.0.0"). WithLoadForGoAnalysis(). - WithPresets(linter.PresetBugs, linter.PresetError). WithURL("https://github.com/kisielk/errcheck"), linter.NewConfig(errchkjson.New(&cfg.LintersSettings.ErrChkJSON)). WithSince("v1.44.0"). - WithPresets(linter.PresetBugs). WithLoadForGoAnalysis(). WithURL("https://github.com/breml/errchkjson"), linter.NewConfig(errname.New()). WithSince("v1.42.0"). - WithPresets(linter.PresetStyle). WithLoadForGoAnalysis(). WithURL("https://github.com/Antonboom/errname"), linter.NewConfig(errorlint.New(&cfg.LintersSettings.ErrorLint)). WithSince("v1.32.0"). - WithPresets(linter.PresetBugs, linter.PresetError). WithLoadForGoAnalysis(). WithAutoFix(). WithURL("https://github.com/polyfloyd/go-errorlint"), linter.NewConfig(exhaustive.New(&cfg.LintersSettings.Exhaustive)). WithSince(" v1.28.0"). - WithPresets(linter.PresetBugs). WithLoadForGoAnalysis(). WithURL("https://github.com/nishanths/exhaustive"), linter.NewConfig(exhaustruct.New(&cfg.LintersSettings.Exhaustruct)). WithSince("v1.46.0"). - WithPresets(linter.PresetStyle, linter.PresetTest). WithLoadForGoAnalysis(). WithURL("https://github.com/GaijinEntertainment/go-exhaustruct"), linter.NewConfig(exptostd.New()). WithSince("v1.63.0"). - WithPresets(linter.PresetStyle). WithLoadForGoAnalysis(). WithAutoFix(). WithURL("https://github.com/ldez/exptostd"), linter.NewConfig(forbidigo.New(&cfg.LintersSettings.Forbidigo)). WithSince("v1.34.0"). - WithPresets(linter.PresetStyle). // Strictly speaking, // the additional information is only needed when forbidigoCfg.AnalyzeTypes is chosen by the user. // But we don't know that here in all cases (sometimes config is not loaded), @@ -276,365 +253,303 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { linter.NewConfig(forcetypeassert.New()). WithSince("v1.38.0"). - WithPresets(linter.PresetStyle). WithLoadForGoAnalysis(). WithURL("https://github.com/gostaticanalysis/forcetypeassert"), linter.NewConfig(fatcontext.New(&cfg.LintersSettings.Fatcontext)). WithSince("v1.58.0"). - WithPresets(linter.PresetPerformance). WithLoadForGoAnalysis(). WithAutoFix(). WithURL("https://github.com/Crocmagnon/fatcontext"), linter.NewConfig(funlen.New(&cfg.LintersSettings.Funlen)). WithSince("v1.18.0"). - WithPresets(linter.PresetComplexity). WithURL("https://github.com/ultraware/funlen"), linter.NewConfig(gci.New(&cfg.LintersSettings.Gci)). WithSince("v1.30.0"). - WithPresets(linter.PresetFormatting, linter.PresetImport). WithAutoFix(). WithURL("https://github.com/daixiang0/gci"), linter.NewConfig(ginkgolinter.New(&cfg.LintersSettings.GinkgoLinter)). WithSince("v1.51.0"). WithLoadForGoAnalysis(). - WithPresets(linter.PresetStyle). WithAutoFix(). WithURL("https://github.com/nunnatsa/ginkgolinter"), linter.NewConfig(gocheckcompilerdirectives.New()). WithSince("v1.51.0"). - WithPresets(linter.PresetBugs). WithURL("https://github.com/leighmcculloch/gocheckcompilerdirectives"), linter.NewConfig(gochecknoglobals.New()). WithSince("v1.12.0"). - WithPresets(linter.PresetStyle). WithLoadForGoAnalysis(). WithURL("https://github.com/leighmcculloch/gochecknoglobals"), linter.NewConfig(gochecknoinits.New()). - WithSince("v1.12.0"). - WithPresets(linter.PresetStyle), + WithSince("v1.12.0"), linter.NewConfig(gochecksumtype.New(&cfg.LintersSettings.GoChecksumType)). WithSince("v1.55.0"). - WithPresets(linter.PresetBugs). WithLoadForGoAnalysis(). WithURL("https://github.com/alecthomas/go-check-sumtype"), linter.NewConfig(gocognit.New(&cfg.LintersSettings.Gocognit)). WithSince("v1.20.0"). - WithPresets(linter.PresetComplexity). WithURL("https://github.com/uudashr/gocognit"), linter.NewConfig(goconst.New(&cfg.LintersSettings.Goconst)). WithSince("v1.0.0"). - WithPresets(linter.PresetStyle). WithURL("https://github.com/jgautheron/goconst"), linter.NewConfig(gocritic.New(&cfg.LintersSettings.Gocritic)). WithSince("v1.12.0"). - WithPresets(linter.PresetStyle, linter.PresetMetaLinter). WithLoadForGoAnalysis(). WithAutoFix(). WithURL("https://github.com/go-critic/go-critic"), linter.NewConfig(gocyclo.New(&cfg.LintersSettings.Gocyclo)). WithSince("v1.0.0"). - WithPresets(linter.PresetComplexity). WithURL("https://github.com/fzipp/gocyclo"), linter.NewConfig(godot.New(&cfg.LintersSettings.Godot)). WithSince("v1.25.0"). - WithPresets(linter.PresetStyle, linter.PresetComment). WithAutoFix(). WithURL("https://github.com/tetafro/godot"), linter.NewConfig(godox.New(&cfg.LintersSettings.Godox)). WithSince("v1.19.0"). - WithPresets(linter.PresetStyle, linter.PresetComment). WithURL("https://github.com/matoous/godox"), linter.NewConfig(err113.New()). WithSince("v1.26.0"). - WithPresets(linter.PresetStyle, linter.PresetError). WithLoadForGoAnalysis(). WithAutoFix(). WithURL("https://github.com/Djarvur/go-err113"), linter.NewConfig(gofmt.New(&cfg.LintersSettings.GoFmt)). WithSince("v1.0.0"). - WithPresets(linter.PresetFormatting). WithAutoFix(). WithURL("https://pkg.go.dev/cmd/gofmt"), linter.NewConfig(gofumpt.New(&cfg.LintersSettings.GoFumpt)). WithSince("v1.28.0"). - WithPresets(linter.PresetFormatting). WithAutoFix(). WithURL("https://github.com/mvdan/gofumpt"), linter.NewConfig(golines.New(&cfg.LintersSettings.GoLines)). WithSince("v2.0.0"). - WithPresets(linter.PresetFormatting). WithAutoFix(). WithURL("https://github.com/segmentio/golines"), linter.NewConfig(goheader.New(&cfg.LintersSettings.Goheader, cfg.GetBasePath())). WithSince("v1.28.0"). - WithPresets(linter.PresetStyle). WithAutoFix(). WithURL("https://github.com/denis-tingaikin/go-header"), linter.NewConfig(goimports.New(&cfg.LintersSettings.GoImports)). WithSince("v1.20.0"). - WithPresets(linter.PresetFormatting, linter.PresetImport). WithAutoFix(). WithURL("https://pkg.go.dev/golang.org/x/tools/cmd/goimports"), linter.NewConfig(mnd.New(&cfg.LintersSettings.Mnd)). WithSince("v1.22.0"). - WithPresets(linter.PresetStyle). WithURL("https://github.com/tommy-muehle/go-mnd"), linter.NewConfig(gomoddirectives.New(&cfg.LintersSettings.GoModDirectives)). WithSince("v1.39.0"). - WithPresets(linter.PresetStyle, linter.PresetModule). WithURL("https://github.com/ldez/gomoddirectives"), linter.NewConfig(gomodguard.New(&cfg.LintersSettings.Gomodguard)). WithSince("v1.25.0"). - WithPresets(linter.PresetStyle, linter.PresetImport, linter.PresetModule). WithURL("https://github.com/ryancurrah/gomodguard"), linter.NewConfig(goprintffuncname.New()). WithSince("v1.23.0"). - WithPresets(linter.PresetStyle). WithURL("https://github.com/golangci/go-printf-func-name"), linter.NewConfig(gosec.New(&cfg.LintersSettings.Gosec)). WithSince("v1.0.0"). WithLoadForGoAnalysis(). - WithPresets(linter.PresetBugs). WithURL("https://github.com/securego/gosec"), linter.NewConfig(gosimple.New(&cfg.LintersSettings.Gosimple)). WithEnabledByDefault(). WithSince("v1.20.0"). WithLoadForGoAnalysis(). - WithPresets(linter.PresetStyle). WithAutoFix(). WithURL("https://github.com/dominikh/go-tools/tree/HEAD/simple"), linter.NewConfig(gosmopolitan.New(&cfg.LintersSettings.Gosmopolitan)). WithSince("v1.53.0"). WithLoadForGoAnalysis(). - WithPresets(linter.PresetBugs). WithURL("https://github.com/xen0n/gosmopolitan"), linter.NewConfig(govet.New(&cfg.LintersSettings.Govet)). WithEnabledByDefault(). WithSince("v1.0.0"). WithLoadForGoAnalysis(). - WithPresets(linter.PresetBugs, linter.PresetMetaLinter). WithAutoFix(). WithURL("https://pkg.go.dev/cmd/vet"), linter.NewConfig(grouper.New(&cfg.LintersSettings.Grouper)). WithSince("v1.44.0"). - WithPresets(linter.PresetStyle). WithURL("https://github.com/leonklingele/grouper"), linter.NewConfig(iface.New(&cfg.LintersSettings.Iface)). WithSince("v1.62.0"). WithLoadForGoAnalysis(). - WithPresets(linter.PresetStyle). WithAutoFix(). WithURL("https://github.com/uudashr/iface"), linter.NewConfig(importas.New(&cfg.LintersSettings.ImportAs)). WithSince("v1.38.0"). - WithPresets(linter.PresetStyle). WithLoadForGoAnalysis(). WithAutoFix(). WithURL("https://github.com/julz/importas"), linter.NewConfig(inamedparam.New(&cfg.LintersSettings.Inamedparam)). WithSince("v1.55.0"). - WithPresets(linter.PresetStyle). WithURL("https://github.com/macabu/inamedparam"), linter.NewConfig(ineffassign.New()). WithEnabledByDefault(). WithSince("v1.0.0"). - WithPresets(linter.PresetUnused). WithURL("https://github.com/gordonklaus/ineffassign"), linter.NewConfig(interfacebloat.New(&cfg.LintersSettings.InterfaceBloat)). WithSince("v1.49.0"). - WithPresets(linter.PresetStyle). WithURL("https://github.com/sashamelentyev/interfacebloat"), linter.NewConfig(intrange.New()). WithSince("v1.57.0"). WithLoadForGoAnalysis(). - WithPresets(linter.PresetStyle). WithAutoFix(). WithURL("https://github.com/ckaznocha/intrange"). WithNoopFallback(cfg, linter.IsGoLowerThanGo122()), linter.NewConfig(ireturn.New(&cfg.LintersSettings.Ireturn)). WithSince("v1.43.0"). - WithPresets(linter.PresetStyle). WithLoadForGoAnalysis(). WithURL("https://github.com/butuzov/ireturn"), linter.NewConfig(lll.New(&cfg.LintersSettings.Lll)). - WithSince("v1.8.0"). - WithPresets(linter.PresetStyle), + WithSince("v1.8.0"), linter.NewConfig(loggercheck.New(&cfg.LintersSettings.LoggerCheck)). WithSince("v1.49.0"). WithLoadForGoAnalysis(). - WithPresets(linter.PresetStyle, linter.PresetBugs). WithURL("https://github.com/timonwong/loggercheck"), linter.NewConfig(maintidx.New(&cfg.LintersSettings.MaintIdx)). WithSince("v1.44.0"). - WithPresets(linter.PresetComplexity). WithURL("https://github.com/yagipy/maintidx"), linter.NewConfig(makezero.New(&cfg.LintersSettings.Makezero)). WithSince("v1.34.0"). - WithPresets(linter.PresetStyle, linter.PresetBugs). WithLoadForGoAnalysis(). WithURL("https://github.com/ashanbrown/makezero"), linter.NewConfig(mirror.New()). WithSince("v1.53.0"). - WithPresets(linter.PresetStyle). WithLoadForGoAnalysis(). WithAutoFix(). WithURL("https://github.com/butuzov/mirror"), linter.NewConfig(misspell.New(&cfg.LintersSettings.Misspell)). WithSince("v1.8.0"). - WithPresets(linter.PresetStyle, linter.PresetComment). WithAutoFix(). WithURL("https://github.com/client9/misspell"), linter.NewConfig(musttag.New(&cfg.LintersSettings.MustTag)). WithSince("v1.51.0"). WithLoadForGoAnalysis(). - WithPresets(linter.PresetStyle, linter.PresetBugs). WithURL("https://github.com/go-simpler/musttag"), linter.NewConfig(nakedret.New(&cfg.LintersSettings.Nakedret)). WithSince("v1.19.0"). - WithPresets(linter.PresetStyle). WithAutoFix(). WithURL("https://github.com/alexkohler/nakedret"), linter.NewConfig(nestif.New(&cfg.LintersSettings.Nestif)). WithSince("v1.25.0"). - WithPresets(linter.PresetComplexity). WithURL("https://github.com/nakabonne/nestif"), linter.NewConfig(nilerr.New()). WithSince("v1.38.0"). WithLoadForGoAnalysis(). - WithPresets(linter.PresetBugs). WithURL("https://github.com/gostaticanalysis/nilerr"), linter.NewConfig(nilnesserr.New()). WithSince("v1.63.0"). WithLoadForGoAnalysis(). - WithPresets(linter.PresetBugs). WithURL("https://github.com/alingse/nilnesserr"), linter.NewConfig(nilnil.New(&cfg.LintersSettings.NilNil)). WithSince("v1.43.0"). - WithPresets(linter.PresetStyle). WithLoadForGoAnalysis(). WithURL("https://github.com/Antonboom/nilnil"), linter.NewConfig(nlreturn.New(&cfg.LintersSettings.Nlreturn)). WithSince("v1.30.0"). - WithPresets(linter.PresetStyle). WithAutoFix(). WithURL("https://github.com/ssgreg/nlreturn"), linter.NewConfig(noctx.New()). WithSince("v1.28.0"). WithLoadForGoAnalysis(). - WithPresets(linter.PresetPerformance, linter.PresetBugs). WithURL("https://github.com/sonatard/noctx"), linter.NewConfig(nonamedreturns.New(&cfg.LintersSettings.NoNamedReturns)). WithSince("v1.46.0"). WithLoadForGoAnalysis(). - WithPresets(linter.PresetStyle). WithURL("https://github.com/firefart/nonamedreturns"), linter.NewConfig(nosprintfhostport.New()). WithSince("v1.46.0"). - WithPresets(linter.PresetStyle). WithURL("https://github.com/stbenjam/no-sprintf-host-port"), linter.NewConfig(paralleltest.New(&cfg.LintersSettings.ParallelTest)). WithSince("v1.33.0"). WithLoadForGoAnalysis(). - WithPresets(linter.PresetStyle, linter.PresetTest). WithURL("https://github.com/kunwardeep/paralleltest"), linter.NewConfig(perfsprint.New(&cfg.LintersSettings.PerfSprint)). WithSince("v1.55.0"). WithLoadForGoAnalysis(). - WithPresets(linter.PresetPerformance). WithAutoFix(). WithURL("https://github.com/catenacyber/perfsprint"), linter.NewConfig(prealloc.New(&cfg.LintersSettings.Prealloc)). WithSince("v1.19.0"). - WithPresets(linter.PresetPerformance). WithURL("https://github.com/alexkohler/prealloc"), linter.NewConfig(predeclared.New(&cfg.LintersSettings.Predeclared)). WithSince("v1.35.0"). - WithPresets(linter.PresetStyle). WithURL("https://github.com/nishanths/predeclared"), linter.NewConfig(promlinter.New(&cfg.LintersSettings.Promlinter)). WithSince("v1.40.0"). - WithPresets(linter.PresetStyle). WithURL("https://github.com/yeya24/promlinter"), linter.NewConfig(protogetter.New(&cfg.LintersSettings.ProtoGetter)). WithSince("v1.55.0"). - WithPresets(linter.PresetBugs). WithLoadForGoAnalysis(). WithAutoFix(). WithURL("https://github.com/ghostiam/protogetter"), linter.NewConfig(reassign.New(&cfg.LintersSettings.Reassign)). WithSince("v1.49.0"). - WithPresets(linter.PresetBugs). WithLoadForGoAnalysis(). WithURL("https://github.com/curioswitch/go-reassign"), linter.NewConfig(recvcheck.New(&cfg.LintersSettings.Recvcheck)). WithSince("v1.62.0"). - WithPresets(linter.PresetBugs). WithLoadForGoAnalysis(). WithURL("https://github.com/raeperd/recvcheck"), linter.NewConfig(revive.New(&cfg.LintersSettings.Revive)). WithSince("v1.37.0"). - WithPresets(linter.PresetStyle, linter.PresetMetaLinter). ConsiderSlow(). WithAutoFix(). WithURL("https://github.com/mgechev/revive"), @@ -642,80 +557,67 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { linter.NewConfig(rowserrcheck.New(&cfg.LintersSettings.RowsErrCheck)). WithSince("v1.23.0"). WithLoadForGoAnalysis(). - WithPresets(linter.PresetBugs, linter.PresetSQL). WithURL("https://github.com/jingyugao/rowserrcheck"), linter.NewConfig(sloglint.New(&cfg.LintersSettings.SlogLint)). WithSince("v1.55.0"). WithLoadForGoAnalysis(). - WithPresets(linter.PresetStyle). WithURL("https://github.com/go-simpler/sloglint"), linter.NewConfig(sqlclosecheck.New()). WithSince("v1.28.0"). - WithPresets(linter.PresetBugs, linter.PresetSQL). WithLoadForGoAnalysis(). WithURL("https://github.com/ryanrolds/sqlclosecheck"), linter.NewConfig(spancheck.New(&cfg.LintersSettings.Spancheck)). WithSince("v1.56.0"). WithLoadForGoAnalysis(). - WithPresets(linter.PresetBugs). WithURL("https://github.com/jjti/go-spancheck"), linter.NewConfig(staticcheck.New(&cfg.LintersSettings.Staticcheck)). WithEnabledByDefault(). WithSince("v1.0.0"). WithLoadForGoAnalysis(). - WithPresets(linter.PresetBugs, linter.PresetMetaLinter). WithAutoFix(). WithURL("https://staticcheck.dev/"), linter.NewConfig(stylecheck.New(&cfg.LintersSettings.Stylecheck)). WithSince("v1.20.0"). WithLoadForGoAnalysis(). - WithPresets(linter.PresetStyle). WithAutoFix(). WithURL("https://github.com/dominikh/go-tools/tree/HEAD/stylecheck"), linter.NewConfig(tagalign.New(&cfg.LintersSettings.TagAlign)). WithSince("v1.53.0"). - WithPresets(linter.PresetStyle). WithAutoFix(). WithURL("https://github.com/4meepo/tagalign"), linter.NewConfig(tagliatelle.New(&cfg.LintersSettings.Tagliatelle)). WithSince("v1.40.0"). - WithPresets(linter.PresetStyle). WithLoadForGoAnalysis(). WithURL("https://github.com/ldez/tagliatelle"), linter.NewConfig(testableexamples.New()). WithSince("v1.50.0"). - WithPresets(linter.PresetTest). WithURL("https://github.com/maratori/testableexamples"), linter.NewConfig(testifylint.New(&cfg.LintersSettings.Testifylint)). WithSince("v1.55.0"). - WithPresets(linter.PresetTest, linter.PresetBugs). WithLoadForGoAnalysis(). WithAutoFix(). WithURL("https://github.com/Antonboom/testifylint"), linter.NewConfig(testpackage.New(&cfg.LintersSettings.Testpackage)). WithSince("v1.25.0"). - WithPresets(linter.PresetStyle, linter.PresetTest). WithURL("https://github.com/maratori/testpackage"), linter.NewConfig(thelper.New(&cfg.LintersSettings.Thelper)). WithSince("v1.34.0"). - WithPresets(linter.PresetTest). WithLoadForGoAnalysis(). WithURL("https://github.com/kulti/thelper"), linter.NewConfig(tparallel.New()). WithSince("v1.32.0"). - WithPresets(linter.PresetStyle, linter.PresetTest). WithLoadForGoAnalysis(). WithURL("https://github.com/moricho/tparallel"), @@ -727,12 +629,10 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { linter.NewConfig(unconvert.New(&cfg.LintersSettings.Unconvert)). WithSince("v1.0.0"). WithLoadForGoAnalysis(). - WithPresets(linter.PresetStyle). WithURL("https://github.com/mdempsky/unconvert"), linter.NewConfig(unparam.New(&cfg.LintersSettings.Unparam)). WithSince("v1.9.0"). - WithPresets(linter.PresetUnused). WithLoadForGoAnalysis(). WithURL("https://github.com/mvdan/unparam"), @@ -740,64 +640,54 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithEnabledByDefault(). WithSince("v1.20.0"). WithLoadForGoAnalysis(). - WithPresets(linter.PresetUnused). ConsiderSlow(). WithChangeTypes(). WithURL("https://github.com/dominikh/go-tools/tree/HEAD/unused"), linter.NewConfig(usestdlibvars.New(&cfg.LintersSettings.UseStdlibVars)). WithSince("v1.48.0"). - WithPresets(linter.PresetStyle). WithAutoFix(). WithURL("https://github.com/sashamelentyev/usestdlibvars"), linter.NewConfig(usetesting.New(&cfg.LintersSettings.UseTesting)). WithSince("v1.63.0"). - WithPresets(linter.PresetTest). WithLoadForGoAnalysis(). WithAutoFix(). WithURL("https://github.com/ldez/usetesting"), linter.NewConfig(varnamelen.New(&cfg.LintersSettings.Varnamelen)). WithSince("v1.43.0"). - WithPresets(linter.PresetStyle). WithLoadForGoAnalysis(). WithURL("https://github.com/blizzy78/varnamelen"), linter.NewConfig(wastedassign.New()). WithSince("v1.38.0"). - WithPresets(linter.PresetStyle). WithLoadForGoAnalysis(). WithURL("https://github.com/sanposhiho/wastedassign"), linter.NewConfig(whitespace.New(&cfg.LintersSettings.Whitespace)). WithSince("v1.19.0"). - WithPresets(linter.PresetStyle). WithAutoFix(). WithURL("https://github.com/ultraware/whitespace"), linter.NewConfig(wrapcheck.New(&cfg.LintersSettings.Wrapcheck)). WithSince("v1.32.0"). - WithPresets(linter.PresetStyle, linter.PresetError). WithLoadForGoAnalysis(). WithURL("https://github.com/tomarrell/wrapcheck"), linter.NewConfig(wsl.New(&cfg.LintersSettings.WSL)). WithSince("v1.20.0"). - WithPresets(linter.PresetStyle). WithAutoFix(). WithURL("https://github.com/bombsimon/wsl"), linter.NewConfig(zerologlint.New()). WithSince("v1.53.0"). - WithPresets(linter.PresetBugs). WithLoadForGoAnalysis(). WithURL("https://github.com/ykadowak/zerologlint"), // nolintlint must be last because it looks at the results of all the previous linters for unused nolint directives linter.NewConfig(nolintlint.New(&cfg.LintersSettings.NoLintLint)). WithSince("v1.26.0"). - WithPresets(linter.PresetStyle). WithAutoFix(). WithURL("https://github.com/golangci/golangci-lint/tree/HEAD/pkg/golinters/nolintlint/internal"), }, nil diff --git a/pkg/lint/lintersdb/manager.go b/pkg/lint/lintersdb/manager.go index c20aad409641..3c9b1397879d 100644 --- a/pkg/lint/lintersdb/manager.go +++ b/pkg/lint/lintersdb/manager.go @@ -76,21 +76,6 @@ func (m *Manager) GetAllSupportedLinterConfigs() []*linter.Config { return m.linters } -func (m *Manager) GetAllLinterConfigsForPreset(p string) []*linter.Config { - var ret []*linter.Config - for _, lc := range m.linters { - if lc.IsDeprecated() { - continue - } - - if slices.Contains(lc.InPresets, p) { - ret = append(ret, lc) - } - } - - return ret -} - func (m *Manager) GetEnabledLintersMap() (map[string]*linter.Config, error) { enabledLinters := m.build(m.GetAllEnabledByDefaultLinters()) @@ -144,7 +129,6 @@ func (m *Manager) GetAllEnabledByDefaultLinters() []*linter.Config { return ret } -//nolint:gocyclo // the complexity cannot be reduced. func (m *Manager) build(enabledByDefaultLinters []*linter.Config) map[string]*linter.Config { m.debugf("Linters config: %#v", m.cfg.Linters) @@ -152,21 +136,12 @@ func (m *Manager) build(enabledByDefaultLinters []*linter.Config) map[string]*li switch { case m.cfg.Linters.DisableAll: // no default linters - case len(m.cfg.Linters.Presets) != 0: - // imply --disable-all case m.cfg.Linters.EnableAll: resultLintersSet = linterConfigsToMap(m.linters) default: resultLintersSet = linterConfigsToMap(enabledByDefaultLinters) } - // --presets can only add linters to default set - for _, p := range m.cfg.Linters.Presets { - for _, lc := range m.GetAllLinterConfigsForPreset(p) { - resultLintersSet[lc.Name()] = lc - } - } - // --fast removes slow linters from current set. // It should be after --presets to be able to run only fast linters in preset. // It should be before --enable and --disable to be able to enable or disable specific linter. @@ -225,8 +200,6 @@ func (m *Manager) combineGoAnalysisLinters(linters map[string]*linter.Config) { mlConfig.ConsiderSlow() } - mlConfig.InPresets = append(mlConfig.InPresets, lc.InPresets...) - goanalysisLinters = append(goanalysisLinters, lnt) } @@ -256,9 +229,6 @@ func (m *Manager) combineGoAnalysisLinters(linters map[string]*linter.Config) { mlConfig.Linter = goanalysis.NewMetaLinter(goanalysisLinters) - sort.Strings(mlConfig.InPresets) - mlConfig.InPresets = slices.Compact(mlConfig.InPresets) - linters[mlConfig.Linter.Name()] = mlConfig m.debugf("Combined %d go/analysis linters into one metalinter", len(goanalysisLinters)) @@ -275,29 +245,6 @@ func (m *Manager) verbosePrintLintersStatus(lcs map[string]*linter.Config) { } sort.Strings(linterNames) m.log.Infof("Active %d linters: %s", len(linterNames), linterNames) - - if len(m.cfg.Linters.Presets) != 0 { - sort.Strings(m.cfg.Linters.Presets) - m.log.Infof("Active presets: %s", m.cfg.Linters.Presets) - } -} - -func AllPresets() []string { - return []string{ - linter.PresetBugs, - linter.PresetComment, - linter.PresetComplexity, - linter.PresetError, - linter.PresetFormatting, - linter.PresetImport, - linter.PresetMetaLinter, - linter.PresetModule, - linter.PresetPerformance, - linter.PresetSQL, - linter.PresetStyle, - linter.PresetTest, - linter.PresetUnused, - } } func linterConfigsToMap(lcs []*linter.Config) map[string]*linter.Config { diff --git a/pkg/lint/lintersdb/manager_test.go b/pkg/lint/lintersdb/manager_test.go index fa8c783fde71..42f96558abe7 100644 --- a/pkg/lint/lintersdb/manager_test.go +++ b/pkg/lint/lintersdb/manager_test.go @@ -55,8 +55,7 @@ func TestManager_GetOptimizedLinters(t *testing.T) { } mlConfig := &linter.Config{ - Linter: goanalysis.NewMetaLinter(gaLinters), - InPresets: []string{"format"}, + Linter: goanalysis.NewMetaLinter(gaLinters), } expected := []*linter.Config{mlConfig.WithLoadFiles()} @@ -174,14 +173,12 @@ func TestManager_combineGoAnalysisLinters(t *testing.T) { desc: "no combined, one linter", linters: map[string]*linter.Config{ "foo": { - Linter: fooTyped, - InPresets: []string{"A"}, + Linter: fooTyped, }, }, expected: map[string]*linter.Config{ "foo": { - Linter: fooTyped, - InPresets: []string{"A"}, + Linter: fooTyped, }, }, }, @@ -189,18 +186,15 @@ func TestManager_combineGoAnalysisLinters(t *testing.T) { desc: "combined, several linters (typed)", linters: map[string]*linter.Config{ "foo": { - Linter: fooTyped, - InPresets: []string{"A"}, + Linter: fooTyped, }, "bar": { - Linter: barTyped, - InPresets: []string{"B"}, + Linter: barTyped, }, }, expected: func() map[string]*linter.Config { mlConfig := &linter.Config{ - Linter: goanalysis.NewMetaLinter([]*goanalysis.Linter{barTyped, fooTyped}), - InPresets: []string{"A", "B"}, + Linter: goanalysis.NewMetaLinter([]*goanalysis.Linter{barTyped, fooTyped}), } return map[string]*linter.Config{ @@ -212,21 +206,18 @@ func TestManager_combineGoAnalysisLinters(t *testing.T) { desc: "combined, several linters (different LoadMode)", linters: map[string]*linter.Config{ "foo": { - Linter: fooTyped, - InPresets: []string{"A"}, - LoadMode: packages.NeedName, + Linter: fooTyped, + LoadMode: packages.NeedName, }, "bar": { - Linter: barTyped, - InPresets: []string{"B"}, - LoadMode: packages.NeedTypesSizes, + Linter: barTyped, + LoadMode: packages.NeedTypesSizes, }, }, expected: func() map[string]*linter.Config { mlConfig := &linter.Config{ - Linter: goanalysis.NewMetaLinter([]*goanalysis.Linter{barTyped, fooTyped}), - InPresets: []string{"A", "B"}, - LoadMode: packages.NeedName | packages.NeedTypesSizes, + Linter: goanalysis.NewMetaLinter([]*goanalysis.Linter{barTyped, fooTyped}), + LoadMode: packages.NeedName | packages.NeedTypesSizes, } return map[string]*linter.Config{ @@ -238,21 +229,18 @@ func TestManager_combineGoAnalysisLinters(t *testing.T) { desc: "combined, several linters (same LoadMode)", linters: map[string]*linter.Config{ "foo": { - Linter: fooTyped, - InPresets: []string{"A"}, - LoadMode: packages.NeedName, + Linter: fooTyped, + LoadMode: packages.NeedName, }, "bar": { - Linter: barTyped, - InPresets: []string{"B"}, - LoadMode: packages.NeedName, + Linter: barTyped, + LoadMode: packages.NeedName, }, }, expected: func() map[string]*linter.Config { mlConfig := &linter.Config{ - Linter: goanalysis.NewMetaLinter([]*goanalysis.Linter{barTyped, fooTyped}), - InPresets: []string{"A", "B"}, - LoadMode: packages.NeedName, + Linter: goanalysis.NewMetaLinter([]*goanalysis.Linter{barTyped, fooTyped}), + LoadMode: packages.NeedName, } return map[string]*linter.Config{ @@ -264,18 +252,15 @@ func TestManager_combineGoAnalysisLinters(t *testing.T) { desc: "combined, several linters (syntax)", linters: map[string]*linter.Config{ "foo": { - Linter: fooSyntax, - InPresets: []string{"A"}, + Linter: fooSyntax, }, "bar": { - Linter: barSyntax, - InPresets: []string{"B"}, + Linter: barSyntax, }, }, expected: func() map[string]*linter.Config { mlConfig := &linter.Config{ - Linter: goanalysis.NewMetaLinter([]*goanalysis.Linter{barSyntax, fooSyntax}), - InPresets: []string{"A", "B"}, + Linter: goanalysis.NewMetaLinter([]*goanalysis.Linter{barSyntax, fooSyntax}), } return map[string]*linter.Config{ diff --git a/pkg/lint/lintersdb/validator.go b/pkg/lint/lintersdb/validator.go index 264d063aabb4..e9a44bfe5501 100644 --- a/pkg/lint/lintersdb/validator.go +++ b/pkg/lint/lintersdb/validator.go @@ -1,10 +1,8 @@ package lintersdb import ( - "errors" "fmt" "os" - "slices" "strings" "github.com/golangci/golangci-lint/pkg/config" @@ -25,7 +23,6 @@ func NewValidator(m *Manager) *Validator { func (v Validator) Validate(cfg *config.Config) error { validators := []func(cfg *config.Linters) error{ v.validateLintersNames, - v.validatePresets, v.alternativeNamesDeprecation, } @@ -71,23 +68,6 @@ func (v Validator) validateLintersNames(cfg *config.Linters) error { return nil } -func (Validator) validatePresets(cfg *config.Linters) error { - presets := AllPresets() - - for _, p := range cfg.Presets { - if !slices.Contains(presets, p) { - return fmt.Errorf("no such preset %q: only next presets exist: (%s)", - p, strings.Join(presets, "|")) - } - } - - if len(cfg.Presets) != 0 && cfg.EnableAll { - return errors.New("--presets is incompatible with --enable-all") - } - - return nil -} - func (v Validator) alternativeNamesDeprecation(cfg *config.Linters) error { if v.m.cfg.InternalTest || v.m.cfg.InternalCmdTest || os.Getenv(logutils.EnvTestRun) == "1" { return nil diff --git a/pkg/lint/lintersdb/validator_test.go b/pkg/lint/lintersdb/validator_test.go index f7a076348e4e..8d8ad63c2272 100644 --- a/pkg/lint/lintersdb/validator_test.go +++ b/pkg/lint/lintersdb/validator_test.go @@ -33,26 +33,6 @@ var validateLintersNamesErrorTestCases = []validateErrorTestCase{ }, } -var validatePresetsErrorTestCases = []validateErrorTestCase{ - { - desc: "unknown preset", - cfg: &config.Linters{ - EnableAll: false, - Presets: []string{"golangci"}, - }, - expected: "no such preset \"golangci\": only next presets exist: " + - "(bugs|comment|complexity|error|format|import|metalinter|module|performance|sql|style|test|unused)", - }, - { - desc: "presets and enable-all", - cfg: &config.Linters{ - EnableAll: true, - Presets: []string{"bugs"}, - }, - expected: `--presets is incompatible with --enable-all`, - }, -} - type validatorTestCase struct { desc string cfg *config.Linters @@ -82,30 +62,6 @@ var validateLintersNamesTestCases = []validatorTestCase{ }, } -var validatePresetsTestCases = []validatorTestCase{ - { - desc: "known preset", - cfg: &config.Linters{ - EnableAll: false, - Presets: []string{"bugs"}, - }, - }, - { - desc: "enable-all and no presets", - cfg: &config.Linters{ - EnableAll: true, - Presets: nil, - }, - }, - { - desc: "no presets", - cfg: &config.Linters{ - EnableAll: false, - Presets: nil, - }, - }, -} - func TestValidator_Validate(t *testing.T) { m, err := NewManager(nil, nil, NewLinterBuilder()) require.NoError(t, err) @@ -114,7 +70,6 @@ func TestValidator_Validate(t *testing.T) { var testCases []validatorTestCase testCases = append(testCases, validateLintersNamesTestCases...) - testCases = append(testCases, validatePresetsTestCases...) for _, test := range testCases { t.Run(test.desc, func(t *testing.T) { @@ -134,7 +89,6 @@ func TestValidator_Validate_error(t *testing.T) { var testCases []validateErrorTestCase testCases = append(testCases, validateLintersNamesErrorTestCases...) - testCases = append(testCases, validatePresetsErrorTestCases...) for _, test := range testCases { t.Run(test.desc, func(t *testing.T) { @@ -181,31 +135,3 @@ func TestValidator_validateLintersNames_error(t *testing.T) { }) } } - -func TestValidator_validatePresets(t *testing.T) { - v := NewValidator(nil) - - for _, test := range validatePresetsTestCases { - t.Run(test.desc, func(t *testing.T) { - t.Parallel() - - err := v.validatePresets(test.cfg) - require.NoError(t, err) - }) - } -} - -func TestValidator_validatePresets_error(t *testing.T) { - v := NewValidator(nil) - - for _, test := range validatePresetsErrorTestCases { - t.Run(test.desc, func(t *testing.T) { - t.Parallel() - - err := v.validatePresets(test.cfg) - require.Error(t, err) - - require.EqualError(t, err, test.expected) - }) - } -} diff --git a/scripts/website/dump_info/main.go b/scripts/website/dump_info/main.go index c1227d1e4406..f7fd0e1f1757 100644 --- a/scripts/website/dump_info/main.go +++ b/scripts/website/dump_info/main.go @@ -47,7 +47,6 @@ func saveLinters() error { Desc: l.Linter.Desc(), EnabledByDefault: l.EnabledByDefault, LoadMode: l.LoadMode, - InPresets: l.InPresets, AlternativeNames: l.AlternativeNames, OriginalURL: l.OriginalURL, Internal: l.Internal, diff --git a/scripts/website/expand_templates/linters.go b/scripts/website/expand_templates/linters.go index 1213dc45edc3..abb99b77b934 100644 --- a/scripts/website/expand_templates/linters.go +++ b/scripts/website/expand_templates/linters.go @@ -71,15 +71,14 @@ func getLintersListMarkdown(enabled bool) string { }) lines := []string{ - "|Name|Description|Presets|AutoFix|Since|", - "|---|---|---|---|---|---|", + "|Name|Description|AutoFix|Since|", + "|---|---|---|---|---|", } for _, lc := range neededLcs { - line := fmt.Sprintf("|%s|%s|%s|%v|%s|", + line := fmt.Sprintf("|%s|%s|%v|%s|", getName(lc), getDesc(lc), - strings.Join(lc.InPresets, ", "), check(lc.CanAutoFix, "Auto fix supported"), lc.Since, ) diff --git a/test/run_test.go b/test/run_test.go index 5dbe7e72750a..4b757388bbdf 100644 --- a/test/run_test.go +++ b/test/run_test.go @@ -489,17 +489,6 @@ func TestEnableAllFastAndEnableCanCoexist(t *testing.T) { } } -func TestEnabledPresetsAreNotDuplicated(t *testing.T) { - testshared.NewRunnerBuilder(t). - WithNoConfig(). - WithArgs("-v", "-p", "style,bugs"). - WithTargetPath(testdataDir, minimalPkg). - Runner(). - Install(). - Run(). - ExpectOutputContains("Active presets: [bugs style]") -} - func TestAbsPathDirAnalysis(t *testing.T) { dir := filepath.Join("testdata_etc", "abspath") // abs paths don't work with testdata dir absDir, err := filepath.Abs(dir) From 991be1c33f74ba27fd8438eee71fff3819a65210 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Sun, 23 Feb 2025 00:41:55 +0100 Subject: [PATCH 2/8] chore: temporally rename previous linter configuration --- pkg/config/config.go | 9 +++-- pkg/config/loader.go | 12 +++--- pkg/config/{linters.go => old_linters.go} | 8 ++-- .../{linters_test.go => old_linters_test.go} | 38 +++++++++---------- pkg/lint/lintersdb/manager.go | 12 +++--- pkg/lint/lintersdb/manager_test.go | 16 ++++---- pkg/lint/lintersdb/validator.go | 8 ++-- pkg/lint/lintersdb/validator_test.go | 18 ++++----- pkg/lint/runner.go | 6 +-- pkg/result/processors/nolint_filter_test.go | 4 +- 10 files changed, 66 insertions(+), 65 deletions(-) rename pkg/config/{linters.go => old_linters.go} (87%) rename pkg/config/{linters_test.go => old_linters_test.go} (91%) diff --git a/pkg/config/config.go b/pkg/config/config.go index fe72c8d60c3c..d65947b6b63f 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -31,9 +31,10 @@ type Config struct { Output Output `mapstructure:"output"` LintersSettings LintersSettings `mapstructure:"linters-settings"` - Linters Linters `mapstructure:"linters"` - Issues Issues `mapstructure:"issues"` - Severity Severity `mapstructure:"severity"` + OldLinters OldLinters `mapstructure:"linters"` + + Issues Issues `mapstructure:"issues"` + Severity Severity `mapstructure:"severity"` Formatters Formatters `mapstructure:"formatters"` @@ -55,7 +56,7 @@ func (c *Config) Validate() error { c.Run.Validate, c.Output.Validate, c.LintersSettings.Validate, - c.Linters.Validate, + c.OldLinters.Validate, c.Severity.Validate, } diff --git a/pkg/config/loader.go b/pkg/config/loader.go index f6e846a00f64..6768f83dd233 100644 --- a/pkg/config/loader.go +++ b/pkg/config/loader.go @@ -67,8 +67,8 @@ func (l *Loader) Load(opts LoadOptions) error { l.applyStringSliceHack() - if l.cfg.Linters.LinterExclusions.Generated == "" { - l.cfg.Linters.LinterExclusions.Generated = GeneratedModeStrict + if l.cfg.OldLinters.LinterExclusions.Generated == "" { + l.cfg.OldLinters.LinterExclusions.Generated = GeneratedModeStrict } l.handleFormatters() @@ -278,8 +278,8 @@ func (l *Loader) applyStringSliceHack() { return } - l.appendStringSlice("enable", &l.cfg.Linters.Enable) - l.appendStringSlice("disable", &l.cfg.Linters.Disable) + l.appendStringSlice("enable", &l.cfg.OldLinters.Enable) + l.appendStringSlice("disable", &l.cfg.OldLinters.Disable) l.appendStringSlice("build-tags", &l.cfg.Run.BuildTags) } @@ -337,7 +337,7 @@ func (l *Loader) handleEnableOnlyOption() error { } if len(only) > 0 { - l.cfg.Linters = Linters{ + l.cfg.OldLinters = OldLinters{ Enable: only, DisableAll: true, } @@ -377,7 +377,7 @@ func (l *Loader) handleFormatterExclusions() { } for _, path := range l.cfg.Formatters.Exclusions.Paths { - l.cfg.Linters.LinterExclusions.Rules = append(l.cfg.Linters.LinterExclusions.Rules, ExcludeRule{ + l.cfg.OldLinters.LinterExclusions.Rules = append(l.cfg.OldLinters.LinterExclusions.Rules, ExcludeRule{ BaseRule: BaseRule{ Linters: l.cfg.Formatters.Enable, Path: path, diff --git a/pkg/config/linters.go b/pkg/config/old_linters.go similarity index 87% rename from pkg/config/linters.go rename to pkg/config/old_linters.go index 72ac14360708..7549edd6949e 100644 --- a/pkg/config/linters.go +++ b/pkg/config/old_linters.go @@ -5,7 +5,7 @@ import ( "fmt" ) -type Linters struct { +type OldLinters struct { Enable []string `mapstructure:"enable"` Disable []string `mapstructure:"disable"` EnableAll bool `mapstructure:"enable-all"` @@ -17,7 +17,7 @@ type Linters struct { LinterExclusions LinterExclusions `mapstructure:"exclusions"` } -func (l *Linters) Validate() error { +func (l *OldLinters) Validate() error { validators := []func() error{ l.validateAllDisableEnableOptions, l.validateDisabledAndEnabledAtOneMoment, @@ -33,7 +33,7 @@ func (l *Linters) Validate() error { return nil } -func (l *Linters) validateAllDisableEnableOptions() error { +func (l *OldLinters) validateAllDisableEnableOptions() error { if l.EnableAll && l.DisableAll { return errors.New("--enable-all and --disable-all options must not be combined") } @@ -55,7 +55,7 @@ func (l *Linters) validateAllDisableEnableOptions() error { return nil } -func (l *Linters) validateDisabledAndEnabledAtOneMoment() error { +func (l *OldLinters) validateDisabledAndEnabledAtOneMoment() error { enabledLintersSet := map[string]bool{} for _, name := range l.Enable { enabledLintersSet[name] = true diff --git a/pkg/config/linters_test.go b/pkg/config/old_linters_test.go similarity index 91% rename from pkg/config/linters_test.go rename to pkg/config/old_linters_test.go index 7b01ebee60da..e4be11162ff0 100644 --- a/pkg/config/linters_test.go +++ b/pkg/config/old_linters_test.go @@ -9,32 +9,32 @@ import ( func TestLinters_validateDisabledAndEnabledAtOneMoment(t *testing.T) { testCases := []struct { desc string - cfg *Linters + cfg *OldLinters }{ { desc: "2 different sets", - cfg: &Linters{ + cfg: &OldLinters{ Enable: []string{"dupl", "gofmt", "misspell"}, Disable: []string{"goimports", "gosec", "nolintlint"}, }, }, { desc: "only enable", - cfg: &Linters{ + cfg: &OldLinters{ Enable: []string{"goimports", "gosec", "nolintlint"}, Disable: nil, }, }, { desc: "only disable", - cfg: &Linters{ + cfg: &OldLinters{ Enable: nil, Disable: []string{"dupl", "gofmt", "misspell"}, }, }, { desc: "no sets", - cfg: &Linters{ + cfg: &OldLinters{ Enable: nil, Disable: nil, }, @@ -54,12 +54,12 @@ func TestLinters_validateDisabledAndEnabledAtOneMoment(t *testing.T) { func TestLinters_validateDisabledAndEnabledAtOneMoment_error(t *testing.T) { testCases := []struct { desc string - cfg *Linters + cfg *OldLinters expected string }{ { desc: "disable one linter of the enabled linters", - cfg: &Linters{ + cfg: &OldLinters{ Enable: []string{"dupl", "gofmt", "misspell"}, Disable: []string{"dupl", "gosec", "nolintlint"}, }, @@ -67,7 +67,7 @@ func TestLinters_validateDisabledAndEnabledAtOneMoment_error(t *testing.T) { }, { desc: "disable multiple enabled linters", - cfg: &Linters{ + cfg: &OldLinters{ Enable: []string{"dupl", "gofmt", "misspell"}, Disable: []string{"dupl", "gofmt", "misspell"}, }, @@ -90,15 +90,15 @@ func TestLinters_validateDisabledAndEnabledAtOneMoment_error(t *testing.T) { func TestLinters_validateAllDisableEnableOptions(t *testing.T) { testCases := []struct { desc string - cfg *Linters + cfg *OldLinters }{ { desc: "nothing", - cfg: &Linters{}, + cfg: &OldLinters{}, }, { desc: "enable and disable", - cfg: &Linters{ + cfg: &OldLinters{ Enable: []string{"goimports", "gosec", "nolintlint"}, EnableAll: false, Disable: []string{"dupl", "gofmt", "misspell"}, @@ -107,7 +107,7 @@ func TestLinters_validateAllDisableEnableOptions(t *testing.T) { }, { desc: "disable-all and enable", - cfg: &Linters{ + cfg: &OldLinters{ Enable: []string{"goimports", "gosec", "nolintlint"}, EnableAll: false, Disable: nil, @@ -116,7 +116,7 @@ func TestLinters_validateAllDisableEnableOptions(t *testing.T) { }, { desc: "enable-all and disable", - cfg: &Linters{ + cfg: &OldLinters{ Enable: nil, EnableAll: true, Disable: []string{"goimports", "gosec", "nolintlint"}, @@ -125,7 +125,7 @@ func TestLinters_validateAllDisableEnableOptions(t *testing.T) { }, { desc: "enable-all and enable and fast", - cfg: &Linters{ + cfg: &OldLinters{ Enable: []string{"dupl", "gofmt", "misspell"}, EnableAll: true, Disable: nil, @@ -148,12 +148,12 @@ func TestLinters_validateAllDisableEnableOptions(t *testing.T) { func TestLinters_validateAllDisableEnableOptions_error(t *testing.T) { testCases := []struct { desc string - cfg *Linters + cfg *OldLinters expected string }{ { desc: "enable-all and disable-all", - cfg: &Linters{ + cfg: &OldLinters{ Enable: nil, EnableAll: true, Disable: nil, @@ -164,7 +164,7 @@ func TestLinters_validateAllDisableEnableOptions_error(t *testing.T) { }, { desc: "disable-all and disable no enable no preset", - cfg: &Linters{ + cfg: &OldLinters{ Enable: nil, EnableAll: false, Disable: []string{"dupl", "gofmt", "misspell"}, @@ -175,7 +175,7 @@ func TestLinters_validateAllDisableEnableOptions_error(t *testing.T) { }, { desc: "disable-all and disable with enable", - cfg: &Linters{ + cfg: &OldLinters{ Enable: []string{"nolintlint"}, EnableAll: false, Disable: []string{"dupl", "gofmt", "misspell"}, @@ -186,7 +186,7 @@ func TestLinters_validateAllDisableEnableOptions_error(t *testing.T) { }, { desc: "enable-all and enable", - cfg: &Linters{ + cfg: &OldLinters{ Enable: []string{"dupl", "gofmt", "misspell"}, EnableAll: true, Disable: nil, diff --git a/pkg/lint/lintersdb/manager.go b/pkg/lint/lintersdb/manager.go index 3c9b1397879d..07b7c8677339 100644 --- a/pkg/lint/lintersdb/manager.go +++ b/pkg/lint/lintersdb/manager.go @@ -130,13 +130,13 @@ func (m *Manager) GetAllEnabledByDefaultLinters() []*linter.Config { } func (m *Manager) build(enabledByDefaultLinters []*linter.Config) map[string]*linter.Config { - m.debugf("Linters config: %#v", m.cfg.Linters) + m.debugf("Linters config: %#v", m.cfg.OldLinters) resultLintersSet := map[string]*linter.Config{} switch { - case m.cfg.Linters.DisableAll: + case m.cfg.OldLinters.DisableAll: // no default linters - case m.cfg.Linters.EnableAll: + case m.cfg.OldLinters.EnableAll: resultLintersSet = linterConfigsToMap(m.linters) default: resultLintersSet = linterConfigsToMap(enabledByDefaultLinters) @@ -145,7 +145,7 @@ func (m *Manager) build(enabledByDefaultLinters []*linter.Config) map[string]*li // --fast removes slow linters from current set. // It should be after --presets to be able to run only fast linters in preset. // It should be before --enable and --disable to be able to enable or disable specific linter. - if m.cfg.Linters.Fast { + if m.cfg.OldLinters.Fast { for name, lc := range resultLintersSet { if lc.IsSlowLinter() { delete(resultLintersSet, name) @@ -153,14 +153,14 @@ func (m *Manager) build(enabledByDefaultLinters []*linter.Config) map[string]*li } } - for _, name := range slices.Concat(m.cfg.Linters.Enable, m.cfg.Formatters.Enable) { + for _, name := range slices.Concat(m.cfg.OldLinters.Enable, m.cfg.Formatters.Enable) { for _, lc := range m.GetLinterConfigs(name) { // it's important to use lc.Name() nor name because name can be alias resultLintersSet[lc.Name()] = lc } } - for _, name := range m.cfg.Linters.Disable { + for _, name := range m.cfg.OldLinters.Disable { for _, lc := range m.GetLinterConfigs(name) { // it's important to use lc.Name() nor name because name can be alias delete(resultLintersSet, lc.Name()) diff --git a/pkg/lint/lintersdb/manager_test.go b/pkg/lint/lintersdb/manager_test.go index 42f96558abe7..806bf1757a3a 100644 --- a/pkg/lint/lintersdb/manager_test.go +++ b/pkg/lint/lintersdb/manager_test.go @@ -15,8 +15,8 @@ import ( func TestManager_GetEnabledLintersMap(t *testing.T) { cfg := config.NewDefault() - cfg.Linters.DisableAll = true - cfg.Linters.Enable = []string{"gofmt"} + cfg.OldLinters.DisableAll = true + cfg.OldLinters.Enable = []string{"gofmt"} m, err := NewManager(logutils.NewStderrLog("skip"), cfg, NewLinterBuilder()) require.NoError(t, err) @@ -37,8 +37,8 @@ func TestManager_GetEnabledLintersMap(t *testing.T) { func TestManager_GetOptimizedLinters(t *testing.T) { cfg := config.NewDefault() - cfg.Linters.DisableAll = true - cfg.Linters.Enable = []string{"gofmt"} + cfg.OldLinters.DisableAll = true + cfg.OldLinters.Enable = []string{"gofmt"} m, err := NewManager(logutils.NewStderrLog("skip"), cfg, NewLinterBuilder()) require.NoError(t, err) @@ -78,7 +78,7 @@ func TestManager_build(t *testing.T) { { desc: "enable gosec by primary name", cfg: &config.Config{ - Linters: config.Linters{ + OldLinters: config.OldLinters{ Enable: []string{"gosec"}, }, }, @@ -87,7 +87,7 @@ func TestManager_build(t *testing.T) { { desc: "disable gosec by primary name", cfg: &config.Config{ - Linters: config.Linters{ + OldLinters: config.OldLinters{ Disable: []string{"gosec"}, }, }, @@ -97,7 +97,7 @@ func TestManager_build(t *testing.T) { { desc: "linters and formatters", cfg: &config.Config{ - Linters: config.Linters{ + OldLinters: config.OldLinters{ Enable: []string{"gosec"}, }, Formatters: config.Formatters{ @@ -109,7 +109,7 @@ func TestManager_build(t *testing.T) { { desc: "linters and formatters but linters configuration disables the formatter", cfg: &config.Config{ - Linters: config.Linters{ + OldLinters: config.OldLinters{ Enable: []string{"gosec"}, Disable: []string{"gofmt"}, }, diff --git a/pkg/lint/lintersdb/validator.go b/pkg/lint/lintersdb/validator.go index e9a44bfe5501..5b627a0b1661 100644 --- a/pkg/lint/lintersdb/validator.go +++ b/pkg/lint/lintersdb/validator.go @@ -21,13 +21,13 @@ func NewValidator(m *Manager) *Validator { // Validate validates the configuration by calling all other validators for different // sections in the configuration and then some additional linter validation functions. func (v Validator) Validate(cfg *config.Config) error { - validators := []func(cfg *config.Linters) error{ + validators := []func(cfg *config.OldLinters) error{ v.validateLintersNames, v.alternativeNamesDeprecation, } for _, v := range validators { - if err := v(&cfg.Linters); err != nil { + if err := v(&cfg.OldLinters); err != nil { return err } } @@ -35,7 +35,7 @@ func (v Validator) Validate(cfg *config.Config) error { return nil } -func (v Validator) validateLintersNames(cfg *config.Linters) error { +func (v Validator) validateLintersNames(cfg *config.OldLinters) error { var unknownNames []string for _, name := range cfg.Enable { @@ -68,7 +68,7 @@ func (v Validator) validateLintersNames(cfg *config.Linters) error { return nil } -func (v Validator) alternativeNamesDeprecation(cfg *config.Linters) error { +func (v Validator) alternativeNamesDeprecation(cfg *config.OldLinters) error { if v.m.cfg.InternalTest || v.m.cfg.InternalCmdTest || os.Getenv(logutils.EnvTestRun) == "1" { return nil } diff --git a/pkg/lint/lintersdb/validator_test.go b/pkg/lint/lintersdb/validator_test.go index 8d8ad63c2272..4c8f00b93587 100644 --- a/pkg/lint/lintersdb/validator_test.go +++ b/pkg/lint/lintersdb/validator_test.go @@ -10,14 +10,14 @@ import ( type validateErrorTestCase struct { desc string - cfg *config.Linters + cfg *config.OldLinters expected string } var validateLintersNamesErrorTestCases = []validateErrorTestCase{ { desc: "unknown enabled linter", - cfg: &config.Linters{ + cfg: &config.OldLinters{ Enable: []string{"golangci"}, Disable: nil, }, @@ -25,7 +25,7 @@ var validateLintersNamesErrorTestCases = []validateErrorTestCase{ }, { desc: "unknown disabled linter", - cfg: &config.Linters{ + cfg: &config.OldLinters{ Enable: nil, Disable: []string{"golangci"}, }, @@ -35,27 +35,27 @@ var validateLintersNamesErrorTestCases = []validateErrorTestCase{ type validatorTestCase struct { desc string - cfg *config.Linters + cfg *config.OldLinters } var validateLintersNamesTestCases = []validatorTestCase{ { desc: "no enable no disable", - cfg: &config.Linters{ + cfg: &config.OldLinters{ Enable: nil, Disable: nil, }, }, { desc: "existing enabled linter", - cfg: &config.Linters{ + cfg: &config.OldLinters{ Enable: []string{"gofmt"}, Disable: nil, }, }, { desc: "existing disabled linter", - cfg: &config.Linters{ + cfg: &config.OldLinters{ Enable: nil, Disable: []string{"gofmt"}, }, @@ -75,7 +75,7 @@ func TestValidator_Validate(t *testing.T) { t.Run(test.desc, func(t *testing.T) { t.Parallel() - err := v.Validate(&config.Config{Linters: *test.cfg}) + err := v.Validate(&config.Config{OldLinters: *test.cfg}) require.NoError(t, err) }) } @@ -94,7 +94,7 @@ func TestValidator_Validate_error(t *testing.T) { t.Run(test.desc, func(t *testing.T) { t.Parallel() - err := v.Validate(&config.Config{Linters: *test.cfg}) + err := v.Validate(&config.Config{OldLinters: *test.cfg}) require.Error(t, err) require.EqualError(t, err, test.expected) diff --git a/pkg/lint/runner.go b/pkg/lint/runner.go index 12be1f7cd41e..3c0bd26ce801 100644 --- a/pkg/lint/runner.go +++ b/pkg/lint/runner.go @@ -47,7 +47,7 @@ func NewRunner(log logutils.Log, cfg *config.Config, goenv *goutil.Env, return nil, fmt.Errorf("error creating path relativity processor: %w", err) } - exclusionPaths, err := processors.NewExclusionPaths(log, &cfg.Linters.LinterExclusions) + exclusionPaths, err := processors.NewExclusionPaths(log, &cfg.OldLinters.LinterExclusions) if err != nil { return nil, err } @@ -93,13 +93,13 @@ func NewRunner(log logutils.Log, cfg *config.Config, goenv *goutil.Env, // Must be after PathRelativity. exclusionPaths, - processors.NewGeneratedFileFilter(cfg.Linters.LinterExclusions.Generated), + processors.NewGeneratedFileFilter(cfg.OldLinters.LinterExclusions.Generated), // Must be before exclude because users see already marked output and configure excluding by it. processors.NewIdentifierMarker(), processors.NewExclusionRules(log.Child(logutils.DebugKeyExclusionRules), files, - &cfg.Linters.LinterExclusions), + &cfg.OldLinters.LinterExclusions), processors.NewNolintFilter(log.Child(logutils.DebugKeyNolintFilter), dbManager, enabledLinters), diff --git a/pkg/result/processors/nolint_filter_test.go b/pkg/result/processors/nolint_filter_test.go index 7238294a1c25..3f98f4a7e20a 100644 --- a/pkg/result/processors/nolint_filter_test.go +++ b/pkg/result/processors/nolint_filter_test.go @@ -272,7 +272,7 @@ func TestNolintFilter_Process_unused(t *testing.T) { enabledSetLog := logutils.NewMockLog() enabledSetLog.On("Infof", "Active %d linters: %s", len(enabledLinters), enabledLinters) - cfg := &config.Config{Linters: config.Linters{DisableAll: true, Enable: enabledLinters}} + cfg := &config.Config{OldLinters: config.OldLinters{DisableAll: true, Enable: enabledLinters}} dbManager, err := lintersdb.NewManager(enabledSetLog, cfg, lintersdb.NewLinterBuilder()) require.NoError(t, err) @@ -336,7 +336,7 @@ func TestNolintFilter_Process_unused(t *testing.T) { enabledSetLog := logutils.NewMockLog() enabledSetLog.On("Infof", "Active %d linters: %s", 1, []string{"nolintlint"}) - cfg := &config.Config{Linters: config.Linters{DisableAll: true, Enable: []string{"nolintlint"}}} + cfg := &config.Config{OldLinters: config.OldLinters{DisableAll: true, Enable: []string{"nolintlint"}}} dbManager, err := lintersdb.NewManager(enabledSetLog, cfg, lintersdb.NewLinterBuilder()) require.NoError(t, err) From 7360aed4eb7be018bf970d133c31a1bfbcc0715f Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Sun, 23 Feb 2025 00:47:21 +0100 Subject: [PATCH 3/8] chore: new setting structures --- pkg/config/config.go | 1 + pkg/config/linters.go | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 pkg/config/linters.go diff --git a/pkg/config/config.go b/pkg/config/config.go index d65947b6b63f..2d8cbe68aec1 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -32,6 +32,7 @@ type Config struct { LintersSettings LintersSettings `mapstructure:"linters-settings"` OldLinters OldLinters `mapstructure:"linters"` + Linters Linters `mapstructure:"linters-TEMP"` Issues Issues `mapstructure:"issues"` Severity Severity `mapstructure:"severity"` diff --git a/pkg/config/linters.go b/pkg/config/linters.go new file mode 100644 index 000000000000..a9373e6c58f5 --- /dev/null +++ b/pkg/config/linters.go @@ -0,0 +1,32 @@ +package config + +const ( + GroupStandard = "standard" + GroupAll = "all" + GroupNone = "none" + GroupFast = "fast" +) + +type Linters struct { + Default string `mapstructure:"default"` + Enable []string `mapstructure:"enable"` + Disable []string `mapstructure:"disable"` + + Settings LintersSettings `mapstructure:"settings"` + + Exclusions LinterExclusions `mapstructure:"exclusions"` +} + +func (l *Linters) Validate() error { + validators := []func() error{ + l.Exclusions.Validate, + } + + for _, v := range validators { + if err := v(); err != nil { + return err + } + } + + return nil +} From 937e5c92f4408894f5e9114af13289cd1b9c0d5b Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Sun, 23 Feb 2025 01:05:52 +0100 Subject: [PATCH 4/8] feat: add Groups field --- pkg/lint/linter/config.go | 36 ++++++++++++++++++++++------ pkg/lint/lintersdb/builder_linter.go | 6 +++++ 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/pkg/lint/linter/config.go b/pkg/lint/linter/config.go index 63f664829e42..e0d043c7b39e 100644 --- a/pkg/lint/linter/config.go +++ b/pkg/lint/linter/config.go @@ -29,6 +29,7 @@ type Deprecation struct { type Config struct { Linter Linter EnabledByDefault bool + Groups map[string]struct{} LoadMode packages.LoadMode @@ -44,6 +45,13 @@ type Config struct { Deprecation *Deprecation } +func NewConfig(linter Linter) *Config { + lc := &Config{ + Linter: linter, + } + return lc.WithLoadFiles() +} + func (lc *Config) WithEnabledByDefault() *Config { lc.EnabledByDefault = true return lc @@ -75,6 +83,27 @@ func (lc *Config) WithLoadForGoAnalysis() *Config { return lc } +func (lc *Config) WithGroups(names ...string) *Config { + if lc.Groups == nil { + lc.Groups = make(map[string]struct{}) + } + + for _, name := range names { + lc.Groups[name] = struct{}{} + } + + return lc +} + +func (lc *Config) FromGroup(name string) bool { + if lc.Groups == nil { + return false + } + + _, ok := lc.Groups[name] + return ok +} + func (lc *Config) WithURL(url string) *Config { lc.OriginalURL = url return lc @@ -154,10 +183,3 @@ func isGoLowerThanGo(v string) func(cfg *config.Config) error { return fmt.Errorf("this linter is disabled because the Go version (%s) of your project is lower than Go %s", cfg.Run.Go, v) } } - -func NewConfig(linter Linter) *Config { - lc := &Config{ - Linter: linter, - } - return lc.WithLoadFiles() -} diff --git a/pkg/lint/lintersdb/builder_linter.go b/pkg/lint/lintersdb/builder_linter.go index 25892ae3a5a6..80316a307558 100644 --- a/pkg/lint/lintersdb/builder_linter.go +++ b/pkg/lint/lintersdb/builder_linter.go @@ -205,6 +205,7 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithURL("https://github.com/charithe/durationcheck"), linter.NewConfig(errcheck.New(&cfg.LintersSettings.Errcheck)). + WithGroups(config.DefaultSetNameStandard). WithEnabledByDefault(). WithSince("v1.0.0"). WithLoadForGoAnalysis(). @@ -374,6 +375,7 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithURL("https://github.com/securego/gosec"), linter.NewConfig(gosimple.New(&cfg.LintersSettings.Gosimple)). + WithGroups(config.DefaultSetNameStandard). WithEnabledByDefault(). WithSince("v1.20.0"). WithLoadForGoAnalysis(). @@ -386,6 +388,7 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithURL("https://github.com/xen0n/gosmopolitan"), linter.NewConfig(govet.New(&cfg.LintersSettings.Govet)). + WithGroups(config.DefaultSetNameStandard). WithEnabledByDefault(). WithSince("v1.0.0"). WithLoadForGoAnalysis(). @@ -413,6 +416,7 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithURL("https://github.com/macabu/inamedparam"), linter.NewConfig(ineffassign.New()). + WithGroups(config.DefaultSetNameStandard). WithEnabledByDefault(). WithSince("v1.0.0"). WithURL("https://github.com/gordonklaus/ineffassign"), @@ -575,6 +579,7 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithURL("https://github.com/jjti/go-spancheck"), linter.NewConfig(staticcheck.New(&cfg.LintersSettings.Staticcheck)). + WithGroups(config.DefaultSetNameStandard). WithEnabledByDefault(). WithSince("v1.0.0"). WithLoadForGoAnalysis(). @@ -637,6 +642,7 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithURL("https://github.com/mvdan/unparam"), linter.NewConfig(unused.New(&cfg.LintersSettings.Unused)). + WithGroups(config.DefaultSetNameStandard). WithEnabledByDefault(). WithSince("v1.20.0"). WithLoadForGoAnalysis(). From 59f734946c643cb6c8698c5ca8044329c983f2e6 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Sun, 23 Feb 2025 03:34:47 +0100 Subject: [PATCH 5/8] feat: new linter configuration --- .golangci.next.reference.yml | 7259 ++++++++--------- .golangci.yml | 173 +- jsonschema/golangci.next.jsonschema.json | 521 +- pkg/commands/flagsets.go | 13 +- pkg/commands/help.go | 41 +- pkg/commands/run.go | 6 +- pkg/config/config.go | 11 +- pkg/config/linters.go | 7 +- pkg/config/loader.go | 34 +- pkg/config/old_linters.go | 71 - pkg/config/old_linters_test.go | 210 - pkg/lint/linter/config.go | 10 +- pkg/lint/linter/context.go | 2 +- pkg/lint/lintersdb/builder_linter.go | 187 +- pkg/lint/lintersdb/builder_plugin_go.go | 4 +- pkg/lint/lintersdb/builder_plugin_module.go | 4 +- pkg/lint/lintersdb/manager.go | 83 +- pkg/lint/lintersdb/manager_test.go | 51 +- pkg/lint/lintersdb/validator.go | 8 +- pkg/lint/lintersdb/validator_test.go | 18 +- pkg/lint/runner.go | 8 +- pkg/printers/testdata/golden-json.json | 2 +- pkg/printers/testdata/in-report-data.json | 21 +- pkg/report/data.go | 12 +- pkg/result/processors/nolint_filter_test.go | 4 +- scripts/website/dump_info/main.go | 2 +- scripts/website/expand_templates/linters.go | 8 +- scripts/website/types/types.go | 2 +- test/bench/bench_test.go | 4 +- test/enabled_linters_test.go | 129 +- test/output_test.go | 8 +- test/run_test.go | 35 +- test/testdata/configs/output.yml | 13 +- test/testdata/configs/path-except.yml | 12 +- test/testdata/linedirective/dupl.yml | 7 +- test/testdata/linedirective/gomodguard.yml | 11 +- test/testdata/linedirective/lll.yml | 7 +- test/testdata/minimalpkg/minimalpkg.go | 2 + .../testdata_etc/unused_exported/golangci.yml | 2 +- test/testshared/integration/fix.go | 2 +- test/testshared/integration/run.go | 2 +- 41 files changed, 4353 insertions(+), 4653 deletions(-) delete mode 100644 pkg/config/old_linters.go delete mode 100644 pkg/config/old_linters_test.go diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index 02c03baa1866..c7efb8f420ba 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -7,9 +7,11 @@ version: "2" linters: - # Disable all linters. - # Default: false - disable-all: true + # Default set of linters. + # The value can be: `standard`, `all`, `none`, or `fast`. + # Default: standard + default: all + # Enable specific linter. # https://golangci-lint.run/usage/linters/#enabled-by-default enable: @@ -123,9 +125,6 @@ linters: - wsl - zerologlint - # Enable all available linters. - # Default: false - enable-all: true # Disable specific linter # https://golangci-lint.run/usage/linters/#disabled-by-default disable: @@ -239,3733 +238,3729 @@ linters: - wsl - zerologlint - # Enable only fast linters from enabled linters set (first run won't be fast) - # Default: false - fast: true + # All available settings of specific linters. + settings: + asasalint: + # To specify a set of function names to exclude. + # The values are merged with the builtin exclusions. + # The builtin exclusions can be disabled by setting `use-builtin-exclusions` to `false`. + # Default: ["^(fmt|log|logger|t|)\.(Print|Fprint|Sprint|Fatal|Panic|Error|Warn|Warning|Info|Debug|Log)(|f|ln)$"] + exclude: + - Append + - \.Wrapf + # To enable/disable the asasalint builtin exclusions of function names. + # See the default value of `exclude` to get the builtin exclusions. + # Default: true + use-builtin-exclusions: false + + bidichk: + # The following configurations check for all mentioned invisible Unicode runes. + # All runes are enabled by default. + left-to-right-embedding: false + right-to-left-embedding: false + pop-directional-formatting: false + left-to-right-override: false + right-to-left-override: false + left-to-right-isolate: false + right-to-left-isolate: false + first-strong-isolate: false + pop-directional-isolate: false + + copyloopvar: + # Check all assigning the loop variable to another variable. + # Default: false + check-alias: true + + cyclop: + # The maximal code complexity to report. + # Default: 10 + max-complexity: 10 + # The maximal average package complexity. + # If it's higher than 0.0 (float) the check is enabled + # Default: 0.0 + package-average: 0.5 + + 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: false + + # 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 + + depguard: + # Rules to apply. + # + # Variables: + # - File Variables + # Use an exclamation mark `!` to negate a variable. + # Example: `!$test` matches any file that is not a go test file. + # + # `$all` - matches all go files + # `$test` - matches all go test files + # + # - Package Variables + # + # `$gostd` - matches all of go's standard library (Pulled from `GOROOT`) + # + # Default (applies if no custom rules are defined): Only allow $gostd in all files. + rules: + # Name of a rule. + main: + # Defines package matching behavior. Available modes: + # - `original`: allowed if it doesn't match the deny list and either matches the allow list or the allow list is empty. + # - `strict`: allowed only if it matches the allow list and either doesn't match the deny list or the allow rule is more specific (longer) than the deny rule. + # - `lax`: allowed if it doesn't match the deny list or the allow rule is more specific (longer) than the deny rule. + # Default: "original" + list-mode: lax + # List of file globs that will match this list of settings to compare against. + # By default, if a path is relative, it is relative to the directory where the golangci-lint command is executed. + # The placeholder '${base-path}' is substituted with a path relative to the mode defined with `run.relative-path-mode`. + # Default: $all + files: + - "!**/*_a _file.go" + # List of allowed packages. + # Entries can be a variable (starting with $), a string prefix, or an exact match (if ending with $). + # Default: [] + allow: + - $gostd + - github.com/OpenPeeDeeP + # List of packages that are not allowed. + # Entries can be a variable (starting with $), a string prefix, or an exact match (if ending with $). + # Default: [] + deny: + - pkg: "math/rand$" + desc: use math/rand/v2 + - pkg: "github.com/sirupsen/logrus" + desc: not allowed + - pkg: "github.com/pkg/errors" + desc: Should be replaced by standard lib errors package + + dogsled: + # Checks assignments with too many blank identifiers. + # Default: 2 + max-blank-identifiers: 3 + + dupl: + # Tokens count to trigger issue. + # Default: 150 + threshold: 100 + + dupword: + # Keywords for detecting duplicate words. + # If this list is not empty, only the words defined in this list will be detected. + # Default: [] + keywords: + - "the" + - "and" + - "a" + # Keywords used to ignore detection. + # Default: [] + ignore: + - "0C0C" - # 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 + 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 - # Excluding configuration per-path, per-linter, per-text and per-source. - rules: - # Exclude some linters from running on tests files. - - path: _test\.go - linters: - - gocyclo - - errcheck - - dupl - - gosec + # report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`. + # Such cases aren't reported by default. + # Default: false + check-blank: true - # Run some linter only for test files by excluding its issues for everything else. - - path-except: _test\.go - linters: - - forbidigo + # 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: + - io/ioutil.ReadFile + - io.Copy(*bytes.Buffer) + - io.Copy(os.Stdout) + + errchkjson: + # With check-error-free-encoding set to true, errchkjson does warn about errors + # from json encoding functions that are safe to be ignored, + # because they are not possible to happen. + # + # if check-error-free-encoding is set to true and errcheck linter is enabled, + # it is recommended to add the following exceptions to prevent from false positives: + # + # linters-settings: + # errcheck: + # exclude-functions: + # - encoding/json.Marshal + # - encoding/json.MarshalIndent + # + # Default: false + check-error-free-encoding: true - # 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 + # Issue on struct encoding that doesn't have exported fields. + # Default: false + report-no-exported: false - # Exclude some `staticcheck` messages. - - linters: - - staticcheck - text: "SA9003:" + errorlint: + # Check whether fmt.Errorf uses the %w verb for formatting errors. + # See the https://github.com/polyfloyd/go-errorlint for caveats. + # Default: true + errorf: false + # Permit more than 1 %w verb, valid per Go 1.20 (Requires errorf:true) + # Default: true + errorf-multi: false + # Check for plain type assertions and type switches. + # Default: true + asserts: false + # Check for plain error comparisons. + # Default: true + comparison: false + # Allowed errors. + # Default: [] + allowed-errors: + - err: "io.EOF" + fun: "example.com/pkg.Read" + # Allowed error "wildcards". + # Default: [] + allowed-errors-wildcard: + - err: "example.com/pkg.ErrMagic" + fun: "example.com/pkg.Magic" + + exhaustive: + # Program elements to check for exhaustiveness. + # Default: [ switch ] + check: + - switch + - map + # Presence of "default" case in switch statements satisfies exhaustiveness, + # even if all enum members are not listed. + # Default: false + default-signifies-exhaustive: true + # Enum members matching the supplied regex do not have to be listed in + # switch statements to satisfy exhaustiveness. + # Default: "" + ignore-enum-members: "Example.+" + # Enum types matching the supplied regex do not have to be listed in + # switch statements to satisfy exhaustiveness. + # Default: "" + ignore-enum-types: "Example.+" + # Consider enums only in package scopes, not in inner scopes. + # Default: false + package-scope-only: true + # Only run exhaustive check on switches with "//exhaustive:enforce" comment. + # Default: false + explicit-exhaustive-switch: true + # Only run exhaustive check on map literals with "//exhaustive:enforce" comment. + # Default: false + explicit-exhaustive-map: true + # Switch statement requires default case even if exhaustive. + # Default: false + default-case-required: true - # Exclude `lll` issues for long lines with `go:generate`. - - linters: - - lll - source: "^//go:generate " + exhaustruct: + # List of regular expressions to match struct packages and their names. + # Regular expressions must match complete canonical struct package/name/structname. + # If this list is empty, all structs are tested. + # Default: [] + include: + - '.+\.Test' + - 'example\.com/package\.ExampleStruct[\d]{1,2}' + # List of regular expressions to exclude struct packages and their names from checks. + # Regular expressions must match complete canonical struct package/name/structname. + # Default: [] + exclude: + - '.+/cobra\.Command$' - # 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 - # Which file paths to not exclude. - # Default: [] - paths-except: - - ".*\\.my\\.go$" - - lib/bad.go + fatcontext: + # Check for potential fat contexts in struct pointers. + # May generate false positives. + # Default: false + check-struct-pointers: true + + forbidigo: + # Forbid the following identifiers (list of regexp). + # Default: ["^(fmt\\.Print(|f|ln)|print|println)$"] + forbid: + # Built-in bootstrapping functions. + - pattern: ^print(ln)?$ + # Optional message that gets included in error reports. + - pattern: ^fmt\.Print.*$ + msg: Do not commit print statements. + # Alternatively, put messages at the end of the regex, surrounded by `(# )?` + # Escape any special characters. Those messages get included in error reports. + - pattern: 'fmt\.Print.*(# Do not commit print statements\.)?' + # Forbid spew Dump, whether it is called as function or method. + # Depends on analyze-types below. + - pattern: ^spew\.(ConfigState\.)?Dump$ + # The package name might be ambiguous. + # The full import path can be used as additional criteria. + # Depends on analyze-types below. + - pattern: ^v1.Dump$ + pkg: ^example.com/pkg/api/v1$ + # 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 + + funlen: + # Checks the number of lines in a function. + # If lower than 0, disable the check. + # Default: 60 + lines: -1 + # Checks the number of statements in a function. + # If lower than 0, disable the check. + # Default: 40 + statements: -1 + # Ignore comments when counting lines. + # Default false + ignore-comments: true + + ginkgolinter: + # Suppress the wrong length assertion warning. + # Default: false + suppress-len-assertion: true -formatters: - # Enable specific formatter. - # Default: [] (uses standard Go formatting) - enable: - - gci - - gofmt - - gofumpt - - goimports - - golines + # Suppress the wrong nil assertion warning. + # Default: false + suppress-nil-assertion: true - # 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/org/project) # 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. + # Suppress the wrong error assertion warning. + # Default: false + suppress-err-assertion: true - # Checks that no inline comments are present. + # Suppress the wrong comparison assertion warning. # Default: false - no-inline-comments: true + suppress-compare-assertion: true - # Checks that no prefix comments (comment lines above an import) are present. + # Suppress the function all in async assertion warning. # Default: false - no-prefix-comments: true + suppress-async-assertion: true - # Enable custom order of sections. - # If `true`, make the section order the same as the order of `sections`. + # Suppress warning for comparing values from different types, like `int32` and `uint32` # Default: false - custom-order: true + suppress-type-compare-assertion: true - # Drops lexical ordering for custom sections. + # Trigger warning for ginkgo focus containers like `FDescribe`, `FContext`, `FWhen` or `FIt` # Default: false - no-lex-order: true + forbid-focus-container: 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:]' + # Don't trigger warnings for HaveLen(0) + # Default: false + allow-havelen-zero: true - gofumpt: - # Module path which contains the source code being formatted. - # Default: "" - module-path: github.com/org/project + # Force using `Expect` with `To`, `ToNot` or `NotTo`. + # Reject using `Expect` with `Should` or `ShouldNot`. + # Default: false + force-expect-to: true - # Choose whether to use the extra rules. + # Best effort validation of async intervals (timeout and polling). + # Ignored the suppress-async-assertion is true. # Default: false - extra-rules: true + validate-async-intervals: true - 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/org/project + # Trigger a warning for variable assignments in ginkgo containers like `Describe`, `Context` and `When`, instead of in `BeforeEach()`. + # Default: false + forbid-spec-pollution: true - golines: - # Target maximum line length. - # Default: 100 - max-len: 200 - # Length of a tabulation. - # Default: 4 - tab-len: 8 - # Shorten single-line comments. + # Force using the Succeed matcher for error functions, and the HaveOccurred matcher for non-function error values. # Default: false - shorten-comments: true + force-succeed: true + + gochecksumtype: + # Presence of `default` case in switch statements satisfies exhaustiveness, if all members are not listed. # Default: true - reformat-tags: false - # Split chained methods on the dots as opposed to the arguments. + default-signifies-exhaustive: false + # Include shared interfaces in the exhaustiviness check. + # Default: false + include-shared-interfaces: true + + gocognit: + # Minimal code complexity to report. + # Default: 30 (but we recommend 10-20) + min-complexity: 10 + + goconst: + # Minimal length of string constant. + # Default: 3 + min-len: 2 + # Minimum occurrences of constant string count to trigger issue. + # Default: 3 + min-occurrences: 2 + # Look for existing constants matching the values. # Default: true - chain-split-dots: false + match-constant: false + # Search also for duplicated numbers. + # Default: false + numbers: true + # Minimum value, only works with goconst.numbers + # Default: 3 + min: 2 + # Maximum value, only works with goconst.numbers + # Default: 3 + max: 2 + # Ignore when constant is not used as function argument. + # Default: true + ignore-calls: false + # Exclude strings matching the given regular expression. + # Default: "" + ignore-strings: 'foo.+' + gocritic: + # Disable all checks. + # Default: false + disable-all: true + # Which checks should be enabled in addition to default checks; can't be combined with 'disabled-checks'. + # By default, list of stable checks is used (https://go-critic.com/overview#checks-overview): + # appendAssign, argOrder, assignOp, badCall, badCond, captLocal, caseOrder, codegenComment, commentFormatting, + # defaultCaseOrder, deprecatedComment, dupArg, dupBranchBody, dupCase, dupSubExpr, elseif, exitAfterDefer, + # flagDeref, flagName, ifElseChain, mapKey, newDeref, offBy1, regexpMust, singleCaseSwitch, sloppyLen, + # sloppyTypeAssert, switchTrue, typeSwitchVar, underef, unlambda, unslice, valSwap, wrapperFunc + # To see which checks are enabled run `GL_DEBUG=gocritic golangci-lint run --enable=gocritic`. + enabled-checks: + # Detects suspicious append result assignments. + # https://go-critic.com/overview.html#appendassign + - appendAssign + # Detects `append` chains to the same slice that can be done in a single `append` call. + # https://go-critic.com/overview.html#appendcombine + - appendCombine + # Detects suspicious arguments order. + # https://go-critic.com/overview.html#argorder + - argOrder + # Detects assignments that can be simplified by using assignment operators. + # https://go-critic.com/overview.html#assignop + - assignOp + # Detects suspicious function calls. + # https://go-critic.com/overview.html#badcall + - badCall + # Detects suspicious condition expressions. + # https://go-critic.com/overview.html#badcond + - badCond + # Detects suspicious mutex lock/unlock operations. + # https://go-critic.com/overview.html#badlock + - badLock + # Detects suspicious regexp patterns. + # https://go-critic.com/overview.html#badregexp + - badRegexp + # Detects bad usage of sort package. + # https://go-critic.com/overview.html#badsorting + - badSorting + # Detects bad usage of sync.OnceFunc. + # https://go-critic.com/overview.html#badsynconcefunc + - badSyncOnceFunc + # Detects bool expressions that can be simplified. + # https://go-critic.com/overview.html#boolexprsimplify + - boolExprSimplify + # Detects when predeclared identifiers are shadowed in assignments. + # https://go-critic.com/overview.html#builtinshadow + - builtinShadow + # Detects top-level declarations that shadow the predeclared identifiers. + # https://go-critic.com/overview.html#builtinshadowdecl + - builtinShadowDecl + # Detects capitalized names for local variables. + # https://go-critic.com/overview.html#captlocal + - captLocal + # Detects erroneous case order inside switch statements. + # https://go-critic.com/overview.html#caseorder + - caseOrder + # Detects malformed 'code generated' file comments. + # https://go-critic.com/overview.html#codegencomment + - codegenComment + # Detects comments with non-idiomatic formatting. + # https://go-critic.com/overview.html#commentformatting + - commentFormatting + # Detects commented-out code inside function bodies. + # https://go-critic.com/overview.html#commentedoutcode + - commentedOutCode + # Detects commented-out imports. + # https://go-critic.com/overview.html#commentedoutimport + - commentedOutImport + # Detects when default case in switch isn't on 1st or last position. + # https://go-critic.com/overview.html#defaultcaseorder + - defaultCaseOrder + # Detects loops inside functions that use defer. + # https://go-critic.com/overview.html#deferinloop + - deferInLoop + # Detects deferred function literals that can be simplified. + # https://go-critic.com/overview.html#deferunlambda + - deferUnlambda + # Detects malformed 'deprecated' doc-comments. + # https://go-critic.com/overview.html#deprecatedcomment + - deprecatedComment + # Detects comments that silence go lint complaints about doc-comment. + # https://go-critic.com/overview.html#docstub + - docStub + # Detects suspicious duplicated arguments. + # https://go-critic.com/overview.html#duparg + - dupArg + # Detects duplicated branch bodies inside conditional statements. + # https://go-critic.com/overview.html#dupbranchbody + - dupBranchBody + # Detects duplicated case clauses inside switch or select statements. + # https://go-critic.com/overview.html#dupcase + - dupCase + # Detects multiple imports of the same package under different aliases. + # https://go-critic.com/overview.html#dupimport + - dupImport + # Detects suspicious duplicated sub-expressions. + # https://go-critic.com/overview.html#dupsubexpr + - dupSubExpr + # Detects suspicious formatting strings usage. + # https://go-critic.com/overview.html#dynamicfmtstring + - dynamicFmtString + # Detects else with nested if statement that can be replaced with else-if. + # https://go-critic.com/overview.html#elseif + - elseif + # Detects suspicious empty declarations blocks. + # https://go-critic.com/overview.html#emptydecl + - emptyDecl + # Detects fallthrough that can be avoided by using multi case values. + # https://go-critic.com/overview.html#emptyfallthrough + - emptyFallthrough + # Detects empty string checks that can be written more idiomatically. + # https://go-critic.com/overview.html#emptystringtest + - emptyStringTest + # Detects unoptimal strings/bytes case-insensitive comparison. + # https://go-critic.com/overview.html#equalfold + - equalFold + # Detects unwanted dependencies on the evaluation order. + # https://go-critic.com/overview.html#evalorder + - evalOrder + # Detects calls to exit/fatal inside functions that use defer. + # https://go-critic.com/overview.html#exitafterdefer + - exitAfterDefer + # Detects exposed methods from sync.Mutex and sync.RWMutex. + # https://go-critic.com/overview.html#exposedsyncmutex + - exposedSyncMutex + # Detects suspicious reassignment of error from another package. + # https://go-critic.com/overview.html#externalerrorreassign + - externalErrorReassign + # Detects problems in filepath.Join() function calls. + # https://go-critic.com/overview.html#filepathjoin + - filepathJoin + # Detects immediate dereferencing of `flag` package pointers. + # https://go-critic.com/overview.html#flagderef + - flagDeref + # Detects suspicious flag names. + # https://go-critic.com/overview.html#flagname + - flagName + # Detects hex literals that have mixed case letter digits. + # https://go-critic.com/overview.html#hexliteral + - hexLiteral + # Detects nil usages in http.NewRequest calls, suggesting http.NoBody as an alternative. + # https://go-critic.com/overview.html#httpnobody + - httpNoBody + # Detects params that incur excessive amount of copying. + # https://go-critic.com/overview.html#hugeparam + - hugeParam + # Detects repeated if-else statements and suggests to replace them with switch statement. + # https://go-critic.com/overview.html#ifelsechain + - ifElseChain + # Detects when imported package names shadowed in the assignments. + # https://go-critic.com/overview.html#importshadow + - importShadow + # Detects strings.Index calls that may cause unwanted allocs. + # https://go-critic.com/overview.html#indexalloc + - indexAlloc + # Detects non-assignment statements inside if/switch init clause. + # https://go-critic.com/overview.html#initclause + - initClause + # Detects suspicious map literal keys. + # https://go-critic.com/overview.html#mapkey + - mapKey + # Detects method expression call that can be replaced with a method call. + # https://go-critic.com/overview.html#methodexprcall + - methodExprCall + # Finds where nesting level could be reduced. + # https://go-critic.com/overview.html#nestingreduce + - nestingReduce + # Detects immediate dereferencing of `new` expressions. + # https://go-critic.com/overview.html#newderef + - newDeref + # Detects return statements those results evaluate to nil. + # https://go-critic.com/overview.html#nilvalreturn + - nilValReturn + # Detects old-style octal literals. + # https://go-critic.com/overview.html#octalliteral + - octalLiteral + # Detects various off-by-one kind of errors. + # https://go-critic.com/overview.html#offby1 + - offBy1 + # Detects if function parameters could be combined by type and suggest the way to do it. + # https://go-critic.com/overview.html#paramtypecombine + - paramTypeCombine + # Detects expressions like []rune(s)[0] that may cause unwanted rune slice allocation. + # https://go-critic.com/overview.html#preferdecoderune + - preferDecodeRune + # Detects concatenation with os.PathSeparator which can be replaced with filepath.Join. + # https://go-critic.com/overview.html#preferfilepathjoin + - preferFilepathJoin + # Detects fmt.Sprint(f/ln) calls which can be replaced with fmt.Fprint(f/ln). + # https://go-critic.com/overview.html#preferfprint + - preferFprint + # Detects w.Write or io.WriteString calls which can be replaced with w.WriteString. + # https://go-critic.com/overview.html#preferstringwriter + - preferStringWriter + # Detects WriteRune calls with rune literal argument that is single byte and reports to use WriteByte instead. + # https://go-critic.com/overview.html#preferwritebyte + - preferWriteByte + # Detects input and output parameters that have a type of pointer to referential type. + # https://go-critic.com/overview.html#ptrtorefparam + - ptrToRefParam + # Detects append all its data while range it. + # https://go-critic.com/overview.html#rangeappendall + - rangeAppendAll + # Detects expensive copies of `for` loop range expressions. + # https://go-critic.com/overview.html#rangeexprcopy + - rangeExprCopy + # Detects loops that copy big objects during each iteration. + # https://go-critic.com/overview.html#rangevalcopy + - rangeValCopy + # Detects redundant fmt.Sprint calls. + # https://go-critic.com/overview.html#redundantsprint + - redundantSprint + # Detects `regexp.Compile*` that can be replaced with `regexp.MustCompile*`. + # https://go-critic.com/overview.html#regexpmust + - regexpMust + # Detects suspicious regexp patterns. + # https://go-critic.com/overview.html#regexppattern + - regexpPattern + # Detects regexp patterns that can be simplified. + # https://go-critic.com/overview.html#regexpsimplify + - regexpSimplify + # Detects suspicious http.Error call without following return. + # https://go-critic.com/overview.html#returnafterhttperror + - returnAfterHttpError + # Runs user-defined rules using ruleguard linter. + # https://go-critic.com/overview.html#ruleguard + - ruleguard + # Detects switch statements that could be better written as if statement. + # https://go-critic.com/overview.html#singlecaseswitch + - singleCaseSwitch + # Detects slice clear loops, suggests an idiom that is recognized by the Go compiler. + # https://go-critic.com/overview.html#sliceclear + - sliceClear + # Detects usage of `len` when result is obvious or doesn't make sense. + # https://go-critic.com/overview.html#sloppylen + - sloppyLen + # Detects suspicious/confusing re-assignments. + # https://go-critic.com/overview.html#sloppyreassign + - sloppyReassign + # Detects redundant type assertions. + # https://go-critic.com/overview.html#sloppytypeassert + - sloppyTypeAssert + # Detects suspicious sort.Slice calls. + # https://go-critic.com/overview.html#sortslice + - sortSlice + # Detects "%s" formatting directives that can be replaced with %q. + # https://go-critic.com/overview.html#sprintfquotedstring + - sprintfQuotedString + # Detects issue in Query() and Exec() calls. + # https://go-critic.com/overview.html#sqlquery + - sqlQuery + # Detects string concat operations that can be simplified. + # https://go-critic.com/overview.html#stringconcatsimplify + - stringConcatSimplify + # Detects redundant conversions between string and []byte. + # https://go-critic.com/overview.html#stringxbytes + - stringXbytes + # Detects strings.Compare usage. + # https://go-critic.com/overview.html#stringscompare + - stringsCompare + # Detects switch-over-bool statements that use explicit `true` tag value. + # https://go-critic.com/overview.html#switchtrue + - switchTrue + # Detects sync.Map load+delete operations that can be replaced with LoadAndDelete. + # https://go-critic.com/overview.html#syncmaploadanddelete + - syncMapLoadAndDelete + # Detects manual conversion to milli- or microseconds. + # https://go-critic.com/overview.html#timeexprsimplify + - timeExprSimplify + # Detects TODO comments without detail/assignee. + # https://go-critic.com/overview.html#todocommentwithoutdetail + - todoCommentWithoutDetail + # Detects function with too many results. + # https://go-critic.com/overview.html#toomanyresultschecker + - tooManyResultsChecker + # Detects potential truncation issues when comparing ints of different sizes. + # https://go-critic.com/overview.html#truncatecmp + - truncateCmp + # Detects repeated type assertions and suggests to replace them with type switch statement. + # https://go-critic.com/overview.html#typeassertchain + - typeAssertChain + # Detects method declarations preceding the type definition itself. + # https://go-critic.com/overview.html#typedeffirst + - typeDefFirst + # Detects type switches that can benefit from type guard clause with variable. + # https://go-critic.com/overview.html#typeswitchvar + - typeSwitchVar + # Detects unneeded parenthesis inside type expressions and suggests to remove them. + # https://go-critic.com/overview.html#typeunparen + - typeUnparen + # Detects unchecked errors in if statements. + # https://go-critic.com/overview.html#uncheckedinlineerr + - uncheckedInlineErr + # Detects dereference expressions that can be omitted. + # https://go-critic.com/overview.html#underef + - underef + # Detects redundant statement labels. + # https://go-critic.com/overview.html#unlabelstmt + - unlabelStmt + # Detects function literals that can be simplified. + # https://go-critic.com/overview.html#unlambda + - unlambda + # Detects unnamed results that may benefit from names. + # https://go-critic.com/overview.html#unnamedresult + - unnamedResult + # Detects unnecessary braced statement blocks. + # https://go-critic.com/overview.html#unnecessaryblock + - unnecessaryBlock + # Detects redundantly deferred calls. + # https://go-critic.com/overview.html#unnecessarydefer + - unnecessaryDefer + # Detects slice expressions that can be simplified to sliced expression itself. + # https://go-critic.com/overview.html#unslice + - unslice + # Detects value swapping code that are not using parallel assignment. + # https://go-critic.com/overview.html#valswap + - valSwap + # Detects conditions that are unsafe due to not being exhaustive. + # https://go-critic.com/overview.html#weakcond + - weakCond + # Ensures that `//nolint` comments include an explanation. + # https://go-critic.com/overview.html#whynolint + - whyNoLint + # Detects function calls that can be replaced with convenience wrappers. + # https://go-critic.com/overview.html#wrapperfunc + - wrapperFunc + # Detects Yoda style expressions and suggests to replace them. + # https://go-critic.com/overview.html#yodastyleexpr + - yodaStyleExpr + + # Enable all checks. + # Default: false + enable-all: true + # Which checks should be disabled; can't be combined with 'enabled-checks'. + # Default: [] + disabled-checks: + - appendAssign + - appendCombine + - argOrder + - assignOp + - badCall + - badCond + - badLock + - badRegexp + - badSorting + - badSyncOnceFunc + - boolExprSimplify + - builtinShadow + - builtinShadowDecl + - captLocal + - caseOrder + - codegenComment + - commentFormatting + - commentedOutCode + - commentedOutImport + - defaultCaseOrder + - deferInLoop + - deferUnlambda + - deprecatedComment + - docStub + - dupArg + - dupBranchBody + - dupCase + - dupImport + - dupSubExpr + - dynamicFmtString + - elseif + - emptyDecl + - emptyFallthrough + - emptyStringTest + - equalFold + - evalOrder + - exitAfterDefer + - exposedSyncMutex + - externalErrorReassign + - filepathJoin + - flagDeref + - flagName + - hexLiteral + - httpNoBody + - hugeParam + - ifElseChain + - importShadow + - indexAlloc + - initClause + - mapKey + - methodExprCall + - nestingReduce + - newDeref + - nilValReturn + - octalLiteral + - offBy1 + - paramTypeCombine + - preferDecodeRune + - preferFilepathJoin + - preferFprint + - preferStringWriter + - preferWriteByte + - ptrToRefParam + - rangeAppendAll + - rangeExprCopy + - rangeValCopy + - redundantSprint + - regexpMust + - regexpPattern + - regexpSimplify + - returnAfterHttpError + - ruleguard + - singleCaseSwitch + - sliceClear + - sloppyLen + - sloppyReassign + - sloppyTypeAssert + - sortSlice + - sprintfQuotedString + - sqlQuery + - stringConcatSimplify + - stringXbytes + - stringsCompare + - switchTrue + - syncMapLoadAndDelete + - timeExprSimplify + - todoCommentWithoutDetail + - tooManyResultsChecker + - truncateCmp + - typeAssertChain + - typeDefFirst + - typeSwitchVar + - typeUnparen + - uncheckedInlineErr + - underef + - unlabelStmt + - unlambda + - unnamedResult + - unnecessaryBlock + - unnecessaryDefer + - unslice + - valSwap + - weakCond + - whyNoLint + - wrapperFunc + - yodaStyleExpr + + # Enable multiple checks by tags in addition to default checks. + # Run `GL_DEBUG=gocritic golangci-lint run --enable=gocritic` to see all tags and checks. + # See https://github.com/go-critic/go-critic#usage -> section "Tags". + # Default: [] + enabled-tags: + - diagnostic + - style + - performance + - experimental + - opinionated + disabled-tags: + - diagnostic + - style + - performance + - experimental + - opinionated + + # Settings passed to gocritic. + # The settings key is the name of a supported gocritic checker. + # The list of supported checkers can be find in https://go-critic.com/overview. + settings: + # Must be valid enabled check name. + captLocal: + # Whether to restrict checker to params only. + # Default: true + paramsOnly: false + commentedOutCode: + # Min length of the comment that triggers a warning. + # Default: 15 + minLength: 50 + elseif: + # Whether to skip balanced if-else pairs. + # Default: true + skipBalanced: false + hugeParam: + # Size in bytes that makes the warning trigger. + # Default: 80 + sizeThreshold: 70 + ifElseChain: + # Min number of if-else blocks that makes the warning trigger. + # Default: 2 + minThreshold: 4 + nestingReduce: + # Min number of statements inside a branch to trigger a warning. + # Default: 5 + bodyWidth: 4 + rangeExprCopy: + # Size in bytes that makes the warning trigger. + # Default: 512 + sizeThreshold: 516 + # Whether to check test functions + # Default: true + skipTestFuncs: false + rangeValCopy: + # Size in bytes that makes the warning trigger. + # Default: 128 + sizeThreshold: 32 + # Whether to check test functions. + # Default: true + skipTestFuncs: false + ruleguard: + # Enable debug to identify which 'Where' condition was rejected. + # The value of the parameter is the name of a function in a ruleguard file. + # + # When a rule is evaluated: + # If: + # The Match() clause is accepted; and + # One of the conditions in the Where() clause is rejected, + # Then: + # ruleguard prints the specific Where() condition that was rejected. + # + # The option is passed to the ruleguard 'debug-group' argument. + # Default: "" + debug: 'emptyDecl' + # Determines the behavior when an error occurs while parsing ruleguard files. + # If flag is not set, log error and skip rule files that contain an error. + # If flag is set, the value must be a comma-separated list of error conditions. + # - 'all': fail on all errors. + # - 'import': ruleguard rule imports a package that cannot be found. + # - 'dsl': gorule file does not comply with the ruleguard DSL. + # Default: "" + failOn: dsl,import + # Comma-separated list of file paths containing ruleguard rules. + # By default, if a path is relative, it is relative to the directory where the golangci-lint command is executed. + # The placeholder '${base-path}' is substituted with a path relative to the mode defined with `run.relative-path-mode`. + # Glob patterns such as 'rules-*.go' may be specified. + # Default: "" + rules: '${base-path}/ruleguard/rules-*.go,${base-path}/myrule1.go' + # Comma-separated list of enabled groups or skip empty to enable everything. + # Tags can be defined with # character prefix. + # Default: "" + enable: "myGroupName,#myTagName" + # Comma-separated list of disabled groups or skip empty to enable everything. + # Tags can be defined with # character prefix. + # Default: "" + disable: "myGroupName,#myTagName" + tooManyResultsChecker: + # Maximum number of results. + # Default: 5 + maxResults: 10 + truncateCmp: + # Whether to skip int/uint/uintptr types. + # Default: true + skipArchDependent: false + underef: + # Whether to skip (*x).method() calls where x is a pointer receiver. + # Default: true + skipRecvDeref: false + unnamedResult: + # Whether to check exported functions. + # Default: false + checkExported: true + + gocyclo: + # Minimal code complexity to report. + # Default: 30 (but we recommend 10-20) + min-complexity: 10 + + godot: + # Comments to be checked: `declarations`, `toplevel`, `noinline` or `all`. + # Default: declarations + scope: toplevel + # List of regexps for excluding particular comment lines from check. + # Default: [] + exclude: + # Exclude todo and fixme comments. + - "^fixme:" + - "^todo:" + # Check that each sentence ends with a period. + # Default: true + period: false + # Check that each sentence starts with a capital letter. + # Default: false + capital: true + + godox: + # Report any comments starting with keywords, this is useful for TODO or FIXME comments that + # might be left in the code accidentally and should be resolved before merging. + # Default: ["TODO", "BUG", "FIXME"] + keywords: + - NOTE + - OPTIMIZE # marks code that should be optimized before merging + - HACK # marks hack-around that should be removed before merging + + goheader: + # Supports two types 'const` and `regexp`. + # Values can be used recursively. + # Default: {} + values: + const: + # Define here const type values in format k:v. + # For example: + COMPANY: MY COMPANY + regexp: + # Define here regexp type values. + # for example: + AUTHOR: .*@mycompany\.com + # The template use for checking. + # Default: "" + template: |- + # Put here copyright header template for source code files + # For example: + # Note: {{ YEAR }} is a builtin value that returns the year relative to the current machine time. + # + # {{ AUTHOR }} {{ COMPANY }} {{ YEAR }} + # SPDX-License-Identifier: Apache-2.0 + + # Licensed under the Apache License, Version 2.0 (the "License"); + # you may not use this file except in compliance with the License. + # You may obtain a copy of the License at: + + # http://www.apache.org/licenses/LICENSE-2.0 + + # Unless required by applicable law or agreed to in writing, software + # distributed under the License is distributed on an "AS IS" BASIS, + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + # See the License for the specific language governing permissions and + # limitations under the License. + # As alternative of directive 'template', you may put the path to file with the template source. + # Useful if you need to load the template from a specific file. + # By default, if a path is relative, it is relative to the directory where the golangci-lint command is executed. + # The placeholder '${base-path}' is substituted with a path relative to the mode defined with `run.relative-path-mode`. + # Default: "" + template-path: /path/to/my/template.tmpl -# All available settings of specific linters. -linters-settings: - asasalint: - # To specify a set of function names to exclude. - # The values are merged with the builtin exclusions. - # The builtin exclusions can be disabled by setting `use-builtin-exclusions` to `false`. - # Default: ["^(fmt|log|logger|t|)\.(Print|Fprint|Sprint|Fatal|Panic|Error|Warn|Warning|Info|Debug|Log)(|f|ln)$"] - exclude: - - Append - - \.Wrapf - # To enable/disable the asasalint builtin exclusions of function names. - # See the default value of `exclude` to get the builtin exclusions. - # Default: true - use-builtin-exclusions: false - - bidichk: - # The following configurations check for all mentioned invisible Unicode runes. - # All runes are enabled by default. - left-to-right-embedding: false - right-to-left-embedding: false - pop-directional-formatting: false - left-to-right-override: false - right-to-left-override: false - left-to-right-isolate: false - right-to-left-isolate: false - first-strong-isolate: false - pop-directional-isolate: false - - copyloopvar: - # Check all assigning the loop variable to another variable. - # Default: false - check-alias: true - - cyclop: - # The maximal code complexity to report. - # Default: 10 - max-complexity: 10 - # The maximal average package complexity. - # If it's higher than 0.0 (float) the check is enabled - # Default: 0.0 - package-average: 0.5 - - 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: false - - # 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 - - depguard: - # Rules to apply. - # - # Variables: - # - File Variables - # Use an exclamation mark `!` to negate a variable. - # Example: `!$test` matches any file that is not a go test file. - # - # `$all` - matches all go files - # `$test` - matches all go test files - # - # - Package Variables - # - # `$gostd` - matches all of go's standard library (Pulled from `GOROOT`) - # - # Default (applies if no custom rules are defined): Only allow $gostd in all files. - rules: - # Name of a rule. - main: - # Defines package matching behavior. Available modes: - # - `original`: allowed if it doesn't match the deny list and either matches the allow list or the allow list is empty. - # - `strict`: allowed only if it matches the allow list and either doesn't match the deny list or the allow rule is more specific (longer) than the deny rule. - # - `lax`: allowed if it doesn't match the deny list or the allow rule is more specific (longer) than the deny rule. - # Default: "original" - list-mode: lax - # List of file globs that will match this list of settings to compare against. - # By default, if a path is relative, it is relative to the directory where the golangci-lint command is executed. - # The placeholder '${base-path}' is substituted with a path relative to the mode defined with `run.relative-path-mode`. - # Default: $all - files: - - "!**/*_a _file.go" - # List of allowed packages. - # Entries can be a variable (starting with $), a string prefix, or an exact match (if ending with $). + gomoddirectives: + # Allow local `replace` directives. + # Default: false + replace-local: true + # List of allowed `replace` directives. + # Default: [] + replace-allow-list: + - launchpad.net/gocheck + # Allow to not explain why the version has been retracted in the `retract` directives. + # Default: false + retract-allow-no-explanation: true + # Forbid the use of the `exclude` directives. + # Default: false + exclude-forbidden: true + # Forbid the use of the `toolchain` directive. + # Default: false + toolchain-forbidden: true + # Defines a pattern to validate `toolchain` directive. + # Default: '' (no match) + toolchain-pattern: 'go1\.23\.\d+$' + # Forbid the use of the `tool` directives. + # Default: false + tool-forbidden: true + # Forbid the use of the `godebug` directive. + # Default: false + go-debug-forbidden: true + # Defines a pattern to validate `go` minimum version directive. + # Default: '' (no match) + go-version-pattern: '\d\.\d+(\.0)?' + + gomodguard: + allowed: + # List of allowed modules. # Default: [] - allow: - - $gostd - - github.com/OpenPeeDeeP - # List of packages that are not allowed. - # Entries can be a variable (starting with $), a string prefix, or an exact match (if ending with $). + modules: + - gopkg.in/yaml.v2 + # List of allowed module domains. # Default: [] - deny: - - pkg: "math/rand$" - desc: use math/rand/v2 - - pkg: "github.com/sirupsen/logrus" - desc: not allowed - - pkg: "github.com/pkg/errors" - desc: Should be replaced by standard lib errors package - - dogsled: - # Checks assignments with too many blank identifiers. - # Default: 2 - max-blank-identifiers: 3 - - dupl: - # Tokens count to trigger issue. - # Default: 150 - threshold: 100 - - dupword: - # Keywords for detecting duplicate words. - # If this list is not empty, only the words defined in this list will be detected. - # Default: [] - keywords: - - "the" - - "and" - - "a" - # Keywords used to ignore detection. - # Default: [] - ignore: - - "0C0C" + domains: + - golang.org + blocked: + # List of blocked modules. + # Default: [] + modules: + # Blocked module. + - github.com/uudashr/go-module: + # Recommended modules that should be used instead. (Optional) + recommendations: + - golang.org/x/mod + # Reason why the recommended module should be used. (Optional) + reason: "`mod` is the official go.mod parser library." + # List of blocked module version constraints. + # Default: [] + versions: + # Blocked module with version constraint. + - github.com/mitchellh/go-homedir: + # Version constraint, see https://github.com/Masterminds/semver#basic-comparisons. + version: "< 1.1.0" + # Reason why the version constraint exists. (Optional) + reason: "testing if blocked version constraint works." + # Set to true to raise lint issues for packages that are loaded from a local path via replace directive. + # Default: false + local-replace-directives: false + + gosimple: + # Sxxxx checks in https://staticcheck.dev/docs/configuration/options/#checks + # Default: ["*"] + checks: + # Use plain channel send or receive instead of single-case select. + # https://staticcheck.dev/docs/checks/#S1000 + - S1000 + # Replace for loop with call to copy. + # https://staticcheck.dev/docs/checks/#S1001 + - S1001 + # Omit comparison with boolean constant. + # https://staticcheck.dev/docs/checks/#S1002 + - S1002 + # Replace call to 'strings.Index' with 'strings.Contains'. + # https://staticcheck.dev/docs/checks/#S1003 + - S1003 + # Replace call to 'bytes.Compare' with 'bytes.Equal'. + # https://staticcheck.dev/docs/checks/#S1004 + - S1004 + # Drop unnecessary use of the blank identifier. + # https://staticcheck.dev/docs/checks/#S1005 + - S1005 + # Use "for { ... }" for infinite loops. + # https://staticcheck.dev/docs/checks/#S1006 + - S1006 + # Simplify regular expression by using raw string literal. + # https://staticcheck.dev/docs/checks/#S1007 + - S1007 + # Simplify returning boolean expression. + # https://staticcheck.dev/docs/checks/#S1008 + - S1008 + # Omit redundant nil check on slices, maps, and channels. + # https://staticcheck.dev/docs/checks/#S1009 + - S1009 + # Omit default slice index. + # https://staticcheck.dev/docs/checks/#S1010 + - S1010 + # Use a single 'append' to concatenate two slices. + # https://staticcheck.dev/docs/checks/#S1011 + - S1011 + # Replace 'time.Now().Sub(x)' with 'time.Since(x)'. + # https://staticcheck.dev/docs/checks/#S1012 + - S1012 + # Use a type conversion instead of manually copying struct fields. + # https://staticcheck.dev/docs/checks/#S1016 + - S1016 + # Replace manual trimming with 'strings.TrimPrefix'. + # https://staticcheck.dev/docs/checks/#S1017 + - S1017 + # Use "copy" for sliding elements. + # https://staticcheck.dev/docs/checks/#S1018 + - S1018 + # Simplify "make" call by omitting redundant arguments. + # https://staticcheck.dev/docs/checks/#S1019 + - S1019 + # Omit redundant nil check in type assertion. + # https://staticcheck.dev/docs/checks/#S1020 + - S1020 + # Merge variable declaration and assignment. + # https://staticcheck.dev/docs/checks/#S1021 + - S1021 + # Omit redundant control flow. + # https://staticcheck.dev/docs/checks/#S1023 + - S1023 + # Replace 'x.Sub(time.Now())' with 'time.Until(x)'. + # https://staticcheck.dev/docs/checks/#S1024 + - S1024 + # Don't use 'fmt.Sprintf("%s", x)' unnecessarily. + # https://staticcheck.dev/docs/checks/#S1025 + - S1025 + # Simplify error construction with 'fmt.Errorf'. + # https://staticcheck.dev/docs/checks/#S1028 + - S1028 + # Range over the string directly. + # https://staticcheck.dev/docs/checks/#S1029 + - S1029 + # Use 'bytes.Buffer.String' or 'bytes.Buffer.Bytes'. + # https://staticcheck.dev/docs/checks/#S1030 + - S1030 + # Omit redundant nil check around loop. + # https://staticcheck.dev/docs/checks/#S1031 + - S1031 + # Use 'sort.Ints(x)', 'sort.Float64s(x)', and 'sort.Strings(x)'. + # https://staticcheck.dev/docs/checks/#S1032 + - S1032 + # Unnecessary guard around call to "delete". + # https://staticcheck.dev/docs/checks/#S1033 + - S1033 + # Use result of type assertion to simplify cases. + # https://staticcheck.dev/docs/checks/#S1034 + - S1034 + # Redundant call to 'net/http.CanonicalHeaderKey' in method call on 'net/http.Header'. + # https://staticcheck.dev/docs/checks/#S1035 + - S1035 + # Unnecessary guard around map access. + # https://staticcheck.dev/docs/checks/#S1036 + - S1036 + # Elaborate way of sleeping. + # https://staticcheck.dev/docs/checks/#S1037 + - S1037 + # Unnecessarily complex way of printing formatted string. + # https://staticcheck.dev/docs/checks/#S1038 + - S1038 + # Unnecessary use of 'fmt.Sprint'. + # https://staticcheck.dev/docs/checks/#S1039 + - S1039 + # Type assertion to current type. + # https://staticcheck.dev/docs/checks/#S1040 + - S1040 + + 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 hard coded credentials + - G102 # Bind to all interfaces + - G103 # Audit the use of unsafe block + - G104 # Audit errors not checked + - G106 # Audit the use of ssh.InsecureIgnoreHostKey + - G107 # Url provided to HTTP request as taint input + - G108 # Profiling endpoint automatically exposed on /debug/pprof + - G109 # Potential Integer overflow made by strconv.Atoi result conversion to int16/32 + - G110 # Potential DoS vulnerability via decompression bomb + - G111 # Potential directory traversal + - G112 # Potential slowloris attack + - G113 # Usage of Rat.SetString in math/big with an overflow (CVE-2022-23772) + - G114 # Use of net/http serve function that has no support for setting timeouts + - G115 # Potential integer overflow when converting between integer types + - G201 # SQL query construction using format string + - G202 # SQL query construction using string concatenation + - G203 # Use of unescaped data in HTML templates + - G204 # Audit use of command execution + - G301 # Poor file permissions used when creating a directory + - G302 # Poor file permissions used with chmod + - G303 # Creating tempfile using a predictable path + - G304 # File path provided as taint input + - G305 # File traversal when extracting zip/tar archive + - G306 # Poor file permissions used when writing to a new file + - G307 # Poor file permissions used when creating a file with os.Create + - G401 # Detect the usage of MD5 or SHA1 + - G402 # Look for bad TLS connection settings + - G403 # Ensure minimum RSA key length of 2048 bits + - G404 # Insecure random number source (rand) + - G405 # Detect the usage of DES or RC4 + - G406 # Detect the usage of MD4 or RIPEMD160 + - G501 # Import blocklist: crypto/md5 + - G502 # Import blocklist: crypto/des + - G503 # Import blocklist: crypto/rc4 + - G504 # Import blocklist: net/http/cgi + - G505 # Import blocklist: crypto/sha1 + - G506 # Import blocklist: golang.org/x/crypto/md4 + - G507 #Import blocklist: golang.org/x/crypto/ripemd160 + - G601 # Implicit memory aliasing of items from a range statement + - G602 # Slice access out of bounds + + # To specify a set of rules to explicitly exclude. + # Available rules: https://github.com/securego/gosec#available-rules + # Default: [] + excludes: + - G101 # Look for hard coded credentials + - G102 # Bind to all interfaces + - G103 # Audit the use of unsafe block + - G104 # Audit errors not checked + - G106 # Audit the use of ssh.InsecureIgnoreHostKey + - G107 # Url provided to HTTP request as taint input + - G108 # Profiling endpoint automatically exposed on /debug/pprof + - G109 # Potential Integer overflow made by strconv.Atoi result conversion to int16/32 + - G110 # Potential DoS vulnerability via decompression bomb + - G111 # Potential directory traversal + - G112 # Potential slowloris attack + - G113 # Usage of Rat.SetString in math/big with an overflow (CVE-2022-23772) + - G114 # Use of net/http serve function that has no support for setting timeouts + - G115 # Potential integer overflow when converting between integer types + - G201 # SQL query construction using format string + - G202 # SQL query construction using string concatenation + - G203 # Use of unescaped data in HTML templates + - G204 # Audit use of command execution + - G301 # Poor file permissions used when creating a directory + - G302 # Poor file permissions used with chmod + - G303 # Creating tempfile using a predictable path + - G304 # File path provided as taint input + - G305 # File traversal when extracting zip/tar archive + - G306 # Poor file permissions used when writing to a new file + - G307 # Poor file permissions used when creating a file with os.Create + - G401 # Detect the usage of MD5 or SHA1 + - G402 # Look for bad TLS connection settings + - G403 # Ensure minimum RSA key length of 2048 bits + - G404 # Insecure random number source (rand) + - G405 # Detect the usage of DES or RC4 + - G406 # Detect the usage of MD4 or RIPEMD160 + - G501 # Import blocklist: crypto/md5 + - G502 # Import blocklist: crypto/des + - G503 # Import blocklist: crypto/rc4 + - G504 # Import blocklist: net/http/cgi + - G505 # Import blocklist: crypto/sha1 + - G506 # Import blocklist: golang.org/x/crypto/md4 + - G507 #Import blocklist: golang.org/x/crypto/ripemd160 + - G601 # Implicit memory aliasing of items from a range statement + - G602 # Slice access out of bounds + + # Filter out the issues with a lower severity than the given value. + # Valid options are: low, medium, high. + # Default: low + severity: medium + + # Filter out the issues with a lower confidence than the given value. + # Valid options are: low, medium, high. + # Default: low + confidence: medium + + # Concurrency value. + # Default: the number of logical CPUs usable by the current process. + concurrency: 12 + + # To specify the configuration of rules. + config: + # Globals are applicable to all rules. + global: + # If true, ignore #nosec in comments (and an alternative as well). + # Default: false + nosec: true + # Add an alternative comment prefix to #nosec (both will work at the same time). + # Default: "" + "#nosec": "#my-custom-nosec" + # Define whether nosec issues are counted as finding or not. + # Default: false + show-ignored: true + # Audit mode enables addition checks that for normal code analysis might be too nosy. + # Default: false + audit: true + G101: + # Regexp pattern for variables and constants to find. + # Default: "(?i)passwd|pass|password|pwd|secret|token|pw|apiKey|bearer|cred" + pattern: "(?i)example" + # If true, complain about all cases (even with low entropy). + # Default: false + ignore_entropy: false + # Maximum allowed entropy of the string. + # Default: "80.0" + entropy_threshold: "80.0" + # Maximum allowed value of entropy/string length. + # Is taken into account if entropy >= entropy_threshold/2. + # Default: "3.0" + per_char_threshold: "3.0" + # Calculate entropy for first N chars of the string. + # Default: "16" + truncate: "32" + # Additional functions to ignore while checking unhandled errors. + # Following functions always ignored: + # bytes.Buffer: + # - Write + # - WriteByte + # - WriteRune + # - WriteString + # fmt: + # - Print + # - Printf + # - Println + # - Fprint + # - Fprintf + # - Fprintln + # strings.Builder: + # - Write + # - WriteByte + # - WriteRune + # - WriteString + # io.PipeWriter: + # - CloseWithError + # hash.Hash: + # - Write + # os: + # - Unsetenv + # Default: {} + G104: + fmt: + - Fscanf + G111: + # Regexp pattern to find potential directory traversal. + # Default: "http\\.Dir\\(\"\\/\"\\)|http\\.Dir\\('\\/'\\)" + pattern: "custom\\.Dir\\(\\)" + # Maximum allowed permissions mode for os.Mkdir and os.MkdirAll + # Default: "0750" + G301: "0750" + # Maximum allowed permissions mode for os.OpenFile and os.Chmod + # Default: "0600" + G302: "0600" + # Maximum allowed permissions mode for os.WriteFile and ioutil.WriteFile + # Default: "0600" + G306: "0600" + + gosmopolitan: + # Allow and ignore `time.Local` usages. + # + # Default: false + allow-time-local: true + # List of fully qualified names in the `full/pkg/path.name` form, to act as "i18n escape hatches". + # String literals inside call-like expressions to, or struct literals of those names, + # are exempt from the writing system check. + # + # Default: [] + escape-hatches: + - 'github.com/nicksnyder/go-i18n/v2/i18n.Message' + - 'example.com/your/project/i18n/markers.Raw' + - 'example.com/your/project/i18n/markers.OK' + - 'example.com/your/project/i18n/markers.TODO' + - 'command-line-arguments.Simple' + # List of Unicode scripts to watch for any usage in string literals. + # https://pkg.go.dev/unicode#pkg-variables + # + # Default: ["Han"] + watch-for-scripts: + - Devanagari + - Han + - Hangul + - Hiragana + - Katakana + + govet: + # Disable all analyzers. + # Default: false + disable-all: true + # Enable analyzers by name. + # (in addition to default: + # appends, asmdecl, assign, atomic, bools, buildtag, cgocall, composites, copylocks, defers, directive, errorsas, + # framepointer, httpresponse, ifaceassert, loopclosure, lostcancel, nilfunc, printf, shift, sigchanyzer, slog, + # stdmethods, stringintconv, structtag, testinggoroutine, tests, timeformat, unmarshal, unreachable, unsafeptr, + # unusedresult + # ). + # Run `GL_DEBUG=govet golangci-lint run --enable=govet` to see default, all available analyzers, and enabled analyzers. + # Default: [] + enable: + # Check for missing values after append. + - appends + # Report mismatches between assembly files and Go declarations. + - asmdecl + # Check for useless assignments. + - assign + # Check for common mistakes using the sync/atomic package. + - atomic + # Check for non-64-bits-aligned arguments to sync/atomic functions. + - atomicalign + # Check for common mistakes involving boolean operators. + - bools + # Check //go:build and // +build directives. + - buildtag + # Detect some violations of the cgo pointer passing rules. + - cgocall + # Check for unkeyed composite literals. + - composites + # Check for locks erroneously passed by value. + - copylocks + # Check for calls of reflect.DeepEqual on error values. + - deepequalerrors + # Report common mistakes in defer statements. + - defers + # Check Go toolchain directives such as //go:debug. + - directive + # Report passing non-pointer or non-error values to errors.As. + - errorsas + # Find structs that would use less memory if their fields were sorted. + - fieldalignment + # Find calls to a particular function. + - findcall + # Report assembly that clobbers the frame pointer before saving it. + - framepointer + # Check for mistakes using HTTP responses. + - httpresponse + # Detect impossible interface-to-interface type assertions. + - ifaceassert + # Check references to loop variables from within nested functions. + - loopclosure + # Check cancel func returned by context.WithCancel is called. + - lostcancel + # Check for useless comparisons between functions and nil. + - nilfunc + # Check for redundant or impossible nil comparisons. + - nilness + # Check consistency of Printf format strings and arguments. + - printf + # Check for comparing reflect.Value values with == or reflect.DeepEqual. + - reflectvaluecompare + # Check for possible unintended shadowing of variables. + - shadow + # Check for shifts that equal or exceed the width of the integer. + - shift + # Check for unbuffered channel of os.Signal. + - sigchanyzer + # Check for invalid structured logging calls. + - slog + # Check the argument type of sort.Slice. + - sortslice + # Check signature of methods of well-known interfaces. + - stdmethods + # Report uses of too-new standard library symbols. + - stdversion + # Check for string(int) conversions. + - stringintconv + # Check that struct field tags conform to reflect.StructTag.Get. + - structtag + # Report calls to (*testing.T).Fatal from goroutines started by a test. + - testinggoroutine + # Check for common mistaken usages of tests and examples. + - tests + # Check for calls of (time.Time).Format or time.Parse with 2006-02-01. + - timeformat + # Report passing non-pointer or non-interface values to unmarshal. + - unmarshal + # Check for unreachable code. + - unreachable + # Check for invalid conversions of uintptr to unsafe.Pointer. + - unsafeptr + # Check for unused results of calls to some functions. + - unusedresult + # Checks for unused writes. + - unusedwrite + # Check for misuses of sync.WaitGroup. + - waitgroup + + # Enable all analyzers. + # Default: false + enable-all: true + # Disable analyzers by name. + # (in addition to default + # atomicalign, deepequalerrors, fieldalignment, findcall, nilness, reflectvaluecompare, shadow, sortslice, + # timeformat, unusedwrite + # ). + # Run `GL_DEBUG=govet golangci-lint run --enable=govet` to see default, all available analyzers, and enabled analyzers. + # Default: [] + disable: + - appends + - asmdecl + - assign + - atomic + - atomicalign + - bools + - buildtag + - cgocall + - composites + - copylocks + - deepequalerrors + - defers + - directive + - errorsas + - fieldalignment + - findcall + - framepointer + - httpresponse + - ifaceassert + - loopclosure + - lostcancel + - nilfunc + - nilness + - printf + - reflectvaluecompare + - shadow + - shift + - sigchanyzer + - slog + - sortslice + - stdmethods + - stdversion + - stringintconv + - structtag + - testinggoroutine + - tests + - timeformat + - unmarshal + - unreachable + - unsafeptr + - unusedresult + - unusedwrite + - waitgroup + + # Settings per analyzer. + settings: + # Analyzer name, run `go tool vet help` to see all analyzers. + printf: + # Comma-separated list of print function names to check (in addition to default, see `go tool vet help printf`). + # Default: [] + funcs: + - (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof + - (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf + - (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf + - (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf + shadow: + # Whether to be strict about shadowing; can be noisy. + # Default: false + strict: true + unusedresult: + # Comma-separated list of functions whose results must be used + # (in addition to default: + # context.WithCancel, context.WithDeadline, context.WithTimeout, context.WithValue, errors.New, fmt.Errorf, + # fmt.Sprint, fmt.Sprintf, sort.Reverse + # ). + # Default: [] + funcs: + - pkg.MyFunc + # Comma-separated list of names of methods of type func() string whose results must be used + # (in addition to default Error,String) + # Default: [] + stringmethods: + - MyMethod + + grouper: + # Require the use of a single global 'const' declaration only. + # Default: false + const-require-single-const: true + # Require the use of grouped global 'const' declarations. + # Default: false + const-require-grouping: true - 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 + # Require the use of a single 'import' declaration only. + # Default: false + import-require-single-import: true + # Require the use of grouped 'import' declarations. + # Default: false + import-require-grouping: 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 + # Require the use of a single global 'type' declaration only. + # Default: false + type-require-single-type: true + # Require the use of grouped global 'type' declarations. + # Default: false + type-require-grouping: 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: - - io/ioutil.ReadFile - - io.Copy(*bytes.Buffer) - - io.Copy(os.Stdout) - - errchkjson: - # With check-error-free-encoding set to true, errchkjson does warn about errors - # from json encoding functions that are safe to be ignored, - # because they are not possible to happen. - # - # if check-error-free-encoding is set to true and errcheck linter is enabled, - # it is recommended to add the following exceptions to prevent from false positives: - # - # linters-settings: - # errcheck: - # exclude-functions: - # - encoding/json.Marshal - # - encoding/json.MarshalIndent - # - # Default: false - check-error-free-encoding: true + # Require the use of a single global 'var' declaration only. + # Default: false + var-require-single-var: true + # Require the use of grouped global 'var' declarations. + # Default: false + var-require-grouping: true + + iface: + # List of analyzers. + # Default: ["identical"] + enable: + - identical # Identifies interfaces in the same package that have identical method sets. + - unused # Identifies interfaces that are not used anywhere in the same package where the interface is defined. + - opaque # Identifies functions that return interfaces, but the actual returned value is always a single concrete implementation. + settings: + unused: + # List of packages path to exclude from the check. + # Default: [] + exclude: + - github.com/example/log + + importas: + # Do not allow unaliased imports of aliased packages. + # Default: false + no-unaliased: true + # Do not allow non-required aliases. + # Default: false + no-extra-aliases: true + # List of aliases + # Default: [] + alias: + # Using `servingv1` alias for `knative.dev/serving/pkg/apis/serving/v1` package. + - pkg: knative.dev/serving/pkg/apis/serving/v1 + alias: servingv1 + # Using `autoscalingv1alpha1` alias for `knative.dev/serving/pkg/apis/autoscaling/v1alpha1` package. + - pkg: knative.dev/serving/pkg/apis/autoscaling/v1alpha1 + alias: autoscalingv1alpha1 + # You can specify the package path by regular expression, + # and alias by regular expression expansion syntax like below. + # see https://github.com/julz/importas#use-regular-expression for details + - pkg: knative.dev/serving/pkg/apis/(\w+)/(v[\w\d]+) + alias: $1$2 + # An explicit empty alias can be used to ensure no aliases are used for a package. + # This can be useful if `no-extra-aliases: true` doesn't fit your need. + # Multiple packages can use an empty alias. + - pkg: errors + alias: "" + + inamedparam: + # Skips check for interface methods with only a single parameter. + # Default: false + skip-single-param: true - # Issue on struct encoding that doesn't have exported fields. - # Default: false - report-no-exported: false - - errorlint: - # Check whether fmt.Errorf uses the %w verb for formatting errors. - # See the https://github.com/polyfloyd/go-errorlint for caveats. - # Default: true - errorf: false - # Permit more than 1 %w verb, valid per Go 1.20 (Requires errorf:true) - # Default: true - errorf-multi: false - # Check for plain type assertions and type switches. - # Default: true - asserts: false - # Check for plain error comparisons. - # Default: true - comparison: false - # Allowed errors. - # Default: [] - allowed-errors: - - err: "io.EOF" - fun: "example.com/pkg.Read" - # Allowed error "wildcards". - # Default: [] - allowed-errors-wildcard: - - err: "example.com/pkg.ErrMagic" - fun: "example.com/pkg.Magic" - - exhaustive: - # Program elements to check for exhaustiveness. - # Default: [ switch ] - check: - - switch - - map - # Presence of "default" case in switch statements satisfies exhaustiveness, - # even if all enum members are not listed. - # Default: false - default-signifies-exhaustive: true - # Enum members matching the supplied regex do not have to be listed in - # switch statements to satisfy exhaustiveness. - # Default: "" - ignore-enum-members: "Example.+" - # Enum types matching the supplied regex do not have to be listed in - # switch statements to satisfy exhaustiveness. - # Default: "" - ignore-enum-types: "Example.+" - # Consider enums only in package scopes, not in inner scopes. - # Default: false - package-scope-only: true - # Only run exhaustive check on switches with "//exhaustive:enforce" comment. - # Default: false - explicit-exhaustive-switch: true - # Only run exhaustive check on map literals with "//exhaustive:enforce" comment. - # Default: false - explicit-exhaustive-map: true - # Switch statement requires default case even if exhaustive. - # Default: false - default-case-required: true + interfacebloat: + # The maximum number of methods allowed for an interface. + # Default: 10 + max: 5 - exhaustruct: - # List of regular expressions to match struct packages and their names. - # Regular expressions must match complete canonical struct package/name/structname. - # If this list is empty, all structs are tested. - # Default: [] - include: - - '.+\.Test' - - 'example\.com/package\.ExampleStruct[\d]{1,2}' - # List of regular expressions to exclude struct packages and their names from checks. - # Regular expressions must match complete canonical struct package/name/structname. - # Default: [] - exclude: - - '.+/cobra\.Command$' - - fatcontext: - # Check for potential fat contexts in struct pointers. - # May generate false positives. - # Default: false - check-struct-pointers: true - - forbidigo: - # Forbid the following identifiers (list of regexp). - # Default: ["^(fmt\\.Print(|f|ln)|print|println)$"] - forbid: - # Built-in bootstrapping functions. - - pattern: ^print(ln)?$ - # Optional message that gets included in error reports. - - pattern: ^fmt\.Print.*$ - msg: Do not commit print statements. - # Alternatively, put messages at the end of the regex, surrounded by `(# )?` - # Escape any special characters. Those messages get included in error reports. - - pattern: 'fmt\.Print.*(# Do not commit print statements\.)?' - # Forbid spew Dump, whether it is called as function or method. - # Depends on analyze-types below. - - pattern: ^spew\.(ConfigState\.)?Dump$ - # The package name might be ambiguous. - # The full import path can be used as additional criteria. - # Depends on analyze-types below. - - pattern: ^v1.Dump$ - pkg: ^example.com/pkg/api/v1$ - # 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 - - funlen: - # Checks the number of lines in a function. - # If lower than 0, disable the check. - # Default: 60 - lines: -1 - # Checks the number of statements in a function. - # If lower than 0, disable the check. - # Default: 40 - statements: -1 - # Ignore comments when counting lines. - # Default false - ignore-comments: true - - ginkgolinter: - # Suppress the wrong length assertion warning. - # Default: false - suppress-len-assertion: true + ireturn: + # List of interfaces to allow. + # Lists of the keywords and regular expressions matched to interface or package names can be used. + # `allow` and `reject` settings cannot be used at the same time. + # + # Keywords: + # - `empty` for `interface{}` + # - `error` for errors + # - `stdlib` for standard library + # - `anon` for anonymous interfaces + # - `generic` for generic interfaces added in go 1.18 + # + # Default: [anon, error, empty, stdlib] + allow: + - anon + # You can specify idiomatic endings for interface + - (or|er)$ + + # List of interfaces to reject. + # Lists of the keywords and regular expressions matched to interface or package names can be used. + # `allow` and `reject` settings cannot be used at the same time. + # + # Keywords: + # - `empty` for `interface{}` + # - `error` for errors + # - `stdlib` for standard library + # - `anon` for anonymous interfaces + # - `generic` for generic interfaces added in go 1.18 + # + # Default: [] + reject: + - github.com\/user\/package\/v4\.Type + + lll: + # Max line length, lines longer will be reported. + # '\t' is counted as 1 character by default, and can be changed with the tab-width option. + # Default: 120. + line-length: 120 + # Tab width in spaces. + # Default: 1 + tab-width: 1 + + loggercheck: + # Allow check for the github.com/go-kit/log library. + # Default: true + kitlog: false + # Allow check for the k8s.io/klog/v2 library. + # Default: true + klog: false + # Allow check for the github.com/go-logr/logr library. + # Default: true + logr: false + # Allow check for the log/slog library. + # Default: true + slog: false + # Allow check for the "sugar logger" from go.uber.org/zap library. + # Default: true + zap: false + # Require all logging keys to be inlined constant strings. + # Default: false + require-string-key: true + # Require printf-like format specifier (%s, %d for example) not present. + # Default: false + no-printf-like: true + # List of custom rules to check against, where each rule is a single logger pattern, useful for wrapped loggers. + # For example: https://github.com/timonwong/loggercheck/blob/7395ab86595781e33f7afba27ad7b55e6956ebcd/testdata/custom-rules.txt + # Default: empty + rules: + - k8s.io/klog/v2.InfoS # package level exported functions + - (github.com/go-logr/logr.Logger).Error # "Methods" + - (*go.uber.org/zap.SugaredLogger).With # Also "Methods", but with a pointer receiver + + maintidx: + # Show functions with maintainability index lower than N. + # A high index indicates better maintainability (it's kind of the opposite of complexity). + # Default: 20 + under: 100 + + makezero: + # Allow only slices initialized with a length of zero. + # Default: false + always: true + + misspell: + # Correct spellings using locale preferences for US or UK. + # Setting locale to US will correct the British spelling of 'colour' to 'color'. + # Default is to use a neutral variety of English. + locale: US + # Typos to ignore. + # Should be in lower case. + # Default: [] + ignore-rules: + - someword + # Extra word corrections. + # `typo` and `correction` should only contain letters. + # The words are case-insensitive. + # Default: [] + extra-words: + - typo: "iff" + correction: "if" + - typo: "cancelation" + correction: "cancellation" + # Mode of the analysis: + # - default: checks all the file content. + # - restricted: checks only comments. + # Default: "" + mode: restricted + + mnd: + # List of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description. + # Default: ["argument", "case", "condition", "operation", "return", "assign"] + checks: + - argument + - case + - condition + - operation + - return + - assign + # List of numbers to exclude from analysis. + # The numbers should be written as string. + # Values always ignored: "1", "1.0", "0" and "0.0" + # Default: [] + ignored-numbers: + - '0666' + - '0755' + - '42' + # List of file patterns to exclude from analysis. + # Values always ignored: `.+_test.go` + # Default: [] + ignored-files: + - 'magic1_.+\.go$' + # List of function patterns to exclude from analysis. + # Following functions are always ignored: `time.Date`, + # `strconv.FormatInt`, `strconv.FormatUint`, `strconv.FormatFloat`, + # `strconv.ParseInt`, `strconv.ParseUint`, `strconv.ParseFloat`. + # Default: [] + ignored-functions: + - '^math\.' + - '^http\.StatusText$' + + musttag: + # A set of custom functions to check in addition to the builtin ones. + # Default: json, xml, gopkg.in/yaml.v3, BurntSushi/toml, mitchellh/mapstructure, jmoiron/sqlx + functions: + # The full name of the function, including the package. + - name: github.com/hashicorp/hcl/v2/hclsimple.DecodeFile + # The struct tag whose presence should be ensured. + tag: hcl + # The position of the argument to check. + arg-pos: 2 + + nakedret: + # Make an issue if func has more lines of code than this setting, and it has naked returns. + # Default: 30 + max-func-lines: 31 + + nestif: + # Minimal complexity of if statements to report. + # Default: 5 + min-complexity: 4 + + nilnil: + # In addition, detect opposite situation (simultaneous return of non-nil error and valid value). + # Default: false + detect-opposite: true + # List of return types to check. + # Default: ["chan", "func", "iface", "map", "ptr", "uintptr", "unsafeptr"] + checked-types: + - chan + - func + - iface + - map + - ptr + - uintptr + - unsafeptr + + nlreturn: + # Size of the block (including return statement that is still "OK") + # so no return split required. + # Default: 1 + block-size: 2 + + nolintlint: + # Disable to ensure that all nolint directives actually have an effect. + # Default: false + allow-unused: true + # Exclude following linters from requiring an explanation. + # Default: [] + allow-no-explanation: [ ] + # Enable to require an explanation of nonzero length after each nolint directive. + # Default: false + require-explanation: true + # Enable to require nolint directives to mention the specific linter being suppressed. + # Default: false + require-specific: true - # Suppress the wrong nil assertion warning. - # Default: false - suppress-nil-assertion: true + nonamedreturns: + # Report named error if it is assigned inside defer. + # Default: false + report-error-in-defer: true - # Suppress the wrong error assertion warning. - # Default: false - suppress-err-assertion: true + 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 - # Suppress the wrong comparison assertion warning. - # Default: false - suppress-compare-assertion: true + perfsprint: + # Enable/disable optimization of integer formatting. + # Default: true + integer-format: false + # Optimizes even if it requires an int or uint type cast. + # Default: true + int-conversion: false + # Enable/disable optimization of error formatting. + # Default: true + error-format: false + # Optimizes into `err.Error()` even if it is only equivalent for non-nil errors. + # Default: false + err-error: true + # Optimizes `fmt.Errorf`. + # Default: true + errorf: false + # Enable/disable optimization of string formatting. + # Default: true + string-format: false + # Optimizes `fmt.Sprintf` with only one argument. + # Default: true + sprintf1: false + # Optimizes into strings concatenation. + # Default: true + strconcat: false + # Enable/disable optimization of bool formatting. + # Default: true + bool-format: false + # Enable/disable optimization of hex formatting. + # Default: true + hex-format: false - # Suppress the function all in async assertion warning. - # Default: false - suppress-async-assertion: true + prealloc: + # IMPORTANT: we don't recommend using this linter before doing performance profiling. + # For most programs usage of prealloc will be a premature optimization. - # Suppress warning for comparing values from different types, like `int32` and `uint32` - # Default: false - suppress-type-compare-assertion: true + # Report pre-allocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them. + # Default: true + simple: false + # Report pre-allocation suggestions on range loops. + # Default: true + range-loops: false + # Report pre-allocation suggestions on for loops. + # Default: false + for-loops: true - # Trigger warning for ginkgo focus containers like `FDescribe`, `FContext`, `FWhen` or `FIt` - # Default: false - forbid-focus-container: true + predeclared: + # List of predeclared identifiers to not report on. + # Default: [] + ignore: + - new + - int + # Include method names and field names in checks. + # Default: false + qualified-name: true - # Don't trigger warnings for HaveLen(0) - # Default: false - allow-havelen-zero: true + promlinter: + # Promlinter cannot infer all metrics name in static analysis. + # Enable strict mode will also include the errors caused by failing to parse the args. + # Default: false + strict: true + # Please refer to https://github.com/yeya24/promlinter#usage for detailed usage. + # Default: [] + disabled-linters: + # Help detects issues related to the help text for a metric. + - Help + # MetricUnits detects issues with metric unit names. + - MetricUnits + # Counter detects issues specific to counters, as well as patterns that should only be used with counters. + - Counter + # HistogramSummaryReserved detects when other types of metrics use names or labels reserved for use by histograms and/or summaries. + - HistogramSummaryReserved + # MetricTypeInName detects when metric types are included in the metric name. + - MetricTypeInName + # ReservedChars detects colons in metric names. + - ReservedChars + # CamelCase detects metric names and label names written in camelCase. + - CamelCase + # UnitAbbreviations detects abbreviated units in the metric name. + - UnitAbbreviations + + protogetter: + # Skip files generated by specified generators from the checking. + # Checks only the file's initial comment, which must follow the format: "// Code generated by ". + # Files generated by protoc-gen-go, protoc-gen-go-grpc, and protoc-gen-grpc-gateway are always excluded automatically. + # Default: [] + skip-generated-by: ["protoc-gen-go-my-own-generator"] + # Skip files matching the specified glob pattern from the checking. + # Default: [] + skip-files: + - "*.pb.go" + - "*/vendor/*" + - "/full/path/to/file.go" + # Skip any generated files from the checking. + # Default: false + skip-any-generated: true + # Skip first argument of append function. + # Default: false + replace-first-arg-in-append: true + + reassign: + # Patterns for global variable names that are checked for reassignment. + # See https://github.com/curioswitch/go-reassign#usage + # Default: ["EOF", "Err.*"] + patterns: + - ".*" + + recvcheck: + # Disables the built-in method exclusions: + # - `MarshalText` + # - `MarshalJSON` + # - `MarshalYAML` + # - `MarshalXML` + # - `MarshalBinary` + # - `GobEncode` + # Default: false + disable-builtin: true + # User-defined method exclusions. + # The format is `struct_name.method_name` (ex: `Foo.MethodName`). + # A wildcard `*` can use as a struct name (ex: `*.MethodName`). + # Default: [] + exclusions: + - "*.Value" - # Force using `Expect` with `To`, `ToNot` or `NotTo`. - # Reject using `Expect` with `Should` or `ShouldNot`. - # Default: false - force-expect-to: true + revive: + # Maximum number of open files at the same time. + # See https://github.com/mgechev/revive#command-line-flags + # Defaults to unlimited. + max-open-files: 2048 - # Best effort validation of async intervals (timeout and polling). - # Ignored the suppress-async-assertion is true. - # Default: false - validate-async-intervals: true + # Sets the default severity. + # See https://github.com/mgechev/revive#configuration + # Default: warning + severity: error - # Trigger a warning for variable assignments in ginkgo containers like `Describe`, `Context` and `When`, instead of in `BeforeEach()`. - # Default: false - forbid-spec-pollution: true + # Enable all available rules. + # Default: false + enable-all-rules: true - # Force using the Succeed matcher for error functions, and the HaveOccurred matcher for non-function error values. - # Default: false - force-succeed: true + # Sets the default failure confidence. + # This means that linting errors with less than 0.8 confidence will be ignored. + # Default: 0.8 + confidence: 0.1 + # Run `GL_DEBUG=revive golangci-lint run --enable-only=revive` to see default, all available rules, and enabled rules. + rules: + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#add-constant + - name: add-constant + severity: warning + disabled: false + exclude: [""] + arguments: + - maxLitCount: "3" + allowStrs: '""' + allowInts: "0,1,2" + allowFloats: "0.0,0.,1.0,1.,2.0,2." + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#argument-limit + - name: argument-limit + severity: warning + disabled: false + exclude: [""] + arguments: [ 4 ] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#atomic + - name: atomic + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#banned-characters + - name: banned-characters + severity: warning + disabled: false + exclude: [""] + arguments: [ "Ω","Σ","σ", "7" ] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#bare-return + - name: bare-return + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#blank-imports + - name: blank-imports + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#bool-literal-in-expr + - name: bool-literal-in-expr + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#call-to-gc + - name: call-to-gc + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#cognitive-complexity + - name: cognitive-complexity + severity: warning + disabled: false + exclude: [""] + arguments: [ 7 ] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#comment-spacings + - name: comment-spacings + severity: warning + disabled: false + exclude: [""] + arguments: + - mypragma + - otherpragma + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#comments-density + - name: comments-density + severity: warning + disabled: false + exclude: [""] + arguments: [ 15 ] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#confusing-naming + - name: confusing-naming + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#confusing-results + - name: confusing-results + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#constant-logical-expr + - name: constant-logical-expr + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#context-as-argument + - name: context-as-argument + severity: warning + disabled: false + exclude: [""] + arguments: + - allowTypesBefore: "*testing.T,*github.com/user/repo/testing.Harness" + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#context-keys-type + - name: context-keys-type + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#cyclomatic + - name: cyclomatic + severity: warning + disabled: false + exclude: [""] + arguments: [ 3 ] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#datarace + - name: datarace + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#deep-exit + - name: deep-exit + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#defer + - name: defer + severity: warning + disabled: false + exclude: [""] + arguments: + - [ "call-chain", "loop" ] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#dot-imports + - name: dot-imports + severity: warning + disabled: false + exclude: [""] + arguments: [ ] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#duplicated-imports + - name: duplicated-imports + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#early-return + - name: early-return + severity: warning + disabled: false + exclude: [""] + arguments: + - "preserveScope" + - "allowJump" + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#empty-block + - name: empty-block + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#empty-lines + - name: empty-lines + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#enforce-map-style + - name: enforce-map-style + severity: warning + disabled: false + exclude: [""] + arguments: + - "make" + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#enforce-repeated-arg-type-style + - name: enforce-repeated-arg-type-style + severity: warning + disabled: false + exclude: [""] + arguments: + - "short" + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#enforce-slice-style + - name: enforce-slice-style + severity: warning + disabled: false + exclude: [""] + arguments: + - "make" + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#error-naming + - name: error-naming + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#error-return + - name: error-return + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#error-strings + - name: error-strings + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#errorf + - name: errorf + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#exported + - name: exported + severity: warning + disabled: false + exclude: [""] + arguments: + - "checkPrivateReceivers" + - "disableStutteringCheck" + - "checkPublicInterface" + - "disableChecksOnFunctions" + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#file-header + - name: file-header + severity: warning + disabled: false + exclude: [""] + arguments: + - This is the text that must appear at the top of source files. + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#file-length-limit + - name: file-length-limit + severity: warning + disabled: false + exclude: [""] + arguments: + - max: 100 + skipComments: true + skipBlankLines: true + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#filename-format + - name: filename-format + severity: warning + disabled: false + exclude: [""] + arguments: + - "^[_a-z][_a-z0-9]*\\.go$" + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#flag-parameter + - name: flag-parameter + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#function-length + - name: function-length + severity: warning + disabled: false + exclude: [""] + arguments: [ 10, 0 ] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#function-result-limit + - name: function-result-limit + severity: warning + disabled: false + exclude: [""] + arguments: [ 3 ] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#get-return + - name: get-return + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#identical-branches + - name: identical-branches + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#if-return + - name: if-return + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#import-alias-naming + - name: import-alias-naming + severity: warning + disabled: false + exclude: [""] + arguments: + - "^[a-z][a-z0-9]{0,}$" + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#import-shadowing + - name: import-shadowing + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#imports-blocklist + - name: imports-blocklist + severity: warning + disabled: false + exclude: [""] + arguments: + - "crypto/md5" + - "crypto/sha1" + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#increment-decrement + - name: increment-decrement + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#indent-error-flow + - name: indent-error-flow + severity: warning + disabled: false + exclude: [""] + arguments: + - "preserveScope" + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#line-length-limit + - name: line-length-limit + severity: warning + disabled: false + exclude: [""] + arguments: [ 80 ] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#max-control-nesting + - name: max-control-nesting + severity: warning + disabled: false + exclude: [""] + arguments: [ 3 ] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#max-public-structs + - name: max-public-structs + severity: warning + disabled: false + exclude: [""] + arguments: [ 3 ] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#modifies-parameter + - name: modifies-parameter + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#modifies-value-receiver + - name: modifies-value-receiver + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#nested-structs + - name: nested-structs + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#optimize-operands-order + - name: optimize-operands-order + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#package-comments + - name: package-comments + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#range + - name: range + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#range-val-address + - name: range-val-address + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#range-val-in-closure + - name: range-val-in-closure + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#receiver-naming + - name: receiver-naming + severity: warning + disabled: false + exclude: [""] + arguments: + - maxLength: 2 + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#redefines-builtin-id + - name: redefines-builtin-id + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#redundant-build-tag + - name: redundant-build-tag + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#redundant-import-alias + - name: redundant-import-alias + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#string-format + - name: string-format + severity: warning + disabled: false + exclude: [""] + arguments: + - - 'core.WriteError[1].Message' + - '/^([^A-Z]|$)/' + - must not start with a capital letter + - - 'fmt.Errorf[0]' + - '/(^|[^\.!?])$/' + - must not end in punctuation + - - panic + - '/^[^\n]*$/' + - must not contain line breaks + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#string-of-int + - name: string-of-int + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#struct-tag + - name: struct-tag + severity: warning + disabled: false + exclude: [""] + arguments: + - "json,inline" + - "bson,outline,gnu" + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#superfluous-else + - name: superfluous-else + severity: warning + disabled: false + exclude: [""] + arguments: + - "preserveScope" + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#time-equal + - name: time-equal + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#time-naming + - name: time-naming + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#unchecked-type-assertion + - name: unchecked-type-assertion + severity: warning + disabled: false + exclude: [""] + arguments: + - acceptIgnoredAssertionResult: true + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#unconditional-recursion + - name: unconditional-recursion + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#unexported-naming + - name: unexported-naming + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#unexported-return + - name: unexported-return + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#unhandled-error + - name: unhandled-error + severity: warning + disabled: false + exclude: [""] + arguments: + - "fmt.Printf" + - "myFunction" + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#unnecessary-stmt + - name: unnecessary-stmt + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#unreachable-code + - name: unreachable-code + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#unused-parameter + - name: unused-parameter + severity: warning + disabled: false + exclude: [""] + arguments: + - allowRegex: "^_" + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#unused-receiver + - name: unused-receiver + severity: warning + disabled: false + exclude: [""] + arguments: + - allowRegex: "^_" + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#use-any + - name: use-any + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#use-errors-new + - name: use-errors-new + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#useless-break + - name: useless-break + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#var-declaration + - name: var-declaration + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#var-naming + - name: var-naming + severity: warning + disabled: false + exclude: [""] + arguments: + - [ "ID" ] # AllowList + - [ "VM" ] # DenyList + - - upperCaseConst: true # Extra parameter (upperCaseConst|skipPackageNameChecks) + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#waitgroup-by-value + - name: waitgroup-by-value + severity: warning + disabled: false + exclude: [""] + + rowserrcheck: + # database/sql is always checked + # Default: [] + packages: + - github.com/jmoiron/sqlx - gochecksumtype: - # Presence of `default` case in switch statements satisfies exhaustiveness, if all members are not listed. - # Default: true - default-signifies-exhaustive: false - # Include shared interfaces in the exhaustiviness check. - # Default: false - include-shared-interfaces: true - - gocognit: - # Minimal code complexity to report. - # Default: 30 (but we recommend 10-20) - min-complexity: 10 - - goconst: - # Minimal length of string constant. - # Default: 3 - min-len: 2 - # Minimum occurrences of constant string count to trigger issue. - # Default: 3 - min-occurrences: 2 - # Look for existing constants matching the values. - # Default: true - match-constant: false - # Search also for duplicated numbers. - # Default: false - numbers: true - # Minimum value, only works with goconst.numbers - # Default: 3 - min: 2 - # Maximum value, only works with goconst.numbers - # Default: 3 - max: 2 - # Ignore when constant is not used as function argument. - # Default: true - ignore-calls: false - # Exclude strings matching the given regular expression. - # Default: "" - ignore-strings: 'foo.+' - - gocritic: - # Disable all checks. - # Default: false - disable-all: true - # Which checks should be enabled in addition to default checks; can't be combined with 'disabled-checks'. - # By default, list of stable checks is used (https://go-critic.com/overview#checks-overview): - # appendAssign, argOrder, assignOp, badCall, badCond, captLocal, caseOrder, codegenComment, commentFormatting, - # defaultCaseOrder, deprecatedComment, dupArg, dupBranchBody, dupCase, dupSubExpr, elseif, exitAfterDefer, - # flagDeref, flagName, ifElseChain, mapKey, newDeref, offBy1, regexpMust, singleCaseSwitch, sloppyLen, - # sloppyTypeAssert, switchTrue, typeSwitchVar, underef, unlambda, unslice, valSwap, wrapperFunc - # To see which checks are enabled run `GL_DEBUG=gocritic golangci-lint run --enable=gocritic`. - enabled-checks: - # Detects suspicious append result assignments. - # https://go-critic.com/overview.html#appendassign - - appendAssign - # Detects `append` chains to the same slice that can be done in a single `append` call. - # https://go-critic.com/overview.html#appendcombine - - appendCombine - # Detects suspicious arguments order. - # https://go-critic.com/overview.html#argorder - - argOrder - # Detects assignments that can be simplified by using assignment operators. - # https://go-critic.com/overview.html#assignop - - assignOp - # Detects suspicious function calls. - # https://go-critic.com/overview.html#badcall - - badCall - # Detects suspicious condition expressions. - # https://go-critic.com/overview.html#badcond - - badCond - # Detects suspicious mutex lock/unlock operations. - # https://go-critic.com/overview.html#badlock - - badLock - # Detects suspicious regexp patterns. - # https://go-critic.com/overview.html#badregexp - - badRegexp - # Detects bad usage of sort package. - # https://go-critic.com/overview.html#badsorting - - badSorting - # Detects bad usage of sync.OnceFunc. - # https://go-critic.com/overview.html#badsynconcefunc - - badSyncOnceFunc - # Detects bool expressions that can be simplified. - # https://go-critic.com/overview.html#boolexprsimplify - - boolExprSimplify - # Detects when predeclared identifiers are shadowed in assignments. - # https://go-critic.com/overview.html#builtinshadow - - builtinShadow - # Detects top-level declarations that shadow the predeclared identifiers. - # https://go-critic.com/overview.html#builtinshadowdecl - - builtinShadowDecl - # Detects capitalized names for local variables. - # https://go-critic.com/overview.html#captlocal - - captLocal - # Detects erroneous case order inside switch statements. - # https://go-critic.com/overview.html#caseorder - - caseOrder - # Detects malformed 'code generated' file comments. - # https://go-critic.com/overview.html#codegencomment - - codegenComment - # Detects comments with non-idiomatic formatting. - # https://go-critic.com/overview.html#commentformatting - - commentFormatting - # Detects commented-out code inside function bodies. - # https://go-critic.com/overview.html#commentedoutcode - - commentedOutCode - # Detects commented-out imports. - # https://go-critic.com/overview.html#commentedoutimport - - commentedOutImport - # Detects when default case in switch isn't on 1st or last position. - # https://go-critic.com/overview.html#defaultcaseorder - - defaultCaseOrder - # Detects loops inside functions that use defer. - # https://go-critic.com/overview.html#deferinloop - - deferInLoop - # Detects deferred function literals that can be simplified. - # https://go-critic.com/overview.html#deferunlambda - - deferUnlambda - # Detects malformed 'deprecated' doc-comments. - # https://go-critic.com/overview.html#deprecatedcomment - - deprecatedComment - # Detects comments that silence go lint complaints about doc-comment. - # https://go-critic.com/overview.html#docstub - - docStub - # Detects suspicious duplicated arguments. - # https://go-critic.com/overview.html#duparg - - dupArg - # Detects duplicated branch bodies inside conditional statements. - # https://go-critic.com/overview.html#dupbranchbody - - dupBranchBody - # Detects duplicated case clauses inside switch or select statements. - # https://go-critic.com/overview.html#dupcase - - dupCase - # Detects multiple imports of the same package under different aliases. - # https://go-critic.com/overview.html#dupimport - - dupImport - # Detects suspicious duplicated sub-expressions. - # https://go-critic.com/overview.html#dupsubexpr - - dupSubExpr - # Detects suspicious formatting strings usage. - # https://go-critic.com/overview.html#dynamicfmtstring - - dynamicFmtString - # Detects else with nested if statement that can be replaced with else-if. - # https://go-critic.com/overview.html#elseif - - elseif - # Detects suspicious empty declarations blocks. - # https://go-critic.com/overview.html#emptydecl - - emptyDecl - # Detects fallthrough that can be avoided by using multi case values. - # https://go-critic.com/overview.html#emptyfallthrough - - emptyFallthrough - # Detects empty string checks that can be written more idiomatically. - # https://go-critic.com/overview.html#emptystringtest - - emptyStringTest - # Detects unoptimal strings/bytes case-insensitive comparison. - # https://go-critic.com/overview.html#equalfold - - equalFold - # Detects unwanted dependencies on the evaluation order. - # https://go-critic.com/overview.html#evalorder - - evalOrder - # Detects calls to exit/fatal inside functions that use defer. - # https://go-critic.com/overview.html#exitafterdefer - - exitAfterDefer - # Detects exposed methods from sync.Mutex and sync.RWMutex. - # https://go-critic.com/overview.html#exposedsyncmutex - - exposedSyncMutex - # Detects suspicious reassignment of error from another package. - # https://go-critic.com/overview.html#externalerrorreassign - - externalErrorReassign - # Detects problems in filepath.Join() function calls. - # https://go-critic.com/overview.html#filepathjoin - - filepathJoin - # Detects immediate dereferencing of `flag` package pointers. - # https://go-critic.com/overview.html#flagderef - - flagDeref - # Detects suspicious flag names. - # https://go-critic.com/overview.html#flagname - - flagName - # Detects hex literals that have mixed case letter digits. - # https://go-critic.com/overview.html#hexliteral - - hexLiteral - # Detects nil usages in http.NewRequest calls, suggesting http.NoBody as an alternative. - # https://go-critic.com/overview.html#httpnobody - - httpNoBody - # Detects params that incur excessive amount of copying. - # https://go-critic.com/overview.html#hugeparam - - hugeParam - # Detects repeated if-else statements and suggests to replace them with switch statement. - # https://go-critic.com/overview.html#ifelsechain - - ifElseChain - # Detects when imported package names shadowed in the assignments. - # https://go-critic.com/overview.html#importshadow - - importShadow - # Detects strings.Index calls that may cause unwanted allocs. - # https://go-critic.com/overview.html#indexalloc - - indexAlloc - # Detects non-assignment statements inside if/switch init clause. - # https://go-critic.com/overview.html#initclause - - initClause - # Detects suspicious map literal keys. - # https://go-critic.com/overview.html#mapkey - - mapKey - # Detects method expression call that can be replaced with a method call. - # https://go-critic.com/overview.html#methodexprcall - - methodExprCall - # Finds where nesting level could be reduced. - # https://go-critic.com/overview.html#nestingreduce - - nestingReduce - # Detects immediate dereferencing of `new` expressions. - # https://go-critic.com/overview.html#newderef - - newDeref - # Detects return statements those results evaluate to nil. - # https://go-critic.com/overview.html#nilvalreturn - - nilValReturn - # Detects old-style octal literals. - # https://go-critic.com/overview.html#octalliteral - - octalLiteral - # Detects various off-by-one kind of errors. - # https://go-critic.com/overview.html#offby1 - - offBy1 - # Detects if function parameters could be combined by type and suggest the way to do it. - # https://go-critic.com/overview.html#paramtypecombine - - paramTypeCombine - # Detects expressions like []rune(s)[0] that may cause unwanted rune slice allocation. - # https://go-critic.com/overview.html#preferdecoderune - - preferDecodeRune - # Detects concatenation with os.PathSeparator which can be replaced with filepath.Join. - # https://go-critic.com/overview.html#preferfilepathjoin - - preferFilepathJoin - # Detects fmt.Sprint(f/ln) calls which can be replaced with fmt.Fprint(f/ln). - # https://go-critic.com/overview.html#preferfprint - - preferFprint - # Detects w.Write or io.WriteString calls which can be replaced with w.WriteString. - # https://go-critic.com/overview.html#preferstringwriter - - preferStringWriter - # Detects WriteRune calls with rune literal argument that is single byte and reports to use WriteByte instead. - # https://go-critic.com/overview.html#preferwritebyte - - preferWriteByte - # Detects input and output parameters that have a type of pointer to referential type. - # https://go-critic.com/overview.html#ptrtorefparam - - ptrToRefParam - # Detects append all its data while range it. - # https://go-critic.com/overview.html#rangeappendall - - rangeAppendAll - # Detects expensive copies of `for` loop range expressions. - # https://go-critic.com/overview.html#rangeexprcopy - - rangeExprCopy - # Detects loops that copy big objects during each iteration. - # https://go-critic.com/overview.html#rangevalcopy - - rangeValCopy - # Detects redundant fmt.Sprint calls. - # https://go-critic.com/overview.html#redundantsprint - - redundantSprint - # Detects `regexp.Compile*` that can be replaced with `regexp.MustCompile*`. - # https://go-critic.com/overview.html#regexpmust - - regexpMust - # Detects suspicious regexp patterns. - # https://go-critic.com/overview.html#regexppattern - - regexpPattern - # Detects regexp patterns that can be simplified. - # https://go-critic.com/overview.html#regexpsimplify - - regexpSimplify - # Detects suspicious http.Error call without following return. - # https://go-critic.com/overview.html#returnafterhttperror - - returnAfterHttpError - # Runs user-defined rules using ruleguard linter. - # https://go-critic.com/overview.html#ruleguard - - ruleguard - # Detects switch statements that could be better written as if statement. - # https://go-critic.com/overview.html#singlecaseswitch - - singleCaseSwitch - # Detects slice clear loops, suggests an idiom that is recognized by the Go compiler. - # https://go-critic.com/overview.html#sliceclear - - sliceClear - # Detects usage of `len` when result is obvious or doesn't make sense. - # https://go-critic.com/overview.html#sloppylen - - sloppyLen - # Detects suspicious/confusing re-assignments. - # https://go-critic.com/overview.html#sloppyreassign - - sloppyReassign - # Detects redundant type assertions. - # https://go-critic.com/overview.html#sloppytypeassert - - sloppyTypeAssert - # Detects suspicious sort.Slice calls. - # https://go-critic.com/overview.html#sortslice - - sortSlice - # Detects "%s" formatting directives that can be replaced with %q. - # https://go-critic.com/overview.html#sprintfquotedstring - - sprintfQuotedString - # Detects issue in Query() and Exec() calls. - # https://go-critic.com/overview.html#sqlquery - - sqlQuery - # Detects string concat operations that can be simplified. - # https://go-critic.com/overview.html#stringconcatsimplify - - stringConcatSimplify - # Detects redundant conversions between string and []byte. - # https://go-critic.com/overview.html#stringxbytes - - stringXbytes - # Detects strings.Compare usage. - # https://go-critic.com/overview.html#stringscompare - - stringsCompare - # Detects switch-over-bool statements that use explicit `true` tag value. - # https://go-critic.com/overview.html#switchtrue - - switchTrue - # Detects sync.Map load+delete operations that can be replaced with LoadAndDelete. - # https://go-critic.com/overview.html#syncmaploadanddelete - - syncMapLoadAndDelete - # Detects manual conversion to milli- or microseconds. - # https://go-critic.com/overview.html#timeexprsimplify - - timeExprSimplify - # Detects TODO comments without detail/assignee. - # https://go-critic.com/overview.html#todocommentwithoutdetail - - todoCommentWithoutDetail - # Detects function with too many results. - # https://go-critic.com/overview.html#toomanyresultschecker - - tooManyResultsChecker - # Detects potential truncation issues when comparing ints of different sizes. - # https://go-critic.com/overview.html#truncatecmp - - truncateCmp - # Detects repeated type assertions and suggests to replace them with type switch statement. - # https://go-critic.com/overview.html#typeassertchain - - typeAssertChain - # Detects method declarations preceding the type definition itself. - # https://go-critic.com/overview.html#typedeffirst - - typeDefFirst - # Detects type switches that can benefit from type guard clause with variable. - # https://go-critic.com/overview.html#typeswitchvar - - typeSwitchVar - # Detects unneeded parenthesis inside type expressions and suggests to remove them. - # https://go-critic.com/overview.html#typeunparen - - typeUnparen - # Detects unchecked errors in if statements. - # https://go-critic.com/overview.html#uncheckedinlineerr - - uncheckedInlineErr - # Detects dereference expressions that can be omitted. - # https://go-critic.com/overview.html#underef - - underef - # Detects redundant statement labels. - # https://go-critic.com/overview.html#unlabelstmt - - unlabelStmt - # Detects function literals that can be simplified. - # https://go-critic.com/overview.html#unlambda - - unlambda - # Detects unnamed results that may benefit from names. - # https://go-critic.com/overview.html#unnamedresult - - unnamedResult - # Detects unnecessary braced statement blocks. - # https://go-critic.com/overview.html#unnecessaryblock - - unnecessaryBlock - # Detects redundantly deferred calls. - # https://go-critic.com/overview.html#unnecessarydefer - - unnecessaryDefer - # Detects slice expressions that can be simplified to sliced expression itself. - # https://go-critic.com/overview.html#unslice - - unslice - # Detects value swapping code that are not using parallel assignment. - # https://go-critic.com/overview.html#valswap - - valSwap - # Detects conditions that are unsafe due to not being exhaustive. - # https://go-critic.com/overview.html#weakcond - - weakCond - # Ensures that `//nolint` comments include an explanation. - # https://go-critic.com/overview.html#whynolint - - whyNoLint - # Detects function calls that can be replaced with convenience wrappers. - # https://go-critic.com/overview.html#wrapperfunc - - wrapperFunc - # Detects Yoda style expressions and suggests to replace them. - # https://go-critic.com/overview.html#yodastyleexpr - - yodaStyleExpr - - # Enable all checks. - # Default: false - enable-all: true - # Which checks should be disabled; can't be combined with 'enabled-checks'. - # Default: [] - disabled-checks: - - appendAssign - - appendCombine - - argOrder - - assignOp - - badCall - - badCond - - badLock - - badRegexp - - badSorting - - badSyncOnceFunc - - boolExprSimplify - - builtinShadow - - builtinShadowDecl - - captLocal - - caseOrder - - codegenComment - - commentFormatting - - commentedOutCode - - commentedOutImport - - defaultCaseOrder - - deferInLoop - - deferUnlambda - - deprecatedComment - - docStub - - dupArg - - dupBranchBody - - dupCase - - dupImport - - dupSubExpr - - dynamicFmtString - - elseif - - emptyDecl - - emptyFallthrough - - emptyStringTest - - equalFold - - evalOrder - - exitAfterDefer - - exposedSyncMutex - - externalErrorReassign - - filepathJoin - - flagDeref - - flagName - - hexLiteral - - httpNoBody - - hugeParam - - ifElseChain - - importShadow - - indexAlloc - - initClause - - mapKey - - methodExprCall - - nestingReduce - - newDeref - - nilValReturn - - octalLiteral - - offBy1 - - paramTypeCombine - - preferDecodeRune - - preferFilepathJoin - - preferFprint - - preferStringWriter - - preferWriteByte - - ptrToRefParam - - rangeAppendAll - - rangeExprCopy - - rangeValCopy - - redundantSprint - - regexpMust - - regexpPattern - - regexpSimplify - - returnAfterHttpError - - ruleguard - - singleCaseSwitch - - sliceClear - - sloppyLen - - sloppyReassign - - sloppyTypeAssert - - sortSlice - - sprintfQuotedString - - sqlQuery - - stringConcatSimplify - - stringXbytes - - stringsCompare - - switchTrue - - syncMapLoadAndDelete - - timeExprSimplify - - todoCommentWithoutDetail - - tooManyResultsChecker - - truncateCmp - - typeAssertChain - - typeDefFirst - - typeSwitchVar - - typeUnparen - - uncheckedInlineErr - - underef - - unlabelStmt - - unlambda - - unnamedResult - - unnecessaryBlock - - unnecessaryDefer - - unslice - - valSwap - - weakCond - - whyNoLint - - wrapperFunc - - yodaStyleExpr - - # Enable multiple checks by tags in addition to default checks. - # Run `GL_DEBUG=gocritic golangci-lint run --enable=gocritic` to see all tags and checks. - # See https://github.com/go-critic/go-critic#usage -> section "Tags". - # Default: [] - enabled-tags: - - diagnostic - - style - - performance - - experimental - - opinionated - disabled-tags: - - diagnostic - - style - - performance - - experimental - - opinionated - - # Settings passed to gocritic. - # The settings key is the name of a supported gocritic checker. - # The list of supported checkers can be find in https://go-critic.com/overview. - settings: - # Must be valid enabled check name. - captLocal: - # Whether to restrict checker to params only. - # Default: true - paramsOnly: false - commentedOutCode: - # Min length of the comment that triggers a warning. - # Default: 15 - minLength: 50 - elseif: - # Whether to skip balanced if-else pairs. - # Default: true - skipBalanced: false - hugeParam: - # Size in bytes that makes the warning trigger. - # Default: 80 - sizeThreshold: 70 - ifElseChain: - # Min number of if-else blocks that makes the warning trigger. - # Default: 2 - minThreshold: 4 - nestingReduce: - # Min number of statements inside a branch to trigger a warning. - # Default: 5 - bodyWidth: 4 - rangeExprCopy: - # Size in bytes that makes the warning trigger. - # Default: 512 - sizeThreshold: 516 - # Whether to check test functions - # Default: true - skipTestFuncs: false - rangeValCopy: - # Size in bytes that makes the warning trigger. - # Default: 128 - sizeThreshold: 32 - # Whether to check test functions. - # Default: true - skipTestFuncs: false - ruleguard: - # Enable debug to identify which 'Where' condition was rejected. - # The value of the parameter is the name of a function in a ruleguard file. - # - # When a rule is evaluated: - # If: - # The Match() clause is accepted; and - # One of the conditions in the Where() clause is rejected, - # Then: - # ruleguard prints the specific Where() condition that was rejected. - # - # The option is passed to the ruleguard 'debug-group' argument. - # Default: "" - debug: 'emptyDecl' - # Determines the behavior when an error occurs while parsing ruleguard files. - # If flag is not set, log error and skip rule files that contain an error. - # If flag is set, the value must be a comma-separated list of error conditions. - # - 'all': fail on all errors. - # - 'import': ruleguard rule imports a package that cannot be found. - # - 'dsl': gorule file does not comply with the ruleguard DSL. - # Default: "" - failOn: dsl,import - # Comma-separated list of file paths containing ruleguard rules. - # By default, if a path is relative, it is relative to the directory where the golangci-lint command is executed. - # The placeholder '${base-path}' is substituted with a path relative to the mode defined with `run.relative-path-mode`. - # Glob patterns such as 'rules-*.go' may be specified. - # Default: "" - rules: '${base-path}/ruleguard/rules-*.go,${base-path}/myrule1.go' - # Comma-separated list of enabled groups or skip empty to enable everything. - # Tags can be defined with # character prefix. - # Default: "" - enable: "myGroupName,#myTagName" - # Comma-separated list of disabled groups or skip empty to enable everything. - # Tags can be defined with # character prefix. - # Default: "" - disable: "myGroupName,#myTagName" - tooManyResultsChecker: - # Maximum number of results. - # Default: 5 - maxResults: 10 - truncateCmp: - # Whether to skip int/uint/uintptr types. - # Default: true - skipArchDependent: false - underef: - # Whether to skip (*x).method() calls where x is a pointer receiver. - # Default: true - skipRecvDeref: false - unnamedResult: - # Whether to check exported functions. - # Default: false - checkExported: true - - gocyclo: - # Minimal code complexity to report. - # Default: 30 (but we recommend 10-20) - min-complexity: 10 - - godot: - # Comments to be checked: `declarations`, `toplevel`, `noinline` or `all`. - # Default: declarations - scope: toplevel - # List of regexps for excluding particular comment lines from check. - # Default: [] - exclude: - # Exclude todo and fixme comments. - - "^fixme:" - - "^todo:" - # Check that each sentence ends with a period. - # Default: true - period: false - # Check that each sentence starts with a capital letter. - # Default: false - capital: true - - godox: - # Report any comments starting with keywords, this is useful for TODO or FIXME comments that - # might be left in the code accidentally and should be resolved before merging. - # Default: ["TODO", "BUG", "FIXME"] - keywords: - - NOTE - - OPTIMIZE # marks code that should be optimized before merging - - HACK # marks hack-around that should be removed before merging - - goheader: - # Supports two types 'const` and `regexp`. - # Values can be used recursively. - # Default: {} - values: - const: - # Define here const type values in format k:v. - # For example: - COMPANY: MY COMPANY - regexp: - # Define here regexp type values. - # for example: - AUTHOR: .*@mycompany\.com - # The template use for checking. - # Default: "" - template: |- - # Put here copyright header template for source code files - # For example: - # Note: {{ YEAR }} is a builtin value that returns the year relative to the current machine time. - # - # {{ AUTHOR }} {{ COMPANY }} {{ YEAR }} - # SPDX-License-Identifier: Apache-2.0 - - # Licensed under the Apache License, Version 2.0 (the "License"); - # you may not use this file except in compliance with the License. - # You may obtain a copy of the License at: - - # http://www.apache.org/licenses/LICENSE-2.0 - - # Unless required by applicable law or agreed to in writing, software - # distributed under the License is distributed on an "AS IS" BASIS, - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - # See the License for the specific language governing permissions and - # limitations under the License. - # As alternative of directive 'template', you may put the path to file with the template source. - # Useful if you need to load the template from a specific file. - # By default, if a path is relative, it is relative to the directory where the golangci-lint command is executed. - # The placeholder '${base-path}' is substituted with a path relative to the mode defined with `run.relative-path-mode`. - # Default: "" - template-path: /path/to/my/template.tmpl - - gomoddirectives: - # Allow local `replace` directives. - # Default: false - replace-local: true - # List of allowed `replace` directives. - # Default: [] - replace-allow-list: - - launchpad.net/gocheck - # Allow to not explain why the version has been retracted in the `retract` directives. - # Default: false - retract-allow-no-explanation: true - # Forbid the use of the `exclude` directives. - # Default: false - exclude-forbidden: true - # Forbid the use of the `toolchain` directive. - # Default: false - toolchain-forbidden: true - # Defines a pattern to validate `toolchain` directive. - # Default: '' (no match) - toolchain-pattern: 'go1\.23\.\d+$' - # Forbid the use of the `tool` directives. - # Default: false - tool-forbidden: true - # Forbid the use of the `godebug` directive. - # Default: false - go-debug-forbidden: true - # Defines a pattern to validate `go` minimum version directive. - # Default: '' (no match) - go-version-pattern: '\d\.\d+(\.0)?' - - gomodguard: - allowed: - # List of allowed modules. + sloglint: + # Enforce not mixing key-value pairs and attributes. + # https://github.com/go-simpler/sloglint?tab=readme-ov-file#no-mixed-arguments + # Default: true + no-mixed-args: false + # Enforce using key-value pairs only (overrides no-mixed-args, incompatible with attr-only). + # https://github.com/go-simpler/sloglint?tab=readme-ov-file#key-value-pairs-only + # Default: false + kv-only: true + # Enforce using attributes only (overrides no-mixed-args, incompatible with kv-only). + # https://github.com/go-simpler/sloglint?tab=readme-ov-file#attributes-only + # Default: false + attr-only: true + # Enforce not using global loggers. + # Values: + # - "": disabled + # - "all": report all global loggers + # - "default": report only the default slog logger + # https://github.com/go-simpler/sloglint?tab=readme-ov-file#no-global + # Default: "" + no-global: "all" + # Enforce using methods that accept a context. + # Values: + # - "": disabled + # - "all": report all contextless calls + # - "scope": report only if a context exists in the scope of the outermost function + # https://github.com/go-simpler/sloglint?tab=readme-ov-file#context-only + # Default: "" + context: "all" + # Enforce using static values for log messages. + # https://github.com/go-simpler/sloglint?tab=readme-ov-file#static-messages + # Default: false + static-msg: true + # Enforce using constants instead of raw keys. + # https://github.com/go-simpler/sloglint?tab=readme-ov-file#no-raw-keys + # Default: false + no-raw-keys: true + # Enforce a single key naming convention. + # Values: snake, kebab, camel, pascal + # https://github.com/go-simpler/sloglint?tab=readme-ov-file#key-naming-convention + # Default: "" + key-naming-case: snake + # Enforce not using specific keys. + # https://github.com/go-simpler/sloglint?tab=readme-ov-file#forbidden-keys # Default: [] - modules: - - gopkg.in/yaml.v2 - # List of allowed module domains. + forbidden-keys: + - time + - level + - msg + - source + - foo + # Enforce putting arguments on separate lines. + # https://github.com/go-simpler/sloglint?tab=readme-ov-file#arguments-on-separate-lines + # Default: false + args-on-sep-lines: true + + spancheck: + # Checks to enable. + # Options include: + # - `end`: check that `span.End()` is called + # - `record-error`: check that `span.RecordError(err)` is called when an error is returned + # - `set-status`: check that `span.SetStatus(codes.Error, msg)` is called when an error is returned + # Default: ["end"] + checks: + - end + - record-error + - set-status + # A list of regexes for function signatures that silence `record-error` and `set-status` reports + # if found in the call path to a returned error. + # https://github.com/jjti/go-spancheck#ignore-check-signatures # Default: [] - domains: - - golang.org - blocked: - # List of blocked modules. + ignore-check-signatures: + - "telemetry.RecordError" + # A list of regexes for additional function signatures that create spans. + # This is useful if you have a utility method to create spans. + # Each entry should be of the form `:`, where `telemetry-type` can be `opentelemetry` or `opencensus`. + # https://github.com/jjti/go-spancheck#extra-start-span-signatures # Default: [] - modules: - # Blocked module. - - github.com/uudashr/go-module: - # Recommended modules that should be used instead. (Optional) - recommendations: - - golang.org/x/mod - # Reason why the recommended module should be used. (Optional) - reason: "`mod` is the official go.mod parser library." - # List of blocked module version constraints. + extra-start-span-signatures: + - "github.com/user/repo/telemetry/trace.Start:opentelemetry" + + staticcheck: + # SAxxxx checks in https://staticcheck.dev/docs/configuration/options/#checks + # Example (to disable some checks): [ "all", "-SA1000", "-SA1001"] + # Default: ["*"] + checks: + # Invalid regular expression. + # https://staticcheck.dev/docs/checks/#SA1000 + - SA1000 + # Invalid template. + # https://staticcheck.dev/docs/checks/#SA1001 + - SA1001 + # Invalid format in 'time.Parse'. + # https://staticcheck.dev/docs/checks/#SA1002 + - SA1002 + # Unsupported argument to functions in 'encoding/binary'. + # https://staticcheck.dev/docs/checks/#SA1003 + - SA1003 + # Suspiciously small untyped constant in 'time.Sleep'. + # https://staticcheck.dev/docs/checks/#SA1004 + - SA1004 + # Invalid first argument to 'exec.Command'. + # https://staticcheck.dev/docs/checks/#SA1005 + - SA1005 + # 'Printf' with dynamic first argument and no further arguments. + # https://staticcheck.dev/docs/checks/#SA1006 + - SA1006 + # Invalid URL in 'net/url.Parse'. + # https://staticcheck.dev/docs/checks/#SA1007 + - SA1007 + # Non-canonical key in 'http.Header' map. + # https://staticcheck.dev/docs/checks/#SA1008 + - SA1008 + # '(*regexp.Regexp).FindAll' called with 'n == 0', which will always return zero results. + # https://staticcheck.dev/docs/checks/#SA1010 + - SA1010 + # Various methods in the "strings" package expect valid UTF-8, but invalid input is provided. + # https://staticcheck.dev/docs/checks/#SA1011 + - SA1011 + # A nil 'context.Context' is being passed to a function, consider using 'context.TODO' instead. + # https://staticcheck.dev/docs/checks/#SA1012 + - SA1012 + # 'io.Seeker.Seek' is being called with the whence constant as the first argument, but it should be the second. + # https://staticcheck.dev/docs/checks/#SA1013 + - SA1013 + # Non-pointer value passed to 'Unmarshal' or 'Decode'. + # https://staticcheck.dev/docs/checks/#SA1014 + - SA1014 + # Using 'time.Tick' in a way that will leak. Consider using 'time.NewTicker', and only use 'time.Tick' in tests, commands and endless functions. + # https://staticcheck.dev/docs/checks/#SA1015 + - SA1015 + # Trapping a signal that cannot be trapped. + # https://staticcheck.dev/docs/checks/#SA1016 + - SA1016 + # Channels used with 'os/signal.Notify' should be buffered. + # https://staticcheck.dev/docs/checks/#SA1017 + - SA1017 + # 'strings.Replace' called with 'n == 0', which does nothing. + # https://staticcheck.dev/docs/checks/#SA1018 + - SA1018 + # Using a deprecated function, variable, constant or field. + # https://staticcheck.dev/docs/checks/#SA1019 + - SA1019 + # Using an invalid host:port pair with a 'net.Listen'-related function. + # https://staticcheck.dev/docs/checks/#SA1020 + - SA1020 + # Using 'bytes.Equal' to compare two 'net.IP'. + # https://staticcheck.dev/docs/checks/#SA1021 + - SA1021 + # Modifying the buffer in an 'io.Writer' implementation. + # https://staticcheck.dev/docs/checks/#SA1023 + - SA1023 + # A string cutset contains duplicate characters. + # https://staticcheck.dev/docs/checks/#SA1024 + - SA1024 + # It is not possible to use '(*time.Timer).Reset''s return value correctly. + # https://staticcheck.dev/docs/checks/#SA1025 + - SA1025 + # Cannot marshal channels or functions. + # https://staticcheck.dev/docs/checks/#SA1026 + - SA1026 + # Atomic access to 64-bit variable must be 64-bit aligned. + # https://staticcheck.dev/docs/checks/#SA1027 + - SA1027 + # 'sort.Slice' can only be used on slices. + # https://staticcheck.dev/docs/checks/#SA1028 + - SA1028 + # Inappropriate key in call to 'context.WithValue'. + # https://staticcheck.dev/docs/checks/#SA1029 + - SA1029 + # Invalid argument in call to a 'strconv' function. + # https://staticcheck.dev/docs/checks/#SA1030 + - SA1030 + # Overlapping byte slices passed to an encoder. + # https://staticcheck.dev/docs/checks/#SA1031 + - SA1031 + # Wrong order of arguments to 'errors.Is'. + # https://staticcheck.dev/docs/checks/#SA1032 + - SA1032 + # 'sync.WaitGroup.Add' called inside the goroutine, leading to a race condition. + # https://staticcheck.dev/docs/checks/#SA2000 + - SA2000 + # Empty critical section, did you mean to defer the unlock?. + # https://staticcheck.dev/docs/checks/#SA2001 + - SA2001 + # Called 'testing.T.FailNow' or 'SkipNow' in a goroutine, which isn't allowed. + # https://staticcheck.dev/docs/checks/#SA2002 + - SA2002 + # Deferred 'Lock' right after locking, likely meant to defer 'Unlock' instead. + # https://staticcheck.dev/docs/checks/#SA2003 + - SA2003 + # 'TestMain' doesn't call 'os.Exit', hiding test failures. + # https://staticcheck.dev/docs/checks/#SA3000 + - SA3000 + # Assigning to 'b.N' in benchmarks distorts the results. + # https://staticcheck.dev/docs/checks/#SA3001 + - SA3001 + # Binary operator has identical expressions on both sides. + # https://staticcheck.dev/docs/checks/#SA4000 + - SA4000 + # '&*x' gets simplified to 'x', it does not copy 'x'. + # https://staticcheck.dev/docs/checks/#SA4001 + - SA4001 + # Comparing unsigned values against negative values is pointless. + # https://staticcheck.dev/docs/checks/#SA4003 + - SA4003 + # The loop exits unconditionally after one iteration. + # https://staticcheck.dev/docs/checks/#SA4004 + - SA4004 + # Field assignment that will never be observed. Did you mean to use a pointer receiver?. + # https://staticcheck.dev/docs/checks/#SA4005 + - SA4005 + # A value assigned to a variable is never read before being overwritten. Forgotten error check or dead code?. + # https://staticcheck.dev/docs/checks/#SA4006 + - SA4006 + # The variable in the loop condition never changes, are you incrementing the wrong variable?. + # https://staticcheck.dev/docs/checks/#SA4008 + - SA4008 + # A function argument is overwritten before its first use. + # https://staticcheck.dev/docs/checks/#SA4009 + - SA4009 + # The result of 'append' will never be observed anywhere. + # https://staticcheck.dev/docs/checks/#SA4010 + - SA4010 + # Break statement with no effect. Did you mean to break out of an outer loop?. + # https://staticcheck.dev/docs/checks/#SA4011 + - SA4011 + # Comparing a value against NaN even though no value is equal to NaN. + # https://staticcheck.dev/docs/checks/#SA4012 + - SA4012 + # Negating a boolean twice ('!!b') is the same as writing 'b'. This is either redundant, or a typo. + # https://staticcheck.dev/docs/checks/#SA4013 + - SA4013 + # An if/else if chain has repeated conditions and no side-effects; if the condition didn't match the first time, it won't match the second time, either. + # https://staticcheck.dev/docs/checks/#SA4014 + - SA4014 + # Calling functions like 'math.Ceil' on floats converted from integers doesn't do anything useful. + # https://staticcheck.dev/docs/checks/#SA4015 + - SA4015 + # Certain bitwise operations, such as 'x ^ 0', do not do anything useful. + # https://staticcheck.dev/docs/checks/#SA4016 + - SA4016 + # Discarding the return values of a function without side effects, making the call pointless. + # https://staticcheck.dev/docs/checks/#SA4017 + - SA4017 + # Self-assignment of variables. + # https://staticcheck.dev/docs/checks/#SA4018 + - SA4018 + # Multiple, identical build constraints in the same file. + # https://staticcheck.dev/docs/checks/#SA4019 + - SA4019 + # Unreachable case clause in a type switch. + # https://staticcheck.dev/docs/checks/#SA4020 + - SA4020 + # "x = append(y)" is equivalent to "x = y". + # https://staticcheck.dev/docs/checks/#SA4021 + - SA4021 + # Comparing the address of a variable against nil. + # https://staticcheck.dev/docs/checks/#SA4022 + - SA4022 + # Impossible comparison of interface value with untyped nil. + # https://staticcheck.dev/docs/checks/#SA4023 + - SA4023 + # Checking for impossible return value from a builtin function. + # https://staticcheck.dev/docs/checks/#SA4024 + - SA4024 + # Integer division of literals that results in zero. + # https://staticcheck.dev/docs/checks/#SA4025 + - SA4025 + # Go constants cannot express negative zero. + # https://staticcheck.dev/docs/checks/#SA4026 + - SA4026 + # '(*net/url.URL).Query' returns a copy, modifying it doesn't change the URL. + # https://staticcheck.dev/docs/checks/#SA4027 + - SA4027 + # 'x % 1' is always zero. + # https://staticcheck.dev/docs/checks/#SA4028 + - SA4028 + # Ineffective attempt at sorting slice. + # https://staticcheck.dev/docs/checks/#SA4029 + - SA4029 + # Ineffective attempt at generating random number. + # https://staticcheck.dev/docs/checks/#SA4030 + - SA4030 + # Checking never-nil value against nil. + # https://staticcheck.dev/docs/checks/#SA4031 + - SA4031 + # Comparing 'runtime.GOOS' or 'runtime.GOARCH' against impossible value. + # https://staticcheck.dev/docs/checks/#SA4032 + - SA4032 + # Assignment to nil map. + # https://staticcheck.dev/docs/checks/#SA5000 + - SA5000 + # Deferring 'Close' before checking for a possible error. + # https://staticcheck.dev/docs/checks/#SA5001 + - SA5001 + # The empty for loop ("for {}") spins and can block the scheduler. + # https://staticcheck.dev/docs/checks/#SA5002 + - SA5002 + # Defers in infinite loops will never execute. + # https://staticcheck.dev/docs/checks/#SA5003 + - SA5003 + # "for { select { ..." with an empty default branch spins. + # https://staticcheck.dev/docs/checks/#SA5004 + - SA5004 + # The finalizer references the finalized object, preventing garbage collection. + # https://staticcheck.dev/docs/checks/#SA5005 + - SA5005 + # Infinite recursive call. + # https://staticcheck.dev/docs/checks/#SA5007 + - SA5007 + # Invalid struct tag. + # https://staticcheck.dev/docs/checks/#SA5008 + - SA5008 + # Invalid Printf call. + # https://staticcheck.dev/docs/checks/#SA5009 + - SA5009 + # Impossible type assertion. + # https://staticcheck.dev/docs/checks/#SA5010 + - SA5010 + # Possible nil pointer dereference. + # https://staticcheck.dev/docs/checks/#SA5011 + - SA5011 + # Passing odd-sized slice to function expecting even size. + # https://staticcheck.dev/docs/checks/#SA5012 + - SA5012 + # Using 'regexp.Match' or related in a loop, should use 'regexp.Compile'. + # https://staticcheck.dev/docs/checks/#SA6000 + - SA6000 + # Missing an optimization opportunity when indexing maps by byte slices. + # https://staticcheck.dev/docs/checks/#SA6001 + - SA6001 + # Storing non-pointer values in 'sync.Pool' allocates memory. + # https://staticcheck.dev/docs/checks/#SA6002 + - SA6002 + # Converting a string to a slice of runes before ranging over it. + # https://staticcheck.dev/docs/checks/#SA6003 + - SA6003 + # Inefficient string comparison with 'strings.ToLower' or 'strings.ToUpper'. + # https://staticcheck.dev/docs/checks/#SA6005 + - SA6005 + # Using io.WriteString to write '[]byte'. + # https://staticcheck.dev/docs/checks/#SA6006 + - SA6006 + # Defers in range loops may not run when you expect them to. + # https://staticcheck.dev/docs/checks/#SA9001 + - SA9001 + # Using a non-octal 'os.FileMode' that looks like it was meant to be in octal. + # https://staticcheck.dev/docs/checks/#SA9002 + - SA9002 + # Empty body in an if or else branch. + # https://staticcheck.dev/docs/checks/#SA9003 + - SA9003 + # Only the first constant has an explicit type. + # https://staticcheck.dev/docs/checks/#SA9004 + - SA9004 + # Trying to marshal a struct with no public fields nor custom marshaling. + # https://staticcheck.dev/docs/checks/#SA9005 + - SA9005 + # Dubious bit shifting of a fixed size integer value. + # https://staticcheck.dev/docs/checks/#SA9006 + - SA9006 + # Deleting a directory that shouldn't be deleted. + # https://staticcheck.dev/docs/checks/#SA9007 + - SA9007 + # 'else' branch of a type assertion is probably not reading the right value. + # https://staticcheck.dev/docs/checks/#SA9008 + - SA9008 + # Ineffectual Go compiler directive. + # https://staticcheck.dev/docs/checks/#SA9009 + - SA9009 + + stylecheck: + # https://staticcheck.dev/docs/configuration/options/#dot_import_whitelist + # Default: ["github.com/mmcloughlin/avo/build", "github.com/mmcloughlin/avo/operand", "github.com/mmcloughlin/avo/reg"] + dot-import-whitelist: + - fmt + # https://staticcheck.dev/docs/configuration/options/#initialisms + # Default: ["ACL", "API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", "IP", "JSON", "QPS", "RAM", "RPC", "SLA", "SMTP", "SQL", "SSH", "TCP", "TLS", "TTL", "UDP", "UI", "GID", "UID", "UUID", "URI", "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", "XSS", "SIP", "RTP", "AMQP", "DB", "TS"] + initialisms: [ "ACL", "API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", "IP", "JSON", "QPS", "RAM", "RPC", "SLA", "SMTP", "SQL", "SSH", "TCP", "TLS", "TTL", "UDP", "UI", "GID", "UID", "UUID", "URI", "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", "XSS", "SIP", "RTP", "AMQP", "DB", "TS" ] + # https://staticcheck.dev/docs/configuration/options/#http_status_code_whitelist + # Default: ["200", "400", "404", "500"] + http-status-code-whitelist: [ "200", "400", "404", "500" ] + # STxxxx checks in https://staticcheck.dev/docs/configuration/options/#checks + # Example (to disable some checks): [ "all", "-ST1000", "-ST1003", "-ST1016", "-ST1020", "-ST1021", "-ST1022" ] + # Default: ["*"] + checks: + # Incorrect or missing package comment. + # https://staticcheck.dev/docs/checks/#ST1000 + - ST1000 + # Dot imports are discouraged. + # https://staticcheck.dev/docs/checks/#ST1001 + - ST1001 + # Poorly chosen identifier. + # https://staticcheck.dev/docs/checks/#ST1003 + - ST1003 + # Incorrectly formatted error string. + # https://staticcheck.dev/docs/checks/#ST1005 + - ST1005 + # Poorly chosen receiver name. + # https://staticcheck.dev/docs/checks/#ST1006 + - ST1006 + # A function's error value should be its last return value. + # https://staticcheck.dev/docs/checks/#ST1008 + - ST1008 + # Poorly chosen name for variable of type 'time.Duration'. + # https://staticcheck.dev/docs/checks/#ST1011 + - ST1011 + # Poorly chosen name for error variable. + # https://staticcheck.dev/docs/checks/#ST1012 + - ST1012 + # Should use constants for HTTP error codes, not magic numbers. + # https://staticcheck.dev/docs/checks/#ST1013 + - ST1013 + # A switch's default case should be the first or last case. + # https://staticcheck.dev/docs/checks/#ST1015 + - ST1015 + # Use consistent method receiver names. + # https://staticcheck.dev/docs/checks/#ST1016 + - ST1016 + # Don't use Yoda conditions. + # https://staticcheck.dev/docs/checks/#ST1017 + - ST1017 + # Avoid zero-width and control characters in string literals. + # https://staticcheck.dev/docs/checks/#ST1018 + - ST1018 + # Importing the same package multiple times. + # https://staticcheck.dev/docs/checks/#ST1019 + - ST1019 + # The documentation of an exported function should start with the function's name. + # https://staticcheck.dev/docs/checks/#ST1020 + - ST1020 + # The documentation of an exported type should start with type's name. + # https://staticcheck.dev/docs/checks/#ST1021 + - ST1021 + # The documentation of an exported variable or constant should start with variable's name. + # https://staticcheck.dev/docs/checks/#ST1022 + - ST1022 + # Redundant type in variable declaration. + # https://staticcheck.dev/docs/checks/#ST1023 + - ST1023 + + tagalign: + # Align and sort can be used together or separately. + # + # Whether enable align. If true, the struct tags will be aligned. + # e.g.: + # type FooBar struct { + # Bar string `json:"bar" validate:"required"` + # FooFoo int8 `json:"foo_foo" validate:"required"` + # } + # will be formatted to: + # type FooBar struct { + # Bar string `json:"bar" validate:"required"` + # FooFoo int8 `json:"foo_foo" validate:"required"` + # } + # Default: true. + align: false + # Whether enable tags sort. + # If true, the tags will be sorted by name in ascending order. + # e.g.: `xml:"bar" json:"bar" validate:"required"` -> `json:"bar" validate:"required" xml:"bar"` + # Default: true + sort: false + # Specify the order of tags, the other tags will be sorted by name. + # This option will be ignored if `sort` is false. # Default: [] - versions: - # Blocked module with version constraint. - - github.com/mitchellh/go-homedir: - # Version constraint, see https://github.com/Masterminds/semver#basic-comparisons. - version: "< 1.1.0" - # Reason why the version constraint exists. (Optional) - reason: "testing if blocked version constraint works." - # Set to true to raise lint issues for packages that are loaded from a local path via replace directive. + order: + - json + - yaml + - yml + - toml + - mapstructure + - binding + - validate + # Whether enable strict style. + # In this style, the tags will be sorted and aligned in the dictionary order, + # and the tags with the same name will be aligned together. + # Note: This option will be ignored if 'align' or 'sort' is false. # Default: false - local-replace-directives: false - - gosimple: - # Sxxxx checks in https://staticcheck.dev/docs/configuration/options/#checks - # Default: ["*"] - checks: - # Use plain channel send or receive instead of single-case select. - # https://staticcheck.dev/docs/checks/#S1000 - - S1000 - # Replace for loop with call to copy. - # https://staticcheck.dev/docs/checks/#S1001 - - S1001 - # Omit comparison with boolean constant. - # https://staticcheck.dev/docs/checks/#S1002 - - S1002 - # Replace call to 'strings.Index' with 'strings.Contains'. - # https://staticcheck.dev/docs/checks/#S1003 - - S1003 - # Replace call to 'bytes.Compare' with 'bytes.Equal'. - # https://staticcheck.dev/docs/checks/#S1004 - - S1004 - # Drop unnecessary use of the blank identifier. - # https://staticcheck.dev/docs/checks/#S1005 - - S1005 - # Use "for { ... }" for infinite loops. - # https://staticcheck.dev/docs/checks/#S1006 - - S1006 - # Simplify regular expression by using raw string literal. - # https://staticcheck.dev/docs/checks/#S1007 - - S1007 - # Simplify returning boolean expression. - # https://staticcheck.dev/docs/checks/#S1008 - - S1008 - # Omit redundant nil check on slices, maps, and channels. - # https://staticcheck.dev/docs/checks/#S1009 - - S1009 - # Omit default slice index. - # https://staticcheck.dev/docs/checks/#S1010 - - S1010 - # Use a single 'append' to concatenate two slices. - # https://staticcheck.dev/docs/checks/#S1011 - - S1011 - # Replace 'time.Now().Sub(x)' with 'time.Since(x)'. - # https://staticcheck.dev/docs/checks/#S1012 - - S1012 - # Use a type conversion instead of manually copying struct fields. - # https://staticcheck.dev/docs/checks/#S1016 - - S1016 - # Replace manual trimming with 'strings.TrimPrefix'. - # https://staticcheck.dev/docs/checks/#S1017 - - S1017 - # Use "copy" for sliding elements. - # https://staticcheck.dev/docs/checks/#S1018 - - S1018 - # Simplify "make" call by omitting redundant arguments. - # https://staticcheck.dev/docs/checks/#S1019 - - S1019 - # Omit redundant nil check in type assertion. - # https://staticcheck.dev/docs/checks/#S1020 - - S1020 - # Merge variable declaration and assignment. - # https://staticcheck.dev/docs/checks/#S1021 - - S1021 - # Omit redundant control flow. - # https://staticcheck.dev/docs/checks/#S1023 - - S1023 - # Replace 'x.Sub(time.Now())' with 'time.Until(x)'. - # https://staticcheck.dev/docs/checks/#S1024 - - S1024 - # Don't use 'fmt.Sprintf("%s", x)' unnecessarily. - # https://staticcheck.dev/docs/checks/#S1025 - - S1025 - # Simplify error construction with 'fmt.Errorf'. - # https://staticcheck.dev/docs/checks/#S1028 - - S1028 - # Range over the string directly. - # https://staticcheck.dev/docs/checks/#S1029 - - S1029 - # Use 'bytes.Buffer.String' or 'bytes.Buffer.Bytes'. - # https://staticcheck.dev/docs/checks/#S1030 - - S1030 - # Omit redundant nil check around loop. - # https://staticcheck.dev/docs/checks/#S1031 - - S1031 - # Use 'sort.Ints(x)', 'sort.Float64s(x)', and 'sort.Strings(x)'. - # https://staticcheck.dev/docs/checks/#S1032 - - S1032 - # Unnecessary guard around call to "delete". - # https://staticcheck.dev/docs/checks/#S1033 - - S1033 - # Use result of type assertion to simplify cases. - # https://staticcheck.dev/docs/checks/#S1034 - - S1034 - # Redundant call to 'net/http.CanonicalHeaderKey' in method call on 'net/http.Header'. - # https://staticcheck.dev/docs/checks/#S1035 - - S1035 - # Unnecessary guard around map access. - # https://staticcheck.dev/docs/checks/#S1036 - - S1036 - # Elaborate way of sleeping. - # https://staticcheck.dev/docs/checks/#S1037 - - S1037 - # Unnecessarily complex way of printing formatted string. - # https://staticcheck.dev/docs/checks/#S1038 - - S1038 - # Unnecessary use of 'fmt.Sprint'. - # https://staticcheck.dev/docs/checks/#S1039 - - S1039 - # Type assertion to current type. - # https://staticcheck.dev/docs/checks/#S1040 - - S1040 - - 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 hard coded credentials - - G102 # Bind to all interfaces - - G103 # Audit the use of unsafe block - - G104 # Audit errors not checked - - G106 # Audit the use of ssh.InsecureIgnoreHostKey - - G107 # Url provided to HTTP request as taint input - - G108 # Profiling endpoint automatically exposed on /debug/pprof - - G109 # Potential Integer overflow made by strconv.Atoi result conversion to int16/32 - - G110 # Potential DoS vulnerability via decompression bomb - - G111 # Potential directory traversal - - G112 # Potential slowloris attack - - G113 # Usage of Rat.SetString in math/big with an overflow (CVE-2022-23772) - - G114 # Use of net/http serve function that has no support for setting timeouts - - G115 # Potential integer overflow when converting between integer types - - G201 # SQL query construction using format string - - G202 # SQL query construction using string concatenation - - G203 # Use of unescaped data in HTML templates - - G204 # Audit use of command execution - - G301 # Poor file permissions used when creating a directory - - G302 # Poor file permissions used with chmod - - G303 # Creating tempfile using a predictable path - - G304 # File path provided as taint input - - G305 # File traversal when extracting zip/tar archive - - G306 # Poor file permissions used when writing to a new file - - G307 # Poor file permissions used when creating a file with os.Create - - G401 # Detect the usage of MD5 or SHA1 - - G402 # Look for bad TLS connection settings - - G403 # Ensure minimum RSA key length of 2048 bits - - G404 # Insecure random number source (rand) - - G405 # Detect the usage of DES or RC4 - - G406 # Detect the usage of MD4 or RIPEMD160 - - G501 # Import blocklist: crypto/md5 - - G502 # Import blocklist: crypto/des - - G503 # Import blocklist: crypto/rc4 - - G504 # Import blocklist: net/http/cgi - - G505 # Import blocklist: crypto/sha1 - - G506 # Import blocklist: golang.org/x/crypto/md4 - - G507 #Import blocklist: golang.org/x/crypto/ripemd160 - - G601 # Implicit memory aliasing of items from a range statement - - G602 # Slice access out of bounds - - # To specify a set of rules to explicitly exclude. - # Available rules: https://github.com/securego/gosec#available-rules - # Default: [] - excludes: - - G101 # Look for hard coded credentials - - G102 # Bind to all interfaces - - G103 # Audit the use of unsafe block - - G104 # Audit errors not checked - - G106 # Audit the use of ssh.InsecureIgnoreHostKey - - G107 # Url provided to HTTP request as taint input - - G108 # Profiling endpoint automatically exposed on /debug/pprof - - G109 # Potential Integer overflow made by strconv.Atoi result conversion to int16/32 - - G110 # Potential DoS vulnerability via decompression bomb - - G111 # Potential directory traversal - - G112 # Potential slowloris attack - - G113 # Usage of Rat.SetString in math/big with an overflow (CVE-2022-23772) - - G114 # Use of net/http serve function that has no support for setting timeouts - - G115 # Potential integer overflow when converting between integer types - - G201 # SQL query construction using format string - - G202 # SQL query construction using string concatenation - - G203 # Use of unescaped data in HTML templates - - G204 # Audit use of command execution - - G301 # Poor file permissions used when creating a directory - - G302 # Poor file permissions used with chmod - - G303 # Creating tempfile using a predictable path - - G304 # File path provided as taint input - - G305 # File traversal when extracting zip/tar archive - - G306 # Poor file permissions used when writing to a new file - - G307 # Poor file permissions used when creating a file with os.Create - - G401 # Detect the usage of MD5 or SHA1 - - G402 # Look for bad TLS connection settings - - G403 # Ensure minimum RSA key length of 2048 bits - - G404 # Insecure random number source (rand) - - G405 # Detect the usage of DES or RC4 - - G406 # Detect the usage of MD4 or RIPEMD160 - - G501 # Import blocklist: crypto/md5 - - G502 # Import blocklist: crypto/des - - G503 # Import blocklist: crypto/rc4 - - G504 # Import blocklist: net/http/cgi - - G505 # Import blocklist: crypto/sha1 - - G506 # Import blocklist: golang.org/x/crypto/md4 - - G507 #Import blocklist: golang.org/x/crypto/ripemd160 - - G601 # Implicit memory aliasing of items from a range statement - - G602 # Slice access out of bounds - - # Filter out the issues with a lower severity than the given value. - # Valid options are: low, medium, high. - # Default: low - severity: medium - - # Filter out the issues with a lower confidence than the given value. - # Valid options are: low, medium, high. - # Default: low - confidence: medium - - # Concurrency value. - # Default: the number of logical CPUs usable by the current process. - concurrency: 12 - - # To specify the configuration of rules. - config: - # Globals are applicable to all rules. - global: - # If true, ignore #nosec in comments (and an alternative as well). - # Default: false - nosec: true - # Add an alternative comment prefix to #nosec (both will work at the same time). - # Default: "" - "#nosec": "#my-custom-nosec" - # Define whether nosec issues are counted as finding or not. + strict: true + + tagliatelle: + # Checks the struct tag name case. + case: + # Defines the association between tag name and case. + # Any struct tag name can be used. + # Supported string cases: + # - `camel` + # - `pascal` + # - `kebab` + # - `snake` + # - `upperSnake` + # - `goCamel` + # - `goPascal` + # - `goKebab` + # - `goSnake` + # - `upper` + # - `lower` + # - `header` + rules: + json: camel + yaml: camel + xml: camel + toml: camel + bson: camel + avro: snake + mapstructure: kebab + env: upperSnake + envconfig: upperSnake + whatever: snake + # Defines the association between tag name and case. + # Important: the `extended-rules` overrides `rules`. + # Default: empty + extended-rules: + json: + # Supported string cases: + # - `camel` + # - `pascal` + # - `kebab` + # - `snake` + # - `upperSnake` + # - `goCamel` + # - `goPascal` + # - `goKebab` + # - `goSnake` + # - `header` + # - `lower` + # - `header` + # + # Required + case: camel + # Adds 'AMQP', 'DB', 'GID', 'RTP', 'SIP', 'TS' to initialisms, + # and removes 'LHS', 'RHS' from initialisms. + # Default: false + extra-initialisms: true + # Defines initialism additions and overrides. + # Default: empty + initialism-overrides: + DB: true # add a new initialism + LHS: false # disable a default initialism. + # ... + # Uses the struct field name to check the name of the struct tag. # Default: false - show-ignored: true - # Audit mode enables addition checks that for normal code analysis might be too nosy. - # Default: false - audit: true - G101: - # Regexp pattern for variables and constants to find. - # Default: "(?i)passwd|pass|password|pwd|secret|token|pw|apiKey|bearer|cred" - pattern: "(?i)example" - # If true, complain about all cases (even with low entropy). - # Default: false - ignore_entropy: false - # Maximum allowed entropy of the string. - # Default: "80.0" - entropy_threshold: "80.0" - # Maximum allowed value of entropy/string length. - # Is taken into account if entropy >= entropy_threshold/2. - # Default: "3.0" - per_char_threshold: "3.0" - # Calculate entropy for first N chars of the string. - # Default: "16" - truncate: "32" - # Additional functions to ignore while checking unhandled errors. - # Following functions always ignored: - # bytes.Buffer: - # - Write - # - WriteByte - # - WriteRune - # - WriteString - # fmt: - # - Print - # - Printf - # - Println - # - Fprint - # - Fprintf - # - Fprintln - # strings.Builder: - # - Write - # - WriteByte - # - WriteRune - # - WriteString - # io.PipeWriter: - # - CloseWithError - # hash.Hash: - # - Write - # os: - # - Unsetenv - # Default: {} - G104: - fmt: - - Fscanf - G111: - # Regexp pattern to find potential directory traversal. - # Default: "http\\.Dir\\(\"\\/\"\\)|http\\.Dir\\('\\/'\\)" - pattern: "custom\\.Dir\\(\\)" - # Maximum allowed permissions mode for os.Mkdir and os.MkdirAll - # Default: "0750" - G301: "0750" - # Maximum allowed permissions mode for os.OpenFile and os.Chmod - # Default: "0600" - G302: "0600" - # Maximum allowed permissions mode for os.WriteFile and ioutil.WriteFile - # Default: "0600" - G306: "0600" - - gosmopolitan: - # Allow and ignore `time.Local` usages. - # - # Default: false - allow-time-local: true - # List of fully qualified names in the `full/pkg/path.name` form, to act as "i18n escape hatches". - # String literals inside call-like expressions to, or struct literals of those names, - # are exempt from the writing system check. - # - # Default: [] - escape-hatches: - - 'github.com/nicksnyder/go-i18n/v2/i18n.Message' - - 'example.com/your/project/i18n/markers.Raw' - - 'example.com/your/project/i18n/markers.OK' - - 'example.com/your/project/i18n/markers.TODO' - - 'command-line-arguments.Simple' - # List of Unicode scripts to watch for any usage in string literals. - # https://pkg.go.dev/unicode#pkg-variables - # - # Default: ["Han"] - watch-for-scripts: - - Devanagari - - Han - - Hangul - - Hiragana - - Katakana - - govet: - # Disable all analyzers. - # Default: false - disable-all: true - # Enable analyzers by name. - # (in addition to default: - # appends, asmdecl, assign, atomic, bools, buildtag, cgocall, composites, copylocks, defers, directive, errorsas, - # framepointer, httpresponse, ifaceassert, loopclosure, lostcancel, nilfunc, printf, shift, sigchanyzer, slog, - # stdmethods, stringintconv, structtag, testinggoroutine, tests, timeformat, unmarshal, unreachable, unsafeptr, - # unusedresult - # ). - # Run `GL_DEBUG=govet golangci-lint run --enable=govet` to see default, all available analyzers, and enabled analyzers. - # Default: [] - enable: - # Check for missing values after append. - - appends - # Report mismatches between assembly files and Go declarations. - - asmdecl - # Check for useless assignments. - - assign - # Check for common mistakes using the sync/atomic package. - - atomic - # Check for non-64-bits-aligned arguments to sync/atomic functions. - - atomicalign - # Check for common mistakes involving boolean operators. - - bools - # Check //go:build and // +build directives. - - buildtag - # Detect some violations of the cgo pointer passing rules. - - cgocall - # Check for unkeyed composite literals. - - composites - # Check for locks erroneously passed by value. - - copylocks - # Check for calls of reflect.DeepEqual on error values. - - deepequalerrors - # Report common mistakes in defer statements. - - defers - # Check Go toolchain directives such as //go:debug. - - directive - # Report passing non-pointer or non-error values to errors.As. - - errorsas - # Find structs that would use less memory if their fields were sorted. - - fieldalignment - # Find calls to a particular function. - - findcall - # Report assembly that clobbers the frame pointer before saving it. - - framepointer - # Check for mistakes using HTTP responses. - - httpresponse - # Detect impossible interface-to-interface type assertions. - - ifaceassert - # Check references to loop variables from within nested functions. - - loopclosure - # Check cancel func returned by context.WithCancel is called. - - lostcancel - # Check for useless comparisons between functions and nil. - - nilfunc - # Check for redundant or impossible nil comparisons. - - nilness - # Check consistency of Printf format strings and arguments. - - printf - # Check for comparing reflect.Value values with == or reflect.DeepEqual. - - reflectvaluecompare - # Check for possible unintended shadowing of variables. - - shadow - # Check for shifts that equal or exceed the width of the integer. - - shift - # Check for unbuffered channel of os.Signal. - - sigchanyzer - # Check for invalid structured logging calls. - - slog - # Check the argument type of sort.Slice. - - sortslice - # Check signature of methods of well-known interfaces. - - stdmethods - # Report uses of too-new standard library symbols. - - stdversion - # Check for string(int) conversions. - - stringintconv - # Check that struct field tags conform to reflect.StructTag.Get. - - structtag - # Report calls to (*testing.T).Fatal from goroutines started by a test. - - testinggoroutine - # Check for common mistaken usages of tests and examples. - - tests - # Check for calls of (time.Time).Format or time.Parse with 2006-02-01. - - timeformat - # Report passing non-pointer or non-interface values to unmarshal. - - unmarshal - # Check for unreachable code. - - unreachable - # Check for invalid conversions of uintptr to unsafe.Pointer. - - unsafeptr - # Check for unused results of calls to some functions. - - unusedresult - # Checks for unused writes. - - unusedwrite - # Check for misuses of sync.WaitGroup. - - waitgroup - - # Enable all analyzers. - # Default: false - enable-all: true - # Disable analyzers by name. - # (in addition to default - # atomicalign, deepequalerrors, fieldalignment, findcall, nilness, reflectvaluecompare, shadow, sortslice, - # timeformat, unusedwrite - # ). - # Run `GL_DEBUG=govet golangci-lint run --enable=govet` to see default, all available analyzers, and enabled analyzers. - # Default: [] - disable: - - appends - - asmdecl - - assign - - atomic - - atomicalign - - bools - - buildtag - - cgocall - - composites - - copylocks - - deepequalerrors - - defers - - directive - - errorsas - - fieldalignment - - findcall - - framepointer - - httpresponse - - ifaceassert - - loopclosure - - lostcancel - - nilfunc - - nilness - - printf - - reflectvaluecompare - - shadow - - shift - - sigchanyzer - - slog - - sortslice - - stdmethods - - stdversion - - stringintconv - - structtag - - testinggoroutine - - tests - - timeformat - - unmarshal - - unreachable - - unsafeptr - - unusedresult - - unusedwrite - - waitgroup - - # Settings per analyzer. - settings: - # Analyzer name, run `go tool vet help` to see all analyzers. - printf: - # Comma-separated list of print function names to check (in addition to default, see `go tool vet help printf`). - # Default: [] - funcs: - - (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof - - (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf - - (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf - - (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf - shadow: - # Whether to be strict about shadowing; can be noisy. - # Default: false - strict: true - unusedresult: - # Comma-separated list of functions whose results must be used - # (in addition to default: - # context.WithCancel, context.WithDeadline, context.WithTimeout, context.WithValue, errors.New, fmt.Errorf, - # fmt.Sprint, fmt.Sprintf, sort.Reverse - # ). + use-field-name: true + # The field names to ignore. # Default: [] - funcs: - - pkg.MyFunc - # Comma-separated list of names of methods of type func() string whose results must be used - # (in addition to default Error,String) - # Default: [] - stringmethods: - - MyMethod - - grouper: - # Require the use of a single global 'const' declaration only. - # Default: false - const-require-single-const: true - # Require the use of grouped global 'const' declarations. - # Default: false - const-require-grouping: true - - # Require the use of a single 'import' declaration only. - # Default: false - import-require-single-import: true - # Require the use of grouped 'import' declarations. - # Default: false - import-require-grouping: true - - # Require the use of a single global 'type' declaration only. - # Default: false - type-require-single-type: true - # Require the use of grouped global 'type' declarations. - # Default: false - type-require-grouping: true - - # Require the use of a single global 'var' declaration only. - # Default: false - var-require-single-var: true - # Require the use of grouped global 'var' declarations. - # Default: false - var-require-grouping: true - - iface: - # List of analyzers. - # Default: ["identical"] - enable: - - identical # Identifies interfaces in the same package that have identical method sets. - - unused # Identifies interfaces that are not used anywhere in the same package where the interface is defined. - - opaque # Identifies functions that return interfaces, but the actual returned value is always a single concrete implementation. - settings: - unused: - # List of packages path to exclude from the check. + ignored-fields: + - Bar + - Foo + # Overrides the default/root configuration. # Default: [] - exclude: - - github.com/example/log - - importas: - # Do not allow unaliased imports of aliased packages. - # Default: false - no-unaliased: true - # Do not allow non-required aliases. - # Default: false - no-extra-aliases: true - # List of aliases - # Default: [] - alias: - # Using `servingv1` alias for `knative.dev/serving/pkg/apis/serving/v1` package. - - pkg: knative.dev/serving/pkg/apis/serving/v1 - alias: servingv1 - # Using `autoscalingv1alpha1` alias for `knative.dev/serving/pkg/apis/autoscaling/v1alpha1` package. - - pkg: knative.dev/serving/pkg/apis/autoscaling/v1alpha1 - alias: autoscalingv1alpha1 - # You can specify the package path by regular expression, - # and alias by regular expression expansion syntax like below. - # see https://github.com/julz/importas#use-regular-expression for details - - pkg: knative.dev/serving/pkg/apis/(\w+)/(v[\w\d]+) - alias: $1$2 - # An explicit empty alias can be used to ensure no aliases are used for a package. - # This can be useful if `no-extra-aliases: true` doesn't fit your need. - # Multiple packages can use an empty alias. - - pkg: errors - alias: "" - - inamedparam: - # Skips check for interface methods with only a single parameter. - # Default: false - skip-single-param: true + overrides: + - + # The package path (uses `/` only as a separator). + # Required + pkg: foo/bar + # Default: empty or the same as the default/root configuration. + rules: + json: snake + xml: pascal + # Default: empty or the same as the default/root configuration. + extended-rules: + # Same options as the base `extended-rules`. + # Default: false (WARNING: it doesn't follow the default/root configuration) + use-field-name: true + # The field names to ignore. + # Default: [] or the same as the default/root configuration. + ignored-fields: + - Bar + - Foo + # Ignore the package (takes precedence over all other configurations). + # Default: false + ignore: true + + tenv: + # The option `all` will run against whole test files (`_test.go`) regardless of method/function signatures. + # Otherwise, only methods that take `*testing.T`, `*testing.B`, and `testing.TB` as arguments are checked. + # Default: false + all: false - interfacebloat: - # The maximum number of methods allowed for an interface. - # Default: 10 - max: 5 + testifylint: + # Enable all checkers (https://github.com/Antonboom/testifylint#checkers). + # Default: false + enable-all: true + # Disable checkers by name + # (in addition to default + # suite-thelper + # ). + disable: + - blank-import + - bool-compare + - compares + - contains + - empty + - encoded-compare + - error-is-as + - error-nil + - expected-actual + - float-compare + - formatter + - go-require + - len + - negative-positive + - nil-compare + - regexp + - require-error + - suite-broken-parallel + - suite-dont-use-pkg + - suite-extra-assert-call + - suite-subtest-run + - suite-thelper + - useless-assert + + # Disable all checkers (https://github.com/Antonboom/testifylint#checkers). + # Default: false + disable-all: true + # Enable checkers by name + # (in addition to default + # blank-import, bool-compare, compares, contains, empty, encoded-compare, error-is-as, error-nil, expected-actual, + # go-require, float-compare, formatter, len, negative-positive, nil-compare, regexp, require-error, + # suite-broken-parallel, suite-dont-use-pkg, suite-extra-assert-call, suite-subtest-run, useless-assert + # ). + enable: + - blank-import + - bool-compare + - compares + - contains + - empty + - encoded-compare + - error-is-as + - error-nil + - expected-actual + - float-compare + - formatter + - go-require + - len + - negative-positive + - nil-compare + - regexp + - require-error + - suite-broken-parallel + - suite-dont-use-pkg + - suite-extra-assert-call + - suite-subtest-run + - suite-thelper + - useless-assert + + bool-compare: + # To ignore user defined types (over builtin bool). + # Default: false + ignore-custom-types: true + expected-actual: + # Regexp for expected variable name. + # Default: (^(exp(ected)?|want(ed)?)([A-Z]\w*)?$)|(^(\w*[a-z])?(Exp(ected)?|Want(ed)?)$) + pattern: ^expected + formatter: + # To enable go vet's printf checks. + # Default: true + check-format-string: false + # To require f-assertions (e.g. `assert.Equalf`) if format string is used, even if there are no variable-length + # variables, i.e. it requires `require.NoErrorf` for both these cases: + # - require.NoErrorf(t, err, "unexpected error") + # - require.NoErrorf(t, err, "unexpected error for sid: %v", sid) + # To understand this behavior, please read the + # https://github.com/Antonboom/testifylint?tab=readme-ov-file#historical-reference-of-formatter. + # Default: false + require-f-funcs: true + go-require: + # To ignore HTTP handlers (like http.HandlerFunc). + # Default: false + ignore-http-handlers: true + require-error: + # Regexp for assertions to analyze. If defined, then only matched error assertions will be reported. + # Default: "" + fn-pattern: ^(Errorf?|NoErrorf?)$ + suite-extra-assert-call: + # To require or remove extra Assert() call? + # Default: remove + mode: require + + testpackage: + # Regexp pattern to skip files. + # Default: "(export|internal)_test\\.go" + skip-regexp: (export|internal)_test\.go + # List of packages that don't end with _test that tests are allowed to be in. + # Default: "main" + allow-packages: + - example + - main + + thelper: + test: + # Check *testing.T is first param (or after context.Context) of helper function. + # Default: true + first: false + # Check *testing.T param has name t. + # Default: true + name: false + # Check t.Helper() begins helper function. + # Default: true + begin: false + benchmark: + # Check *testing.B is first param (or after context.Context) of helper function. + # Default: true + first: false + # Check *testing.B param has name b. + # Default: true + name: false + # Check b.Helper() begins helper function. + # Default: true + begin: false + tb: + # Check *testing.TB is first param (or after context.Context) of helper function. + # Default: true + first: false + # Check *testing.TB param has name tb. + # Default: true + name: false + # Check tb.Helper() begins helper function. + # Default: true + begin: false + fuzz: + # Check *testing.F is first param (or after context.Context) of helper function. + # Default: true + first: false + # Check *testing.F param has name f. + # Default: true + name: false + # Check f.Helper() begins helper function. + # Default: true + begin: false - ireturn: - # List of interfaces to allow. - # Lists of the keywords and regular expressions matched to interface or package names can be used. - # `allow` and `reject` settings cannot be used at the same time. - # - # Keywords: - # - `empty` for `interface{}` - # - `error` for errors - # - `stdlib` for standard library - # - `anon` for anonymous interfaces - # - `generic` for generic interfaces added in go 1.18 - # - # Default: [anon, error, empty, stdlib] - allow: - - anon - # You can specify idiomatic endings for interface - - (or|er)$ - - # List of interfaces to reject. - # Lists of the keywords and regular expressions matched to interface or package names can be used. - # `allow` and `reject` settings cannot be used at the same time. - # - # Keywords: - # - `empty` for `interface{}` - # - `error` for errors - # - `stdlib` for standard library - # - `anon` for anonymous interfaces - # - `generic` for generic interfaces added in go 1.18 - # - # Default: [] - reject: - - github.com\/user\/package\/v4\.Type - - lll: - # Max line length, lines longer will be reported. - # '\t' is counted as 1 character by default, and can be changed with the tab-width option. - # Default: 120. - line-length: 120 - # Tab width in spaces. - # Default: 1 - tab-width: 1 - - loggercheck: - # Allow check for the github.com/go-kit/log library. - # Default: true - kitlog: false - # Allow check for the k8s.io/klog/v2 library. - # Default: true - klog: false - # Allow check for the github.com/go-logr/logr library. - # Default: true - logr: false - # Allow check for the log/slog library. - # Default: true - slog: false - # Allow check for the "sugar logger" from go.uber.org/zap library. - # Default: true - zap: false - # Require all logging keys to be inlined constant strings. - # Default: false - require-string-key: true - # Require printf-like format specifier (%s, %d for example) not present. - # Default: false - no-printf-like: true - # List of custom rules to check against, where each rule is a single logger pattern, useful for wrapped loggers. - # For example: https://github.com/timonwong/loggercheck/blob/7395ab86595781e33f7afba27ad7b55e6956ebcd/testdata/custom-rules.txt - # Default: empty - rules: - - k8s.io/klog/v2.InfoS # package level exported functions - - (github.com/go-logr/logr.Logger).Error # "Methods" - - (*go.uber.org/zap.SugaredLogger).With # Also "Methods", but with a pointer receiver - - maintidx: - # Show functions with maintainability index lower than N. - # A high index indicates better maintainability (it's kind of the opposite of complexity). - # Default: 20 - under: 100 - - makezero: - # Allow only slices initialized with a length of zero. - # Default: false - always: true - - misspell: - # Correct spellings using locale preferences for US or UK. - # Setting locale to US will correct the British spelling of 'colour' to 'color'. - # Default is to use a neutral variety of English. - locale: US - # Typos to ignore. - # Should be in lower case. - # Default: [] - ignore-rules: - - someword - # Extra word corrections. - # `typo` and `correction` should only contain letters. - # The words are case-insensitive. - # Default: [] - extra-words: - - typo: "iff" - correction: "if" - - typo: "cancelation" - correction: "cancellation" - # Mode of the analysis: - # - default: checks all the file content. - # - restricted: checks only comments. - # Default: "" - mode: restricted - - mnd: - # List of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description. - # Default: ["argument", "case", "condition", "operation", "return", "assign"] - checks: - - argument - - case - - condition - - operation - - return - - assign - # List of numbers to exclude from analysis. - # The numbers should be written as string. - # Values always ignored: "1", "1.0", "0" and "0.0" - # Default: [] - ignored-numbers: - - '0666' - - '0755' - - '42' - # List of file patterns to exclude from analysis. - # Values always ignored: `.+_test.go` - # Default: [] - ignored-files: - - 'magic1_.+\.go$' - # List of function patterns to exclude from analysis. - # Following functions are always ignored: `time.Date`, - # `strconv.FormatInt`, `strconv.FormatUint`, `strconv.FormatFloat`, - # `strconv.ParseInt`, `strconv.ParseUint`, `strconv.ParseFloat`. - # Default: [] - ignored-functions: - - '^math\.' - - '^http\.StatusText$' - - musttag: - # A set of custom functions to check in addition to the builtin ones. - # Default: json, xml, gopkg.in/yaml.v3, BurntSushi/toml, mitchellh/mapstructure, jmoiron/sqlx - functions: - # The full name of the function, including the package. - - name: github.com/hashicorp/hcl/v2/hclsimple.DecodeFile - # The struct tag whose presence should be ensured. - tag: hcl - # The position of the argument to check. - arg-pos: 2 - - nakedret: - # Make an issue if func has more lines of code than this setting, and it has naked returns. - # Default: 30 - max-func-lines: 31 - - nestif: - # Minimal complexity of if statements to report. - # Default: 5 - min-complexity: 4 - - nilnil: - # In addition, detect opposite situation (simultaneous return of non-nil error and valid value). - # Default: false - detect-opposite: true - # List of return types to check. - # Default: ["chan", "func", "iface", "map", "ptr", "uintptr", "unsafeptr"] - checked-types: - - chan - - func - - iface - - map - - ptr - - uintptr - - unsafeptr - - nlreturn: - # Size of the block (including return statement that is still "OK") - # so no return split required. - # Default: 1 - block-size: 2 - - nolintlint: - # Disable to ensure that all nolint directives actually have an effect. - # Default: false - allow-unused: true - # Exclude following linters from requiring an explanation. - # Default: [] - allow-no-explanation: [ ] - # Enable to require an explanation of nonzero length after each nolint directive. - # Default: false - require-explanation: true - # Enable to require nolint directives to mention the specific linter being suppressed. - # Default: false - require-specific: true + usestdlibvars: + # Suggest the use of http.MethodXX. + # Default: true + http-method: false + # Suggest the use of http.StatusXX. + # Default: true + http-status-code: false + # Suggest the use of time.Weekday.String(). + # Default: true + time-weekday: true + # Suggest the use of time.Month.String(). + # Default: false + time-month: true + # Suggest the use of time.Layout. + # Default: false + time-layout: true + # Suggest the use of crypto.Hash.String(). + # Default: false + crypto-hash: true + # Suggest the use of rpc.DefaultXXPath. + # Default: false + default-rpc-path: true + # Suggest the use of sql.LevelXX.String(). + # Default: false + sql-isolation-level: true + # Suggest the use of tls.SignatureScheme.String(). + # Default: false + tls-signature-scheme: true + # Suggest the use of constant.Kind.String(). + # Default: false + constant-kind: true - nonamedreturns: - # Report named error if it is assigned inside defer. - # Default: false - report-error-in-defer: true + usetesting: + # Enable/disable `os.CreateTemp("", ...)` detections. + # Default: true + os-create-temp: false - 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 - perfsprint: - # Enable/disable optimization of integer formatting. - # Default: true - integer-format: false - # Optimizes even if it requires an int or uint type cast. - # Default: true - int-conversion: false - # Enable/disable optimization of error formatting. - # Default: true - error-format: false - # Optimizes into `err.Error()` even if it is only equivalent for non-nil errors. - # Default: false - err-error: true - # Optimizes `fmt.Errorf`. - # Default: true - errorf: false - # Enable/disable optimization of string formatting. - # Default: true - string-format: false - # Optimizes `fmt.Sprintf` with only one argument. - # Default: true - sprintf1: false - # Optimizes into strings concatenation. - # Default: true - strconcat: false - # Enable/disable optimization of bool formatting. - # Default: true - bool-format: false - # Enable/disable optimization of hex formatting. - # Default: true - hex-format: false - - prealloc: - # IMPORTANT: we don't recommend using this linter before doing performance profiling. - # For most programs usage of prealloc will be a premature optimization. - - # Report pre-allocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them. - # Default: true - simple: false - # Report pre-allocation suggestions on range loops. - # Default: true - range-loops: false - # Report pre-allocation suggestions on for loops. - # Default: false - for-loops: true + # Enable/disable `os.MkdirTemp()` detections. + # Default: true + os-mkdir-temp: false - predeclared: - # List of predeclared identifiers to not report on. - # Default: [] - ignore: - - new - - int - # Include method names and field names in checks. - # Default: false - qualified-name: true + # Enable/disable `os.Setenv()` detections. + # Default: true + os-setenv: false - promlinter: - # Promlinter cannot infer all metrics name in static analysis. - # Enable strict mode will also include the errors caused by failing to parse the args. - # Default: false - strict: true - # Please refer to https://github.com/yeya24/promlinter#usage for detailed usage. - # Default: [] - disabled-linters: - # Help detects issues related to the help text for a metric. - - Help - # MetricUnits detects issues with metric unit names. - - MetricUnits - # Counter detects issues specific to counters, as well as patterns that should only be used with counters. - - Counter - # HistogramSummaryReserved detects when other types of metrics use names or labels reserved for use by histograms and/or summaries. - - HistogramSummaryReserved - # MetricTypeInName detects when metric types are included in the metric name. - - MetricTypeInName - # ReservedChars detects colons in metric names. - - ReservedChars - # CamelCase detects metric names and label names written in camelCase. - - CamelCase - # UnitAbbreviations detects abbreviated units in the metric name. - - UnitAbbreviations - - - protogetter: - # Skip files generated by specified generators from the checking. - # Checks only the file's initial comment, which must follow the format: "// Code generated by ". - # Files generated by protoc-gen-go, protoc-gen-go-grpc, and protoc-gen-grpc-gateway are always excluded automatically. - # Default: [] - skip-generated-by: ["protoc-gen-go-my-own-generator"] - # Skip files matching the specified glob pattern from the checking. - # Default: [] - skip-files: - - "*.pb.go" - - "*/vendor/*" - - "/full/path/to/file.go" - # Skip any generated files from the checking. - # Default: false - skip-any-generated: true - # Skip first argument of append function. - # Default: false - replace-first-arg-in-append: true - - reassign: - # Patterns for global variable names that are checked for reassignment. - # See https://github.com/curioswitch/go-reassign#usage - # Default: ["EOF", "Err.*"] - patterns: - - ".*" - - recvcheck: - # Disables the built-in method exclusions: - # - `MarshalText` - # - `MarshalJSON` - # - `MarshalYAML` - # - `MarshalXML` - # - `MarshalBinary` - # - `GobEncode` - # Default: false - disable-builtin: true - # User-defined method exclusions. - # The format is `struct_name.method_name` (ex: `Foo.MethodName`). - # A wildcard `*` can use as a struct name (ex: `*.MethodName`). - # Default: [] - exclusions: - - "*.Value" + # Enable/disable `os.TempDir()` detections. + # Default: false + os-temp-dir: true - revive: - # Maximum number of open files at the same time. - # See https://github.com/mgechev/revive#command-line-flags - # Defaults to unlimited. - max-open-files: 2048 + # Enable/disable `os.Chdir()` detections. + # Disabled if Go < 1.24. + # Default: true + os-chdir: false - # Sets the default severity. - # See https://github.com/mgechev/revive#configuration - # Default: warning - severity: error + # Enable/disable `context.Background()` detections. + # Disabled if Go < 1.24. + # Default: true + context-background: false - # Enable all available rules. - # Default: false - enable-all-rules: true + # Enable/disable `context.TODO()` detections. + # Disabled if Go < 1.24. + # Default: true + context-todo: false - # Sets the default failure confidence. - # This means that linting errors with less than 0.8 confidence will be ignored. - # Default: 0.8 - confidence: 0.1 - # Run `GL_DEBUG=revive golangci-lint run --enable-only=revive` to see default, all available rules, and enabled rules. - rules: - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#add-constant - - name: add-constant - severity: warning - disabled: false - exclude: [""] - arguments: - - maxLitCount: "3" - allowStrs: '""' - allowInts: "0,1,2" - allowFloats: "0.0,0.,1.0,1.,2.0,2." - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#argument-limit - - name: argument-limit - severity: warning - disabled: false - exclude: [""] - arguments: [ 4 ] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#atomic - - name: atomic - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#banned-characters - - name: banned-characters - severity: warning - disabled: false - exclude: [""] - arguments: [ "Ω","Σ","σ", "7" ] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#bare-return - - name: bare-return - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#blank-imports - - name: blank-imports - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#bool-literal-in-expr - - name: bool-literal-in-expr - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#call-to-gc - - name: call-to-gc - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#cognitive-complexity - - name: cognitive-complexity - severity: warning - disabled: false - exclude: [""] - arguments: [ 7 ] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#comment-spacings - - name: comment-spacings - severity: warning - disabled: false - exclude: [""] - arguments: - - mypragma - - otherpragma - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#comments-density - - name: comments-density - severity: warning - disabled: false - exclude: [""] - arguments: [ 15 ] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#confusing-naming - - name: confusing-naming - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#confusing-results - - name: confusing-results - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#constant-logical-expr - - name: constant-logical-expr - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#context-as-argument - - name: context-as-argument - severity: warning - disabled: false - exclude: [""] - arguments: - - allowTypesBefore: "*testing.T,*github.com/user/repo/testing.Harness" - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#context-keys-type - - name: context-keys-type - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#cyclomatic - - name: cyclomatic - severity: warning - disabled: false - exclude: [""] - arguments: [ 3 ] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#datarace - - name: datarace - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#deep-exit - - name: deep-exit - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#defer - - name: defer - severity: warning - disabled: false - exclude: [""] - arguments: - - [ "call-chain", "loop" ] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#dot-imports - - name: dot-imports - severity: warning - disabled: false - exclude: [""] - arguments: [ ] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#duplicated-imports - - name: duplicated-imports - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#early-return - - name: early-return - severity: warning - disabled: false - exclude: [""] - arguments: - - "preserveScope" - - "allowJump" - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#empty-block - - name: empty-block - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#empty-lines - - name: empty-lines - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#enforce-map-style - - name: enforce-map-style - severity: warning - disabled: false - exclude: [""] - arguments: - - "make" - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#enforce-repeated-arg-type-style - - name: enforce-repeated-arg-type-style - severity: warning - disabled: false - exclude: [""] - arguments: - - "short" - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#enforce-slice-style - - name: enforce-slice-style - severity: warning - disabled: false - exclude: [""] - arguments: - - "make" - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#error-naming - - name: error-naming - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#error-return - - name: error-return - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#error-strings - - name: error-strings - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#errorf - - name: errorf - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#exported - - name: exported - severity: warning - disabled: false - exclude: [""] - arguments: - - "checkPrivateReceivers" - - "disableStutteringCheck" - - "checkPublicInterface" - - "disableChecksOnFunctions" - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#file-header - - name: file-header - severity: warning - disabled: false - exclude: [""] - arguments: - - This is the text that must appear at the top of source files. - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#file-length-limit - - name: file-length-limit - severity: warning - disabled: false - exclude: [""] - arguments: - - max: 100 - skipComments: true - skipBlankLines: true - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#filename-format - - name: filename-format - severity: warning - disabled: false - exclude: [""] - arguments: - - "^[_a-z][_a-z0-9]*\\.go$" - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#flag-parameter - - name: flag-parameter - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#function-length - - name: function-length - severity: warning - disabled: false - exclude: [""] - arguments: [ 10, 0 ] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#function-result-limit - - name: function-result-limit - severity: warning - disabled: false - exclude: [""] - arguments: [ 3 ] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#get-return - - name: get-return - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#identical-branches - - name: identical-branches - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#if-return - - name: if-return - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#import-alias-naming - - name: import-alias-naming - severity: warning - disabled: false - exclude: [""] - arguments: - - "^[a-z][a-z0-9]{0,}$" - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#import-shadowing - - name: import-shadowing - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#imports-blocklist - - name: imports-blocklist - severity: warning - disabled: false - exclude: [""] - arguments: - - "crypto/md5" - - "crypto/sha1" - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#increment-decrement - - name: increment-decrement - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#indent-error-flow - - name: indent-error-flow - severity: warning - disabled: false - exclude: [""] - arguments: - - "preserveScope" - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#line-length-limit - - name: line-length-limit - severity: warning - disabled: false - exclude: [""] - arguments: [ 80 ] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#max-control-nesting - - name: max-control-nesting - severity: warning - disabled: false - exclude: [""] - arguments: [ 3 ] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#max-public-structs - - name: max-public-structs - severity: warning - disabled: false - exclude: [""] - arguments: [ 3 ] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#modifies-parameter - - name: modifies-parameter - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#modifies-value-receiver - - name: modifies-value-receiver - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#nested-structs - - name: nested-structs - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#optimize-operands-order - - name: optimize-operands-order - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#package-comments - - name: package-comments - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#range - - name: range - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#range-val-address - - name: range-val-address - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#range-val-in-closure - - name: range-val-in-closure - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#receiver-naming - - name: receiver-naming - severity: warning - disabled: false - exclude: [""] - arguments: - - maxLength: 2 - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#redefines-builtin-id - - name: redefines-builtin-id - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#redundant-build-tag - - name: redundant-build-tag - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#redundant-import-alias - - name: redundant-import-alias - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#string-format - - name: string-format - severity: warning - disabled: false - exclude: [""] - arguments: - - - 'core.WriteError[1].Message' - - '/^([^A-Z]|$)/' - - must not start with a capital letter - - - 'fmt.Errorf[0]' - - '/(^|[^\.!?])$/' - - must not end in punctuation - - - panic - - '/^[^\n]*$/' - - must not contain line breaks - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#string-of-int - - name: string-of-int - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#struct-tag - - name: struct-tag - severity: warning - disabled: false - exclude: [""] - arguments: - - "json,inline" - - "bson,outline,gnu" - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#superfluous-else - - name: superfluous-else - severity: warning - disabled: false - exclude: [""] - arguments: - - "preserveScope" - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#time-equal - - name: time-equal - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#time-naming - - name: time-naming - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#unchecked-type-assertion - - name: unchecked-type-assertion - severity: warning - disabled: false - exclude: [""] - arguments: - - acceptIgnoredAssertionResult: true - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#unconditional-recursion - - name: unconditional-recursion - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#unexported-naming - - name: unexported-naming - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#unexported-return - - name: unexported-return - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#unhandled-error - - name: unhandled-error - severity: warning - disabled: false - exclude: [""] - arguments: - - "fmt.Printf" - - "myFunction" - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#unnecessary-stmt - - name: unnecessary-stmt - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#unreachable-code - - name: unreachable-code - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#unused-parameter - - name: unused-parameter - severity: warning - disabled: false - exclude: [""] - arguments: - - allowRegex: "^_" - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#unused-receiver - - name: unused-receiver - severity: warning - disabled: false - exclude: [""] - arguments: - - allowRegex: "^_" - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#use-any - - name: use-any - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#use-errors-new - - name: use-errors-new - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#useless-break - - name: useless-break - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#var-declaration - - name: var-declaration - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#var-naming - - name: var-naming - severity: warning - disabled: false - exclude: [""] - arguments: - - [ "ID" ] # AllowList - - [ "VM" ] # DenyList - - - upperCaseConst: true # Extra parameter (upperCaseConst|skipPackageNameChecks) - # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#waitgroup-by-value - - name: waitgroup-by-value - severity: warning - disabled: false - exclude: [""] - - rowserrcheck: - # database/sql is always checked - # Default: [] - packages: - - github.com/jmoiron/sqlx - - sloglint: - # Enforce not mixing key-value pairs and attributes. - # https://github.com/go-simpler/sloglint?tab=readme-ov-file#no-mixed-arguments - # Default: true - no-mixed-args: false - # Enforce using key-value pairs only (overrides no-mixed-args, incompatible with attr-only). - # https://github.com/go-simpler/sloglint?tab=readme-ov-file#key-value-pairs-only - # Default: false - kv-only: true - # Enforce using attributes only (overrides no-mixed-args, incompatible with kv-only). - # https://github.com/go-simpler/sloglint?tab=readme-ov-file#attributes-only - # Default: false - attr-only: true - # Enforce not using global loggers. - # Values: - # - "": disabled - # - "all": report all global loggers - # - "default": report only the default slog logger - # https://github.com/go-simpler/sloglint?tab=readme-ov-file#no-global - # Default: "" - no-global: "all" - # Enforce using methods that accept a context. - # Values: - # - "": disabled - # - "all": report all contextless calls - # - "scope": report only if a context exists in the scope of the outermost function - # https://github.com/go-simpler/sloglint?tab=readme-ov-file#context-only - # Default: "" - context: "all" - # Enforce using static values for log messages. - # https://github.com/go-simpler/sloglint?tab=readme-ov-file#static-messages - # Default: false - static-msg: true - # Enforce using constants instead of raw keys. - # https://github.com/go-simpler/sloglint?tab=readme-ov-file#no-raw-keys - # Default: false - no-raw-keys: true - # Enforce a single key naming convention. - # Values: snake, kebab, camel, pascal - # https://github.com/go-simpler/sloglint?tab=readme-ov-file#key-naming-convention - # Default: "" - key-naming-case: snake - # Enforce not using specific keys. - # https://github.com/go-simpler/sloglint?tab=readme-ov-file#forbidden-keys - # Default: [] - forbidden-keys: - - time - - level - - msg - - source - - foo - # Enforce putting arguments on separate lines. - # https://github.com/go-simpler/sloglint?tab=readme-ov-file#arguments-on-separate-lines - # Default: false - args-on-sep-lines: true - - spancheck: - # Checks to enable. - # Options include: - # - `end`: check that `span.End()` is called - # - `record-error`: check that `span.RecordError(err)` is called when an error is returned - # - `set-status`: check that `span.SetStatus(codes.Error, msg)` is called when an error is returned - # Default: ["end"] - checks: - - end - - record-error - - set-status - # A list of regexes for function signatures that silence `record-error` and `set-status` reports - # if found in the call path to a returned error. - # https://github.com/jjti/go-spancheck#ignore-check-signatures - # Default: [] - ignore-check-signatures: - - "telemetry.RecordError" - # A list of regexes for additional function signatures that create spans. - # This is useful if you have a utility method to create spans. - # Each entry should be of the form `:`, where `telemetry-type` can be `opentelemetry` or `opencensus`. - # https://github.com/jjti/go-spancheck#extra-start-span-signatures - # Default: [] - extra-start-span-signatures: - - "github.com/user/repo/telemetry/trace.Start:opentelemetry" - staticcheck: - # SAxxxx checks in https://staticcheck.dev/docs/configuration/options/#checks - # Example (to disable some checks): [ "all", "-SA1000", "-SA1001"] - # Default: ["*"] - checks: - # Invalid regular expression. - # https://staticcheck.dev/docs/checks/#SA1000 - - SA1000 - # Invalid template. - # https://staticcheck.dev/docs/checks/#SA1001 - - SA1001 - # Invalid format in 'time.Parse'. - # https://staticcheck.dev/docs/checks/#SA1002 - - SA1002 - # Unsupported argument to functions in 'encoding/binary'. - # https://staticcheck.dev/docs/checks/#SA1003 - - SA1003 - # Suspiciously small untyped constant in 'time.Sleep'. - # https://staticcheck.dev/docs/checks/#SA1004 - - SA1004 - # Invalid first argument to 'exec.Command'. - # https://staticcheck.dev/docs/checks/#SA1005 - - SA1005 - # 'Printf' with dynamic first argument and no further arguments. - # https://staticcheck.dev/docs/checks/#SA1006 - - SA1006 - # Invalid URL in 'net/url.Parse'. - # https://staticcheck.dev/docs/checks/#SA1007 - - SA1007 - # Non-canonical key in 'http.Header' map. - # https://staticcheck.dev/docs/checks/#SA1008 - - SA1008 - # '(*regexp.Regexp).FindAll' called with 'n == 0', which will always return zero results. - # https://staticcheck.dev/docs/checks/#SA1010 - - SA1010 - # Various methods in the "strings" package expect valid UTF-8, but invalid input is provided. - # https://staticcheck.dev/docs/checks/#SA1011 - - SA1011 - # A nil 'context.Context' is being passed to a function, consider using 'context.TODO' instead. - # https://staticcheck.dev/docs/checks/#SA1012 - - SA1012 - # 'io.Seeker.Seek' is being called with the whence constant as the first argument, but it should be the second. - # https://staticcheck.dev/docs/checks/#SA1013 - - SA1013 - # Non-pointer value passed to 'Unmarshal' or 'Decode'. - # https://staticcheck.dev/docs/checks/#SA1014 - - SA1014 - # Using 'time.Tick' in a way that will leak. Consider using 'time.NewTicker', and only use 'time.Tick' in tests, commands and endless functions. - # https://staticcheck.dev/docs/checks/#SA1015 - - SA1015 - # Trapping a signal that cannot be trapped. - # https://staticcheck.dev/docs/checks/#SA1016 - - SA1016 - # Channels used with 'os/signal.Notify' should be buffered. - # https://staticcheck.dev/docs/checks/#SA1017 - - SA1017 - # 'strings.Replace' called with 'n == 0', which does nothing. - # https://staticcheck.dev/docs/checks/#SA1018 - - SA1018 - # Using a deprecated function, variable, constant or field. - # https://staticcheck.dev/docs/checks/#SA1019 - - SA1019 - # Using an invalid host:port pair with a 'net.Listen'-related function. - # https://staticcheck.dev/docs/checks/#SA1020 - - SA1020 - # Using 'bytes.Equal' to compare two 'net.IP'. - # https://staticcheck.dev/docs/checks/#SA1021 - - SA1021 - # Modifying the buffer in an 'io.Writer' implementation. - # https://staticcheck.dev/docs/checks/#SA1023 - - SA1023 - # A string cutset contains duplicate characters. - # https://staticcheck.dev/docs/checks/#SA1024 - - SA1024 - # It is not possible to use '(*time.Timer).Reset''s return value correctly. - # https://staticcheck.dev/docs/checks/#SA1025 - - SA1025 - # Cannot marshal channels or functions. - # https://staticcheck.dev/docs/checks/#SA1026 - - SA1026 - # Atomic access to 64-bit variable must be 64-bit aligned. - # https://staticcheck.dev/docs/checks/#SA1027 - - SA1027 - # 'sort.Slice' can only be used on slices. - # https://staticcheck.dev/docs/checks/#SA1028 - - SA1028 - # Inappropriate key in call to 'context.WithValue'. - # https://staticcheck.dev/docs/checks/#SA1029 - - SA1029 - # Invalid argument in call to a 'strconv' function. - # https://staticcheck.dev/docs/checks/#SA1030 - - SA1030 - # Overlapping byte slices passed to an encoder. - # https://staticcheck.dev/docs/checks/#SA1031 - - SA1031 - # Wrong order of arguments to 'errors.Is'. - # https://staticcheck.dev/docs/checks/#SA1032 - - SA1032 - # 'sync.WaitGroup.Add' called inside the goroutine, leading to a race condition. - # https://staticcheck.dev/docs/checks/#SA2000 - - SA2000 - # Empty critical section, did you mean to defer the unlock?. - # https://staticcheck.dev/docs/checks/#SA2001 - - SA2001 - # Called 'testing.T.FailNow' or 'SkipNow' in a goroutine, which isn't allowed. - # https://staticcheck.dev/docs/checks/#SA2002 - - SA2002 - # Deferred 'Lock' right after locking, likely meant to defer 'Unlock' instead. - # https://staticcheck.dev/docs/checks/#SA2003 - - SA2003 - # 'TestMain' doesn't call 'os.Exit', hiding test failures. - # https://staticcheck.dev/docs/checks/#SA3000 - - SA3000 - # Assigning to 'b.N' in benchmarks distorts the results. - # https://staticcheck.dev/docs/checks/#SA3001 - - SA3001 - # Binary operator has identical expressions on both sides. - # https://staticcheck.dev/docs/checks/#SA4000 - - SA4000 - # '&*x' gets simplified to 'x', it does not copy 'x'. - # https://staticcheck.dev/docs/checks/#SA4001 - - SA4001 - # Comparing unsigned values against negative values is pointless. - # https://staticcheck.dev/docs/checks/#SA4003 - - SA4003 - # The loop exits unconditionally after one iteration. - # https://staticcheck.dev/docs/checks/#SA4004 - - SA4004 - # Field assignment that will never be observed. Did you mean to use a pointer receiver?. - # https://staticcheck.dev/docs/checks/#SA4005 - - SA4005 - # A value assigned to a variable is never read before being overwritten. Forgotten error check or dead code?. - # https://staticcheck.dev/docs/checks/#SA4006 - - SA4006 - # The variable in the loop condition never changes, are you incrementing the wrong variable?. - # https://staticcheck.dev/docs/checks/#SA4008 - - SA4008 - # A function argument is overwritten before its first use. - # https://staticcheck.dev/docs/checks/#SA4009 - - SA4009 - # The result of 'append' will never be observed anywhere. - # https://staticcheck.dev/docs/checks/#SA4010 - - SA4010 - # Break statement with no effect. Did you mean to break out of an outer loop?. - # https://staticcheck.dev/docs/checks/#SA4011 - - SA4011 - # Comparing a value against NaN even though no value is equal to NaN. - # https://staticcheck.dev/docs/checks/#SA4012 - - SA4012 - # Negating a boolean twice ('!!b') is the same as writing 'b'. This is either redundant, or a typo. - # https://staticcheck.dev/docs/checks/#SA4013 - - SA4013 - # An if/else if chain has repeated conditions and no side-effects; if the condition didn't match the first time, it won't match the second time, either. - # https://staticcheck.dev/docs/checks/#SA4014 - - SA4014 - # Calling functions like 'math.Ceil' on floats converted from integers doesn't do anything useful. - # https://staticcheck.dev/docs/checks/#SA4015 - - SA4015 - # Certain bitwise operations, such as 'x ^ 0', do not do anything useful. - # https://staticcheck.dev/docs/checks/#SA4016 - - SA4016 - # Discarding the return values of a function without side effects, making the call pointless. - # https://staticcheck.dev/docs/checks/#SA4017 - - SA4017 - # Self-assignment of variables. - # https://staticcheck.dev/docs/checks/#SA4018 - - SA4018 - # Multiple, identical build constraints in the same file. - # https://staticcheck.dev/docs/checks/#SA4019 - - SA4019 - # Unreachable case clause in a type switch. - # https://staticcheck.dev/docs/checks/#SA4020 - - SA4020 - # "x = append(y)" is equivalent to "x = y". - # https://staticcheck.dev/docs/checks/#SA4021 - - SA4021 - # Comparing the address of a variable against nil. - # https://staticcheck.dev/docs/checks/#SA4022 - - SA4022 - # Impossible comparison of interface value with untyped nil. - # https://staticcheck.dev/docs/checks/#SA4023 - - SA4023 - # Checking for impossible return value from a builtin function. - # https://staticcheck.dev/docs/checks/#SA4024 - - SA4024 - # Integer division of literals that results in zero. - # https://staticcheck.dev/docs/checks/#SA4025 - - SA4025 - # Go constants cannot express negative zero. - # https://staticcheck.dev/docs/checks/#SA4026 - - SA4026 - # '(*net/url.URL).Query' returns a copy, modifying it doesn't change the URL. - # https://staticcheck.dev/docs/checks/#SA4027 - - SA4027 - # 'x % 1' is always zero. - # https://staticcheck.dev/docs/checks/#SA4028 - - SA4028 - # Ineffective attempt at sorting slice. - # https://staticcheck.dev/docs/checks/#SA4029 - - SA4029 - # Ineffective attempt at generating random number. - # https://staticcheck.dev/docs/checks/#SA4030 - - SA4030 - # Checking never-nil value against nil. - # https://staticcheck.dev/docs/checks/#SA4031 - - SA4031 - # Comparing 'runtime.GOOS' or 'runtime.GOARCH' against impossible value. - # https://staticcheck.dev/docs/checks/#SA4032 - - SA4032 - # Assignment to nil map. - # https://staticcheck.dev/docs/checks/#SA5000 - - SA5000 - # Deferring 'Close' before checking for a possible error. - # https://staticcheck.dev/docs/checks/#SA5001 - - SA5001 - # The empty for loop ("for {}") spins and can block the scheduler. - # https://staticcheck.dev/docs/checks/#SA5002 - - SA5002 - # Defers in infinite loops will never execute. - # https://staticcheck.dev/docs/checks/#SA5003 - - SA5003 - # "for { select { ..." with an empty default branch spins. - # https://staticcheck.dev/docs/checks/#SA5004 - - SA5004 - # The finalizer references the finalized object, preventing garbage collection. - # https://staticcheck.dev/docs/checks/#SA5005 - - SA5005 - # Infinite recursive call. - # https://staticcheck.dev/docs/checks/#SA5007 - - SA5007 - # Invalid struct tag. - # https://staticcheck.dev/docs/checks/#SA5008 - - SA5008 - # Invalid Printf call. - # https://staticcheck.dev/docs/checks/#SA5009 - - SA5009 - # Impossible type assertion. - # https://staticcheck.dev/docs/checks/#SA5010 - - SA5010 - # Possible nil pointer dereference. - # https://staticcheck.dev/docs/checks/#SA5011 - - SA5011 - # Passing odd-sized slice to function expecting even size. - # https://staticcheck.dev/docs/checks/#SA5012 - - SA5012 - # Using 'regexp.Match' or related in a loop, should use 'regexp.Compile'. - # https://staticcheck.dev/docs/checks/#SA6000 - - SA6000 - # Missing an optimization opportunity when indexing maps by byte slices. - # https://staticcheck.dev/docs/checks/#SA6001 - - SA6001 - # Storing non-pointer values in 'sync.Pool' allocates memory. - # https://staticcheck.dev/docs/checks/#SA6002 - - SA6002 - # Converting a string to a slice of runes before ranging over it. - # https://staticcheck.dev/docs/checks/#SA6003 - - SA6003 - # Inefficient string comparison with 'strings.ToLower' or 'strings.ToUpper'. - # https://staticcheck.dev/docs/checks/#SA6005 - - SA6005 - # Using io.WriteString to write '[]byte'. - # https://staticcheck.dev/docs/checks/#SA6006 - - SA6006 - # Defers in range loops may not run when you expect them to. - # https://staticcheck.dev/docs/checks/#SA9001 - - SA9001 - # Using a non-octal 'os.FileMode' that looks like it was meant to be in octal. - # https://staticcheck.dev/docs/checks/#SA9002 - - SA9002 - # Empty body in an if or else branch. - # https://staticcheck.dev/docs/checks/#SA9003 - - SA9003 - # Only the first constant has an explicit type. - # https://staticcheck.dev/docs/checks/#SA9004 - - SA9004 - # Trying to marshal a struct with no public fields nor custom marshaling. - # https://staticcheck.dev/docs/checks/#SA9005 - - SA9005 - # Dubious bit shifting of a fixed size integer value. - # https://staticcheck.dev/docs/checks/#SA9006 - - SA9006 - # Deleting a directory that shouldn't be deleted. - # https://staticcheck.dev/docs/checks/#SA9007 - - SA9007 - # 'else' branch of a type assertion is probably not reading the right value. - # https://staticcheck.dev/docs/checks/#SA9008 - - SA9008 - # Ineffectual Go compiler directive. - # https://staticcheck.dev/docs/checks/#SA9009 - - SA9009 - - stylecheck: - # https://staticcheck.dev/docs/configuration/options/#dot_import_whitelist - # Default: ["github.com/mmcloughlin/avo/build", "github.com/mmcloughlin/avo/operand", "github.com/mmcloughlin/avo/reg"] - dot-import-whitelist: - - fmt - # https://staticcheck.dev/docs/configuration/options/#initialisms - # Default: ["ACL", "API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", "IP", "JSON", "QPS", "RAM", "RPC", "SLA", "SMTP", "SQL", "SSH", "TCP", "TLS", "TTL", "UDP", "UI", "GID", "UID", "UUID", "URI", "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", "XSS", "SIP", "RTP", "AMQP", "DB", "TS"] - initialisms: [ "ACL", "API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", "IP", "JSON", "QPS", "RAM", "RPC", "SLA", "SMTP", "SQL", "SSH", "TCP", "TLS", "TTL", "UDP", "UI", "GID", "UID", "UUID", "URI", "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", "XSS", "SIP", "RTP", "AMQP", "DB", "TS" ] - # https://staticcheck.dev/docs/configuration/options/#http_status_code_whitelist - # Default: ["200", "400", "404", "500"] - http-status-code-whitelist: [ "200", "400", "404", "500" ] - # STxxxx checks in https://staticcheck.dev/docs/configuration/options/#checks - # Example (to disable some checks): [ "all", "-ST1000", "-ST1003", "-ST1016", "-ST1020", "-ST1021", "-ST1022" ] - # Default: ["*"] - checks: - # Incorrect or missing package comment. - # https://staticcheck.dev/docs/checks/#ST1000 - - ST1000 - # Dot imports are discouraged. - # https://staticcheck.dev/docs/checks/#ST1001 - - ST1001 - # Poorly chosen identifier. - # https://staticcheck.dev/docs/checks/#ST1003 - - ST1003 - # Incorrectly formatted error string. - # https://staticcheck.dev/docs/checks/#ST1005 - - ST1005 - # Poorly chosen receiver name. - # https://staticcheck.dev/docs/checks/#ST1006 - - ST1006 - # A function's error value should be its last return value. - # https://staticcheck.dev/docs/checks/#ST1008 - - ST1008 - # Poorly chosen name for variable of type 'time.Duration'. - # https://staticcheck.dev/docs/checks/#ST1011 - - ST1011 - # Poorly chosen name for error variable. - # https://staticcheck.dev/docs/checks/#ST1012 - - ST1012 - # Should use constants for HTTP error codes, not magic numbers. - # https://staticcheck.dev/docs/checks/#ST1013 - - ST1013 - # A switch's default case should be the first or last case. - # https://staticcheck.dev/docs/checks/#ST1015 - - ST1015 - # Use consistent method receiver names. - # https://staticcheck.dev/docs/checks/#ST1016 - - ST1016 - # Don't use Yoda conditions. - # https://staticcheck.dev/docs/checks/#ST1017 - - ST1017 - # Avoid zero-width and control characters in string literals. - # https://staticcheck.dev/docs/checks/#ST1018 - - ST1018 - # Importing the same package multiple times. - # https://staticcheck.dev/docs/checks/#ST1019 - - ST1019 - # The documentation of an exported function should start with the function's name. - # https://staticcheck.dev/docs/checks/#ST1020 - - ST1020 - # The documentation of an exported type should start with type's name. - # https://staticcheck.dev/docs/checks/#ST1021 - - ST1021 - # The documentation of an exported variable or constant should start with variable's name. - # https://staticcheck.dev/docs/checks/#ST1022 - - ST1022 - # Redundant type in variable declaration. - # https://staticcheck.dev/docs/checks/#ST1023 - - ST1023 - - tagalign: - # Align and sort can be used together or separately. - # - # Whether enable align. If true, the struct tags will be aligned. - # e.g.: - # type FooBar struct { - # Bar string `json:"bar" validate:"required"` - # FooFoo int8 `json:"foo_foo" validate:"required"` - # } - # will be formatted to: - # type FooBar struct { - # Bar string `json:"bar" validate:"required"` - # FooFoo int8 `json:"foo_foo" validate:"required"` - # } - # Default: true. - align: false - # Whether enable tags sort. - # If true, the tags will be sorted by name in ascending order. - # e.g.: `xml:"bar" json:"bar" validate:"required"` -> `json:"bar" validate:"required" xml:"bar"` - # Default: true - sort: false - # Specify the order of tags, the other tags will be sorted by name. - # This option will be ignored if `sort` is false. - # Default: [] - order: - - json - - yaml - - yml - - toml - - mapstructure - - binding - - validate - # Whether enable strict style. - # In this style, the tags will be sorted and aligned in the dictionary order, - # and the tags with the same name will be aligned together. - # Note: This option will be ignored if 'align' or 'sort' is false. - # Default: false - strict: true - - tagliatelle: - # Checks the struct tag name case. - case: - # Defines the association between tag name and case. - # Any struct tag name can be used. - # Supported string cases: - # - `camel` - # - `pascal` - # - `kebab` - # - `snake` - # - `upperSnake` - # - `goCamel` - # - `goPascal` - # - `goKebab` - # - `goSnake` - # - `upper` - # - `lower` - # - `header` - rules: - json: camel - yaml: camel - xml: camel - toml: camel - bson: camel - avro: snake - mapstructure: kebab - env: upperSnake - envconfig: upperSnake - whatever: snake - # Defines the association between tag name and case. - # Important: the `extended-rules` overrides `rules`. - # Default: empty - extended-rules: - json: - # Supported string cases: - # - `camel` - # - `pascal` - # - `kebab` - # - `snake` - # - `upperSnake` - # - `goCamel` - # - `goPascal` - # - `goKebab` - # - `goSnake` - # - `header` - # - `lower` - # - `header` - # - # Required - case: camel - # Adds 'AMQP', 'DB', 'GID', 'RTP', 'SIP', 'TS' to initialisms, - # and removes 'LHS', 'RHS' from initialisms. - # Default: false - extra-initialisms: true - # Defines initialism additions and overrides. - # Default: empty - initialism-overrides: - DB: true # add a new initialism - LHS: false # disable a default initialism. - # ... - # Uses the struct field name to check the name of the struct tag. + unconvert: + # Remove conversions that force intermediate rounding. # Default: false - use-field-name: true - # The field names to ignore. - # Default: [] - ignored-fields: - - Bar - - Foo - # Overrides the default/root configuration. - # Default: [] - overrides: - - - # The package path (uses `/` only as a separator). - # Required - pkg: foo/bar - # Default: empty or the same as the default/root configuration. - rules: - json: snake - xml: pascal - # Default: empty or the same as the default/root configuration. - extended-rules: - # Same options as the base `extended-rules`. - # Default: false (WARNING: it doesn't follow the default/root configuration) - use-field-name: true - # The field names to ignore. - # Default: [] or the same as the default/root configuration. - ignored-fields: - - Bar - - Foo - # Ignore the package (takes precedence over all other configurations). - # Default: false - ignore: true + fast-math: true + # Be more conservative (experimental). + # Default: false + safe: true - tenv: - # The option `all` will run against whole test files (`_test.go`) regardless of method/function signatures. - # Otherwise, only methods that take `*testing.T`, `*testing.B`, and `testing.TB` as arguments are checked. - # Default: false - all: false + unparam: + # Inspect exported functions. + # + # Set to true if no external program/library imports your code. + # XXX: if you enable this setting, unparam will report a lot of false-positives in text editors: + # if it's called for subdir of a project it can't find external interfaces. All text editor integrations + # with golangci-lint call it on a directory with the changed file. + # + # Default: false + check-exported: true - testifylint: - # Enable all checkers (https://github.com/Antonboom/testifylint#checkers). - # Default: false - enable-all: true - # Disable checkers by name - # (in addition to default - # suite-thelper - # ). - disable: - - blank-import - - bool-compare - - compares - - contains - - empty - - encoded-compare - - error-is-as - - error-nil - - expected-actual - - float-compare - - formatter - - go-require - - len - - negative-positive - - nil-compare - - regexp - - require-error - - suite-broken-parallel - - suite-dont-use-pkg - - suite-extra-assert-call - - suite-subtest-run - - suite-thelper - - useless-assert - - # Disable all checkers (https://github.com/Antonboom/testifylint#checkers). - # Default: false - disable-all: true - # Enable checkers by name - # (in addition to default - # blank-import, bool-compare, compares, contains, empty, encoded-compare, error-is-as, error-nil, expected-actual, - # go-require, float-compare, formatter, len, negative-positive, nil-compare, regexp, require-error, - # suite-broken-parallel, suite-dont-use-pkg, suite-extra-assert-call, suite-subtest-run, useless-assert - # ). - enable: - - blank-import - - bool-compare - - compares - - contains - - empty - - encoded-compare - - error-is-as - - error-nil - - expected-actual - - float-compare - - formatter - - go-require - - len - - negative-positive - - nil-compare - - regexp - - require-error - - suite-broken-parallel - - suite-dont-use-pkg - - suite-extra-assert-call - - suite-subtest-run - - suite-thelper - - useless-assert - - bool-compare: - # To ignore user defined types (over builtin bool). + unused: + # Mark all struct fields that have been written to as used. + # Default: true + field-writes-are-uses: false + # Treat IncDec statement (e.g. `i++` or `i--`) as both read and write operation instead of just write. # Default: false - ignore-custom-types: true - expected-actual: - # Regexp for expected variable name. - # Default: (^(exp(ected)?|want(ed)?)([A-Z]\w*)?$)|(^(\w*[a-z])?(Exp(ected)?|Want(ed)?)$) - pattern: ^expected - formatter: - # To enable go vet's printf checks. + post-statements-are-reads: true + # Mark all exported fields as used. + # default: true + exported-fields-are-used: false + # Mark all function parameters as used. + # default: true + parameters-are-used: false + # Mark all local variables as used. + # default: true + local-variables-are-used: false + # Mark all identifiers inside generated files as used. # Default: true - check-format-string: false - # To require f-assertions (e.g. `assert.Equalf`) if format string is used, even if there are no variable-length - # variables, i.e. it requires `require.NoErrorf` for both these cases: - # - require.NoErrorf(t, err, "unexpected error") - # - require.NoErrorf(t, err, "unexpected error for sid: %v", sid) - # To understand this behavior, please read the - # https://github.com/Antonboom/testifylint?tab=readme-ov-file#historical-reference-of-formatter. + generated-is-used: false + + varnamelen: + # The longest distance, in source lines, that is being considered a "small scope". + # Variables used in at most this many lines will be ignored. + # Default: 5 + max-distance: 6 + # The minimum length of a variable's name that is considered "long". + # Variable names that are at least this long will be ignored. + # Default: 3 + min-name-length: 2 + # Check method receivers. # Default: false - require-f-funcs: true - go-require: - # To ignore HTTP handlers (like http.HandlerFunc). + check-receiver: true + # Check named return values. # Default: false - ignore-http-handlers: true - require-error: - # Regexp for assertions to analyze. If defined, then only matched error assertions will be reported. - # Default: "" - fn-pattern: ^(Errorf?|NoErrorf?)$ - suite-extra-assert-call: - # To require or remove extra Assert() call? - # Default: remove - mode: require - - testpackage: - # Regexp pattern to skip files. - # Default: "(export|internal)_test\\.go" - skip-regexp: (export|internal)_test\.go - # List of packages that don't end with _test that tests are allowed to be in. - # Default: "main" - allow-packages: - - example - - main - - thelper: - test: - # Check *testing.T is first param (or after context.Context) of helper function. - # Default: true - first: false - # Check *testing.T param has name t. - # Default: true - name: false - # Check t.Helper() begins helper function. - # Default: true - begin: false - benchmark: - # Check *testing.B is first param (or after context.Context) of helper function. - # Default: true - first: false - # Check *testing.B param has name b. - # Default: true - name: false - # Check b.Helper() begins helper function. - # Default: true - begin: false - tb: - # Check *testing.TB is first param (or after context.Context) of helper function. - # Default: true - first: false - # Check *testing.TB param has name tb. - # Default: true - name: false - # Check tb.Helper() begins helper function. - # Default: true - begin: false - fuzz: - # Check *testing.F is first param (or after context.Context) of helper function. + check-return: true + # Check type parameters. + # Default: false + check-type-param: true + # Ignore "ok" variables that hold the bool return value of a type assertion. + # Default: false + ignore-type-assert-ok: true + # Ignore "ok" variables that hold the bool return value of a map index. + # Default: false + ignore-map-index-ok: true + # Ignore "ok" variables that hold the bool return value of a channel receive. + # Default: false + ignore-chan-recv-ok: true + # Optional list of variable names that should be ignored completely. + # Default: [] + ignore-names: + - err + # Optional list of variable declarations that should be ignored completely. + # Entries must be in one of the following forms (see below for examples): + # - for variables, parameters, named return values, method receivers, or type parameters: + # ( can also be a pointer/slice/map/chan/...) + # - for constants: const + # + # Default: [] + ignore-decls: + - c echo.Context + - t testing.T + - f *foo.Bar + - e error + - i int + - const C + - T any + - m map[string]int + + whitespace: + # Enforces newlines (or comments) after every multi-line if statement. + # Default: false + multi-if: true + # Enforces newlines (or comments) after every multi-line function signature. + # Default: false + multi-func: true + + 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: + - encoding/* + - github.com/pkg/* + # An array of strings that specify regular expressions of interfaces to ignore. + # Default: [] + ignore-interface-regexps: + - ^(?i)c(?-i)ach(ing|e) + + wsl: + # Do strict checking when assigning from append (x = append(x, y)). + # If this is set to true - the append call must append either a variable + # assigned, called or used on the line above. + # https://github.com/bombsimon/wsl/blob/HEAD/doc/configuration.md#strict-append # Default: true - first: false - # Check *testing.F param has name f. + strict-append: false + + # Allows assignments to be cuddled with variables used in calls on + # line above and calls to be cuddled with assignments of variables + # used in call on line above. + # https://github.com/bombsimon/wsl/blob/HEAD/doc/configuration.md#allow-assign-and-call # Default: true - name: false - # Check f.Helper() begins helper function. + allow-assign-and-call: false + + # Allows assignments to be cuddled with anything. + # https://github.com/bombsimon/wsl/blob/HEAD/doc/configuration.md#allow-assign-and-anything + # Default: false + allow-assign-and-anything: true + + # Allows cuddling to assignments even if they span over multiple lines. + # https://github.com/bombsimon/wsl/blob/HEAD/doc/configuration.md#allow-multiline-assign # Default: true - begin: false - - usestdlibvars: - # Suggest the use of http.MethodXX. - # Default: true - http-method: false - # Suggest the use of http.StatusXX. - # Default: true - http-status-code: false - # Suggest the use of time.Weekday.String(). - # Default: true - time-weekday: true - # Suggest the use of time.Month.String(). - # Default: false - time-month: true - # Suggest the use of time.Layout. - # Default: false - time-layout: true - # Suggest the use of crypto.Hash.String(). - # Default: false - crypto-hash: true - # Suggest the use of rpc.DefaultXXPath. - # Default: false - default-rpc-path: true - # Suggest the use of sql.LevelXX.String(). - # Default: false - sql-isolation-level: true - # Suggest the use of tls.SignatureScheme.String(). - # Default: false - tls-signature-scheme: true - # Suggest the use of constant.Kind.String(). - # Default: false - constant-kind: true + allow-multiline-assign: false - usetesting: - # Enable/disable `os.CreateTemp("", ...)` detections. - # Default: true - os-create-temp: false + # If the number of lines in a case block is equal to or lager than this number, + # the case *must* end white a newline. + # https://github.com/bombsimon/wsl/blob/HEAD/doc/configuration.md#force-case-trailing-whitespace + # Default: 0 + force-case-trailing-whitespace: 1 - # Enable/disable `os.MkdirTemp()` detections. - # Default: true - os-mkdir-temp: false + # Allow blocks to end with comments. + # https://github.com/bombsimon/wsl/blob/HEAD/doc/configuration.md#allow-trailing-comment + # Default: false + allow-trailing-comment: true - # Enable/disable `os.Setenv()` detections. - # Default: true - os-setenv: false + # Allow multiple comments in the beginning of a block separated with newline. + # https://github.com/bombsimon/wsl/blob/HEAD/doc/configuration.md#allow-separated-leading-comment + # Default: false + allow-separated-leading-comment: true - # Enable/disable `os.TempDir()` detections. - # Default: false - os-temp-dir: true + # Allow multiple var/declaration statements to be cuddled. + # https://github.com/bombsimon/wsl/blob/HEAD/doc/configuration.md#allow-cuddle-declarations + # Default: false + allow-cuddle-declarations: true - # Enable/disable `os.Chdir()` detections. - # Disabled if Go < 1.24. - # Default: true - os-chdir: false + # A list of call idents that everything can be cuddled with. + # Defaults: [ "Lock", "RLock" ] + allow-cuddle-with-calls: [ "Foo", "Bar" ] - # Enable/disable `context.Background()` detections. - # Disabled if Go < 1.24. - # Default: true - context-background: false + # AllowCuddleWithRHS is a list of right hand side variables that is allowed + # to be cuddled with anything. + # Defaults: [ "Unlock", "RUnlock" ] + allow-cuddle-with-rhs: [ "Foo", "Bar" ] - # Enable/disable `context.TODO()` detections. - # Disabled if Go < 1.24. - # Default: true - context-todo: false + # Causes an error when an If statement that checks an error variable doesn't + # cuddle with the assignment of that variable. + # https://github.com/bombsimon/wsl/blob/HEAD/doc/configuration.md#force-err-cuddling + # Default: false + force-err-cuddling: true - unconvert: - # Remove conversions that force intermediate rounding. - # Default: false - fast-math: true - # Be more conservative (experimental). - # Default: false - safe: true + # When force-err-cuddling is enabled this is a list of names + # used for error variables to check for in the conditional. + # Default: [ "err" ] + error-variable-names: [ "foo" ] + + # Causes an error if a short declaration (:=) cuddles with anything other than + # another short declaration. + # This logic overrides force-err-cuddling among others. + # https://github.com/bombsimon/wsl/blob/HEAD/doc/configuration.md#force-short-decl-cuddling + # Default: false + force-short-decl-cuddling: true + + # The custom section can be used to define linter plugins to be loaded at runtime. + # See README documentation for more info. + custom: + # Each custom linter should have a unique name. + example: + # The plugin type. + # It can be `goplugin` or `module`. + # Default: goplugin + type: module + # The path to the plugin *.so. Can be absolute or local. + # Required for each custom linter. + path: /path/to/example.so + # The description of the linter. + # Optional. + description: This is an example usage of a plugin linter. + # Intended to point to the repo location of the linter. + # Optional. + original-url: github.com/golangci/example-linter + # Plugins settings/configuration. + # Only work with plugin based on `linterdb.PluginConstructor`. + # Optional. + settings: + foo: bar - unparam: - # Inspect exported functions. + # 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. # - # Set to true if no external program/library imports your code. - # XXX: if you enable this setting, unparam will report a lot of false-positives in text editors: - # if it's called for subdir of a project it can't find external interfaces. All text editor integrations - # with golangci-lint call it on a directory with the changed file. + # - `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 - check-exported: true - - unused: - # Mark all struct fields that have been written to as used. - # Default: true - field-writes-are-uses: false - # Treat IncDec statement (e.g. `i++` or `i--`) as both read and write operation instead of just write. - # Default: false - post-statements-are-reads: true - # Mark all exported fields as used. - # default: true - exported-fields-are-used: false - # Mark all function parameters as used. - # default: true - parameters-are-used: false - # Mark all local variables as used. - # default: true - local-variables-are-used: false - # Mark all identifiers inside generated files as used. - # Default: true - generated-is-used: false - - varnamelen: - # The longest distance, in source lines, that is being considered a "small scope". - # Variables used in at most this many lines will be ignored. - # Default: 5 - max-distance: 6 - # The minimum length of a variable's name that is considered "long". - # Variable names that are at least this long will be ignored. - # Default: 3 - min-name-length: 2 - # Check method receivers. - # Default: false - check-receiver: true - # Check named return values. - # Default: false - check-return: true - # Check type parameters. - # Default: false - check-type-param: true - # Ignore "ok" variables that hold the bool return value of a type assertion. - # Default: false - ignore-type-assert-ok: true - # Ignore "ok" variables that hold the bool return value of a map index. - # Default: false - ignore-map-index-ok: true - # Ignore "ok" variables that hold the bool return value of a channel receive. - # Default: false - ignore-chan-recv-ok: true - # Optional list of variable names that should be ignored completely. - # Default: [] - ignore-names: - - err - # Optional list of variable declarations that should be ignored completely. - # Entries must be in one of the following forms (see below for examples): - # - for variables, parameters, named return values, method receivers, or type parameters: - # ( can also be a pointer/slice/map/chan/...) - # - for constants: const - # + warn-unused: true + # Predefined exclusion rules. # Default: [] - ignore-decls: - - c echo.Context - - t testing.T - - f *foo.Bar - - e error - - i int - - const C - - T any - - m map[string]int - - whitespace: - # Enforces newlines (or comments) after every multi-line if statement. - # Default: false - multi-if: true - # Enforces newlines (or comments) after every multi-line function signature. - # Default: false - multi-func: true + presets: + - comments + - std-error-handling + - common-false-positives + - legacy - 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. + # Excluding configuration per-path, per-linter, per-text and per-source. + rules: + # Exclude some linters from running on tests files. + - path: _test\.go + linters: + - gocyclo + - errcheck + - dupl + - gosec + + # 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: [] - ignore-package-globs: - - encoding/* - - github.com/pkg/* - # An array of strings that specify regular expressions of interfaces to ignore. + paths: + - ".*\\.my\\.go$" + - lib/bad.go + # Which file paths to not exclude. # Default: [] - ignore-interface-regexps: - - ^(?i)c(?-i)ach(ing|e) - - wsl: - # Do strict checking when assigning from append (x = append(x, y)). - # If this is set to true - the append call must append either a variable - # assigned, called or used on the line above. - # https://github.com/bombsimon/wsl/blob/HEAD/doc/configuration.md#strict-append - # Default: true - strict-append: false - - # Allows assignments to be cuddled with variables used in calls on - # line above and calls to be cuddled with assignments of variables - # used in call on line above. - # https://github.com/bombsimon/wsl/blob/HEAD/doc/configuration.md#allow-assign-and-call - # Default: true - allow-assign-and-call: false - - # Allows assignments to be cuddled with anything. - # https://github.com/bombsimon/wsl/blob/HEAD/doc/configuration.md#allow-assign-and-anything - # Default: false - allow-assign-and-anything: true + paths-except: + - ".*\\.my\\.go$" + - lib/bad.go - # Allows cuddling to assignments even if they span over multiple lines. - # https://github.com/bombsimon/wsl/blob/HEAD/doc/configuration.md#allow-multiline-assign - # Default: true - allow-multiline-assign: false +formatters: + # Enable specific formatter. + # Default: [] (uses standard Go formatting) + enable: + - gci + - gofmt + - gofumpt + - goimports + - golines - # If the number of lines in a case block is equal to or lager than this number, - # the case *must* end white a newline. - # https://github.com/bombsimon/wsl/blob/HEAD/doc/configuration.md#force-case-trailing-whitespace - # Default: 0 - force-case-trailing-whitespace: 1 + # 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/org/project) # 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. - # Allow blocks to end with comments. - # https://github.com/bombsimon/wsl/blob/HEAD/doc/configuration.md#allow-trailing-comment - # Default: false - allow-trailing-comment: true + # Checks that no inline comments are present. + # Default: false + no-inline-comments: true - # Allow multiple comments in the beginning of a block separated with newline. - # https://github.com/bombsimon/wsl/blob/HEAD/doc/configuration.md#allow-separated-leading-comment - # Default: false - allow-separated-leading-comment: true + # Checks that no prefix comments (comment lines above an import) are present. + # Default: false + no-prefix-comments: true - # Allow multiple var/declaration statements to be cuddled. - # https://github.com/bombsimon/wsl/blob/HEAD/doc/configuration.md#allow-cuddle-declarations - # Default: false - allow-cuddle-declarations: true + # Enable custom order of sections. + # If `true`, make the section order the same as the order of `sections`. + # Default: false + custom-order: true - # A list of call idents that everything can be cuddled with. - # Defaults: [ "Lock", "RLock" ] - allow-cuddle-with-calls: [ "Foo", "Bar" ] + # Drops lexical ordering for custom sections. + # Default: false + no-lex-order: true - # AllowCuddleWithRHS is a list of right hand side variables that is allowed - # to be cuddled with anything. - # Defaults: [ "Unlock", "RUnlock" ] - allow-cuddle-with-rhs: [ "Foo", "Bar" ] + 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:]' - # Causes an error when an If statement that checks an error variable doesn't - # cuddle with the assignment of that variable. - # https://github.com/bombsimon/wsl/blob/HEAD/doc/configuration.md#force-err-cuddling - # Default: false - force-err-cuddling: true + gofumpt: + # Module path which contains the source code being formatted. + # Default: "" + module-path: github.com/org/project - # When force-err-cuddling is enabled this is a list of names - # used for error variables to check for in the conditional. - # Default: [ "err" ] - error-variable-names: [ "foo" ] + # Choose whether to use the extra rules. + # Default: false + extra-rules: true - # Causes an error if a short declaration (:=) cuddles with anything other than - # another short declaration. - # This logic overrides force-err-cuddling among others. - # https://github.com/bombsimon/wsl/blob/HEAD/doc/configuration.md#force-short-decl-cuddling - # Default: false - force-short-decl-cuddling: true - - # The custom section can be used to define linter plugins to be loaded at runtime. - # See README documentation for more info. - custom: - # Each custom linter should have a unique name. - example: - # The plugin type. - # It can be `goplugin` or `module`. - # Default: goplugin - type: module - # The path to the plugin *.so. Can be absolute or local. - # Required for each custom linter. - path: /path/to/example.so - # The description of the linter. - # Optional. - description: This is an example usage of a plugin linter. - # Intended to point to the repo location of the linter. - # Optional. - original-url: github.com/golangci/example-linter - # Plugins settings/configuration. - # Only work with plugin based on `linterdb.PluginConstructor`. - # Optional. - settings: - foo: bar + 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/org/project + + golines: + # Target maximum line length. + # Default: 100 + max-len: 200 + # Length of a tabulation. + # Default: 4 + tab-len: 8 + # Shorten single-line comments. + # Default: false + shorten-comments: true + # Default: true + reformat-tags: false + # Split chained methods on the dots as opposed to the arguments. + # Default: true + chain-split-dots: false issues: diff --git a/.golangci.yml b/.golangci.yml index e4acf0709bf2..a90002a784e4 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -14,7 +14,7 @@ version: "2" linters: - disable-all: true + default: none # This list of linters is not a recommendation (same thing for all this configuration file). # We intentionally use a limited set of linters. # See the comment on top of this file. @@ -53,6 +53,92 @@ linters: - unparam - unused - whitespace + + settings: + depguard: + rules: + logger: + deny: + # logging is allowed only by logutils.Log, + - pkg: "github.com/sirupsen/logrus" + desc: logging is allowed only by logutils.Log. + - pkg: "github.com/pkg/errors" + desc: Should be replaced by standard lib errors package. + - pkg: "github.com/instana/testify" + desc: It's a fork of github.com/stretchr/testify. + files: + # logrus is allowed to use only in logutils package. + - "!**/pkg/logutils/**.go" + dupl: + threshold: 100 + funlen: + lines: -1 # the number of lines (code + empty lines) is not a right metric and leads to code without empty line or one-liner. + statements: 50 + goconst: + min-len: 2 + min-occurrences: 3 + gocritic: + enabled-tags: + - diagnostic + - experimental + - opinionated + - performance + - style + disabled-checks: + - dupImport # https://github.com/go-critic/go-critic/issues/845 + - ifElseChain + - octalLiteral + - whyNoLint + gocyclo: + min-complexity: 15 + godox: + keywords: + - FIXME + mnd: + # don't include the "operation" and "assign" + checks: + - argument + - case + - condition + - return + ignored-numbers: + - '0' + - '1' + - '2' + - '3' + ignored-functions: + - strings.SplitN + govet: + settings: + printf: + funcs: + - (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof + - (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf + - (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf + - (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf + enable: + - nilness + - shadow + errorlint: + asserts: false + lll: + line-length: 140 + misspell: + locale: US + ignore-rules: + - "importas" # linter name + nolintlint: + allow-unused: false # report any unused nolint directives + require-explanation: true # require an explanation for nolint directives + require-specific: true # require nolint directives to be specific about which linter is being skipped + revive: + rules: + - name: indent-error-flow + - name: unexported-return + disabled: true + - name: unused-parameter + - name: unused-receiver + exclusions: presets: - comments @@ -95,88 +181,3 @@ formatters: local-prefixes: - github.com/golangci/golangci-lint -linters-settings: - depguard: - rules: - logger: - deny: - # logging is allowed only by logutils.Log, - - pkg: "github.com/sirupsen/logrus" - desc: logging is allowed only by logutils.Log. - - pkg: "github.com/pkg/errors" - desc: Should be replaced by standard lib errors package. - - pkg: "github.com/instana/testify" - desc: It's a fork of github.com/stretchr/testify. - files: - # logrus is allowed to use only in logutils package. - - "!**/pkg/logutils/**.go" - dupl: - threshold: 100 - funlen: - lines: -1 # the number of lines (code + empty lines) is not a right metric and leads to code without empty line or one-liner. - statements: 50 - goconst: - min-len: 2 - min-occurrences: 3 - gocritic: - enabled-tags: - - diagnostic - - experimental - - opinionated - - performance - - style - disabled-checks: - - dupImport # https://github.com/go-critic/go-critic/issues/845 - - ifElseChain - - octalLiteral - - whyNoLint - gocyclo: - min-complexity: 15 - godox: - keywords: - - FIXME - mnd: - # don't include the "operation" and "assign" - checks: - - argument - - case - - condition - - return - ignored-numbers: - - '0' - - '1' - - '2' - - '3' - ignored-functions: - - strings.SplitN - govet: - settings: - printf: - funcs: - - (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof - - (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf - - (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf - - (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf - enable: - - nilness - - shadow - errorlint: - asserts: false - lll: - line-length: 140 - misspell: - locale: US - ignore-rules: - - "importas" # linter name - nolintlint: - allow-unused: false # report any unused nolint directives - require-explanation: true # require an explanation for nolint directives - require-specific: true # require nolint directives to be specific about which linter is being skipped - revive: - rules: - - name: indent-error-flow - - name: unexported-return - disabled: true - - name: unused-parameter - - name: unused-receiver - diff --git a/jsonschema/golangci.next.jsonschema.json b/jsonschema/golangci.next.jsonschema.json index 9574412be29d..6ded83e2f751 100644 --- a/jsonschema/golangci.next.jsonschema.json +++ b/jsonschema/golangci.next.jsonschema.json @@ -3898,260 +3898,18 @@ } } }, - "linters-settings": { - "description": "All available settings of specific linters.", - "type": "object", - "additionalProperties": false, - "properties": { - "dupword": { - "$ref": "#/definitions/settings/definitions/dupwordSettings" - }, - "asasalint": { - "$ref": "#/definitions/settings/definitions/asasalintSettings" - }, - "bidichk": { - "$ref": "#/definitions/settings/definitions/bidichkSettings" - }, - "cyclop": { - "$ref": "#/definitions/settings/definitions/cyclopSettings" - }, - "decorder": { - "$ref": "#/definitions/settings/definitions/decorderSettings" - }, - "depguard":{ - "$ref": "#/definitions/settings/definitions/depguardSettings" - }, - "dogsled": { - "$ref": "#/definitions/settings/definitions/dogsledSettings" - }, - "dupl": { - "$ref": "#/definitions/settings/definitions/duplSettings" - }, - "errcheck": { - "$ref": "#/definitions/settings/definitions/errcheckSettings" - }, - "errchkjson": { - "$ref": "#/definitions/settings/definitions/errchkjsonSettings" - }, - "errorlint": { - "$ref": "#/definitions/settings/definitions/errorlintSettings" - }, - "exhaustive": { - "$ref": "#/definitions/settings/definitions/exhaustiveSettings" - }, - "exhaustruct": { - "$ref": "#/definitions/settings/definitions/exhaustructSettings" - }, - "fatcontext": { - "$ref": "#/definitions/settings/definitions/fatcontextSettings" - }, - "forbidigo": { - "$ref": "#/definitions/settings/definitions/forbidigoSettings" - }, - "funlen": { - "$ref": "#/definitions/settings/definitions/funlenSettings" - }, - "ginkgolinter": { - "$ref": "#/definitions/settings/definitions/ginkgolinterSettings" - }, - "gochecksumtype": { - "$ref": "#/definitions/settings/definitions/gochecksumtypeSettings" - }, - "gocognit": { - "$ref": "#/definitions/settings/definitions/gocognitSettings" - }, - "goconst": { - "$ref": "#/definitions/settings/definitions/goconstSettings" - }, - "gocritic": { - "$ref": "#/definitions/settings/definitions/gocriticSettings" - }, - "gocyclo": { - "$ref": "#/definitions/settings/definitions/gocycloSettings" - }, - "godot": { - "$ref": "#/definitions/settings/definitions/godotSettings" - }, - "godox": { - "$ref": "#/definitions/settings/definitions/godoxSettings" - }, - "interfacebloat":{ - "$ref": "#/definitions/settings/definitions/interfacebloatSettings" - }, - "goheader": { - "$ref": "#/definitions/settings/definitions/goheaderSettings" - }, - "gomoddirectives": { - "$ref": "#/definitions/settings/definitions/gomoddirectivesSettings" - }, - "gomodguard": { - "$ref": "#/definitions/settings/definitions/gomodguardSettings" - }, - "gosimple": { - "$ref": "#/definitions/settings/definitions/gosimpleSettings" - }, - "gosec": { - "$ref": "#/definitions/settings/definitions/gosecSettings" - }, - "gosmopolitan": { - "$ref": "#/definitions/settings/definitions/gosmopolitanSettings" - }, - "govet": { - "$ref": "#/definitions/settings/definitions/govetSettings" - }, - "grouper": { - "$ref": "#/definitions/settings/definitions/grouperSettings" - }, - "iface": { - "$ref": "#/definitions/settings/definitions/ifaceSettings" - }, - "importas": { - "$ref": "#/definitions/settings/definitions/importasSettings" - }, - "inamedparam": { - "$ref": "#/definitions/settings/definitions/inamedparamSettings" - }, - "ireturn": { - "$ref": "#/definitions/settings/definitions/ireturnSettings" - }, - "lll": { - "$ref": "#/definitions/settings/definitions/lllSettings" - }, - "maintidx": { - "$ref": "#/definitions/settings/definitions/maintidxSettings" - }, - "makezero":{ - "$ref": "#/definitions/settings/definitions/makezeroSettings" - }, - "loggercheck": { - "$ref": "#/definitions/settings/definitions/loggercheckSettings" - }, - "misspell": { - "$ref": "#/definitions/settings/definitions/misspellSettings" - }, - "musttag": { - "$ref": "#/definitions/settings/definitions/musttagSettings" - }, - "nakedret": { - "$ref": "#/definitions/settings/definitions/nakedretSettings" - }, - "nestif": { - "$ref": "#/definitions/settings/definitions/nestifSettings" - }, - "nilnil": { - "$ref": "#/definitions/settings/definitions/nilnilSettings" - }, - "nlreturn": { - "$ref": "#/definitions/settings/definitions/nlreturnSettings" - }, - "mnd": { - "$ref": "#/definitions/settings/definitions/mndSettings" - }, - "nolintlint":{ - "$ref": "#/definitions/settings/definitions/nolintlintSettings" - }, - "reassign": { - "$ref": "#/definitions/settings/definitions/reassignSettings" - }, - "recvcheck": { - "$ref": "#/definitions/settings/definitions/recvcheckSettings" - }, - "nonamedreturns": { - "$ref": "#/definitions/settings/definitions/nonamedreturnsSettings" - }, - "paralleltest": { - "$ref": "#/definitions/settings/definitions/paralleltestSettings" - }, - "perfsprint": { - "$ref": "#/definitions/settings/definitions/perfsprintSettings" - }, - "prealloc": { - "$ref": "#/definitions/settings/definitions/preallocSettings" - }, - "predeclared": { - "$ref": "#/definitions/settings/definitions/predeclaredSettings" - }, - "promlinter": { - "$ref": "#/definitions/settings/definitions/promlinterSettings" - }, - "protogetter": { - "$ref": "#/definitions/settings/definitions/protogetterSettings" - }, - "revive": { - "$ref": "#/definitions/settings/definitions/reviveSettings" - }, - "rowserrcheck": { - "$ref": "#/definitions/settings/definitions/rowserrcheckSettings" - }, - "sloglint": { - "$ref": "#/definitions/settings/definitions/sloglintSettings" - }, - "spancheck": { - "$ref": "#/definitions/settings/definitions/spancheckSettings" - }, - "staticcheck":{ - "$ref": "#/definitions/settings/definitions/staticcheckSettings" - }, - "stylecheck": { - "$ref": "#/definitions/settings/definitions/stylecheckSettings" - }, - "tagalign": { - "$ref": "#/definitions/settings/definitions/tagalignSettings" - }, - "tagliatelle": { - "$ref": "#/definitions/settings/definitions/tagliatelleSettings" - }, - "tenv": { - "$ref": "#/definitions/settings/definitions/tenvSettings" - }, - "testifylint": { - "$ref": "#/definitions/settings/definitions/testifylintSettings" - }, - "testpackage": { - "$ref": "#/definitions/settings/definitions/testpackageSettings" - }, - "thelper": { - "$ref": "#/definitions/settings/definitions/thelperSettings" - }, - "usestdlibvars": { - "$ref": "#/definitions/settings/definitions/usestdlibvarsSettings" - }, - "usetesting": { - "$ref": "#/definitions/settings/definitions/usetestingSettings" - }, - "unconvert": { - "$ref": "#/definitions/settings/definitions/unconvertSettings" - }, - "unparam": { - "$ref": "#/definitions/settings/definitions/unparamSettings" - }, - "unused": { - "$ref": "#/definitions/settings/definitions/unusedSettings" - }, - "varnamelen": { - "$ref": "#/definitions/settings/definitions/varnamelenSettings" - }, - "whitespace": { - "$ref": "#/definitions/settings/definitions/whitespaceSettings" - }, - "wrapcheck": { - "$ref": "#/definitions/settings/definitions/wrapcheckSettings" - }, - "wsl": { - "$ref": "#/definitions/settings/definitions/wslSettings" - }, - "copyloopvar": { - "$ref": "#/definitions/settings/definitions/copyloopvarSettings" - }, - "custom":{ - "$ref": "#/definitions/settings/definitions/customSettings" - } - } - }, "linters": { "type": "object", "additionalProperties": false, "properties": { + "default": { + "enum": [ + "standard", + "all", + "none", + "fast" + ] + }, "enable": { "description": "List of enabled linters.", "type": "array", @@ -4166,20 +3924,255 @@ "$ref": "#/definitions/linter-names" } }, - "enable-all": { - "description": "Whether to enable all linters. You can re-disable them with `disable` explicitly.", - "type": "boolean", - "default": false - }, - "disable-all": { - "description": "Whether to disable all linters. You can re-enable them with `enable` explicitly.", - "type": "boolean", - "default": false - }, - "fast": { - "description": "Enable run of fast linters.", - "type": "boolean", - "default": false + "settings": { + "description": "All available settings of specific linters.", + "type": "object", + "additionalProperties": false, + "properties": { + "dupword": { + "$ref": "#/definitions/settings/definitions/dupwordSettings" + }, + "asasalint": { + "$ref": "#/definitions/settings/definitions/asasalintSettings" + }, + "bidichk": { + "$ref": "#/definitions/settings/definitions/bidichkSettings" + }, + "cyclop": { + "$ref": "#/definitions/settings/definitions/cyclopSettings" + }, + "decorder": { + "$ref": "#/definitions/settings/definitions/decorderSettings" + }, + "depguard":{ + "$ref": "#/definitions/settings/definitions/depguardSettings" + }, + "dogsled": { + "$ref": "#/definitions/settings/definitions/dogsledSettings" + }, + "dupl": { + "$ref": "#/definitions/settings/definitions/duplSettings" + }, + "errcheck": { + "$ref": "#/definitions/settings/definitions/errcheckSettings" + }, + "errchkjson": { + "$ref": "#/definitions/settings/definitions/errchkjsonSettings" + }, + "errorlint": { + "$ref": "#/definitions/settings/definitions/errorlintSettings" + }, + "exhaustive": { + "$ref": "#/definitions/settings/definitions/exhaustiveSettings" + }, + "exhaustruct": { + "$ref": "#/definitions/settings/definitions/exhaustructSettings" + }, + "fatcontext": { + "$ref": "#/definitions/settings/definitions/fatcontextSettings" + }, + "forbidigo": { + "$ref": "#/definitions/settings/definitions/forbidigoSettings" + }, + "funlen": { + "$ref": "#/definitions/settings/definitions/funlenSettings" + }, + "ginkgolinter": { + "$ref": "#/definitions/settings/definitions/ginkgolinterSettings" + }, + "gochecksumtype": { + "$ref": "#/definitions/settings/definitions/gochecksumtypeSettings" + }, + "gocognit": { + "$ref": "#/definitions/settings/definitions/gocognitSettings" + }, + "goconst": { + "$ref": "#/definitions/settings/definitions/goconstSettings" + }, + "gocritic": { + "$ref": "#/definitions/settings/definitions/gocriticSettings" + }, + "gocyclo": { + "$ref": "#/definitions/settings/definitions/gocycloSettings" + }, + "godot": { + "$ref": "#/definitions/settings/definitions/godotSettings" + }, + "godox": { + "$ref": "#/definitions/settings/definitions/godoxSettings" + }, + "interfacebloat":{ + "$ref": "#/definitions/settings/definitions/interfacebloatSettings" + }, + "goheader": { + "$ref": "#/definitions/settings/definitions/goheaderSettings" + }, + "gomoddirectives": { + "$ref": "#/definitions/settings/definitions/gomoddirectivesSettings" + }, + "gomodguard": { + "$ref": "#/definitions/settings/definitions/gomodguardSettings" + }, + "gosimple": { + "$ref": "#/definitions/settings/definitions/gosimpleSettings" + }, + "gosec": { + "$ref": "#/definitions/settings/definitions/gosecSettings" + }, + "gosmopolitan": { + "$ref": "#/definitions/settings/definitions/gosmopolitanSettings" + }, + "govet": { + "$ref": "#/definitions/settings/definitions/govetSettings" + }, + "grouper": { + "$ref": "#/definitions/settings/definitions/grouperSettings" + }, + "iface": { + "$ref": "#/definitions/settings/definitions/ifaceSettings" + }, + "importas": { + "$ref": "#/definitions/settings/definitions/importasSettings" + }, + "inamedparam": { + "$ref": "#/definitions/settings/definitions/inamedparamSettings" + }, + "ireturn": { + "$ref": "#/definitions/settings/definitions/ireturnSettings" + }, + "lll": { + "$ref": "#/definitions/settings/definitions/lllSettings" + }, + "maintidx": { + "$ref": "#/definitions/settings/definitions/maintidxSettings" + }, + "makezero":{ + "$ref": "#/definitions/settings/definitions/makezeroSettings" + }, + "loggercheck": { + "$ref": "#/definitions/settings/definitions/loggercheckSettings" + }, + "misspell": { + "$ref": "#/definitions/settings/definitions/misspellSettings" + }, + "musttag": { + "$ref": "#/definitions/settings/definitions/musttagSettings" + }, + "nakedret": { + "$ref": "#/definitions/settings/definitions/nakedretSettings" + }, + "nestif": { + "$ref": "#/definitions/settings/definitions/nestifSettings" + }, + "nilnil": { + "$ref": "#/definitions/settings/definitions/nilnilSettings" + }, + "nlreturn": { + "$ref": "#/definitions/settings/definitions/nlreturnSettings" + }, + "mnd": { + "$ref": "#/definitions/settings/definitions/mndSettings" + }, + "nolintlint":{ + "$ref": "#/definitions/settings/definitions/nolintlintSettings" + }, + "reassign": { + "$ref": "#/definitions/settings/definitions/reassignSettings" + }, + "recvcheck": { + "$ref": "#/definitions/settings/definitions/recvcheckSettings" + }, + "nonamedreturns": { + "$ref": "#/definitions/settings/definitions/nonamedreturnsSettings" + }, + "paralleltest": { + "$ref": "#/definitions/settings/definitions/paralleltestSettings" + }, + "perfsprint": { + "$ref": "#/definitions/settings/definitions/perfsprintSettings" + }, + "prealloc": { + "$ref": "#/definitions/settings/definitions/preallocSettings" + }, + "predeclared": { + "$ref": "#/definitions/settings/definitions/predeclaredSettings" + }, + "promlinter": { + "$ref": "#/definitions/settings/definitions/promlinterSettings" + }, + "protogetter": { + "$ref": "#/definitions/settings/definitions/protogetterSettings" + }, + "revive": { + "$ref": "#/definitions/settings/definitions/reviveSettings" + }, + "rowserrcheck": { + "$ref": "#/definitions/settings/definitions/rowserrcheckSettings" + }, + "sloglint": { + "$ref": "#/definitions/settings/definitions/sloglintSettings" + }, + "spancheck": { + "$ref": "#/definitions/settings/definitions/spancheckSettings" + }, + "staticcheck":{ + "$ref": "#/definitions/settings/definitions/staticcheckSettings" + }, + "stylecheck": { + "$ref": "#/definitions/settings/definitions/stylecheckSettings" + }, + "tagalign": { + "$ref": "#/definitions/settings/definitions/tagalignSettings" + }, + "tagliatelle": { + "$ref": "#/definitions/settings/definitions/tagliatelleSettings" + }, + "tenv": { + "$ref": "#/definitions/settings/definitions/tenvSettings" + }, + "testifylint": { + "$ref": "#/definitions/settings/definitions/testifylintSettings" + }, + "testpackage": { + "$ref": "#/definitions/settings/definitions/testpackageSettings" + }, + "thelper": { + "$ref": "#/definitions/settings/definitions/thelperSettings" + }, + "usestdlibvars": { + "$ref": "#/definitions/settings/definitions/usestdlibvarsSettings" + }, + "usetesting": { + "$ref": "#/definitions/settings/definitions/usetestingSettings" + }, + "unconvert": { + "$ref": "#/definitions/settings/definitions/unconvertSettings" + }, + "unparam": { + "$ref": "#/definitions/settings/definitions/unparamSettings" + }, + "unused": { + "$ref": "#/definitions/settings/definitions/unusedSettings" + }, + "varnamelen": { + "$ref": "#/definitions/settings/definitions/varnamelenSettings" + }, + "whitespace": { + "$ref": "#/definitions/settings/definitions/whitespaceSettings" + }, + "wrapcheck": { + "$ref": "#/definitions/settings/definitions/wrapcheckSettings" + }, + "wsl": { + "$ref": "#/definitions/settings/definitions/wslSettings" + }, + "copyloopvar": { + "$ref": "#/definitions/settings/definitions/copyloopvarSettings" + }, + "custom":{ + "$ref": "#/definitions/settings/definitions/customSettings" + } + } }, "exclusions":{ "type": "object", diff --git a/pkg/commands/flagsets.go b/pkg/commands/flagsets.go index bc39d755b7de..e7f60eae9771 100644 --- a/pkg/commands/flagsets.go +++ b/pkg/commands/flagsets.go @@ -6,23 +6,24 @@ import ( "github.com/spf13/viper" "github.com/golangci/golangci-lint/pkg/commands/internal" + "github.com/golangci/golangci-lint/pkg/config" "github.com/golangci/golangci-lint/pkg/exitcodes" ) const defaultMaxIssuesPerLinter = 50 func setupLintersFlagSet(v *viper.Viper, fs *pflag.FlagSet) { - internal.AddHackedStringSliceP(fs, "disable", "D", color.GreenString("Disable specific linter")) - internal.AddFlagAndBind(v, fs, fs.Bool, "disable-all", "linters.disable-all", false, color.GreenString("Disable all linters")) + internal.AddFlagAndBind(v, fs, fs.String, "default", "linters.default", config.GroupStandard, + color.GreenString("Default set of linters to enable")) + internal.AddHackedStringSliceP(fs, "disable", "D", color.GreenString("Disable specific linter")) internal.AddHackedStringSliceP(fs, "enable", "E", color.GreenString("Enable specific linter")) - internal.AddFlagAndBind(v, fs, fs.Bool, "enable-all", "linters.enable-all", false, color.GreenString("Enable all linters")) - - internal.AddFlagAndBind(v, fs, fs.Bool, "fast", "linters.fast", false, - color.GreenString("Enable only fast linters from enabled linters set (first run won't be fast)")) fs.StringSlice("enable-only", nil, color.GreenString("Override linters configuration section to only run the specific linter(s)")) // Flags only. + + internal.AddFlagAndBind(v, fs, fs.Bool, "fast-only", "linters.fast-only", false, + color.GreenString("Filter enabled linters to run only fast linters")) } func setupFormattersFlagSet(v *viper.Viper, fs *pflag.FlagSet) { diff --git a/pkg/commands/help.go b/pkg/commands/help.go index 94af684bf736..f9e5c8949320 100644 --- a/pkg/commands/help.go +++ b/pkg/commands/help.go @@ -3,6 +3,7 @@ package commands import ( "encoding/json" "fmt" + "maps" "slices" "strings" "unicode" @@ -18,14 +19,14 @@ import ( ) type linterHelp struct { - Name string `json:"name"` - Desc string `json:"description"` - Fast bool `json:"fast"` - AutoFix bool `json:"autoFix"` - EnabledByDefault bool `json:"enabledByDefault"` - Deprecated bool `json:"deprecated"` - Since string `json:"since"` - OriginalURL string `json:"originalURL,omitempty"` + Name string `json:"name"` + Desc string `json:"description"` + Groups []string `json:"groups"` + Fast bool `json:"fast"` + AutoFix bool `json:"autoFix"` + Deprecated bool `json:"deprecated"` + Since string `json:"since"` + OriginalURL string `json:"originalURL,omitempty"` } type helpOptions struct { @@ -106,15 +107,21 @@ func (c *helpCommand) printJSON() error { continue } + groups := []string{config.GroupAll} + + if !lc.IsSlowLinter() { + groups = append(groups, config.GroupFast) + } + linters = append(linters, linterHelp{ - Name: lc.Name(), - Desc: formatDescription(lc.Linter.Desc()), - Fast: !lc.IsSlowLinter(), - AutoFix: lc.CanAutoFix, - EnabledByDefault: lc.EnabledByDefault, - Deprecated: lc.IsDeprecated(), - Since: lc.Since, - OriginalURL: lc.OriginalURL, + Name: lc.Name(), + Desc: formatDescription(lc.Linter.Desc()), + Groups: slices.Concat(groups, slices.Collect(maps.Keys(lc.Groups))), + Fast: !lc.IsSlowLinter(), + AutoFix: lc.CanAutoFix, + Deprecated: lc.IsDeprecated(), + Since: lc.Since, + OriginalURL: lc.OriginalURL, }) } @@ -128,7 +135,7 @@ func (c *helpCommand) print() { continue } - if lc.EnabledByDefault { + if lc.FromGroup(config.GroupStandard) { enabledLCs = append(enabledLCs, lc) } else { disabledLCs = append(disabledLCs, lc) diff --git a/pkg/commands/run.go b/pkg/commands/run.go index a668521316c1..88eff67b303f 100644 --- a/pkg/commands/run.go +++ b/pkg/commands/run.go @@ -358,7 +358,7 @@ func (c *runCommand) runAndPrint(ctx context.Context) error { // Fills linters information for the JSON printer. for _, lc := range c.dbManager.GetAllSupportedLinterConfigs() { isEnabled := enabledLintersMap[lc.Name()] != nil - c.reportData.AddLinter(lc.Name(), isEnabled, lc.EnabledByDefault) + c.reportData.AddLinter(lc.Name(), isEnabled) } err = c.printer.Print(issues) @@ -667,12 +667,12 @@ func computeBinarySalt(version string) ([]byte, error) { // At least, it has a huge impact on tests speed. // Fields: `LintersSettings` and `Run.BuildTags`. func computeConfigSalt(cfg *config.Config) ([]byte, error) { - lintersSettingsBytes, err := yaml.Marshal(cfg.LintersSettings) + lintersSettingsBytes, err := yaml.Marshal(cfg.Linters.Settings) if err != nil { return nil, fmt.Errorf("failed to JSON marshal config linter settings: %w", err) } - configData := bytes.NewBufferString("linters-settings=") + configData := bytes.NewBufferString("linters.settings=") configData.Write(lintersSettingsBytes) configData.WriteString("\nbuild-tags=%s" + strings.Join(cfg.Run.BuildTags, ",")) diff --git a/pkg/config/config.go b/pkg/config/config.go index 2d8cbe68aec1..759f9223b4b5 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -30,9 +30,7 @@ type Config struct { Output Output `mapstructure:"output"` - LintersSettings LintersSettings `mapstructure:"linters-settings"` - OldLinters OldLinters `mapstructure:"linters"` - Linters Linters `mapstructure:"linters-TEMP"` + Linters Linters `mapstructure:"linters"` Issues Issues `mapstructure:"issues"` Severity Severity `mapstructure:"severity"` @@ -56,8 +54,7 @@ func (c *Config) Validate() error { validators := []func() error{ c.Run.Validate, c.Output.Validate, - c.LintersSettings.Validate, - c.OldLinters.Validate, + c.Linters.Validate, c.Severity.Validate, } @@ -72,7 +69,9 @@ func (c *Config) Validate() error { func NewDefault() *Config { return &Config{ - LintersSettings: defaultLintersSettings, + Linters: Linters{ + Settings: defaultLintersSettings, + }, Formatters: Formatters{ Settings: defaultFormatterSettings, }, diff --git a/pkg/config/linters.go b/pkg/config/linters.go index a9373e6c58f5..0e159e981e8e 100644 --- a/pkg/config/linters.go +++ b/pkg/config/linters.go @@ -8,9 +8,10 @@ const ( ) type Linters struct { - Default string `mapstructure:"default"` - Enable []string `mapstructure:"enable"` - Disable []string `mapstructure:"disable"` + Default string `mapstructure:"default"` + Enable []string `mapstructure:"enable"` + Disable []string `mapstructure:"disable"` + FastOnly bool `mapstructure:"fast-only"` // Flag only option. Settings LintersSettings `mapstructure:"settings"` diff --git a/pkg/config/loader.go b/pkg/config/loader.go index 6768f83dd233..da64a3af36a3 100644 --- a/pkg/config/loader.go +++ b/pkg/config/loader.go @@ -67,8 +67,8 @@ func (l *Loader) Load(opts LoadOptions) error { l.applyStringSliceHack() - if l.cfg.OldLinters.LinterExclusions.Generated == "" { - l.cfg.OldLinters.LinterExclusions.Generated = GeneratedModeStrict + if l.cfg.Linters.Exclusions.Generated == "" { + l.cfg.Linters.Exclusions.Generated = GeneratedModeStrict } l.handleFormatters() @@ -278,8 +278,8 @@ func (l *Loader) applyStringSliceHack() { return } - l.appendStringSlice("enable", &l.cfg.OldLinters.Enable) - l.appendStringSlice("disable", &l.cfg.OldLinters.Disable) + l.appendStringSlice("enable", &l.cfg.Linters.Enable) + l.appendStringSlice("disable", &l.cfg.Linters.Disable) l.appendStringSlice("build-tags", &l.cfg.Run.BuildTags) } @@ -295,18 +295,18 @@ func (l *Loader) handleGoVersion() { l.cfg.Run.Go = detectGoVersion(context.Background()) } - l.cfg.LintersSettings.Govet.Go = l.cfg.Run.Go + l.cfg.Linters.Settings.Govet.Go = l.cfg.Run.Go - l.cfg.LintersSettings.ParallelTest.Go = l.cfg.Run.Go + l.cfg.Linters.Settings.ParallelTest.Go = l.cfg.Run.Go - l.cfg.LintersSettings.GoFumpt.LangVersion = l.cfg.Run.Go + l.cfg.Linters.Settings.GoFumpt.LangVersion = l.cfg.Run.Go l.cfg.Formatters.Settings.GoFumpt.LangVersion = l.cfg.Run.Go trimmedGoVersion := goutil.TrimGoVersion(l.cfg.Run.Go) - l.cfg.LintersSettings.Revive.Go = trimmedGoVersion + l.cfg.Linters.Settings.Revive.Go = trimmedGoVersion - l.cfg.LintersSettings.Gocritic.Go = trimmedGoVersion + l.cfg.Linters.Settings.Gocritic.Go = trimmedGoVersion os.Setenv("GOSECGOVERSION", l.cfg.Run.Go) } @@ -337,9 +337,9 @@ func (l *Loader) handleEnableOnlyOption() error { } if len(only) > 0 { - l.cfg.OldLinters = OldLinters{ - Enable: only, - DisableAll: true, + l.cfg.Linters = Linters{ + Enable: only, + Default: GroupNone, } } @@ -354,19 +354,19 @@ func (l *Loader) handleFormatters() { // Overrides linter settings with formatter settings if the formatter is enabled. func (l *Loader) handleFormatterOverrides() { if slices.Contains(l.cfg.Formatters.Enable, "gofmt") { - l.cfg.LintersSettings.GoFmt = l.cfg.Formatters.Settings.GoFmt + l.cfg.Linters.Settings.GoFmt = l.cfg.Formatters.Settings.GoFmt } if slices.Contains(l.cfg.Formatters.Enable, "gofumpt") { - l.cfg.LintersSettings.GoFumpt = l.cfg.Formatters.Settings.GoFumpt + l.cfg.Linters.Settings.GoFumpt = l.cfg.Formatters.Settings.GoFumpt } if slices.Contains(l.cfg.Formatters.Enable, "goimports") { - l.cfg.LintersSettings.GoImports = l.cfg.Formatters.Settings.GoImports + l.cfg.Linters.Settings.GoImports = l.cfg.Formatters.Settings.GoImports } if slices.Contains(l.cfg.Formatters.Enable, "gci") { - l.cfg.LintersSettings.Gci = l.cfg.Formatters.Settings.Gci + l.cfg.Linters.Settings.Gci = l.cfg.Formatters.Settings.Gci } } @@ -377,7 +377,7 @@ func (l *Loader) handleFormatterExclusions() { } for _, path := range l.cfg.Formatters.Exclusions.Paths { - l.cfg.OldLinters.LinterExclusions.Rules = append(l.cfg.OldLinters.LinterExclusions.Rules, ExcludeRule{ + l.cfg.Linters.Exclusions.Rules = append(l.cfg.Linters.Exclusions.Rules, ExcludeRule{ BaseRule: BaseRule{ Linters: l.cfg.Formatters.Enable, Path: path, diff --git a/pkg/config/old_linters.go b/pkg/config/old_linters.go deleted file mode 100644 index 7549edd6949e..000000000000 --- a/pkg/config/old_linters.go +++ /dev/null @@ -1,71 +0,0 @@ -package config - -import ( - "errors" - "fmt" -) - -type OldLinters struct { - Enable []string `mapstructure:"enable"` - Disable []string `mapstructure:"disable"` - EnableAll bool `mapstructure:"enable-all"` - DisableAll bool `mapstructure:"disable-all"` - Fast bool `mapstructure:"fast"` - - Presets []string `mapstructure:"presets"` - - LinterExclusions LinterExclusions `mapstructure:"exclusions"` -} - -func (l *OldLinters) Validate() error { - validators := []func() error{ - l.validateAllDisableEnableOptions, - l.validateDisabledAndEnabledAtOneMoment, - l.LinterExclusions.Validate, - } - - for _, v := range validators { - if err := v(); err != nil { - return err - } - } - - return nil -} - -func (l *OldLinters) validateAllDisableEnableOptions() error { - if l.EnableAll && l.DisableAll { - return errors.New("--enable-all and --disable-all options must not be combined") - } - - if l.DisableAll { - if len(l.Enable) == 0 { - return errors.New("all linters were disabled, but no one linter was enabled: must enable at least one") - } - - if len(l.Disable) != 0 { - return errors.New("can't combine options --disable-all and --disable") - } - } - - if l.EnableAll && len(l.Enable) != 0 && !l.Fast { - return errors.New("can't combine options --enable-all and --enable") - } - - return nil -} - -func (l *OldLinters) validateDisabledAndEnabledAtOneMoment() error { - enabledLintersSet := map[string]bool{} - for _, name := range l.Enable { - enabledLintersSet[name] = true - } - - for _, name := range l.Disable { - if enabledLintersSet[name] { - return fmt.Errorf("linter %q can't be disabled and enabled at one moment", name) - } - } - - return nil -} diff --git a/pkg/config/old_linters_test.go b/pkg/config/old_linters_test.go deleted file mode 100644 index e4be11162ff0..000000000000 --- a/pkg/config/old_linters_test.go +++ /dev/null @@ -1,210 +0,0 @@ -package config - -import ( - "testing" - - "github.com/stretchr/testify/require" -) - -func TestLinters_validateDisabledAndEnabledAtOneMoment(t *testing.T) { - testCases := []struct { - desc string - cfg *OldLinters - }{ - { - desc: "2 different sets", - cfg: &OldLinters{ - Enable: []string{"dupl", "gofmt", "misspell"}, - Disable: []string{"goimports", "gosec", "nolintlint"}, - }, - }, - { - desc: "only enable", - cfg: &OldLinters{ - Enable: []string{"goimports", "gosec", "nolintlint"}, - Disable: nil, - }, - }, - { - desc: "only disable", - cfg: &OldLinters{ - Enable: nil, - Disable: []string{"dupl", "gofmt", "misspell"}, - }, - }, - { - desc: "no sets", - cfg: &OldLinters{ - Enable: nil, - Disable: nil, - }, - }, - } - - for _, test := range testCases { - t.Run(test.desc, func(t *testing.T) { - t.Parallel() - - err := test.cfg.validateDisabledAndEnabledAtOneMoment() - require.NoError(t, err) - }) - } -} - -func TestLinters_validateDisabledAndEnabledAtOneMoment_error(t *testing.T) { - testCases := []struct { - desc string - cfg *OldLinters - expected string - }{ - { - desc: "disable one linter of the enabled linters", - cfg: &OldLinters{ - Enable: []string{"dupl", "gofmt", "misspell"}, - Disable: []string{"dupl", "gosec", "nolintlint"}, - }, - expected: `linter "dupl" can't be disabled and enabled at one moment`, - }, - { - desc: "disable multiple enabled linters", - cfg: &OldLinters{ - Enable: []string{"dupl", "gofmt", "misspell"}, - Disable: []string{"dupl", "gofmt", "misspell"}, - }, - expected: `linter "dupl" can't be disabled and enabled at one moment`, - }, - } - - for _, test := range testCases { - t.Run(test.desc, func(t *testing.T) { - t.Parallel() - - err := test.cfg.validateDisabledAndEnabledAtOneMoment() - require.Error(t, err) - - require.EqualError(t, err, test.expected) - }) - } -} - -func TestLinters_validateAllDisableEnableOptions(t *testing.T) { - testCases := []struct { - desc string - cfg *OldLinters - }{ - { - desc: "nothing", - cfg: &OldLinters{}, - }, - { - desc: "enable and disable", - cfg: &OldLinters{ - Enable: []string{"goimports", "gosec", "nolintlint"}, - EnableAll: false, - Disable: []string{"dupl", "gofmt", "misspell"}, - DisableAll: false, - }, - }, - { - desc: "disable-all and enable", - cfg: &OldLinters{ - Enable: []string{"goimports", "gosec", "nolintlint"}, - EnableAll: false, - Disable: nil, - DisableAll: true, - }, - }, - { - desc: "enable-all and disable", - cfg: &OldLinters{ - Enable: nil, - EnableAll: true, - Disable: []string{"goimports", "gosec", "nolintlint"}, - DisableAll: false, - }, - }, - { - desc: "enable-all and enable and fast", - cfg: &OldLinters{ - Enable: []string{"dupl", "gofmt", "misspell"}, - EnableAll: true, - Disable: nil, - DisableAll: false, - Fast: true, - }, - }, - } - - for _, test := range testCases { - t.Run(test.desc, func(t *testing.T) { - t.Parallel() - - err := test.cfg.validateAllDisableEnableOptions() - require.NoError(t, err) - }) - } -} - -func TestLinters_validateAllDisableEnableOptions_error(t *testing.T) { - testCases := []struct { - desc string - cfg *OldLinters - expected string - }{ - { - desc: "enable-all and disable-all", - cfg: &OldLinters{ - Enable: nil, - EnableAll: true, - Disable: nil, - DisableAll: true, - Fast: false, - }, - expected: "--enable-all and --disable-all options must not be combined", - }, - { - desc: "disable-all and disable no enable no preset", - cfg: &OldLinters{ - Enable: nil, - EnableAll: false, - Disable: []string{"dupl", "gofmt", "misspell"}, - DisableAll: true, - Fast: false, - }, - expected: "all linters were disabled, but no one linter was enabled: must enable at least one", - }, - { - desc: "disable-all and disable with enable", - cfg: &OldLinters{ - Enable: []string{"nolintlint"}, - EnableAll: false, - Disable: []string{"dupl", "gofmt", "misspell"}, - DisableAll: true, - Fast: false, - }, - expected: "can't combine options --disable-all and --disable", - }, - { - desc: "enable-all and enable", - cfg: &OldLinters{ - Enable: []string{"dupl", "gofmt", "misspell"}, - EnableAll: true, - Disable: nil, - DisableAll: false, - Fast: false, - }, - expected: "can't combine options --enable-all and --enable", - }, - } - - for _, test := range testCases { - t.Run(test.desc, func(t *testing.T) { - t.Parallel() - - err := test.cfg.validateAllDisableEnableOptions() - require.Error(t, err) - - require.EqualError(t, err, test.expected) - }) - } -} diff --git a/pkg/lint/linter/config.go b/pkg/lint/linter/config.go index e0d043c7b39e..cd0ecdd79171 100644 --- a/pkg/lint/linter/config.go +++ b/pkg/lint/linter/config.go @@ -27,9 +27,8 @@ type Deprecation struct { } type Config struct { - Linter Linter - EnabledByDefault bool - Groups map[string]struct{} + Linter Linter + Groups map[string]struct{} LoadMode packages.LoadMode @@ -52,11 +51,6 @@ func NewConfig(linter Linter) *Config { return lc.WithLoadFiles() } -func (lc *Config) WithEnabledByDefault() *Config { - lc.EnabledByDefault = true - return lc -} - func (lc *Config) WithInternal() *Config { lc.Internal = true return lc diff --git a/pkg/lint/linter/context.go b/pkg/lint/linter/context.go index 6986b6231477..302a15ddc5c4 100644 --- a/pkg/lint/linter/context.go +++ b/pkg/lint/linter/context.go @@ -27,7 +27,7 @@ type Context struct { } func (c *Context) Settings() *config.LintersSettings { - return &c.Cfg.LintersSettings + return &c.Cfg.Linters.Settings } func (c *Context) ClearTypesInPackages() { diff --git a/pkg/lint/lintersdb/builder_linter.go b/pkg/lint/lintersdb/builder_linter.go index 80316a307558..e5b79d5007f3 100644 --- a/pkg/lint/lintersdb/builder_linter.go +++ b/pkg/lint/lintersdb/builder_linter.go @@ -134,7 +134,7 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { // The linters are sorted in the alphabetical order (case-insensitive). // When a new linter is added the version in `WithSince(...)` must be the next minor version of golangci-lint. return []*linter.Config{ - linter.NewConfig(asasalint.New(&cfg.LintersSettings.Asasalint)). + linter.NewConfig(asasalint.New(&cfg.Linters.Settings.Asasalint)). WithSince("v1.47.0"). WithLoadForGoAnalysis(). WithURL("https://github.com/alingse/asasalint"), @@ -143,7 +143,7 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithSince("v1.26.0"). WithURL("https://github.com/tdakkota/asciicheck"), - linter.NewConfig(bidichk.New(&cfg.LintersSettings.BiDiChk)). + linter.NewConfig(bidichk.New(&cfg.Linters.Settings.BiDiChk)). WithSince("v1.43.0"). WithURL("https://github.com/breml/bidichk"), @@ -168,33 +168,33 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithLoadForGoAnalysis(). WithURL("https://github.com/kkHAIKE/contextcheck"), - linter.NewConfig(copyloopvar.New(&cfg.LintersSettings.CopyLoopVar)). + linter.NewConfig(copyloopvar.New(&cfg.Linters.Settings.CopyLoopVar)). WithSince("v1.57.0"). WithAutoFix(). WithURL("https://github.com/karamaru-alpha/copyloopvar"). WithNoopFallback(cfg, linter.IsGoLowerThanGo122()), - linter.NewConfig(cyclop.New(&cfg.LintersSettings.Cyclop)). + linter.NewConfig(cyclop.New(&cfg.Linters.Settings.Cyclop)). WithSince("v1.37.0"). WithURL("https://github.com/bkielbasa/cyclop"), - linter.NewConfig(decorder.New(&cfg.LintersSettings.Decorder)). + linter.NewConfig(decorder.New(&cfg.Linters.Settings.Decorder)). WithSince("v1.44.0"). WithURL("https://gitlab.com/bosi/decorder"), - linter.NewConfig(depguard.New(&cfg.LintersSettings.Depguard, cfg.GetBasePath())). + linter.NewConfig(depguard.New(&cfg.Linters.Settings.Depguard, cfg.GetBasePath())). WithSince("v1.4.0"). WithURL("https://github.com/OpenPeeDeeP/depguard"), - linter.NewConfig(dogsled.New(&cfg.LintersSettings.Dogsled)). + linter.NewConfig(dogsled.New(&cfg.Linters.Settings.Dogsled)). WithSince("v1.19.0"). WithURL("https://github.com/alexkohler/dogsled"), - linter.NewConfig(dupl.New(&cfg.LintersSettings.Dupl)). + linter.NewConfig(dupl.New(&cfg.Linters.Settings.Dupl)). WithSince("v1.0.0"). WithURL("https://github.com/mibk/dupl"), - linter.NewConfig(dupword.New(&cfg.LintersSettings.DupWord)). + linter.NewConfig(dupword.New(&cfg.Linters.Settings.DupWord)). WithSince("v1.50.0"). WithAutoFix(). WithURL("https://github.com/Abirdcfly/dupword"), @@ -204,14 +204,13 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithLoadForGoAnalysis(). WithURL("https://github.com/charithe/durationcheck"), - linter.NewConfig(errcheck.New(&cfg.LintersSettings.Errcheck)). - WithGroups(config.DefaultSetNameStandard). - WithEnabledByDefault(). + linter.NewConfig(errcheck.New(&cfg.Linters.Settings.Errcheck)). + WithGroups(config.GroupStandard). WithSince("v1.0.0"). WithLoadForGoAnalysis(). WithURL("https://github.com/kisielk/errcheck"), - linter.NewConfig(errchkjson.New(&cfg.LintersSettings.ErrChkJSON)). + linter.NewConfig(errchkjson.New(&cfg.Linters.Settings.ErrChkJSON)). WithSince("v1.44.0"). WithLoadForGoAnalysis(). WithURL("https://github.com/breml/errchkjson"), @@ -221,18 +220,18 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithLoadForGoAnalysis(). WithURL("https://github.com/Antonboom/errname"), - linter.NewConfig(errorlint.New(&cfg.LintersSettings.ErrorLint)). + linter.NewConfig(errorlint.New(&cfg.Linters.Settings.ErrorLint)). WithSince("v1.32.0"). WithLoadForGoAnalysis(). WithAutoFix(). WithURL("https://github.com/polyfloyd/go-errorlint"), - linter.NewConfig(exhaustive.New(&cfg.LintersSettings.Exhaustive)). + linter.NewConfig(exhaustive.New(&cfg.Linters.Settings.Exhaustive)). WithSince(" v1.28.0"). WithLoadForGoAnalysis(). WithURL("https://github.com/nishanths/exhaustive"), - linter.NewConfig(exhaustruct.New(&cfg.LintersSettings.Exhaustruct)). + linter.NewConfig(exhaustruct.New(&cfg.Linters.Settings.Exhaustruct)). WithSince("v1.46.0"). WithLoadForGoAnalysis(). WithURL("https://github.com/GaijinEntertainment/go-exhaustruct"), @@ -243,7 +242,7 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithAutoFix(). WithURL("https://github.com/ldez/exptostd"), - linter.NewConfig(forbidigo.New(&cfg.LintersSettings.Forbidigo)). + linter.NewConfig(forbidigo.New(&cfg.Linters.Settings.Forbidigo)). WithSince("v1.34.0"). // Strictly speaking, // the additional information is only needed when forbidigoCfg.AnalyzeTypes is chosen by the user. @@ -257,22 +256,22 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithLoadForGoAnalysis(). WithURL("https://github.com/gostaticanalysis/forcetypeassert"), - linter.NewConfig(fatcontext.New(&cfg.LintersSettings.Fatcontext)). + linter.NewConfig(fatcontext.New(&cfg.Linters.Settings.Fatcontext)). WithSince("v1.58.0"). WithLoadForGoAnalysis(). WithAutoFix(). WithURL("https://github.com/Crocmagnon/fatcontext"), - linter.NewConfig(funlen.New(&cfg.LintersSettings.Funlen)). + linter.NewConfig(funlen.New(&cfg.Linters.Settings.Funlen)). WithSince("v1.18.0"). WithURL("https://github.com/ultraware/funlen"), - linter.NewConfig(gci.New(&cfg.LintersSettings.Gci)). + linter.NewConfig(gci.New(&cfg.Linters.Settings.Gci)). WithSince("v1.30.0"). WithAutoFix(). WithURL("https://github.com/daixiang0/gci"), - linter.NewConfig(ginkgolinter.New(&cfg.LintersSettings.GinkgoLinter)). + linter.NewConfig(ginkgolinter.New(&cfg.Linters.Settings.GinkgoLinter)). WithSince("v1.51.0"). WithLoadForGoAnalysis(). WithAutoFix(). @@ -290,35 +289,35 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { linter.NewConfig(gochecknoinits.New()). WithSince("v1.12.0"), - linter.NewConfig(gochecksumtype.New(&cfg.LintersSettings.GoChecksumType)). + linter.NewConfig(gochecksumtype.New(&cfg.Linters.Settings.GoChecksumType)). WithSince("v1.55.0"). WithLoadForGoAnalysis(). WithURL("https://github.com/alecthomas/go-check-sumtype"), - linter.NewConfig(gocognit.New(&cfg.LintersSettings.Gocognit)). + linter.NewConfig(gocognit.New(&cfg.Linters.Settings.Gocognit)). WithSince("v1.20.0"). WithURL("https://github.com/uudashr/gocognit"), - linter.NewConfig(goconst.New(&cfg.LintersSettings.Goconst)). + linter.NewConfig(goconst.New(&cfg.Linters.Settings.Goconst)). WithSince("v1.0.0"). WithURL("https://github.com/jgautheron/goconst"), - linter.NewConfig(gocritic.New(&cfg.LintersSettings.Gocritic)). + linter.NewConfig(gocritic.New(&cfg.Linters.Settings.Gocritic)). WithSince("v1.12.0"). WithLoadForGoAnalysis(). WithAutoFix(). WithURL("https://github.com/go-critic/go-critic"), - linter.NewConfig(gocyclo.New(&cfg.LintersSettings.Gocyclo)). + linter.NewConfig(gocyclo.New(&cfg.Linters.Settings.Gocyclo)). WithSince("v1.0.0"). WithURL("https://github.com/fzipp/gocyclo"), - linter.NewConfig(godot.New(&cfg.LintersSettings.Godot)). + linter.NewConfig(godot.New(&cfg.Linters.Settings.Godot)). WithSince("v1.25.0"). WithAutoFix(). WithURL("https://github.com/tetafro/godot"), - linter.NewConfig(godox.New(&cfg.LintersSettings.Godox)). + linter.NewConfig(godox.New(&cfg.Linters.Settings.Godox)). WithSince("v1.19.0"). WithURL("https://github.com/matoous/godox"), @@ -328,40 +327,40 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithAutoFix(). WithURL("https://github.com/Djarvur/go-err113"), - linter.NewConfig(gofmt.New(&cfg.LintersSettings.GoFmt)). + linter.NewConfig(gofmt.New(&cfg.Linters.Settings.GoFmt)). WithSince("v1.0.0"). WithAutoFix(). WithURL("https://pkg.go.dev/cmd/gofmt"), - linter.NewConfig(gofumpt.New(&cfg.LintersSettings.GoFumpt)). + linter.NewConfig(gofumpt.New(&cfg.Linters.Settings.GoFumpt)). WithSince("v1.28.0"). WithAutoFix(). WithURL("https://github.com/mvdan/gofumpt"), - linter.NewConfig(golines.New(&cfg.LintersSettings.GoLines)). + linter.NewConfig(golines.New(&cfg.Linters.Settings.GoLines)). WithSince("v2.0.0"). WithAutoFix(). WithURL("https://github.com/segmentio/golines"), - linter.NewConfig(goheader.New(&cfg.LintersSettings.Goheader, cfg.GetBasePath())). + linter.NewConfig(goheader.New(&cfg.Linters.Settings.Goheader, cfg.GetBasePath())). WithSince("v1.28.0"). WithAutoFix(). WithURL("https://github.com/denis-tingaikin/go-header"), - linter.NewConfig(goimports.New(&cfg.LintersSettings.GoImports)). + linter.NewConfig(goimports.New(&cfg.Linters.Settings.GoImports)). WithSince("v1.20.0"). WithAutoFix(). WithURL("https://pkg.go.dev/golang.org/x/tools/cmd/goimports"), - linter.NewConfig(mnd.New(&cfg.LintersSettings.Mnd)). + linter.NewConfig(mnd.New(&cfg.Linters.Settings.Mnd)). WithSince("v1.22.0"). WithURL("https://github.com/tommy-muehle/go-mnd"), - linter.NewConfig(gomoddirectives.New(&cfg.LintersSettings.GoModDirectives)). + linter.NewConfig(gomoddirectives.New(&cfg.Linters.Settings.GoModDirectives)). WithSince("v1.39.0"). WithURL("https://github.com/ldez/gomoddirectives"), - linter.NewConfig(gomodguard.New(&cfg.LintersSettings.Gomodguard)). + linter.NewConfig(gomodguard.New(&cfg.Linters.Settings.Gomodguard)). WithSince("v1.25.0"). WithURL("https://github.com/ryancurrah/gomodguard"), @@ -369,59 +368,56 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithSince("v1.23.0"). WithURL("https://github.com/golangci/go-printf-func-name"), - linter.NewConfig(gosec.New(&cfg.LintersSettings.Gosec)). + linter.NewConfig(gosec.New(&cfg.Linters.Settings.Gosec)). WithSince("v1.0.0"). WithLoadForGoAnalysis(). WithURL("https://github.com/securego/gosec"), - linter.NewConfig(gosimple.New(&cfg.LintersSettings.Gosimple)). - WithGroups(config.DefaultSetNameStandard). - WithEnabledByDefault(). + linter.NewConfig(gosimple.New(&cfg.Linters.Settings.Gosimple)). + WithGroups(config.GroupStandard). WithSince("v1.20.0"). WithLoadForGoAnalysis(). WithAutoFix(). WithURL("https://github.com/dominikh/go-tools/tree/HEAD/simple"), - linter.NewConfig(gosmopolitan.New(&cfg.LintersSettings.Gosmopolitan)). + linter.NewConfig(gosmopolitan.New(&cfg.Linters.Settings.Gosmopolitan)). WithSince("v1.53.0"). WithLoadForGoAnalysis(). WithURL("https://github.com/xen0n/gosmopolitan"), - linter.NewConfig(govet.New(&cfg.LintersSettings.Govet)). - WithGroups(config.DefaultSetNameStandard). - WithEnabledByDefault(). + linter.NewConfig(govet.New(&cfg.Linters.Settings.Govet)). + WithGroups(config.GroupStandard). WithSince("v1.0.0"). WithLoadForGoAnalysis(). WithAutoFix(). WithURL("https://pkg.go.dev/cmd/vet"), - linter.NewConfig(grouper.New(&cfg.LintersSettings.Grouper)). + linter.NewConfig(grouper.New(&cfg.Linters.Settings.Grouper)). WithSince("v1.44.0"). WithURL("https://github.com/leonklingele/grouper"), - linter.NewConfig(iface.New(&cfg.LintersSettings.Iface)). + linter.NewConfig(iface.New(&cfg.Linters.Settings.Iface)). WithSince("v1.62.0"). WithLoadForGoAnalysis(). WithAutoFix(). WithURL("https://github.com/uudashr/iface"), - linter.NewConfig(importas.New(&cfg.LintersSettings.ImportAs)). + linter.NewConfig(importas.New(&cfg.Linters.Settings.ImportAs)). WithSince("v1.38.0"). WithLoadForGoAnalysis(). WithAutoFix(). WithURL("https://github.com/julz/importas"), - linter.NewConfig(inamedparam.New(&cfg.LintersSettings.Inamedparam)). + linter.NewConfig(inamedparam.New(&cfg.Linters.Settings.Inamedparam)). WithSince("v1.55.0"). WithURL("https://github.com/macabu/inamedparam"), linter.NewConfig(ineffassign.New()). - WithGroups(config.DefaultSetNameStandard). - WithEnabledByDefault(). + WithGroups(config.GroupStandard). WithSince("v1.0.0"). WithURL("https://github.com/gordonklaus/ineffassign"), - linter.NewConfig(interfacebloat.New(&cfg.LintersSettings.InterfaceBloat)). + linter.NewConfig(interfacebloat.New(&cfg.Linters.Settings.InterfaceBloat)). WithSince("v1.49.0"). WithURL("https://github.com/sashamelentyev/interfacebloat"), @@ -432,24 +428,24 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithURL("https://github.com/ckaznocha/intrange"). WithNoopFallback(cfg, linter.IsGoLowerThanGo122()), - linter.NewConfig(ireturn.New(&cfg.LintersSettings.Ireturn)). + linter.NewConfig(ireturn.New(&cfg.Linters.Settings.Ireturn)). WithSince("v1.43.0"). WithLoadForGoAnalysis(). WithURL("https://github.com/butuzov/ireturn"), - linter.NewConfig(lll.New(&cfg.LintersSettings.Lll)). + linter.NewConfig(lll.New(&cfg.Linters.Settings.Lll)). WithSince("v1.8.0"), - linter.NewConfig(loggercheck.New(&cfg.LintersSettings.LoggerCheck)). + linter.NewConfig(loggercheck.New(&cfg.Linters.Settings.LoggerCheck)). WithSince("v1.49.0"). WithLoadForGoAnalysis(). WithURL("https://github.com/timonwong/loggercheck"), - linter.NewConfig(maintidx.New(&cfg.LintersSettings.MaintIdx)). + linter.NewConfig(maintidx.New(&cfg.Linters.Settings.MaintIdx)). WithSince("v1.44.0"). WithURL("https://github.com/yagipy/maintidx"), - linter.NewConfig(makezero.New(&cfg.LintersSettings.Makezero)). + linter.NewConfig(makezero.New(&cfg.Linters.Settings.Makezero)). WithSince("v1.34.0"). WithLoadForGoAnalysis(). WithURL("https://github.com/ashanbrown/makezero"), @@ -460,22 +456,22 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithAutoFix(). WithURL("https://github.com/butuzov/mirror"), - linter.NewConfig(misspell.New(&cfg.LintersSettings.Misspell)). + linter.NewConfig(misspell.New(&cfg.Linters.Settings.Misspell)). WithSince("v1.8.0"). WithAutoFix(). WithURL("https://github.com/client9/misspell"), - linter.NewConfig(musttag.New(&cfg.LintersSettings.MustTag)). + linter.NewConfig(musttag.New(&cfg.Linters.Settings.MustTag)). WithSince("v1.51.0"). WithLoadForGoAnalysis(). WithURL("https://github.com/go-simpler/musttag"), - linter.NewConfig(nakedret.New(&cfg.LintersSettings.Nakedret)). + linter.NewConfig(nakedret.New(&cfg.Linters.Settings.Nakedret)). WithSince("v1.19.0"). WithAutoFix(). WithURL("https://github.com/alexkohler/nakedret"), - linter.NewConfig(nestif.New(&cfg.LintersSettings.Nestif)). + linter.NewConfig(nestif.New(&cfg.Linters.Settings.Nestif)). WithSince("v1.25.0"). WithURL("https://github.com/nakabonne/nestif"), @@ -489,12 +485,12 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithLoadForGoAnalysis(). WithURL("https://github.com/alingse/nilnesserr"), - linter.NewConfig(nilnil.New(&cfg.LintersSettings.NilNil)). + linter.NewConfig(nilnil.New(&cfg.Linters.Settings.NilNil)). WithSince("v1.43.0"). WithLoadForGoAnalysis(). WithURL("https://github.com/Antonboom/nilnil"), - linter.NewConfig(nlreturn.New(&cfg.LintersSettings.Nlreturn)). + linter.NewConfig(nlreturn.New(&cfg.Linters.Settings.Nlreturn)). WithSince("v1.30.0"). WithAutoFix(). WithURL("https://github.com/ssgreg/nlreturn"), @@ -504,7 +500,7 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithLoadForGoAnalysis(). WithURL("https://github.com/sonatard/noctx"), - linter.NewConfig(nonamedreturns.New(&cfg.LintersSettings.NoNamedReturns)). + linter.NewConfig(nonamedreturns.New(&cfg.Linters.Settings.NoNamedReturns)). WithSince("v1.46.0"). WithLoadForGoAnalysis(). WithURL("https://github.com/firefart/nonamedreturns"), @@ -513,57 +509,57 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithSince("v1.46.0"). WithURL("https://github.com/stbenjam/no-sprintf-host-port"), - linter.NewConfig(paralleltest.New(&cfg.LintersSettings.ParallelTest)). + linter.NewConfig(paralleltest.New(&cfg.Linters.Settings.ParallelTest)). WithSince("v1.33.0"). WithLoadForGoAnalysis(). WithURL("https://github.com/kunwardeep/paralleltest"), - linter.NewConfig(perfsprint.New(&cfg.LintersSettings.PerfSprint)). + linter.NewConfig(perfsprint.New(&cfg.Linters.Settings.PerfSprint)). WithSince("v1.55.0"). WithLoadForGoAnalysis(). WithAutoFix(). WithURL("https://github.com/catenacyber/perfsprint"), - linter.NewConfig(prealloc.New(&cfg.LintersSettings.Prealloc)). + linter.NewConfig(prealloc.New(&cfg.Linters.Settings.Prealloc)). WithSince("v1.19.0"). WithURL("https://github.com/alexkohler/prealloc"), - linter.NewConfig(predeclared.New(&cfg.LintersSettings.Predeclared)). + linter.NewConfig(predeclared.New(&cfg.Linters.Settings.Predeclared)). WithSince("v1.35.0"). WithURL("https://github.com/nishanths/predeclared"), - linter.NewConfig(promlinter.New(&cfg.LintersSettings.Promlinter)). + linter.NewConfig(promlinter.New(&cfg.Linters.Settings.Promlinter)). WithSince("v1.40.0"). WithURL("https://github.com/yeya24/promlinter"), - linter.NewConfig(protogetter.New(&cfg.LintersSettings.ProtoGetter)). + linter.NewConfig(protogetter.New(&cfg.Linters.Settings.ProtoGetter)). WithSince("v1.55.0"). WithLoadForGoAnalysis(). WithAutoFix(). WithURL("https://github.com/ghostiam/protogetter"), - linter.NewConfig(reassign.New(&cfg.LintersSettings.Reassign)). + linter.NewConfig(reassign.New(&cfg.Linters.Settings.Reassign)). WithSince("v1.49.0"). WithLoadForGoAnalysis(). WithURL("https://github.com/curioswitch/go-reassign"), - linter.NewConfig(recvcheck.New(&cfg.LintersSettings.Recvcheck)). + linter.NewConfig(recvcheck.New(&cfg.Linters.Settings.Recvcheck)). WithSince("v1.62.0"). WithLoadForGoAnalysis(). WithURL("https://github.com/raeperd/recvcheck"), - linter.NewConfig(revive.New(&cfg.LintersSettings.Revive)). + linter.NewConfig(revive.New(&cfg.Linters.Settings.Revive)). WithSince("v1.37.0"). ConsiderSlow(). WithAutoFix(). WithURL("https://github.com/mgechev/revive"), - linter.NewConfig(rowserrcheck.New(&cfg.LintersSettings.RowsErrCheck)). + linter.NewConfig(rowserrcheck.New(&cfg.Linters.Settings.RowsErrCheck)). WithSince("v1.23.0"). WithLoadForGoAnalysis(). WithURL("https://github.com/jingyugao/rowserrcheck"), - linter.NewConfig(sloglint.New(&cfg.LintersSettings.SlogLint)). + linter.NewConfig(sloglint.New(&cfg.Linters.Settings.SlogLint)). WithSince("v1.55.0"). WithLoadForGoAnalysis(). WithURL("https://github.com/go-simpler/sloglint"), @@ -573,31 +569,30 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithLoadForGoAnalysis(). WithURL("https://github.com/ryanrolds/sqlclosecheck"), - linter.NewConfig(spancheck.New(&cfg.LintersSettings.Spancheck)). + linter.NewConfig(spancheck.New(&cfg.Linters.Settings.Spancheck)). WithSince("v1.56.0"). WithLoadForGoAnalysis(). WithURL("https://github.com/jjti/go-spancheck"), - linter.NewConfig(staticcheck.New(&cfg.LintersSettings.Staticcheck)). - WithGroups(config.DefaultSetNameStandard). - WithEnabledByDefault(). + linter.NewConfig(staticcheck.New(&cfg.Linters.Settings.Staticcheck)). + WithGroups(config.GroupStandard). WithSince("v1.0.0"). WithLoadForGoAnalysis(). WithAutoFix(). WithURL("https://staticcheck.dev/"), - linter.NewConfig(stylecheck.New(&cfg.LintersSettings.Stylecheck)). + linter.NewConfig(stylecheck.New(&cfg.Linters.Settings.Stylecheck)). WithSince("v1.20.0"). WithLoadForGoAnalysis(). WithAutoFix(). WithURL("https://github.com/dominikh/go-tools/tree/HEAD/stylecheck"), - linter.NewConfig(tagalign.New(&cfg.LintersSettings.TagAlign)). + linter.NewConfig(tagalign.New(&cfg.Linters.Settings.TagAlign)). WithSince("v1.53.0"). WithAutoFix(). WithURL("https://github.com/4meepo/tagalign"), - linter.NewConfig(tagliatelle.New(&cfg.LintersSettings.Tagliatelle)). + linter.NewConfig(tagliatelle.New(&cfg.Linters.Settings.Tagliatelle)). WithSince("v1.40.0"). WithLoadForGoAnalysis(). WithURL("https://github.com/ldez/tagliatelle"), @@ -606,17 +601,17 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithSince("v1.50.0"). WithURL("https://github.com/maratori/testableexamples"), - linter.NewConfig(testifylint.New(&cfg.LintersSettings.Testifylint)). + linter.NewConfig(testifylint.New(&cfg.Linters.Settings.Testifylint)). WithSince("v1.55.0"). WithLoadForGoAnalysis(). WithAutoFix(). WithURL("https://github.com/Antonboom/testifylint"), - linter.NewConfig(testpackage.New(&cfg.LintersSettings.Testpackage)). + linter.NewConfig(testpackage.New(&cfg.Linters.Settings.Testpackage)). WithSince("v1.25.0"). WithURL("https://github.com/maratori/testpackage"), - linter.NewConfig(thelper.New(&cfg.LintersSettings.Thelper)). + linter.NewConfig(thelper.New(&cfg.Linters.Settings.Thelper)). WithSince("v1.34.0"). WithLoadForGoAnalysis(). WithURL("https://github.com/kulti/thelper"), @@ -628,40 +623,38 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { linter.NewConfig(golinters.NewTypecheck()). WithInternal(). - WithEnabledByDefault(). WithSince("v1.3.0"), - linter.NewConfig(unconvert.New(&cfg.LintersSettings.Unconvert)). + linter.NewConfig(unconvert.New(&cfg.Linters.Settings.Unconvert)). WithSince("v1.0.0"). WithLoadForGoAnalysis(). WithURL("https://github.com/mdempsky/unconvert"), - linter.NewConfig(unparam.New(&cfg.LintersSettings.Unparam)). + linter.NewConfig(unparam.New(&cfg.Linters.Settings.Unparam)). WithSince("v1.9.0"). WithLoadForGoAnalysis(). WithURL("https://github.com/mvdan/unparam"), - linter.NewConfig(unused.New(&cfg.LintersSettings.Unused)). - WithGroups(config.DefaultSetNameStandard). - WithEnabledByDefault(). + linter.NewConfig(unused.New(&cfg.Linters.Settings.Unused)). + WithGroups(config.GroupStandard). WithSince("v1.20.0"). WithLoadForGoAnalysis(). ConsiderSlow(). WithChangeTypes(). WithURL("https://github.com/dominikh/go-tools/tree/HEAD/unused"), - linter.NewConfig(usestdlibvars.New(&cfg.LintersSettings.UseStdlibVars)). + linter.NewConfig(usestdlibvars.New(&cfg.Linters.Settings.UseStdlibVars)). WithSince("v1.48.0"). WithAutoFix(). WithURL("https://github.com/sashamelentyev/usestdlibvars"), - linter.NewConfig(usetesting.New(&cfg.LintersSettings.UseTesting)). + linter.NewConfig(usetesting.New(&cfg.Linters.Settings.UseTesting)). WithSince("v1.63.0"). WithLoadForGoAnalysis(). WithAutoFix(). WithURL("https://github.com/ldez/usetesting"), - linter.NewConfig(varnamelen.New(&cfg.LintersSettings.Varnamelen)). + linter.NewConfig(varnamelen.New(&cfg.Linters.Settings.Varnamelen)). WithSince("v1.43.0"). WithLoadForGoAnalysis(). WithURL("https://github.com/blizzy78/varnamelen"), @@ -671,17 +664,17 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithLoadForGoAnalysis(). WithURL("https://github.com/sanposhiho/wastedassign"), - linter.NewConfig(whitespace.New(&cfg.LintersSettings.Whitespace)). + linter.NewConfig(whitespace.New(&cfg.Linters.Settings.Whitespace)). WithSince("v1.19.0"). WithAutoFix(). WithURL("https://github.com/ultraware/whitespace"), - linter.NewConfig(wrapcheck.New(&cfg.LintersSettings.Wrapcheck)). + linter.NewConfig(wrapcheck.New(&cfg.Linters.Settings.Wrapcheck)). WithSince("v1.32.0"). WithLoadForGoAnalysis(). WithURL("https://github.com/tomarrell/wrapcheck"), - linter.NewConfig(wsl.New(&cfg.LintersSettings.WSL)). + linter.NewConfig(wsl.New(&cfg.Linters.Settings.WSL)). WithSince("v1.20.0"). WithAutoFix(). WithURL("https://github.com/bombsimon/wsl"), @@ -692,7 +685,7 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithURL("https://github.com/ykadowak/zerologlint"), // nolintlint must be last because it looks at the results of all the previous linters for unused nolint directives - linter.NewConfig(nolintlint.New(&cfg.LintersSettings.NoLintLint)). + linter.NewConfig(nolintlint.New(&cfg.Linters.Settings.NoLintLint)). WithSince("v1.26.0"). WithAutoFix(). WithURL("https://github.com/golangci/golangci-lint/tree/HEAD/pkg/golinters/nolintlint/internal"), diff --git a/pkg/lint/lintersdb/builder_plugin_go.go b/pkg/lint/lintersdb/builder_plugin_go.go index 15d0a2586434..78648ccad395 100644 --- a/pkg/lint/lintersdb/builder_plugin_go.go +++ b/pkg/lint/lintersdb/builder_plugin_go.go @@ -40,7 +40,7 @@ func (b *PluginGoBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { var linters []*linter.Config - for name, settings := range cfg.LintersSettings.Custom { + for name, settings := range cfg.Linters.Settings.Custom { if settings.Type != goPluginType && settings.Type != "" { continue } @@ -69,7 +69,7 @@ func (b *PluginGoBuilder) loadConfig(cfg *config.Config, name string, settings * WithLoadMode(goanalysis.LoadModeTypesInfo) linterConfig := linter.NewConfig(customLinter). - WithEnabledByDefault(). + WithGroups(config.GroupStandard). WithLoadForGoAnalysis(). WithURL(settings.OriginalURL) diff --git a/pkg/lint/lintersdb/builder_plugin_module.go b/pkg/lint/lintersdb/builder_plugin_module.go index 60fb58d8ce3a..7738fd3bdff7 100644 --- a/pkg/lint/lintersdb/builder_plugin_module.go +++ b/pkg/lint/lintersdb/builder_plugin_module.go @@ -32,7 +32,7 @@ func (b *PluginModuleBuilder) Build(cfg *config.Config) ([]*linter.Config, error var linters []*linter.Config - for name, settings := range cfg.LintersSettings.Custom { + for name, settings := range cfg.Linters.Settings.Custom { if settings.Type != modulePluginType { continue } @@ -66,7 +66,7 @@ func (b *PluginModuleBuilder) Build(cfg *config.Config) ([]*linter.Config, error } lc := linter.NewConfig(customLinter). - WithEnabledByDefault(). + WithGroups(config.GroupStandard). WithURL(settings.OriginalURL) switch strings.ToLower(p.GetLoadMode()) { diff --git a/pkg/lint/lintersdb/manager.go b/pkg/lint/lintersdb/manager.go index 07b7c8677339..dc4c105c3bb0 100644 --- a/pkg/lint/lintersdb/manager.go +++ b/pkg/lint/lintersdb/manager.go @@ -1,6 +1,7 @@ package lintersdb import ( + "cmp" "fmt" "maps" "os" @@ -77,7 +78,10 @@ func (m *Manager) GetAllSupportedLinterConfigs() []*linter.Config { } func (m *Manager) GetEnabledLintersMap() (map[string]*linter.Config, error) { - enabledLinters := m.build(m.GetAllEnabledByDefaultLinters()) + enabledLinters, err := m.build() + if err != nil { + return nil, err + } if os.Getenv(logutils.EnvTestRun) == "1" { m.verbosePrintLintersStatus(enabledLinters) @@ -89,7 +93,11 @@ func (m *Manager) GetEnabledLintersMap() (map[string]*linter.Config, error) { // GetOptimizedLinters returns enabled linters after optimization (merging) of multiple linters into a fewer number of linters. // E.g. some go/analysis linters can be optimized into one metalinter for data reuse and speed up. func (m *Manager) GetOptimizedLinters() ([]*linter.Config, error) { - resultLintersSet := m.build(m.GetAllEnabledByDefaultLinters()) + resultLintersSet, err := m.build() + if err != nil { + return nil, err + } + m.verbosePrintLintersStatus(resultLintersSet) m.combineGoAnalysisLinters(resultLintersSet) @@ -118,55 +126,72 @@ func (m *Manager) GetOptimizedLinters() ([]*linter.Config, error) { return resultLinters, nil } -func (m *Manager) GetAllEnabledByDefaultLinters() []*linter.Config { - var ret []*linter.Config - for _, lc := range m.linters { - if lc.EnabledByDefault { - ret = append(ret, lc) - } - } +//nolint:gocyclo // the complexity cannot be reduced. +func (m *Manager) build() (map[string]*linter.Config, error) { + m.debugf("Linters config: %#v", m.cfg.Linters) - return ret -} + resultLintersSet := map[string]*linter.Config{} -func (m *Manager) build(enabledByDefaultLinters []*linter.Config) map[string]*linter.Config { - m.debugf("Linters config: %#v", m.cfg.OldLinters) + groupName := cmp.Or(m.cfg.Linters.Default, config.GroupStandard) - resultLintersSet := map[string]*linter.Config{} - switch { - case m.cfg.OldLinters.DisableAll: + switch groupName { + case config.GroupNone: // no default linters - case m.cfg.OldLinters.EnableAll: + + case config.GroupAll: resultLintersSet = linterConfigsToMap(m.linters) - default: - resultLintersSet = linterConfigsToMap(enabledByDefaultLinters) - } - // --fast removes slow linters from current set. - // It should be after --presets to be able to run only fast linters in preset. - // It should be before --enable and --disable to be able to enable or disable specific linter. - if m.cfg.OldLinters.Fast { - for name, lc := range resultLintersSet { + case config.GroupFast: + var selected []*linter.Config + for _, lc := range m.linters { if lc.IsSlowLinter() { - delete(resultLintersSet, name) + continue + } + + selected = append(selected, lc) + } + + resultLintersSet = linterConfigsToMap(selected) + + case config.GroupStandard: + var selected []*linter.Config + for _, lc := range m.linters { + if !lc.FromGroup(config.GroupStandard) { + continue } + + selected = append(selected, lc) } + + resultLintersSet = linterConfigsToMap(selected) + + default: + return nil, fmt.Errorf("unknown group: %s", groupName) } - for _, name := range slices.Concat(m.cfg.OldLinters.Enable, m.cfg.Formatters.Enable) { + for _, name := range slices.Concat(m.cfg.Linters.Enable, m.cfg.Formatters.Enable) { for _, lc := range m.GetLinterConfigs(name) { // it's important to use lc.Name() nor name because name can be alias resultLintersSet[lc.Name()] = lc } } - for _, name := range m.cfg.OldLinters.Disable { + for _, name := range m.cfg.Linters.Disable { for _, lc := range m.GetLinterConfigs(name) { // it's important to use lc.Name() nor name because name can be alias delete(resultLintersSet, lc.Name()) } } + if m.cfg.Linters.FastOnly { + for lc := range maps.Values(resultLintersSet) { + if lc.IsSlowLinter() { + // it's important to use lc.Name() nor name because name can be alias + delete(resultLintersSet, lc.Name()) + } + } + } + // typecheck is not a real linter and cannot be disabled. if _, ok := resultLintersSet["typecheck"]; !ok && (m.cfg == nil || !m.cfg.InternalCmdTest) { for _, lc := range m.GetLinterConfigs("typecheck") { @@ -175,7 +200,7 @@ func (m *Manager) build(enabledByDefaultLinters []*linter.Config) map[string]*li } } - return resultLintersSet + return resultLintersSet, nil } func (m *Manager) combineGoAnalysisLinters(linters map[string]*linter.Config) { diff --git a/pkg/lint/lintersdb/manager_test.go b/pkg/lint/lintersdb/manager_test.go index 806bf1757a3a..62874cba0a0a 100644 --- a/pkg/lint/lintersdb/manager_test.go +++ b/pkg/lint/lintersdb/manager_test.go @@ -15,8 +15,8 @@ import ( func TestManager_GetEnabledLintersMap(t *testing.T) { cfg := config.NewDefault() - cfg.OldLinters.DisableAll = true - cfg.OldLinters.Enable = []string{"gofmt"} + cfg.Linters.Default = config.GroupNone + cfg.Linters.Enable = []string{"gofmt"} m, err := NewManager(logutils.NewStderrLog("skip"), cfg, NewLinterBuilder()) require.NoError(t, err) @@ -37,8 +37,8 @@ func TestManager_GetEnabledLintersMap(t *testing.T) { func TestManager_GetOptimizedLinters(t *testing.T) { cfg := config.NewDefault() - cfg.OldLinters.DisableAll = true - cfg.OldLinters.Enable = []string{"gofmt"} + cfg.Linters.Default = config.GroupNone + cfg.Linters.Enable = []string{"gofmt"} m, err := NewManager(logutils.NewStderrLog("skip"), cfg, NewLinterBuilder()) require.NoError(t, err) @@ -65,21 +65,16 @@ func TestManager_GetOptimizedLinters(t *testing.T) { func TestManager_build(t *testing.T) { testCases := []struct { - desc string - cfg *config.Config - defaultSet []string // enabled by default linters - expected []string // alphabetically ordered enabled linter names + desc string + cfg *config.Config + expected []string // alphabetically ordered enabled linter names }{ - { - desc: "don't disable anything", - defaultSet: []string{"gofmt", "govet", "typecheck"}, - expected: []string{"gofmt", "govet", "typecheck"}, - }, { desc: "enable gosec by primary name", cfg: &config.Config{ - OldLinters: config.OldLinters{ - Enable: []string{"gosec"}, + Linters: config.Linters{ + Default: config.GroupNone, + Enable: []string{"gosec"}, }, }, expected: []string{"gosec", "typecheck"}, @@ -87,18 +82,19 @@ func TestManager_build(t *testing.T) { { desc: "disable gosec by primary name", cfg: &config.Config{ - OldLinters: config.OldLinters{ + Linters: config.Linters{ + Default: config.GroupNone, Disable: []string{"gosec"}, }, }, - defaultSet: []string{"gosec"}, - expected: []string{"typecheck"}, + expected: []string{"typecheck"}, }, { desc: "linters and formatters", cfg: &config.Config{ - OldLinters: config.OldLinters{ - Enable: []string{"gosec"}, + Linters: config.Linters{ + Default: config.GroupNone, + Enable: []string{"gosec"}, }, Formatters: config.Formatters{ Enable: []string{"gofmt"}, @@ -109,7 +105,8 @@ func TestManager_build(t *testing.T) { { desc: "linters and formatters but linters configuration disables the formatter", cfg: &config.Config{ - OldLinters: config.OldLinters{ + Linters: config.Linters{ + Default: config.GroupNone, Enable: []string{"gosec"}, Disable: []string{"gofmt"}, }, @@ -122,6 +119,9 @@ func TestManager_build(t *testing.T) { { desc: "only formatters", cfg: &config.Config{ + Linters: config.Linters{ + Default: config.GroupNone, + }, Formatters: config.Formatters{ Enable: []string{"gofmt"}, }, @@ -135,14 +135,9 @@ func TestManager_build(t *testing.T) { m, err := NewManager(logutils.NewStderrLog("skip"), test.cfg, NewLinterBuilder()) require.NoError(t, err) - var defaultLinters []*linter.Config - for _, ln := range test.defaultSet { - lcs := m.GetLinterConfigs(ln) - assert.NotNil(t, lcs, ln) - defaultLinters = append(defaultLinters, lcs...) - } + els, err := m.build() + require.NoError(t, err) - els := m.build(defaultLinters) var enabledLinters []string for ln, lc := range els { assert.Equal(t, ln, lc.Name()) diff --git a/pkg/lint/lintersdb/validator.go b/pkg/lint/lintersdb/validator.go index 5b627a0b1661..e9a44bfe5501 100644 --- a/pkg/lint/lintersdb/validator.go +++ b/pkg/lint/lintersdb/validator.go @@ -21,13 +21,13 @@ func NewValidator(m *Manager) *Validator { // Validate validates the configuration by calling all other validators for different // sections in the configuration and then some additional linter validation functions. func (v Validator) Validate(cfg *config.Config) error { - validators := []func(cfg *config.OldLinters) error{ + validators := []func(cfg *config.Linters) error{ v.validateLintersNames, v.alternativeNamesDeprecation, } for _, v := range validators { - if err := v(&cfg.OldLinters); err != nil { + if err := v(&cfg.Linters); err != nil { return err } } @@ -35,7 +35,7 @@ func (v Validator) Validate(cfg *config.Config) error { return nil } -func (v Validator) validateLintersNames(cfg *config.OldLinters) error { +func (v Validator) validateLintersNames(cfg *config.Linters) error { var unknownNames []string for _, name := range cfg.Enable { @@ -68,7 +68,7 @@ func (v Validator) validateLintersNames(cfg *config.OldLinters) error { return nil } -func (v Validator) alternativeNamesDeprecation(cfg *config.OldLinters) error { +func (v Validator) alternativeNamesDeprecation(cfg *config.Linters) error { if v.m.cfg.InternalTest || v.m.cfg.InternalCmdTest || os.Getenv(logutils.EnvTestRun) == "1" { return nil } diff --git a/pkg/lint/lintersdb/validator_test.go b/pkg/lint/lintersdb/validator_test.go index 4c8f00b93587..8d8ad63c2272 100644 --- a/pkg/lint/lintersdb/validator_test.go +++ b/pkg/lint/lintersdb/validator_test.go @@ -10,14 +10,14 @@ import ( type validateErrorTestCase struct { desc string - cfg *config.OldLinters + cfg *config.Linters expected string } var validateLintersNamesErrorTestCases = []validateErrorTestCase{ { desc: "unknown enabled linter", - cfg: &config.OldLinters{ + cfg: &config.Linters{ Enable: []string{"golangci"}, Disable: nil, }, @@ -25,7 +25,7 @@ var validateLintersNamesErrorTestCases = []validateErrorTestCase{ }, { desc: "unknown disabled linter", - cfg: &config.OldLinters{ + cfg: &config.Linters{ Enable: nil, Disable: []string{"golangci"}, }, @@ -35,27 +35,27 @@ var validateLintersNamesErrorTestCases = []validateErrorTestCase{ type validatorTestCase struct { desc string - cfg *config.OldLinters + cfg *config.Linters } var validateLintersNamesTestCases = []validatorTestCase{ { desc: "no enable no disable", - cfg: &config.OldLinters{ + cfg: &config.Linters{ Enable: nil, Disable: nil, }, }, { desc: "existing enabled linter", - cfg: &config.OldLinters{ + cfg: &config.Linters{ Enable: []string{"gofmt"}, Disable: nil, }, }, { desc: "existing disabled linter", - cfg: &config.OldLinters{ + cfg: &config.Linters{ Enable: nil, Disable: []string{"gofmt"}, }, @@ -75,7 +75,7 @@ func TestValidator_Validate(t *testing.T) { t.Run(test.desc, func(t *testing.T) { t.Parallel() - err := v.Validate(&config.Config{OldLinters: *test.cfg}) + err := v.Validate(&config.Config{Linters: *test.cfg}) require.NoError(t, err) }) } @@ -94,7 +94,7 @@ func TestValidator_Validate_error(t *testing.T) { t.Run(test.desc, func(t *testing.T) { t.Parallel() - err := v.Validate(&config.Config{OldLinters: *test.cfg}) + err := v.Validate(&config.Config{Linters: *test.cfg}) require.Error(t, err) require.EqualError(t, err, test.expected) diff --git a/pkg/lint/runner.go b/pkg/lint/runner.go index 3c0bd26ce801..0795a35ef4a5 100644 --- a/pkg/lint/runner.go +++ b/pkg/lint/runner.go @@ -47,7 +47,7 @@ func NewRunner(log logutils.Log, cfg *config.Config, goenv *goutil.Env, return nil, fmt.Errorf("error creating path relativity processor: %w", err) } - exclusionPaths, err := processors.NewExclusionPaths(log, &cfg.OldLinters.LinterExclusions) + exclusionPaths, err := processors.NewExclusionPaths(log, &cfg.Linters.Exclusions) if err != nil { return nil, err } @@ -66,7 +66,7 @@ func NewRunner(log logutils.Log, cfg *config.Config, goenv *goutil.Env, formattersCfg := &config.Formatters{ Enable: enabledFormatters, - Settings: cfg.LintersSettings.FormatterSettings, + Settings: cfg.Linters.Settings.FormatterSettings, } metaFormatter, err := goformatters.NewMetaFormatter(log, formattersCfg, &cfg.Run) @@ -93,13 +93,13 @@ func NewRunner(log logutils.Log, cfg *config.Config, goenv *goutil.Env, // Must be after PathRelativity. exclusionPaths, - processors.NewGeneratedFileFilter(cfg.OldLinters.LinterExclusions.Generated), + processors.NewGeneratedFileFilter(cfg.Linters.Exclusions.Generated), // Must be before exclude because users see already marked output and configure excluding by it. processors.NewIdentifierMarker(), processors.NewExclusionRules(log.Child(logutils.DebugKeyExclusionRules), files, - &cfg.OldLinters.LinterExclusions), + &cfg.Linters.Exclusions), processors.NewNolintFilter(log.Child(logutils.DebugKeyNolintFilter), dbManager, enabledLinters), diff --git a/pkg/printers/testdata/golden-json.json b/pkg/printers/testdata/golden-json.json index 880b0dcc8074..493146ac57ad 100644 --- a/pkg/printers/testdata/golden-json.json +++ b/pkg/printers/testdata/golden-json.json @@ -1 +1 @@ -{"Issues":[{"FromLinter":"gochecknoinits","Text":"don't use `init` function","Severity":"","SourceLines":["func init() {"],"Pos":{"Filename":"pkg/experimental/myplugin/myplugin.go","Offset":162,"Line":13,"Column":1},"ExpectNoLint":false,"ExpectedNoLintLinter":""},{"FromLinter":"gocritic","Text":"hugeParam: settings is heavy (80 bytes); consider passing it by pointer","Severity":"","SourceLines":["func (b *PluginBuilder) loadConfig(cfg *config.Config, name string, settings config.CustomLinterSettings) (*linter.Config, error) {"],"Pos":{"Filename":"pkg/lint/lintersdb/builder_plugin.go","Offset":1480,"Line":59,"Column":69},"ExpectNoLint":false,"ExpectedNoLintLinter":""},{"FromLinter":"goimports","Text":"File is not `goimports`-ed with -local github.com/golangci/golangci-lint","Severity":"","SourceLines":[""],"Pos":{"Filename":"pkg/printers/printer_test.go","Offset":0,"Line":6,"Column":0},"SuggestedFixes":[{"Message":"","TextEdits":[{"Pos":13,"End":32,"NewText":null}]}],"ExpectNoLint":false,"ExpectedNoLintLinter":""},{"FromLinter":"maligned","Text":"struct of size 144 bytes could be of size 128 bytes","Severity":"","SourceLines":["type Issues struct {"],"Pos":{"Filename":"pkg/config/issues.go","Offset":3338,"Line":107,"Column":13},"ExpectNoLint":false,"ExpectedNoLintLinter":""},{"FromLinter":"maligned","Text":"struct of size 3144 bytes could be of size 3096 bytes","Severity":"","SourceLines":["type LintersSettings struct {"],"Pos":{"Filename":"pkg/config/linters_settings.go","Offset":4576,"Line":200,"Column":22},"ExpectNoLint":false,"ExpectedNoLintLinter":""},{"FromLinter":"maligned","Text":"struct of size 72 bytes could be of size 64 bytes","Severity":"","SourceLines":["type ExhaustiveSettings struct {"],"Pos":{"Filename":"pkg/config/linters_settings.go","Offset":10829,"Line":383,"Column":25},"ExpectNoLint":false,"ExpectedNoLintLinter":""},{"FromLinter":"maligned","Text":"struct of size 72 bytes could be of size 56 bytes","Severity":"","SourceLines":["type GoConstSettings struct {"],"Pos":{"Filename":"pkg/config/linters_settings.go","Offset":14399,"Line":470,"Column":22},"ExpectNoLint":false,"ExpectedNoLintLinter":""},{"FromLinter":"maligned","Text":"struct of size 136 bytes could be of size 128 bytes","Severity":"","SourceLines":["type GoCriticSettings struct {"],"Pos":{"Filename":"pkg/config/linters_settings.go","Offset":14934,"Line":482,"Column":23},"ExpectNoLint":false,"ExpectedNoLintLinter":""},{"FromLinter":"maligned","Text":"struct of size 64 bytes could be of size 56 bytes","Severity":"","SourceLines":["type GosmopolitanSettings struct {"],"Pos":{"Filename":"pkg/config/linters_settings.go","Offset":18601,"Line":584,"Column":27},"ExpectNoLint":false,"ExpectedNoLintLinter":""},{"FromLinter":"maligned","Text":"struct of size 88 bytes could be of size 80 bytes","Severity":"","SourceLines":["type GovetSettings struct {"],"Pos":{"Filename":"pkg/config/linters_settings.go","Offset":18867,"Line":591,"Column":20},"ExpectNoLint":false,"ExpectedNoLintLinter":""},{"FromLinter":"maligned","Text":"struct of size 40 bytes could be of size 32 bytes","Severity":"","SourceLines":["type NoLintLintSettings struct {"],"Pos":{"Filename":"pkg/config/linters_settings.go","Offset":22337,"Line":710,"Column":25},"ExpectNoLint":false,"ExpectedNoLintLinter":""},{"FromLinter":"maligned","Text":"struct of size 112 bytes could be of size 104 bytes","Severity":"","SourceLines":["type ReviveSettings struct {"],"Pos":{"Filename":"pkg/config/linters_settings.go","Offset":24019,"Line":762,"Column":21},"ExpectNoLint":false,"ExpectedNoLintLinter":""},{"FromLinter":"maligned","Text":"struct of size 32 bytes could be of size 24 bytes","Severity":"","SourceLines":["type SlogLintSettings struct {"],"Pos":{"Filename":"pkg/config/linters_settings.go","Offset":24648,"Line":787,"Column":23},"ExpectNoLint":false,"ExpectedNoLintLinter":""},{"FromLinter":"maligned","Text":"struct of size 40 bytes could be of size 32 bytes","Severity":"","SourceLines":["type TagAlignSettings struct {"],"Pos":{"Filename":"pkg/config/linters_settings.go","Offset":25936,"Line":817,"Column":23},"ExpectNoLint":false,"ExpectedNoLintLinter":""},{"FromLinter":"maligned","Text":"struct of size 80 bytes could be of size 72 bytes","Severity":"","SourceLines":["type VarnamelenSettings struct {"],"Pos":{"Filename":"pkg/config/linters_settings.go","Offset":28758,"Line":902,"Column":25},"ExpectNoLint":false,"ExpectedNoLintLinter":""},{"FromLinter":"maligned","Text":"struct of size 112 bytes could be of size 96 bytes","Severity":"","SourceLines":["type WSLSettings struct {"],"Pos":{"Filename":"pkg/config/linters_settings.go","Offset":29898,"Line":928,"Column":18},"ExpectNoLint":false,"ExpectedNoLintLinter":""},{"FromLinter":"maligned","Text":"struct of size 168 bytes could be of size 160 bytes","Severity":"","SourceLines":["type Run struct {"],"Pos":{"Filename":"pkg/config/run.go","Offset":112,"Line":6,"Column":10},"ExpectNoLint":false,"ExpectedNoLintLinter":""},{"FromLinter":"maligned","Text":"struct of size 128 bytes could be of size 120 bytes","Severity":"","SourceLines":["type Config struct {"],"Pos":{"Filename":"pkg/lint/linter/config.go","Offset":1329,"Line":36,"Column":13},"ExpectNoLint":false,"ExpectedNoLintLinter":""},{"FromLinter":"maligned","Text":"struct of size 96 bytes could be of size 88 bytes","Severity":"","SourceLines":["\tfor _, tc := range []struct {"],"Pos":{"Filename":"pkg/golinters/govet_test.go","Offset":1804,"Line":70,"Column":23},"ExpectNoLint":false,"ExpectedNoLintLinter":""},{"FromLinter":"maligned","Text":"struct of size 64 bytes could be of size 56 bytes","Severity":"","SourceLines":["type Diff struct {"],"Pos":{"Filename":"pkg/result/processors/diff.go","Offset":233,"Line":17,"Column":11},"ExpectNoLint":false,"ExpectedNoLintLinter":""},{"FromLinter":"revive","Text":"unused-parameter: parameter 'pass' seems to be unused, consider removing or renaming it as _","Severity":"warning","SourceLines":["\t\t\tRun: func(pass *analysis.Pass) (any, error) {"],"Pos":{"Filename":"pkg/experimental/myplugin/myplugin.go","Offset":921,"Line":49,"Column":14},"LineRange":{"From":49,"To":49},"ExpectNoLint":false,"ExpectedNoLintLinter":""},{"FromLinter":"unused","Text":"const `defaultFileMode` is unused","Severity":"","SourceLines":["const defaultFileMode = 0644"],"Pos":{"Filename":"pkg/commands/run.go","Offset":1209,"Line":47,"Column":7},"ExpectNoLint":false,"ExpectedNoLintLinter":""}],"Report":{"Warnings":[{"Tag":"runner","Text":"The linter 'maligned' is deprecated (since v1.38.0) due to: The repository of the linter has been archived by the owner. Replaced by govet 'fieldalignment'."}],"Linters":[{"Name":"asasalint"},{"Name":"asciicheck"},{"Name":"bidichk"},{"Name":"bodyclose","Enabled":true},{"Name":"containedctx"},{"Name":"contextcheck"},{"Name":"cyclop"},{"Name":"decorder"},{"Name":"deadcode"},{"Name":"depguard","Enabled":true},{"Name":"dogsled","Enabled":true},{"Name":"dupl","Enabled":true},{"Name":"dupword"},{"Name":"durationcheck"},{"Name":"errcheck","Enabled":true,"EnabledByDefault":true},{"Name":"errchkjson"},{"Name":"errname"},{"Name":"errorlint","Enabled":true},{"Name":"execinquery"},{"Name":"exhaustive"},{"Name":"exhaustivestruct"},{"Name":"exhaustruct"},{"Name":"exportloopref","Enabled":true},{"Name":"forbidigo"},{"Name":"forcetypeassert"},{"Name":"funlen","Enabled":true},{"Name":"gci"},{"Name":"ginkgolinter"},{"Name":"gocheckcompilerdirectives","Enabled":true},{"Name":"gochecknoglobals"},{"Name":"gochecknoinits","Enabled":true},{"Name":"gochecksumtype"},{"Name":"gocognit"},{"Name":"goconst","Enabled":true},{"Name":"gocritic","Enabled":true},{"Name":"gocyclo","Enabled":true},{"Name":"godot"},{"Name":"godox"},{"Name":"err113"},{"Name":"gofmt","Enabled":true},{"Name":"gofumpt"},{"Name":"goheader"},{"Name":"goimports","Enabled":true},{"Name":"golint"},{"Name":"mnd","Enabled":true},{"Name":"gomoddirectives"},{"Name":"gomodguard"},{"Name":"goprintffuncname","Enabled":true},{"Name":"gosec","Enabled":true},{"Name":"gosimple","Enabled":true,"EnabledByDefault":true},{"Name":"gosmopolitan"},{"Name":"govet","Enabled":true,"EnabledByDefault":true},{"Name":"grouper"},{"Name":"ifshort"},{"Name":"importas"},{"Name":"inamedparam"},{"Name":"ineffassign","Enabled":true,"EnabledByDefault":true},{"Name":"interfacebloat"},{"Name":"interfacer"},{"Name":"ireturn"},{"Name":"lll","Enabled":true},{"Name":"loggercheck"},{"Name":"maintidx"},{"Name":"makezero"},{"Name":"maligned","Enabled":true},{"Name":"mirror"},{"Name":"misspell","Enabled":true},{"Name":"musttag"},{"Name":"nakedret","Enabled":true},{"Name":"nestif"},{"Name":"nilerr"},{"Name":"nilnil"},{"Name":"nlreturn"},{"Name":"noctx","Enabled":true},{"Name":"nonamedreturns"},{"Name":"nosnakecase"},{"Name":"nosprintfhostport"},{"Name":"paralleltest"},{"Name":"perfsprint"},{"Name":"prealloc"},{"Name":"predeclared"},{"Name":"promlinter"},{"Name":"protogetter"},{"Name":"reassign"},{"Name":"revive","Enabled":true},{"Name":"rowserrcheck"},{"Name":"sloglint"},{"Name":"scopelint"},{"Name":"sqlclosecheck"},{"Name":"spancheck"},{"Name":"staticcheck","Enabled":true,"EnabledByDefault":true},{"Name":"structcheck"},{"Name":"stylecheck","Enabled":true},{"Name":"tagalign"},{"Name":"tagliatelle"},{"Name":"tenv"},{"Name":"testableexamples"},{"Name":"testifylint"},{"Name":"testpackage"},{"Name":"thelper"},{"Name":"tparallel"},{"Name":"typecheck","Enabled":true,"EnabledByDefault":true},{"Name":"unconvert","Enabled":true},{"Name":"unparam","Enabled":true},{"Name":"unused","Enabled":true,"EnabledByDefault":true},{"Name":"usestdlibvars"},{"Name":"varcheck"},{"Name":"varnamelen"},{"Name":"wastedassign"},{"Name":"whitespace","Enabled":true},{"Name":"wrapcheck"},{"Name":"wsl"},{"Name":"zerologlint"},{"Name":"nolintlint","Enabled":true}]}} +{"Issues":[{"FromLinter":"gochecknoinits","Text":"don't use `init` function","Severity":"","SourceLines":["func init() {"],"Pos":{"Filename":"pkg/experimental/myplugin/myplugin.go","Offset":162,"Line":13,"Column":1},"ExpectNoLint":false,"ExpectedNoLintLinter":""},{"FromLinter":"gocritic","Text":"hugeParam: settings is heavy (80 bytes); consider passing it by pointer","Severity":"","SourceLines":["func (b *PluginBuilder) loadConfig(cfg *config.Config, name string, settings config.CustomLinterSettings) (*linter.Config, error) {"],"Pos":{"Filename":"pkg/lint/lintersdb/builder_plugin.go","Offset":1480,"Line":59,"Column":69},"ExpectNoLint":false,"ExpectedNoLintLinter":""},{"FromLinter":"goimports","Text":"File is not `goimports`-ed with -local github.com/golangci/golangci-lint","Severity":"","SourceLines":[""],"Pos":{"Filename":"pkg/printers/printer_test.go","Offset":0,"Line":6,"Column":0},"SuggestedFixes":[{"Message":"","TextEdits":[{"Pos":13,"End":32,"NewText":null}]}],"ExpectNoLint":false,"ExpectedNoLintLinter":""},{"FromLinter":"maligned","Text":"struct of size 144 bytes could be of size 128 bytes","Severity":"","SourceLines":["type Issues struct {"],"Pos":{"Filename":"pkg/config/issues.go","Offset":3338,"Line":107,"Column":13},"ExpectNoLint":false,"ExpectedNoLintLinter":""},{"FromLinter":"maligned","Text":"struct of size 3144 bytes could be of size 3096 bytes","Severity":"","SourceLines":["type LintersSettings struct {"],"Pos":{"Filename":"pkg/config/linters_settings.go","Offset":4576,"Line":200,"Column":22},"ExpectNoLint":false,"ExpectedNoLintLinter":""},{"FromLinter":"maligned","Text":"struct of size 72 bytes could be of size 64 bytes","Severity":"","SourceLines":["type ExhaustiveSettings struct {"],"Pos":{"Filename":"pkg/config/linters_settings.go","Offset":10829,"Line":383,"Column":25},"ExpectNoLint":false,"ExpectedNoLintLinter":""},{"FromLinter":"maligned","Text":"struct of size 72 bytes could be of size 56 bytes","Severity":"","SourceLines":["type GoConstSettings struct {"],"Pos":{"Filename":"pkg/config/linters_settings.go","Offset":14399,"Line":470,"Column":22},"ExpectNoLint":false,"ExpectedNoLintLinter":""},{"FromLinter":"maligned","Text":"struct of size 136 bytes could be of size 128 bytes","Severity":"","SourceLines":["type GoCriticSettings struct {"],"Pos":{"Filename":"pkg/config/linters_settings.go","Offset":14934,"Line":482,"Column":23},"ExpectNoLint":false,"ExpectedNoLintLinter":""},{"FromLinter":"maligned","Text":"struct of size 64 bytes could be of size 56 bytes","Severity":"","SourceLines":["type GosmopolitanSettings struct {"],"Pos":{"Filename":"pkg/config/linters_settings.go","Offset":18601,"Line":584,"Column":27},"ExpectNoLint":false,"ExpectedNoLintLinter":""},{"FromLinter":"maligned","Text":"struct of size 88 bytes could be of size 80 bytes","Severity":"","SourceLines":["type GovetSettings struct {"],"Pos":{"Filename":"pkg/config/linters_settings.go","Offset":18867,"Line":591,"Column":20},"ExpectNoLint":false,"ExpectedNoLintLinter":""},{"FromLinter":"maligned","Text":"struct of size 40 bytes could be of size 32 bytes","Severity":"","SourceLines":["type NoLintLintSettings struct {"],"Pos":{"Filename":"pkg/config/linters_settings.go","Offset":22337,"Line":710,"Column":25},"ExpectNoLint":false,"ExpectedNoLintLinter":""},{"FromLinter":"maligned","Text":"struct of size 112 bytes could be of size 104 bytes","Severity":"","SourceLines":["type ReviveSettings struct {"],"Pos":{"Filename":"pkg/config/linters_settings.go","Offset":24019,"Line":762,"Column":21},"ExpectNoLint":false,"ExpectedNoLintLinter":""},{"FromLinter":"maligned","Text":"struct of size 32 bytes could be of size 24 bytes","Severity":"","SourceLines":["type SlogLintSettings struct {"],"Pos":{"Filename":"pkg/config/linters_settings.go","Offset":24648,"Line":787,"Column":23},"ExpectNoLint":false,"ExpectedNoLintLinter":""},{"FromLinter":"maligned","Text":"struct of size 40 bytes could be of size 32 bytes","Severity":"","SourceLines":["type TagAlignSettings struct {"],"Pos":{"Filename":"pkg/config/linters_settings.go","Offset":25936,"Line":817,"Column":23},"ExpectNoLint":false,"ExpectedNoLintLinter":""},{"FromLinter":"maligned","Text":"struct of size 80 bytes could be of size 72 bytes","Severity":"","SourceLines":["type VarnamelenSettings struct {"],"Pos":{"Filename":"pkg/config/linters_settings.go","Offset":28758,"Line":902,"Column":25},"ExpectNoLint":false,"ExpectedNoLintLinter":""},{"FromLinter":"maligned","Text":"struct of size 112 bytes could be of size 96 bytes","Severity":"","SourceLines":["type WSLSettings struct {"],"Pos":{"Filename":"pkg/config/linters_settings.go","Offset":29898,"Line":928,"Column":18},"ExpectNoLint":false,"ExpectedNoLintLinter":""},{"FromLinter":"maligned","Text":"struct of size 168 bytes could be of size 160 bytes","Severity":"","SourceLines":["type Run struct {"],"Pos":{"Filename":"pkg/config/run.go","Offset":112,"Line":6,"Column":10},"ExpectNoLint":false,"ExpectedNoLintLinter":""},{"FromLinter":"maligned","Text":"struct of size 128 bytes could be of size 120 bytes","Severity":"","SourceLines":["type Config struct {"],"Pos":{"Filename":"pkg/lint/linter/config.go","Offset":1329,"Line":36,"Column":13},"ExpectNoLint":false,"ExpectedNoLintLinter":""},{"FromLinter":"maligned","Text":"struct of size 96 bytes could be of size 88 bytes","Severity":"","SourceLines":["\tfor _, tc := range []struct {"],"Pos":{"Filename":"pkg/golinters/govet_test.go","Offset":1804,"Line":70,"Column":23},"ExpectNoLint":false,"ExpectedNoLintLinter":""},{"FromLinter":"maligned","Text":"struct of size 64 bytes could be of size 56 bytes","Severity":"","SourceLines":["type Diff struct {"],"Pos":{"Filename":"pkg/result/processors/diff.go","Offset":233,"Line":17,"Column":11},"ExpectNoLint":false,"ExpectedNoLintLinter":""},{"FromLinter":"revive","Text":"unused-parameter: parameter 'pass' seems to be unused, consider removing or renaming it as _","Severity":"warning","SourceLines":["\t\t\tRun: func(pass *analysis.Pass) (any, error) {"],"Pos":{"Filename":"pkg/experimental/myplugin/myplugin.go","Offset":921,"Line":49,"Column":14},"LineRange":{"From":49,"To":49},"ExpectNoLint":false,"ExpectedNoLintLinter":""},{"FromLinter":"unused","Text":"const `defaultFileMode` is unused","Severity":"","SourceLines":["const defaultFileMode = 0644"],"Pos":{"Filename":"pkg/commands/run.go","Offset":1209,"Line":47,"Column":7},"ExpectNoLint":false,"ExpectedNoLintLinter":""}],"Report":{"Warnings":[{"Tag":"runner","Text":"The linter 'maligned' is deprecated (since v1.38.0) due to: The repository of the linter has been archived by the owner. Replaced by govet 'fieldalignment'."}],"Linters":[{"Name":"asasalint"},{"Name":"asciicheck"},{"Name":"bidichk"},{"Name":"bodyclose","Enabled":true},{"Name":"containedctx"},{"Name":"contextcheck"},{"Name":"cyclop"},{"Name":"decorder"},{"Name":"deadcode"},{"Name":"depguard","Enabled":true},{"Name":"dogsled","Enabled":true},{"Name":"dupl","Enabled":true},{"Name":"dupword"},{"Name":"durationcheck"},{"Name":"errcheck","Enabled":true},{"Name":"errchkjson"},{"Name":"errname"},{"Name":"errorlint","Enabled":true},{"Name":"execinquery"},{"Name":"exhaustive"},{"Name":"exhaustivestruct"},{"Name":"exhaustruct"},{"Name":"exportloopref","Enabled":true},{"Name":"forbidigo"},{"Name":"forcetypeassert"},{"Name":"funlen","Enabled":true},{"Name":"gci"},{"Name":"ginkgolinter"},{"Name":"gocheckcompilerdirectives","Enabled":true},{"Name":"gochecknoglobals"},{"Name":"gochecknoinits","Enabled":true},{"Name":"gochecksumtype"},{"Name":"gocognit"},{"Name":"goconst","Enabled":true},{"Name":"gocritic","Enabled":true},{"Name":"gocyclo","Enabled":true},{"Name":"godot"},{"Name":"godox"},{"Name":"err113"},{"Name":"gofmt","Enabled":true},{"Name":"gofumpt"},{"Name":"goheader"},{"Name":"goimports","Enabled":true},{"Name":"golint"},{"Name":"mnd","Enabled":true},{"Name":"gomoddirectives"},{"Name":"gomodguard"},{"Name":"goprintffuncname","Enabled":true},{"Name":"gosec","Enabled":true},{"Name":"gosimple","Enabled":true},{"Name":"gosmopolitan"},{"Name":"govet","Enabled":true},{"Name":"grouper"},{"Name":"ifshort"},{"Name":"importas"},{"Name":"inamedparam"},{"Name":"ineffassign","Enabled":true},{"Name":"interfacebloat"},{"Name":"interfacer"},{"Name":"ireturn"},{"Name":"lll","Enabled":true},{"Name":"loggercheck"},{"Name":"maintidx"},{"Name":"makezero"},{"Name":"maligned","Enabled":true},{"Name":"mirror"},{"Name":"misspell","Enabled":true},{"Name":"musttag"},{"Name":"nakedret","Enabled":true},{"Name":"nestif"},{"Name":"nilerr"},{"Name":"nilnil"},{"Name":"nlreturn"},{"Name":"noctx","Enabled":true},{"Name":"nonamedreturns"},{"Name":"nosnakecase"},{"Name":"nosprintfhostport"},{"Name":"paralleltest"},{"Name":"perfsprint"},{"Name":"prealloc"},{"Name":"predeclared"},{"Name":"promlinter"},{"Name":"protogetter"},{"Name":"reassign"},{"Name":"revive","Enabled":true},{"Name":"rowserrcheck"},{"Name":"sloglint"},{"Name":"scopelint"},{"Name":"sqlclosecheck"},{"Name":"spancheck"},{"Name":"staticcheck","Enabled":true},{"Name":"structcheck"},{"Name":"stylecheck","Enabled":true},{"Name":"tagalign"},{"Name":"tagliatelle"},{"Name":"tenv"},{"Name":"testableexamples"},{"Name":"testifylint"},{"Name":"testpackage"},{"Name":"thelper"},{"Name":"tparallel"},{"Name":"typecheck","Enabled":true},{"Name":"unconvert","Enabled":true},{"Name":"unparam","Enabled":true},{"Name":"unused","Enabled":true},{"Name":"usestdlibvars"},{"Name":"varcheck"},{"Name":"varnamelen"},{"Name":"wastedassign"},{"Name":"whitespace","Enabled":true},{"Name":"wrapcheck"},{"Name":"wsl"},{"Name":"zerologlint"},{"Name":"nolintlint","Enabled":true}]}} diff --git a/pkg/printers/testdata/in-report-data.json b/pkg/printers/testdata/in-report-data.json index 1b5e8241db87..25cee2a0349d 100644 --- a/pkg/printers/testdata/in-report-data.json +++ b/pkg/printers/testdata/in-report-data.json @@ -54,8 +54,7 @@ }, { "Name": "errcheck", - "Enabled": true, - "EnabledByDefault": true + "Enabled": true }, { "Name": "errchkjson" @@ -174,16 +173,14 @@ }, { "Name": "gosimple", - "Enabled": true, - "EnabledByDefault": true + "Enabled": true }, { "Name": "gosmopolitan" }, { "Name": "govet", - "Enabled": true, - "EnabledByDefault": true + "Enabled": true }, { "Name": "grouper" @@ -199,8 +196,7 @@ }, { "Name": "ineffassign", - "Enabled": true, - "EnabledByDefault": true + "Enabled": true }, { "Name": "interfacebloat" @@ -309,8 +305,7 @@ }, { "Name": "staticcheck", - "Enabled": true, - "EnabledByDefault": true + "Enabled": true }, { "Name": "structcheck" @@ -345,8 +340,7 @@ }, { "Name": "typecheck", - "Enabled": true, - "EnabledByDefault": true + "Enabled": true }, { "Name": "unconvert", @@ -358,8 +352,7 @@ }, { "Name": "unused", - "Enabled": true, - "EnabledByDefault": true + "Enabled": true }, { "Name": "usestdlibvars" diff --git a/pkg/report/data.go b/pkg/report/data.go index f083fa9f5186..7aedc5522450 100644 --- a/pkg/report/data.go +++ b/pkg/report/data.go @@ -6,9 +6,8 @@ type Warning struct { } type LinterData struct { - Name string - Enabled bool `json:",omitempty"` - EnabledByDefault bool `json:",omitempty"` + Name string + Enabled bool `json:",omitempty"` } type Data struct { @@ -17,10 +16,9 @@ type Data struct { Error string `json:",omitempty"` } -func (d *Data) AddLinter(name string, enabled, enabledByDefault bool) { +func (d *Data) AddLinter(name string, enabled bool) { d.Linters = append(d.Linters, LinterData{ - Name: name, - Enabled: enabled, - EnabledByDefault: enabledByDefault, + Name: name, + Enabled: enabled, }) } diff --git a/pkg/result/processors/nolint_filter_test.go b/pkg/result/processors/nolint_filter_test.go index 3f98f4a7e20a..463e149a2835 100644 --- a/pkg/result/processors/nolint_filter_test.go +++ b/pkg/result/processors/nolint_filter_test.go @@ -272,7 +272,7 @@ func TestNolintFilter_Process_unused(t *testing.T) { enabledSetLog := logutils.NewMockLog() enabledSetLog.On("Infof", "Active %d linters: %s", len(enabledLinters), enabledLinters) - cfg := &config.Config{OldLinters: config.OldLinters{DisableAll: true, Enable: enabledLinters}} + cfg := &config.Config{Linters: config.Linters{Default: config.GroupNone, Enable: enabledLinters}} dbManager, err := lintersdb.NewManager(enabledSetLog, cfg, lintersdb.NewLinterBuilder()) require.NoError(t, err) @@ -336,7 +336,7 @@ func TestNolintFilter_Process_unused(t *testing.T) { enabledSetLog := logutils.NewMockLog() enabledSetLog.On("Infof", "Active %d linters: %s", 1, []string{"nolintlint"}) - cfg := &config.Config{OldLinters: config.OldLinters{DisableAll: true, Enable: []string{"nolintlint"}}} + cfg := &config.Config{Linters: config.Linters{Default: config.GroupNone, Enable: []string{"nolintlint"}}} dbManager, err := lintersdb.NewManager(enabledSetLog, cfg, lintersdb.NewLinterBuilder()) require.NoError(t, err) diff --git a/scripts/website/dump_info/main.go b/scripts/website/dump_info/main.go index f7fd0e1f1757..16aaf5bdaa3d 100644 --- a/scripts/website/dump_info/main.go +++ b/scripts/website/dump_info/main.go @@ -45,7 +45,7 @@ func saveLinters() error { wrapper := types.LinterWrapper{ Name: l.Linter.Name(), Desc: l.Linter.Desc(), - EnabledByDefault: l.EnabledByDefault, + Groups: l.Groups, LoadMode: l.LoadMode, AlternativeNames: l.AlternativeNames, OriginalURL: l.OriginalURL, diff --git a/scripts/website/expand_templates/linters.go b/scripts/website/expand_templates/linters.go index abb99b77b934..a0ee27eaf979 100644 --- a/scripts/website/expand_templates/linters.go +++ b/scripts/website/expand_templates/linters.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "maps" "os" "path/filepath" "reflect" @@ -45,7 +46,7 @@ func getLintersListMarkdown(enabled bool) string { continue } - if lc.EnabledByDefault == enabled { + if slices.Contains(slices.Collect(maps.Keys(lc.Groups)), config.GroupStandard) == enabled { neededLcs = append(neededLcs, lc) } } @@ -204,7 +205,7 @@ func extractExampleSnippets(example []byte) (*SettingSnippets, error) { for j, node := range root.Content { switch node.Value { - case "run", "output", "linters", "linters-settings", "issues", "severity": + case "run", "output", "linters", "linters-settings", "issues", "severity": // TODO(ldez) documentation default: continue } @@ -232,13 +233,14 @@ func extractExampleSnippets(example []byte) (*SettingSnippets, error) { globalNode.Content = append(globalNode.Content, node, newNode) - if node.Value == "linters-settings" { + if node.Value == "linters-settings" { // TODO(ldez) documentation snippets.LintersSettings, err = getLintersSettingSections(node, nextNode) if err != nil { return nil, err } _, _ = builder.WriteString( + // TODO(ldez) documentation fmt.Sprintf( "### `%s` configuration\n\nSee the dedicated [linters-settings](/usage/linters) documentation section.\n\n", node.Value, diff --git a/scripts/website/types/types.go b/scripts/website/types/types.go index fbdaf5db29ce..19568cf19ba2 100644 --- a/scripts/website/types/types.go +++ b/scripts/website/types/types.go @@ -30,7 +30,7 @@ type LinterWrapper struct { Name string `json:"name"` // From linter. Desc string `json:"desc"` // From linter. - EnabledByDefault bool `json:"enabledByDefault,omitempty"` + Groups map[string]struct{} LoadMode packages.LoadMode `json:"loadMode,omitempty"` diff --git a/test/bench/bench_test.go b/test/bench/bench_test.go index c54fcde870ca..a315b00e82f4 100644 --- a/test/bench/bench_test.go +++ b/test/bench/bench_test.go @@ -57,7 +57,7 @@ func Benchmark_linters(b *testing.B) { "--issues-exit-code=0", "--timeout=30m", "--no-config", - "--disable-all", + "--default=none", "--enable", linter, } @@ -103,7 +103,7 @@ func Benchmark_golangciLint(b *testing.B) { "--issues-exit-code=0", "--timeout=30m", "--no-config", - "--disable-all", + "--default=none", } linters := getLinterNames(b, false) diff --git a/test/enabled_linters_test.go b/test/enabled_linters_test.go index 2121641bd101..b041e760771b 100644 --- a/test/enabled_linters_test.go +++ b/test/enabled_linters_test.go @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/golangci/golangci-lint/pkg/lint/linter" + "github.com/golangci/golangci-lint/pkg/config" "github.com/golangci/golangci-lint/pkg/lint/lintersdb" "github.com/golangci/golangci-lint/pkg/logutils" "github.com/golangci/golangci-lint/test/testshared" @@ -24,7 +24,6 @@ func TestEnabledLinters(t *testing.T) { cfg string enabledLinters []string args []string - noImplicitFast bool }{ { name: "disable govet in config", @@ -33,7 +32,7 @@ func TestEnabledLinters(t *testing.T) { disable: - govet `, - enabledLinters: getEnabledByDefaultFastLintersExcept(t, "govet"), + enabledLinters: getEnabledByDefaultLintersExcept(t, "govet"), }, { name: "enable revive in config", @@ -42,12 +41,12 @@ func TestEnabledLinters(t *testing.T) { enable: - revive `, - enabledLinters: getEnabledByDefaultFastLintersWith(t, "revive"), + enabledLinters: getEnabledByDefaultLintersWith(t, "revive"), }, { name: "disable govet in cmd", args: []string{"-Dgovet"}, - enabledLinters: getEnabledByDefaultFastLintersExcept(t, "govet"), + enabledLinters: getEnabledByDefaultLintersExcept(t, "govet"), }, { name: "enable gofmt in cmd and enable revive in config", @@ -57,57 +56,44 @@ func TestEnabledLinters(t *testing.T) { enable: - revive `, - enabledLinters: getEnabledByDefaultFastLintersWith(t, "revive", "gofmt"), + enabledLinters: getEnabledByDefaultLintersWith(t, "revive", "gofmt"), }, { name: "fast option in config", cfg: ` linters: - fast: true + default: fast `, - enabledLinters: getEnabledByDefaultFastLintersWith(t), - noImplicitFast: true, + enabledLinters: getAllLintersFromGroupFast(t), }, { - name: "explicitly unset fast option in config", - cfg: ` - linters: - fast: false - `, - enabledLinters: getEnabledByDefaultLinters(t), - noImplicitFast: true, - }, - { - name: "set fast option in command-line", - args: []string{"--fast"}, - enabledLinters: getEnabledByDefaultFastLintersWith(t), - noImplicitFast: true, + name: "fast option in flag", + args: []string{"--default=fast"}, + enabledLinters: getAllLintersFromGroupFast(t), }, { name: "fast option in command-line has higher priority to enable", cfg: ` linters: - fast: false + default: none `, - args: []string{"--fast"}, - enabledLinters: getEnabledByDefaultFastLintersWith(t), - noImplicitFast: true, + args: []string{"--default=fast"}, + enabledLinters: getAllLintersFromGroupFast(t), }, { - name: "fast option in command-line has higher priority to disable", - cfg: ` - linters: - fast: true - `, - args: []string{"--fast=false"}, - enabledLinters: getEnabledByDefaultLinters(t), - noImplicitFast: true, + name: "only fast linters with standard group", + args: []string{"--fast-only"}, + enabledLinters: []string{"ineffassign"}, + }, + { + name: "only fast false", + args: []string{"--fast-only=false"}, + enabledLinters: getEnabledByDefaultLintersWith(t), }, { name: "fast option combined with enable and enable-all", - args: []string{"--enable-all", "--fast", "--enable=unused"}, - enabledLinters: getAllFastLintersWith(t, "unused"), - noImplicitFast: true, + args: []string{"--default=all", "--fast-only", "--enable=unused"}, + enabledLinters: getAllLintersFromGroupFast(t), }, } @@ -118,9 +104,6 @@ func TestEnabledLinters(t *testing.T) { t.Parallel() args := []string{"--verbose"} - if !c.noImplicitFast { - args = append(args, "--fast") - } r := testshared.NewRunnerBuilder(t). WithCommand("linters"). @@ -139,77 +122,71 @@ func TestEnabledLinters(t *testing.T) { } } -func getEnabledByDefaultFastLintersExcept(t *testing.T, except ...string) []string { +func getEnabledByDefaultLintersExcept(t *testing.T, excludes ...string) []string { t.Helper() - m, err := lintersdb.NewManager(nil, nil, lintersdb.NewLinterBuilder()) - require.NoError(t, err) + linterNames := getEnabledByDefaultLintersWith(t) - ebdl := m.GetAllEnabledByDefaultLinters() var ret []string - for _, lc := range ebdl { - if lc.IsSlowLinter() || lc.Internal { + for _, lc := range linterNames { + if slices.Contains(excludes, lc) { continue } - if !slices.Contains(except, lc.Name()) { - ret = append(ret, lc.Name()) - } + ret = append(ret, lc) } return ret } -func getAllFastLintersWith(t *testing.T, with ...string) []string { +func getEnabledByDefaultLintersWith(t *testing.T, includes ...string) []string { t.Helper() - ret := append([]string{}, with...) - - dbManager, err := lintersdb.NewManager(nil, nil, lintersdb.NewLinterBuilder()) + cfg := &config.Config{ + Linters: config.Linters{ + Default: config.GroupStandard, + }, + } + dbManager, err := lintersdb.NewManager(logutils.NewStderrLog("skip"), cfg, lintersdb.NewLinterBuilder()) require.NoError(t, err) - linters := dbManager.GetAllSupportedLinterConfigs() + ebdl, err := dbManager.GetEnabledLintersMap() + require.NoError(t, err) - for _, lc := range linters { - if lc.IsSlowLinter() || lc.Internal || (lc.IsDeprecated() && lc.Deprecation.Level > linter.DeprecationWarning) { + var ret []string + for _, lc := range ebdl { + if lc.Internal { continue } ret = append(ret, lc.Name()) } - return ret + return slices.Concat(ret, includes) } -func getEnabledByDefaultLinters(t *testing.T) []string { +func getAllLintersFromGroupFast(t *testing.T) []string { t.Helper() - dbManager, err := lintersdb.NewManager(nil, nil, lintersdb.NewLinterBuilder()) + cfg := &config.Config{ + Linters: config.Linters{ + Default: config.GroupAll, + }, + } + + dbManager, err := lintersdb.NewManager(logutils.NewStderrLog("skip"), cfg, lintersdb.NewLinterBuilder()) + require.NoError(t, err) + + ebdl, err := dbManager.GetEnabledLintersMap() require.NoError(t, err) - ebdl := dbManager.GetAllEnabledByDefaultLinters() var ret []string for _, lc := range ebdl { if lc.Internal { continue } - ret = append(ret, lc.Name()) - } - - return ret -} - -func getEnabledByDefaultFastLintersWith(t *testing.T, with ...string) []string { - t.Helper() - - dbManager, err := lintersdb.NewManager(nil, nil, lintersdb.NewLinterBuilder()) - require.NoError(t, err) - - ebdl := dbManager.GetAllEnabledByDefaultLinters() - ret := append([]string{}, with...) - for _, lc := range ebdl { - if lc.IsSlowLinter() || lc.Internal { + if lc.IsSlowLinter() { continue } diff --git a/test/output_test.go b/test/output_test.go index 86eddd0546d2..d2b98c211a1b 100644 --- a/test/output_test.go +++ b/test/output_test.go @@ -20,7 +20,7 @@ func TestOutput_lineNumber(t *testing.T) { testshared.NewRunnerBuilder(t). WithArgs( - "--disable-all", + "--default=none", "--output.text.print-issued-lines=false", "--output.text.print-linter-name=false", "--output.text.path=stdout", @@ -39,7 +39,7 @@ func TestOutput_Stderr(t *testing.T) { testshared.NewRunnerBuilder(t). WithArgs( - "--disable-all", + "--default=none", "--output.json.path=stderr", ). WithDirectives(sourcePath). @@ -57,7 +57,7 @@ func TestOutput_File(t *testing.T) { testshared.NewRunnerBuilder(t). WithArgs( - "--disable-all", + "--default=none", fmt.Sprintf("--output.json.path=%s", resultPath), ). WithDirectives(sourcePath). @@ -77,7 +77,7 @@ func TestOutput_Multiple(t *testing.T) { testshared.NewRunnerBuilder(t). WithArgs( - "--disable-all", + "--default=none", "--output.text.print-issued-lines=false", "--output.text.print-linter-name=false", "--output.text.path=stdout", diff --git a/test/run_test.go b/test/run_test.go index 4b757388bbdf..b5c023b4314d 100644 --- a/test/run_test.go +++ b/test/run_test.go @@ -126,7 +126,7 @@ func TestCgoOk(t *testing.T) { WithArgs( "--timeout=3m", "--show-stats=false", - "--enable-all", + "--default=all", ). WithTargetPath(testdataDir, "cgo"). Runner(). @@ -146,25 +146,25 @@ func TestCgoWithIssues(t *testing.T) { }{ { desc: "govet", - args: []string{"--no-config", "--disable-all", "-Egovet"}, + args: []string{"--no-config", "--default=none", "-Egovet"}, dir: "cgo_with_issues", expected: "Printf format %t has arg cs of wrong type", }, { desc: "staticcheck", - args: []string{"--no-config", "--disable-all", "-Estaticcheck"}, + args: []string{"--no-config", "--default=none", "-Estaticcheck"}, dir: "cgo_with_issues", expected: "SA5009: Printf format %t has arg #1 of wrong type", }, { desc: "gofmt", - args: []string{"--no-config", "--disable-all", "-Egofmt"}, + args: []string{"--no-config", "--default=none", "-Egofmt"}, dir: "cgo_with_issues", expected: "File is not properly formatted (gofmt)", }, { desc: "revive", - args: []string{"--no-config", "--disable-all", "-Erevive"}, + args: []string{"--no-config", "--default=none", "-Erevive"}, dir: "cgo_with_issues", expected: "indent-error-flow: if block ends with a return statement", }, @@ -200,7 +200,7 @@ func TestLineDirective(t *testing.T) { desc: "dupl", args: []string{ "-Edupl", - "--disable-all", + "--default=none", }, configPath: "testdata/linedirective/dupl.yml", targetPath: "linedirective", @@ -210,7 +210,7 @@ func TestLineDirective(t *testing.T) { desc: "gofmt", args: []string{ "-Egofmt", - "--disable-all", + "--default=none", }, targetPath: "linedirective", expected: "File is not properly formatted (gofmt)", @@ -219,7 +219,7 @@ func TestLineDirective(t *testing.T) { desc: "goimports", args: []string{ "-Egoimports", - "--disable-all", + "--default=none", }, targetPath: "linedirective", expected: "File is not properly formatted (goimports)", @@ -228,7 +228,7 @@ func TestLineDirective(t *testing.T) { desc: "gomodguard", args: []string{ "-Egomodguard", - "--disable-all", + "--default=none", }, configPath: "testdata/linedirective/gomodguard.yml", targetPath: "linedirective", @@ -239,7 +239,7 @@ func TestLineDirective(t *testing.T) { desc: "lll", args: []string{ "-Elll", - "--disable-all", + "--default=none", }, configPath: "testdata/linedirective/lll.yml", targetPath: "linedirective", @@ -249,7 +249,7 @@ func TestLineDirective(t *testing.T) { desc: "misspell", args: []string{ "-Emisspell", - "--disable-all", + "--default=none", }, configPath: "", targetPath: "linedirective", @@ -259,7 +259,7 @@ func TestLineDirective(t *testing.T) { desc: "wsl", args: []string{ "-Ewsl", - "--disable-all", + "--default=none", }, configPath: "", targetPath: "linedirective", @@ -365,7 +365,7 @@ func TestUnsafeOk(t *testing.T) { WithConfig(cfg). WithArgs( "--show-stats=false", - "--enable-all", + "--default=all", ). WithTargetPath(testdataDir, "unsafe"). WithBinPath(binPath). @@ -398,7 +398,7 @@ func TestIdentifierUsedOnlyInTests(t *testing.T) { WithNoConfig(). WithArgs( "--show-stats=false", - "--disable-all", + "--default=none", "-Eunused", ). WithTargetPath(testdataDir, "used_only_in_tests"). @@ -463,13 +463,13 @@ func TestEnableAllFastAndEnableCanCoexist(t *testing.T) { }{ { desc: "fast", - args: []string{"--fast", "--enable-all", "--enable=typecheck"}, + args: []string{"--fast-only", "--default=all", "--enable=typecheck"}, expected: []int{exitcodes.Success, exitcodes.IssuesFound}, }, { desc: "all", - args: []string{"--enable-all", "--enable=typecheck"}, - expected: []int{exitcodes.Failure}, + args: []string{"--default=all", "--enable=typecheck"}, + expected: []int{exitcodes.Success}, }, } @@ -548,6 +548,7 @@ func TestPathPrefix(t *testing.T) { for _, test := range testCases { t.Run(test.desc, func(t *testing.T) { testshared.NewRunnerBuilder(t). + WithArgs("--show-stats=false"). WithArgs(test.args...). WithTargetPath(testdataDir, "withtests"). WithBinPath(binPath). diff --git a/test/testdata/configs/output.yml b/test/testdata/configs/output.yml index 003a0eadf32c..3272584f9311 100644 --- a/test/testdata/configs/output.yml +++ b/test/testdata/configs/output.yml @@ -1,11 +1,12 @@ version: "2" -linters-settings: - misspell: - locale: US - ignore-rules: - - langauge - - Dialogue +linters: + settings: + misspell: + locale: US + ignore-rules: + - langauge + - Dialogue run: relative-path-mode: wd diff --git a/test/testdata/configs/path-except.yml b/test/testdata/configs/path-except.yml index a2c8f86f16f1..4ade0578ed98 100644 --- a/test/testdata/configs/path-except.yml +++ b/test/testdata/configs/path-except.yml @@ -1,12 +1,12 @@ version: "2" -linters-settings: - forbidigo: - forbid: - - pattern: fmt\.Print.* - - pattern: time.Sleep(# no sleeping!)? - linters: + settings: + forbidigo: + forbid: + - pattern: fmt\.Print.* + - pattern: time.Sleep(# no sleeping!)? + exclusions: rules: # Apply forbidigo only to test files, exclude diff --git a/test/testdata/linedirective/dupl.yml b/test/testdata/linedirective/dupl.yml index 2091e83d5305..fe83694bab34 100644 --- a/test/testdata/linedirective/dupl.yml +++ b/test/testdata/linedirective/dupl.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - dupl: - threshold: 10 +linters: + settings: + dupl: + threshold: 10 diff --git a/test/testdata/linedirective/gomodguard.yml b/test/testdata/linedirective/gomodguard.yml index 9575bad2b1a0..d49f14b4bade 100644 --- a/test/testdata/linedirective/gomodguard.yml +++ b/test/testdata/linedirective/gomodguard.yml @@ -1,7 +1,8 @@ version: "2" -linters-settings: - gomodguard: - allowed: - domains: - - github.com +linters: + settings: + gomodguard: + allowed: + domains: + - github.com diff --git a/test/testdata/linedirective/lll.yml b/test/testdata/linedirective/lll.yml index 435a556d06d0..c7e7650cab68 100644 --- a/test/testdata/linedirective/lll.yml +++ b/test/testdata/linedirective/lll.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - lll: - line-length: 50 +linters: + settings: + lll: + line-length: 50 diff --git a/test/testdata/minimalpkg/minimalpkg.go b/test/testdata/minimalpkg/minimalpkg.go index 24aa898237a4..d041b96ca845 100644 --- a/test/testdata/minimalpkg/minimalpkg.go +++ b/test/testdata/minimalpkg/minimalpkg.go @@ -1,3 +1,5 @@ +// Package minimalpkg ... package minimalpkg +// SomeTestFunc ... func SomeTestFunc() {} diff --git a/test/testdata_etc/unused_exported/golangci.yml b/test/testdata_etc/unused_exported/golangci.yml index 9e59f4dc832c..961489f292ae 100644 --- a/test/testdata_etc/unused_exported/golangci.yml +++ b/test/testdata_etc/unused_exported/golangci.yml @@ -1,6 +1,6 @@ version: "2" linters: - disable-all: true + default: none enable: - unused diff --git a/test/testshared/integration/fix.go b/test/testshared/integration/fix.go index 11a0fcdb19ea..53a1c698c265 100644 --- a/test/testshared/integration/fix.go +++ b/test/testshared/integration/fix.go @@ -66,7 +66,7 @@ func runFix(t *testing.T, extraArgs ...string) { } testshared.NewRunnerBuilder(t). - WithArgs("--disable-all", + WithArgs("--default=none", "--output.text.print-issued-lines=false", "--output.text.print-linter-name=false", "--output.text.path=stdout", diff --git a/test/testshared/integration/run.go b/test/testshared/integration/run.go index 5d69be775e7b..ee278cb02724 100644 --- a/test/testshared/integration/run.go +++ b/test/testshared/integration/run.go @@ -62,7 +62,7 @@ func testOneSource(t *testing.T, log *logutils.StderrLog, binPath, sourcePath st } args := []string{ - "--disable-all", + "--default=none", "--show-stats=false", "--output.json.path=stdout", "--max-same-issues=100", From 7adae39e25d7a2e4b108b87788a59a7b00488905 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Sun, 23 Feb 2025 03:35:05 +0100 Subject: [PATCH 6/8] tests: update linter tests --- .../copyloopvar/testdata/copyloopvar.yml | 7 ++-- pkg/golinters/cyclop/testdata/cyclop.yml | 7 ++-- .../decorder/testdata/decorder_custom.yml | 21 +++++------ pkg/golinters/depguard/testdata/depguard.yml | 24 ++++++------- .../testdata/depguard_additional_guards.yml | 32 ++++++++--------- .../testdata/depguard_ignore_file_rules.yml | 27 +++++++------- pkg/golinters/dupl/testdata/dupl.yml | 7 ++-- .../dupword/testdata/dupword_ignore_the.yml | 9 ++--- .../testdata/errcheck_exclude_functions.yml | 13 +++---- .../testdata/errcheck_ignore_default.yml | 7 ++-- .../testdata/errcheck_type_assertions.yml | 7 ++-- .../errchkjson_check_error_free_encoding.yml | 7 ++-- .../testdata/errchkjson_no_exported.yml | 7 ++-- .../errorlint/testdata/errorlint_asserts.yml | 11 +++--- .../testdata/errorlint_comparison.yml | 11 +++--- .../errorlint/testdata/errorlint_errorf.yml | 11 +++--- .../testdata/exhaustive_default.yml | 7 ++-- .../exhaustive_ignore_enum_members.yml | 7 ++-- .../testdata/exhaustruct_custom.yml | 13 +++---- .../testdata/fatcontext_structpointer.yml | 8 ++--- .../forbidigo/testdata/forbidigo.yml | 11 +++--- .../forbidigo_include_godoc_examples.yml | 8 ++--- .../forbidigo/testdata/forbidigo_struct.yml | 17 ++++----- pkg/golinters/funlen/testdata/funlen.yml | 9 ++--- .../ginkgolinter/testdata/ginkgolinter.go | 2 +- .../testdata/ginkgolinter_allow_havelen0.yml | 7 ++-- .../ginkgolinter/testdata/ginkgolinter_cgo.go | 2 +- .../testdata/ginkgolinter_default.yml | 5 +-- .../testdata/ginkgolinter_havelen0.go | 2 +- .../testdata/ginkgolinter_suppress_async.go | 2 +- .../testdata/ginkgolinter_suppress_async.yml | 7 ++-- .../testdata/ginkgolinter_suppress_compare.go | 2 +- .../ginkgolinter_suppress_compare.yml | 7 ++-- .../testdata/ginkgolinter_suppress_err.go | 2 +- .../testdata/ginkgolinter_suppress_err.yml | 7 ++-- ...inkgolinter_suppress_focused_containers.go | 2 +- ...nkgolinter_suppress_focused_containers.yml | 7 ++-- .../testdata/ginkgolinter_suppress_len.go | 2 +- .../testdata/ginkgolinter_suppress_len.yml | 7 ++-- .../testdata/ginkgolinter_suppress_nil.go | 2 +- .../testdata/ginkgolinter_suppress_nil.yml | 7 ++-- .../testdata/gochecksumtype_custom.yml | 7 ++-- pkg/golinters/gocognit/testdata/gocognit.yml | 7 ++-- .../testdata/goconst_calls_enabled.yml | 7 ++-- .../gocritic/testdata/gocritic-fix.yml | 17 ++++----- pkg/golinters/gocritic/testdata/gocritic.yml | 29 +++++++-------- pkg/golinters/gocyclo/testdata/gocyclo.yml | 7 ++-- pkg/golinters/godox/testdata/godox.yml | 11 +++--- .../goheader/testdata/goheader-fix.yml | 19 +++++----- pkg/golinters/goheader/testdata/goheader.yml | 13 +++---- .../gomodguard/testdata/gomodguard.yml | 23 ++++++------ pkg/golinters/gosec/testdata/gosec.yml | 27 +++++++------- .../gosec/testdata/gosec_global_option.yml | 11 +++--- pkg/golinters/gosec/testdata/gosec_nosec.yml | 11 +++--- .../testdata/gosec_severity_confidence.yml | 9 ++--- .../gosmopolitan_allow_time_local.yml | 7 ++-- .../testdata/gosmopolitan_escape_hatches.yml | 17 ++++----- .../testdata/gosmopolitan_scripts.yml | 13 +++---- pkg/golinters/govet/testdata/govet.yml | 9 ++--- .../govet/testdata/govet_fieldalignment.yml | 9 ++--- pkg/golinters/govet/testdata/govet_fix.yml | 27 +++++++------- .../govet/testdata/govet_ifaceassert.yml | 9 ++--- pkg/golinters/grouper/testdata/grouper.yml | 7 ++-- pkg/golinters/iface/testdata/iface_all.yml | 13 +++---- pkg/golinters/iface/testdata/iface_fix.yml | 11 +++--- .../iface/testdata/iface_identical.yml | 9 ++--- pkg/golinters/iface/testdata/iface_opaque.yml | 9 ++--- pkg/golinters/iface/testdata/iface_unused.yml | 9 ++--- pkg/golinters/importas/testdata/importas.yml | 19 +++++----- .../importas_several_empty_aliases.yml | 19 +++++----- .../importas/testdata/importas_strict.yml | 21 +++++------ .../inamedparam_skip_single_param.yml | 7 ++-- .../ireturn/testdata/ireturn_allow.yml | 9 ++--- .../testdata/ireturn_reject_generics.yml | 9 ++--- .../testdata/ireturn_reject_stdlib.yml | 9 ++--- pkg/golinters/lll/testdata/lll.yml | 7 ++-- pkg/golinters/lll/testdata/lll_import.yml | 9 ++--- .../testdata/loggercheck_custom.yml | 27 +++++++------- .../testdata/loggercheck_kitlogonly.yml | 15 ++++---- .../testdata/loggercheck_logronly.yml | 13 +++---- .../testdata/loggercheck_noprintflike.yml | 7 ++-- .../testdata/loggercheck_requirestringkey.yml | 7 ++-- .../testdata/loggercheck_slogonly.yml | 13 +++---- .../testdata/loggercheck_zaponly.yml | 13 +++---- .../maintidx/testdata/maintidx_under_100.yml | 7 ++-- .../makezero/testdata/makezero_always.yml | 7 ++-- pkg/golinters/misspell/testdata/misspell.yml | 13 +++---- .../misspell/testdata/misspell_custom.yml | 15 ++++---- pkg/golinters/musttag/testdata/musttag.yml | 19 +++++----- pkg/golinters/nestif/testdata/nestif.yml | 7 ++-- .../testdata/nilnil_detect_opposite.yml | 7 ++-- .../nilnil/testdata/nilnil_pointers_only.yml | 11 +++--- .../nlreturn/testdata/nlreturn-block-size.yml | 7 ++-- .../nolintlint/testdata/nolintlint.yml | 9 ++--- .../nolintlint/testdata/nolintlint_unused.yml | 7 ++-- .../testdata/nonamedreturns_custom.yml | 7 ++-- .../testdata/paralleltest_custom.yml | 7 ++-- .../perfsprint/testdata/perfsprint_custom.yml | 14 ++++---- .../testdata/predeclared_custom.yml | 13 +++---- .../reassign/testdata/reassign_patterns.yml | 11 +++--- pkg/golinters/revive/testdata/revive-fix.yml | 13 +++---- pkg/golinters/revive/testdata/revive.yml | 35 ++++++++++--------- .../testdata/sloglint_args_on_sep_lines.yml | 7 ++-- .../sloglint/testdata/sloglint_attr_only.yml | 7 ++-- .../testdata/sloglint_context_only.yml | 7 ++-- .../testdata/sloglint_forbidden_keys.yml | 9 ++--- .../testdata/sloglint_key_naming_case.yml | 7 ++-- .../sloglint/testdata/sloglint_kv_only.yml | 7 ++-- .../testdata/sloglint_no_raw_keys.yml | 7 ++-- .../sloglint/testdata/sloglint_static_msg.yml | 7 ++-- .../testdata/spancheck_enable_all.yml | 17 ++++----- .../testdata/spancheck_keep_default.yml | 9 ++--- .../tagalign/testdata/tagalign_align_only.yml | 7 ++-- .../tagalign/testdata/tagalign_order_only.yml | 15 ++++---- .../tagalign/testdata/tagalign_sort_only.yml | 9 ++--- .../tagalign/testdata/tagalign_strict.yml | 11 +++--- .../testdata/tagliatelle_ignored_fields.yml | 13 ++++--- .../testifylint_bool_compare_only.yml | 15 ++++---- .../testdata/testifylint_formatter_only.yml | 17 ++++----- .../testifylint_require_error_only.yml | 15 ++++---- pkg/golinters/thelper/testdata/thelper.yml | 11 +++--- pkg/golinters/unparam/unparam.go | 4 +-- .../testdata/usestdlibvars_non_default.yml | 25 ++++++------- .../testdata/usetesting_configuration.yml | 19 +++++----- .../usetesting_go124_configuration.yml | 19 +++++----- .../whitespace/testdata/whitespace-fix.yml | 9 ++--- .../whitespace/testdata/whitespace.yml | 9 ++--- pkg/golinters/wsl/testdata/wsl.yml | 7 ++-- 128 files changed, 760 insertions(+), 649 deletions(-) diff --git a/pkg/golinters/copyloopvar/testdata/copyloopvar.yml b/pkg/golinters/copyloopvar/testdata/copyloopvar.yml index 89be6e5e54c1..c6e33124315d 100644 --- a/pkg/golinters/copyloopvar/testdata/copyloopvar.yml +++ b/pkg/golinters/copyloopvar/testdata/copyloopvar.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - copyloopvar: - check-alias: true +linters: + settings: + copyloopvar: + check-alias: true diff --git a/pkg/golinters/cyclop/testdata/cyclop.yml b/pkg/golinters/cyclop/testdata/cyclop.yml index 6341d8616f2b..c873b8ce6384 100644 --- a/pkg/golinters/cyclop/testdata/cyclop.yml +++ b/pkg/golinters/cyclop/testdata/cyclop.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - cyclop: - max-complexity: 15 +linters: + settings: + cyclop: + max-complexity: 15 diff --git a/pkg/golinters/decorder/testdata/decorder_custom.yml b/pkg/golinters/decorder/testdata/decorder_custom.yml index 9a12dec5978b..b7468e870ba7 100644 --- a/pkg/golinters/decorder/testdata/decorder_custom.yml +++ b/pkg/golinters/decorder/testdata/decorder_custom.yml @@ -1,12 +1,13 @@ version: "2" -linters-settings: - decorder: - dec-order: - - type - - const - - var - - func - disable-dec-order-check: false - disable-init-func-first-check: false - disable-dec-num-check: false +linters: + settings: + decorder: + dec-order: + - type + - const + - var + - func + disable-dec-order-check: false + disable-init-func-first-check: false + disable-dec-num-check: false diff --git a/pkg/golinters/depguard/testdata/depguard.yml b/pkg/golinters/depguard/testdata/depguard.yml index ced24821d180..6afb038b9e82 100644 --- a/pkg/golinters/depguard/testdata/depguard.yml +++ b/pkg/golinters/depguard/testdata/depguard.yml @@ -1,14 +1,14 @@ version: "2" -linters-settings: - depguard: - rules: - main: - deny: - - pkg: compress - desc: "nope" - - pkg: log - desc: "don't use log" - - pkg: "golang.org/x/tools/go/analysis" - desc: "example import with dot" - +linters: + settings: + depguard: + rules: + main: + deny: + - pkg: compress + desc: "nope" + - pkg: log + desc: "don't use log" + - pkg: "golang.org/x/tools/go/analysis" + desc: "example import with dot" diff --git a/pkg/golinters/depguard/testdata/depguard_additional_guards.yml b/pkg/golinters/depguard/testdata/depguard_additional_guards.yml index c50cfca9d21d..9c7d48deef52 100644 --- a/pkg/golinters/depguard/testdata/depguard_additional_guards.yml +++ b/pkg/golinters/depguard/testdata/depguard_additional_guards.yml @@ -1,18 +1,18 @@ version: "2" -linters-settings: - depguard: - rules: - main: - deny: - - pkg: fmt - desc: "nope" - - pkg: strings - desc: "nope" - - pkg: compress - desc: "nope" - - pkg: log - desc: "don't use log" - - pkg: "golang.org/x/tools/go/analysis" - desc: "example import with dot" - +linters: + settings: + depguard: + rules: + main: + deny: + - pkg: fmt + desc: "nope" + - pkg: strings + desc: "nope" + - pkg: compress + desc: "nope" + - pkg: log + desc: "don't use log" + - pkg: "golang.org/x/tools/go/analysis" + desc: "example import with dot" diff --git a/pkg/golinters/depguard/testdata/depguard_ignore_file_rules.yml b/pkg/golinters/depguard/testdata/depguard_ignore_file_rules.yml index 2849ca458615..bd86648563e8 100644 --- a/pkg/golinters/depguard/testdata/depguard_ignore_file_rules.yml +++ b/pkg/golinters/depguard/testdata/depguard_ignore_file_rules.yml @@ -1,15 +1,16 @@ version: "2" -linters-settings: - depguard: - rules: - main: - files: - - "!**/*_ignore_file_rules.go" - deny: - - pkg: compress - desc: "nope" - - pkg: log - desc: "don't use log" - - pkg: "golang.org/x/tools/go/analysis" - desc: "example import with dot" +linters: + settings: + depguard: + rules: + main: + files: + - "!**/*_ignore_file_rules.go" + deny: + - pkg: compress + desc: "nope" + - pkg: log + desc: "don't use log" + - pkg: "golang.org/x/tools/go/analysis" + desc: "example import with dot" diff --git a/pkg/golinters/dupl/testdata/dupl.yml b/pkg/golinters/dupl/testdata/dupl.yml index f63f092b164a..3de7cdccf592 100644 --- a/pkg/golinters/dupl/testdata/dupl.yml +++ b/pkg/golinters/dupl/testdata/dupl.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - dupl: - threshold: 20 +linters: + settings: + dupl: + threshold: 20 diff --git a/pkg/golinters/dupword/testdata/dupword_ignore_the.yml b/pkg/golinters/dupword/testdata/dupword_ignore_the.yml index 53b4d4ac5724..93fb373e9c5d 100644 --- a/pkg/golinters/dupword/testdata/dupword_ignore_the.yml +++ b/pkg/golinters/dupword/testdata/dupword_ignore_the.yml @@ -1,6 +1,7 @@ version: "2" -linters-settings: - dupword: - ignore: - - "the" +linters: + settings: + dupword: + ignore: + - "the" diff --git a/pkg/golinters/errcheck/testdata/errcheck_exclude_functions.yml b/pkg/golinters/errcheck/testdata/errcheck_exclude_functions.yml index 568661336826..9a6a02698f9d 100644 --- a/pkg/golinters/errcheck/testdata/errcheck_exclude_functions.yml +++ b/pkg/golinters/errcheck/testdata/errcheck_exclude_functions.yml @@ -1,8 +1,9 @@ version: "2" -linters-settings: - errcheck: - check-blank: true - exclude-functions: - - io/ioutil.ReadFile - - io/ioutil.ReadDir +linters: + settings: + errcheck: + check-blank: true + exclude-functions: + - io/ioutil.ReadFile + - io/ioutil.ReadDir diff --git a/pkg/golinters/errcheck/testdata/errcheck_ignore_default.yml b/pkg/golinters/errcheck/testdata/errcheck_ignore_default.yml index 21a7c4f91797..f98a2c913a8d 100644 --- a/pkg/golinters/errcheck/testdata/errcheck_ignore_default.yml +++ b/pkg/golinters/errcheck/testdata/errcheck_ignore_default.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - errcheck: - check-blank: true +linters: + settings: + errcheck: + check-blank: true diff --git a/pkg/golinters/errcheck/testdata/errcheck_type_assertions.yml b/pkg/golinters/errcheck/testdata/errcheck_type_assertions.yml index 2c900b7d6f99..ab923c49edfd 100644 --- a/pkg/golinters/errcheck/testdata/errcheck_type_assertions.yml +++ b/pkg/golinters/errcheck/testdata/errcheck_type_assertions.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - errcheck: - check-type-assertions: true +linters: + settings: + errcheck: + check-type-assertions: true diff --git a/pkg/golinters/errchkjson/testdata/errchkjson_check_error_free_encoding.yml b/pkg/golinters/errchkjson/testdata/errchkjson_check_error_free_encoding.yml index 1fccc634b928..7f3ed89be5a5 100644 --- a/pkg/golinters/errchkjson/testdata/errchkjson_check_error_free_encoding.yml +++ b/pkg/golinters/errchkjson/testdata/errchkjson_check_error_free_encoding.yml @@ -3,6 +3,7 @@ version: "2" issues: max-issues-per-linter: 100 -linters-settings: - errchkjson: - check-error-free-encoding: true +linters: + settings: + errchkjson: + check-error-free-encoding: true diff --git a/pkg/golinters/errchkjson/testdata/errchkjson_no_exported.yml b/pkg/golinters/errchkjson/testdata/errchkjson_no_exported.yml index d808eb69e624..91e3ee85d60a 100644 --- a/pkg/golinters/errchkjson/testdata/errchkjson_no_exported.yml +++ b/pkg/golinters/errchkjson/testdata/errchkjson_no_exported.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - errchkjson: - report-no-exported: true +linters: + settings: + errchkjson: + report-no-exported: true diff --git a/pkg/golinters/errorlint/testdata/errorlint_asserts.yml b/pkg/golinters/errorlint/testdata/errorlint_asserts.yml index 712431ac3c40..14e0986dbbea 100644 --- a/pkg/golinters/errorlint/testdata/errorlint_asserts.yml +++ b/pkg/golinters/errorlint/testdata/errorlint_asserts.yml @@ -1,7 +1,8 @@ version: "2" -linters-settings: - errorlint: - errorf: false - asserts: true - comparison: false +linters: + settings: + errorlint: + errorf: false + asserts: true + comparison: false diff --git a/pkg/golinters/errorlint/testdata/errorlint_comparison.yml b/pkg/golinters/errorlint/testdata/errorlint_comparison.yml index 07680450cbd0..f9f523d9e916 100644 --- a/pkg/golinters/errorlint/testdata/errorlint_comparison.yml +++ b/pkg/golinters/errorlint/testdata/errorlint_comparison.yml @@ -1,7 +1,8 @@ version: "2" -linters-settings: - errorlint: - errorf: false - asserts: false - comparison: true +linters: + settings: + errorlint: + errorf: false + asserts: false + comparison: true diff --git a/pkg/golinters/errorlint/testdata/errorlint_errorf.yml b/pkg/golinters/errorlint/testdata/errorlint_errorf.yml index bb10224e6b99..8b09a3fcf65f 100644 --- a/pkg/golinters/errorlint/testdata/errorlint_errorf.yml +++ b/pkg/golinters/errorlint/testdata/errorlint_errorf.yml @@ -1,7 +1,8 @@ version: "2" -linters-settings: - errorlint: - errorf: true - asserts: false - comparison: false +linters: + settings: + errorlint: + errorf: true + asserts: false + comparison: false diff --git a/pkg/golinters/exhaustive/testdata/exhaustive_default.yml b/pkg/golinters/exhaustive/testdata/exhaustive_default.yml index d57057c264ca..88e33bf2e70c 100644 --- a/pkg/golinters/exhaustive/testdata/exhaustive_default.yml +++ b/pkg/golinters/exhaustive/testdata/exhaustive_default.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - exhaustive: - default-signifies-exhaustive: true +linters: + settings: + exhaustive: + default-signifies-exhaustive: true diff --git a/pkg/golinters/exhaustive/testdata/exhaustive_ignore_enum_members.yml b/pkg/golinters/exhaustive/testdata/exhaustive_ignore_enum_members.yml index 0c460db84b41..765566bd4b0e 100644 --- a/pkg/golinters/exhaustive/testdata/exhaustive_ignore_enum_members.yml +++ b/pkg/golinters/exhaustive/testdata/exhaustive_ignore_enum_members.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - exhaustive: - ignore-enum-members: "West$" +linters: + settings: + exhaustive: + ignore-enum-members: "West$" diff --git a/pkg/golinters/exhaustruct/testdata/exhaustruct_custom.yml b/pkg/golinters/exhaustruct/testdata/exhaustruct_custom.yml index 6064b0fcf2a9..313abea5c879 100644 --- a/pkg/golinters/exhaustruct/testdata/exhaustruct_custom.yml +++ b/pkg/golinters/exhaustruct/testdata/exhaustruct_custom.yml @@ -1,8 +1,9 @@ version: "2" -linters-settings: - exhaustruct: - include: - - .*\.ExhaustructCustom - exclude: - - .*\.ExhaustructCustom[\d]{1,2} +linters: + settings: + exhaustruct: + include: + - .*\.ExhaustructCustom + exclude: + - .*\.ExhaustructCustom[\d]{1,2} diff --git a/pkg/golinters/fatcontext/testdata/fatcontext_structpointer.yml b/pkg/golinters/fatcontext/testdata/fatcontext_structpointer.yml index 0a62d5fe4bdd..84b4488ce9ab 100644 --- a/pkg/golinters/fatcontext/testdata/fatcontext_structpointer.yml +++ b/pkg/golinters/fatcontext/testdata/fatcontext_structpointer.yml @@ -1,6 +1,6 @@ version: "2" -linters-settings: - fatcontext: - check-struct-pointers: true - +linters: + settings: + fatcontext: + check-struct-pointers: true diff --git a/pkg/golinters/forbidigo/testdata/forbidigo.yml b/pkg/golinters/forbidigo/testdata/forbidigo.yml index c1f9a6267849..b3a7e3700b46 100644 --- a/pkg/golinters/forbidigo/testdata/forbidigo.yml +++ b/pkg/golinters/forbidigo/testdata/forbidigo.yml @@ -1,7 +1,8 @@ version: "2" -linters-settings: - forbidigo: - forbid: - - pattern: fmt\.Print.* - - pattern: time.Sleep(# no sleeping!)? +linters: + settings: + forbidigo: + forbid: + - pattern: fmt\.Print.* + - pattern: time.Sleep(# no sleeping!)? diff --git a/pkg/golinters/forbidigo/testdata/forbidigo_include_godoc_examples.yml b/pkg/golinters/forbidigo/testdata/forbidigo_include_godoc_examples.yml index caf8d35d3af4..35246f05042f 100644 --- a/pkg/golinters/forbidigo/testdata/forbidigo_include_godoc_examples.yml +++ b/pkg/golinters/forbidigo/testdata/forbidigo_include_godoc_examples.yml @@ -1,6 +1,6 @@ version: "2" -linters-settings: - forbidigo: - exclude-godoc-examples: false - +linters: + settings: + forbidigo: + exclude-godoc-examples: false diff --git a/pkg/golinters/forbidigo/testdata/forbidigo_struct.yml b/pkg/golinters/forbidigo/testdata/forbidigo_struct.yml index 24c7d6d02bdc..7ca1178a62ef 100644 --- a/pkg/golinters/forbidigo/testdata/forbidigo_struct.yml +++ b/pkg/golinters/forbidigo/testdata/forbidigo_struct.yml @@ -1,10 +1,11 @@ version: "2" -linters-settings: - forbidigo: - analyze-types: true - forbid: - - pattern: fmt\.Print.* - pkg: ^fmt$ - - pattern: time.Sleep - msg: no sleeping! +linters: + settings: + forbidigo: + analyze-types: true + forbid: + - pattern: fmt\.Print.* + pkg: ^fmt$ + - pattern: time.Sleep + msg: no sleeping! diff --git a/pkg/golinters/funlen/testdata/funlen.yml b/pkg/golinters/funlen/testdata/funlen.yml index ef39b55f71a1..05122435020c 100644 --- a/pkg/golinters/funlen/testdata/funlen.yml +++ b/pkg/golinters/funlen/testdata/funlen.yml @@ -1,6 +1,7 @@ version: "2" -linters-settings: - funlen: - lines: 20 - statements: 10 +linters: + settings: + funlen: + lines: 20 + statements: 10 diff --git a/pkg/golinters/ginkgolinter/testdata/ginkgolinter.go b/pkg/golinters/ginkgolinter/testdata/ginkgolinter.go index 74d540e64632..121869173f9b 100644 --- a/pkg/golinters/ginkgolinter/testdata/ginkgolinter.go +++ b/pkg/golinters/ginkgolinter/testdata/ginkgolinter.go @@ -1,4 +1,4 @@ -//golangcitest:args --disable-all -Eginkgolinter +//golangcitest:args -Eginkgolinter package ginkgolinter import ( diff --git a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_allow_havelen0.yml b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_allow_havelen0.yml index 929ef47fa077..76c44941fb3c 100644 --- a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_allow_havelen0.yml +++ b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_allow_havelen0.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - ginkgolinter: - allow-havelen-zero: true +linters: + settings: + ginkgolinter: + allow-havelen-zero: true diff --git a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_cgo.go b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_cgo.go index 5baff8729195..fe375f909e3f 100644 --- a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_cgo.go +++ b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_cgo.go @@ -1,4 +1,4 @@ -//golangcitest:args --disable-all -Eginkgolinter +//golangcitest:args -Eginkgolinter package testdata /* diff --git a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_default.yml b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_default.yml index 019cbba58dcf..5b0b3adc5f86 100644 --- a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_default.yml +++ b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_default.yml @@ -1,4 +1,5 @@ version: "2" -linters-settings: - ginkgolinter: {} +linters: + settings: + ginkgolinter: {} diff --git a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_havelen0.go b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_havelen0.go index ac91a708de66..7bca77c2a5a2 100644 --- a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_havelen0.go +++ b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_havelen0.go @@ -1,5 +1,5 @@ //golangcitest:config_path testdata/ginkgolinter_allow_havelen0.yml -//golangcitest:args --disable-all -Eginkgolinter +//golangcitest:args -Eginkgolinter package ginkgolinter import ( diff --git a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_async.go b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_async.go index 69531b7da300..69481a0833e9 100644 --- a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_async.go +++ b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_async.go @@ -1,5 +1,5 @@ //golangcitest:config_path testdata/ginkgolinter_suppress_async.yml -//golangcitest:args --disable-all -Eginkgolinter +//golangcitest:args -Eginkgolinter package ginkgolinter import ( diff --git a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_async.yml b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_async.yml index 2cc9ad84304a..64d12dfd75cd 100644 --- a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_async.yml +++ b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_async.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - ginkgolinter: - suppress-async-assertion: true +linters: + settings: + ginkgolinter: + suppress-async-assertion: true diff --git a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_compare.go b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_compare.go index 0e9688de9c0b..f1314486a4a8 100644 --- a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_compare.go +++ b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_compare.go @@ -1,5 +1,5 @@ //golangcitest:config_path testdata/ginkgolinter_suppress_compare.yml -//golangcitest:args --disable-all -Eginkgolinter +//golangcitest:args -Eginkgolinter package ginkgolinter import ( diff --git a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_compare.yml b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_compare.yml index a5abb9e5fcd2..a4d5ee66671d 100644 --- a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_compare.yml +++ b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_compare.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - ginkgolinter: - suppress-compare-assertion: true +linters: + settings: + ginkgolinter: + suppress-compare-assertion: true diff --git a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_err.go b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_err.go index ea80afbc2e94..b6f13225abc9 100644 --- a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_err.go +++ b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_err.go @@ -1,5 +1,5 @@ //golangcitest:config_path testdata/ginkgolinter_suppress_err.yml -//golangcitest:args --disable-all -Eginkgolinter +//golangcitest:args -Eginkgolinter package ginkgolinter import ( diff --git a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_err.yml b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_err.yml index c93086a4f4bb..3d032a9e98ba 100644 --- a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_err.yml +++ b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_err.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - ginkgolinter: - suppress-err-assertion: true +linters: + settings: + ginkgolinter: + suppress-err-assertion: true diff --git a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_focused_containers.go b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_focused_containers.go index ff4fd05797a2..b98574006b90 100644 --- a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_focused_containers.go +++ b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_focused_containers.go @@ -1,4 +1,4 @@ -//golangcitest:args --disable-all -Eginkgolinter +//golangcitest:args -Eginkgolinter //golangcitest:config_path testdata/ginkgolinter_suppress_focused_containers.yml package ginkgolinter diff --git a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_focused_containers.yml b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_focused_containers.yml index ca9b2cc3807d..4abcc4d48c71 100644 --- a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_focused_containers.yml +++ b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_focused_containers.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - ginkgolinter: - forbid-focus-container: true +linters: + settings: + ginkgolinter: + forbid-focus-container: true diff --git a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_len.go b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_len.go index ad8d8fdba3e2..4ea7ee1d2a3c 100644 --- a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_len.go +++ b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_len.go @@ -1,5 +1,5 @@ //golangcitest:config_path testdata/ginkgolinter_suppress_len.yml -//golangcitest:args --disable-all -Eginkgolinter +//golangcitest:args -Eginkgolinter package ginkgolinter import ( diff --git a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_len.yml b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_len.yml index e964619832c3..352f72bd1b31 100644 --- a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_len.yml +++ b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_len.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - ginkgolinter: - suppress-len-assertion: true +linters: + settings: + ginkgolinter: + suppress-len-assertion: true diff --git a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_nil.go b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_nil.go index fd13d7ed05fa..3531753fc584 100644 --- a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_nil.go +++ b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_nil.go @@ -1,4 +1,4 @@ -//golangcitest:args --disable-all -Eginkgolinter +//golangcitest:args -Eginkgolinter //golangcitest:config_path testdata/ginkgolinter_suppress_nil.yml package ginkgolinter diff --git a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_nil.yml b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_nil.yml index 53512a80e020..a3c59e04f05b 100644 --- a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_nil.yml +++ b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_nil.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - ginkgolinter: - suppress-nil-assertion: true +linters: + settings: + ginkgolinter: + suppress-nil-assertion: true diff --git a/pkg/golinters/gochecksumtype/testdata/gochecksumtype_custom.yml b/pkg/golinters/gochecksumtype/testdata/gochecksumtype_custom.yml index ae9e64cba14c..b1958b52b1d2 100644 --- a/pkg/golinters/gochecksumtype/testdata/gochecksumtype_custom.yml +++ b/pkg/golinters/gochecksumtype/testdata/gochecksumtype_custom.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - gochecksumtype: - default-signifies-exhaustive: false +linters: + settings: + gochecksumtype: + default-signifies-exhaustive: false diff --git a/pkg/golinters/gocognit/testdata/gocognit.yml b/pkg/golinters/gocognit/testdata/gocognit.yml index 9970f3b8c493..7fdafd0e8e78 100644 --- a/pkg/golinters/gocognit/testdata/gocognit.yml +++ b/pkg/golinters/gocognit/testdata/gocognit.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - gocognit: - min-complexity: 2 +linters: + settings: + gocognit: + min-complexity: 2 diff --git a/pkg/golinters/goconst/testdata/goconst_calls_enabled.yml b/pkg/golinters/goconst/testdata/goconst_calls_enabled.yml index c9e54c7c519c..3178f54b6bc5 100644 --- a/pkg/golinters/goconst/testdata/goconst_calls_enabled.yml +++ b/pkg/golinters/goconst/testdata/goconst_calls_enabled.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - goconst: - ignore-calls: false +linters: + settings: + goconst: + ignore-calls: false diff --git a/pkg/golinters/gocritic/testdata/gocritic-fix.yml b/pkg/golinters/gocritic/testdata/gocritic-fix.yml index 1e215c56ef3d..234cd058f2d4 100644 --- a/pkg/golinters/gocritic/testdata/gocritic-fix.yml +++ b/pkg/golinters/gocritic/testdata/gocritic-fix.yml @@ -1,13 +1,14 @@ version: "2" -linters-settings: - gocritic: - enabled-checks: - - ruleguard - settings: - ruleguard: - failOn: dsl,import - rules: '${base-path}/ruleguard/rangeExprCopy.go,${base-path}/ruleguard/stringsSimplify.go' +linters: + settings: + gocritic: + enabled-checks: + - ruleguard + settings: + ruleguard: + failOn: dsl,import + rules: '${base-path}/ruleguard/rangeExprCopy.go,${base-path}/ruleguard/stringsSimplify.go' run: relative-path-mode: cfg diff --git a/pkg/golinters/gocritic/testdata/gocritic.yml b/pkg/golinters/gocritic/testdata/gocritic.yml index 7e03addb25f3..5c90af7d6f78 100644 --- a/pkg/golinters/gocritic/testdata/gocritic.yml +++ b/pkg/golinters/gocritic/testdata/gocritic.yml @@ -1,19 +1,20 @@ version: "2" -linters-settings: - gocritic: - disabled-checks: - - appendAssign - - switchTrue - enabled-checks: - - hugeParam - - ruleguard - settings: - hugeParam: - sizeThreshold: 24 - ruleguard: - failOn: dsl,import - rules: '${base-path}/ruleguard/preferWriteString.go,${base-path}/ruleguard/stringsSimplify.go' +linters: + settings: + gocritic: + disabled-checks: + - appendAssign + - switchTrue + enabled-checks: + - hugeParam + - ruleguard + settings: + hugeParam: + sizeThreshold: 24 + ruleguard: + failOn: dsl,import + rules: '${base-path}/ruleguard/preferWriteString.go,${base-path}/ruleguard/stringsSimplify.go' run: relative-path-mode: cfg diff --git a/pkg/golinters/gocyclo/testdata/gocyclo.yml b/pkg/golinters/gocyclo/testdata/gocyclo.yml index 03de091856d5..29c6e6a7b32d 100644 --- a/pkg/golinters/gocyclo/testdata/gocyclo.yml +++ b/pkg/golinters/gocyclo/testdata/gocyclo.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - gocyclo: - min-complexity: 20 +linters: + settings: + gocyclo: + min-complexity: 20 diff --git a/pkg/golinters/godox/testdata/godox.yml b/pkg/golinters/godox/testdata/godox.yml index 2c49ffca2d7c..4b995d551cce 100644 --- a/pkg/golinters/godox/testdata/godox.yml +++ b/pkg/golinters/godox/testdata/godox.yml @@ -1,7 +1,8 @@ version: "2" -linters-settings: - godox: - keywords: - - FIXME - - TODO +linters: + settings: + godox: + keywords: + - FIXME + - TODO diff --git a/pkg/golinters/goheader/testdata/goheader-fix.yml b/pkg/golinters/goheader/testdata/goheader-fix.yml index f8b45f374772..183c4076c17e 100644 --- a/pkg/golinters/goheader/testdata/goheader-fix.yml +++ b/pkg/golinters/goheader/testdata/goheader-fix.yml @@ -1,11 +1,12 @@ version: "2" -linters-settings: - goheader: - values: - const: - AUTHOR: The Awesome Project Authors - template: |- - Copyright 2024 {{ AUTHOR }} - - Use of this source code is governed by LICENSE +linters: + settings: + goheader: + values: + const: + AUTHOR: The Awesome Project Authors + template: |- + Copyright 2024 {{ AUTHOR }} + + Use of this source code is governed by LICENSE diff --git a/pkg/golinters/goheader/testdata/goheader.yml b/pkg/golinters/goheader/testdata/goheader.yml index 2977c2b80ae4..cb10cdf025d8 100644 --- a/pkg/golinters/goheader/testdata/goheader.yml +++ b/pkg/golinters/goheader/testdata/goheader.yml @@ -1,8 +1,9 @@ version: "2" -linters-settings: - goheader: - template: MY {{title}} - values: - const: - title: TITLE. +linters: + settings: + goheader: + template: MY {{title}} + values: + const: + title: TITLE. diff --git a/pkg/golinters/gomodguard/testdata/gomodguard.yml b/pkg/golinters/gomodguard/testdata/gomodguard.yml index 9857547d7e61..ddbc0d99f713 100644 --- a/pkg/golinters/gomodguard/testdata/gomodguard.yml +++ b/pkg/golinters/gomodguard/testdata/gomodguard.yml @@ -1,13 +1,14 @@ version: "2" -linters-settings: - gomodguard: - allowed: - modules: # List of allowed modules - - golang.org/x/mod - blocked: - modules: # List of blocked modules - - gopkg.in/yaml.v3: # Blocked module - recommendations: # Recommended modules that should be used instead (Optional) - - github.com/kylelemons/go-gypsy - reason: "This is an example of recommendations." # Reason why the recommended module should be used (Optional) +linters: + settings: + gomodguard: + allowed: + modules: # List of allowed modules + - golang.org/x/mod + blocked: + modules: # List of blocked modules + - gopkg.in/yaml.v3: # Blocked module + recommendations: # Recommended modules that should be used instead (Optional) + - github.com/kylelemons/go-gypsy + reason: "This is an example of recommendations." # Reason why the recommended module should be used (Optional) diff --git a/pkg/golinters/gosec/testdata/gosec.yml b/pkg/golinters/gosec/testdata/gosec.yml index d7cab9ac3616..5b5391e7c9b1 100644 --- a/pkg/golinters/gosec/testdata/gosec.yml +++ b/pkg/golinters/gosec/testdata/gosec.yml @@ -1,15 +1,16 @@ version: "2" -linters-settings: - gosec: - includes: - - G306 - - G101 - config: - G306: "0666" - G101: - pattern: "(?i)simple" - ignore_entropy: false - entropy_threshold: "80.0" - per_char_threshold: "3.0" - truncate: "32" +linters: + settings: + gosec: + includes: + - G306 + - G101 + config: + G306: "0666" + G101: + pattern: "(?i)simple" + ignore_entropy: false + entropy_threshold: "80.0" + per_char_threshold: "3.0" + truncate: "32" diff --git a/pkg/golinters/gosec/testdata/gosec_global_option.yml b/pkg/golinters/gosec/testdata/gosec_global_option.yml index 79cfb23d4c73..fb7f18d13fb0 100644 --- a/pkg/golinters/gosec/testdata/gosec_global_option.yml +++ b/pkg/golinters/gosec/testdata/gosec_global_option.yml @@ -1,7 +1,8 @@ version: "2" -linters-settings: - gosec: - config: - global: - nosec: true +linters: + settings: + gosec: + config: + global: + nosec: true diff --git a/pkg/golinters/gosec/testdata/gosec_nosec.yml b/pkg/golinters/gosec/testdata/gosec_nosec.yml index 0013ee999c2f..fa20682f98fe 100644 --- a/pkg/golinters/gosec/testdata/gosec_nosec.yml +++ b/pkg/golinters/gosec/testdata/gosec_nosec.yml @@ -1,7 +1,8 @@ version: "2" -linters-settings: - gosec: - config: - global: - nosec: false +linters: + settings: + gosec: + config: + global: + nosec: false diff --git a/pkg/golinters/gosec/testdata/gosec_severity_confidence.yml b/pkg/golinters/gosec/testdata/gosec_severity_confidence.yml index 11c6d3fb9311..5c6ec4c0489a 100644 --- a/pkg/golinters/gosec/testdata/gosec_severity_confidence.yml +++ b/pkg/golinters/gosec/testdata/gosec_severity_confidence.yml @@ -1,6 +1,7 @@ version: "2" -linters-settings: - gosec: - severity: "medium" - confidence: "medium" +linters: + settings: + gosec: + severity: "medium" + confidence: "medium" diff --git a/pkg/golinters/gosmopolitan/testdata/gosmopolitan_allow_time_local.yml b/pkg/golinters/gosmopolitan/testdata/gosmopolitan_allow_time_local.yml index bb8c0bd8878f..313587a33a51 100644 --- a/pkg/golinters/gosmopolitan/testdata/gosmopolitan_allow_time_local.yml +++ b/pkg/golinters/gosmopolitan/testdata/gosmopolitan_allow_time_local.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - gosmopolitan: - allow-time-local: true +linters: + settings: + gosmopolitan: + allow-time-local: true diff --git a/pkg/golinters/gosmopolitan/testdata/gosmopolitan_escape_hatches.yml b/pkg/golinters/gosmopolitan/testdata/gosmopolitan_escape_hatches.yml index 2c6c9bcb281a..7dd2ba47c08a 100644 --- a/pkg/golinters/gosmopolitan/testdata/gosmopolitan_escape_hatches.yml +++ b/pkg/golinters/gosmopolitan/testdata/gosmopolitan_escape_hatches.yml @@ -1,10 +1,11 @@ version: "2" -linters-settings: - gosmopolitan: - escape-hatches: - - 'command-line-arguments.A' - - 'command-line-arguments.B' - - 'command-line-arguments.C' - - 'command-line-arguments.D' - - 'fmt.Println' +linters: + settings: + gosmopolitan: + escape-hatches: + - 'command-line-arguments.A' + - 'command-line-arguments.B' + - 'command-line-arguments.C' + - 'command-line-arguments.D' + - 'fmt.Println' diff --git a/pkg/golinters/gosmopolitan/testdata/gosmopolitan_scripts.yml b/pkg/golinters/gosmopolitan/testdata/gosmopolitan_scripts.yml index 6b16c2712c8f..31453b5a04e5 100644 --- a/pkg/golinters/gosmopolitan/testdata/gosmopolitan_scripts.yml +++ b/pkg/golinters/gosmopolitan/testdata/gosmopolitan_scripts.yml @@ -1,8 +1,9 @@ version: "2" -linters-settings: - gosmopolitan: - watch-for-scripts: - - Hiragana - - Katakana - - Latin +linters: + settings: + gosmopolitan: + watch-for-scripts: + - Hiragana + - Katakana + - Latin diff --git a/pkg/golinters/govet/testdata/govet.yml b/pkg/golinters/govet/testdata/govet.yml index 89f9d7d0edc2..232366283b55 100644 --- a/pkg/golinters/govet/testdata/govet.yml +++ b/pkg/golinters/govet/testdata/govet.yml @@ -1,6 +1,7 @@ version: "2" -linters-settings: - govet: - enable: - - shadow +linters: + settings: + govet: + enable: + - shadow diff --git a/pkg/golinters/govet/testdata/govet_fieldalignment.yml b/pkg/golinters/govet/testdata/govet_fieldalignment.yml index 070757844449..554a733bb673 100644 --- a/pkg/golinters/govet/testdata/govet_fieldalignment.yml +++ b/pkg/golinters/govet/testdata/govet_fieldalignment.yml @@ -1,6 +1,7 @@ version: "2" -linters-settings: - govet: - enable: - - fieldalignment +linters: + settings: + govet: + enable: + - fieldalignment diff --git a/pkg/golinters/govet/testdata/govet_fix.yml b/pkg/golinters/govet/testdata/govet_fix.yml index 903535aeba05..658cb9d71daf 100644 --- a/pkg/golinters/govet/testdata/govet_fix.yml +++ b/pkg/golinters/govet/testdata/govet_fix.yml @@ -1,15 +1,16 @@ version: "2" -linters-settings: - govet: - enable: - - assign - - composites - - fieldalignment - - findcall - - printf - - sigchanyzer - - sortslice - - stringintconv - - timeformat - - unreachable +linters: + settings: + govet: + enable: + - assign + - composites + - fieldalignment + - findcall + - printf + - sigchanyzer + - sortslice + - stringintconv + - timeformat + - unreachable diff --git a/pkg/golinters/govet/testdata/govet_ifaceassert.yml b/pkg/golinters/govet/testdata/govet_ifaceassert.yml index 28e5c7c9b3b1..6ae96f26ec93 100644 --- a/pkg/golinters/govet/testdata/govet_ifaceassert.yml +++ b/pkg/golinters/govet/testdata/govet_ifaceassert.yml @@ -1,6 +1,7 @@ version: "2" -linters-settings: - govet: - enable: - - ifaceassert +linters: + settings: + govet: + enable: + - ifaceassert diff --git a/pkg/golinters/grouper/testdata/grouper.yml b/pkg/golinters/grouper/testdata/grouper.yml index d7312efc8165..351da7b9e639 100644 --- a/pkg/golinters/grouper/testdata/grouper.yml +++ b/pkg/golinters/grouper/testdata/grouper.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - grouper: - import-require-grouping: true +linters: + settings: + grouper: + import-require-grouping: true diff --git a/pkg/golinters/iface/testdata/iface_all.yml b/pkg/golinters/iface/testdata/iface_all.yml index 69f306bd92d6..69b0bab2d407 100644 --- a/pkg/golinters/iface/testdata/iface_all.yml +++ b/pkg/golinters/iface/testdata/iface_all.yml @@ -1,8 +1,9 @@ version: "2" -linters-settings: - iface: - enable: - - unused - - identical - - opaque +linters: + settings: + iface: + enable: + - unused + - identical + - opaque diff --git a/pkg/golinters/iface/testdata/iface_fix.yml b/pkg/golinters/iface/testdata/iface_fix.yml index 889884281475..f76b9329c354 100644 --- a/pkg/golinters/iface/testdata/iface_fix.yml +++ b/pkg/golinters/iface/testdata/iface_fix.yml @@ -1,7 +1,8 @@ version: "2" -linters-settings: - iface: - enable: - - unused - - opaque +linters: + settings: + iface: + enable: + - unused + - opaque diff --git a/pkg/golinters/iface/testdata/iface_identical.yml b/pkg/golinters/iface/testdata/iface_identical.yml index 195a1f6baec8..dab15ca1a310 100644 --- a/pkg/golinters/iface/testdata/iface_identical.yml +++ b/pkg/golinters/iface/testdata/iface_identical.yml @@ -1,6 +1,7 @@ version: "2" -linters-settings: - iface: - enable: - - identical +linters: + settings: + iface: + enable: + - identical diff --git a/pkg/golinters/iface/testdata/iface_opaque.yml b/pkg/golinters/iface/testdata/iface_opaque.yml index b9b66466d963..d0089f270f50 100644 --- a/pkg/golinters/iface/testdata/iface_opaque.yml +++ b/pkg/golinters/iface/testdata/iface_opaque.yml @@ -1,6 +1,7 @@ version: "2" -linters-settings: - iface: - enable: - - opaque +linters: + settings: + iface: + enable: + - opaque diff --git a/pkg/golinters/iface/testdata/iface_unused.yml b/pkg/golinters/iface/testdata/iface_unused.yml index 8f1a26cfa9cb..9b3316c14f7d 100644 --- a/pkg/golinters/iface/testdata/iface_unused.yml +++ b/pkg/golinters/iface/testdata/iface_unused.yml @@ -1,6 +1,7 @@ version: "2" -linters-settings: - iface: - enable: - - unused +linters: + settings: + iface: + enable: + - unused diff --git a/pkg/golinters/importas/testdata/importas.yml b/pkg/golinters/importas/testdata/importas.yml index f144ff021e67..3d413ea2fb3e 100644 --- a/pkg/golinters/importas/testdata/importas.yml +++ b/pkg/golinters/importas/testdata/importas.yml @@ -1,11 +1,12 @@ version: "2" -linters-settings: - importas: - alias: - - pkg: fmt - alias: fff - - pkg: os - alias: std_os - - pkg: golang.org/x/tools/go/analysis - alias: ananas +linters: + settings: + importas: + alias: + - pkg: fmt + alias: fff + - pkg: os + alias: std_os + - pkg: golang.org/x/tools/go/analysis + alias: ananas diff --git a/pkg/golinters/importas/testdata/importas_several_empty_aliases.yml b/pkg/golinters/importas/testdata/importas_several_empty_aliases.yml index 9ff17d87bb18..029786ee2ba7 100644 --- a/pkg/golinters/importas/testdata/importas_several_empty_aliases.yml +++ b/pkg/golinters/importas/testdata/importas_several_empty_aliases.yml @@ -1,11 +1,12 @@ version: "2" -linters-settings: - importas: - alias: - - pkg: fmt - alias: '' - - pkg: os - alias: '' - - pkg: math - alias: '' +linters: + settings: + importas: + alias: + - pkg: fmt + alias: '' + - pkg: os + alias: '' + - pkg: math + alias: '' diff --git a/pkg/golinters/importas/testdata/importas_strict.yml b/pkg/golinters/importas/testdata/importas_strict.yml index d670be71c212..f10415c5a0ca 100644 --- a/pkg/golinters/importas/testdata/importas_strict.yml +++ b/pkg/golinters/importas/testdata/importas_strict.yml @@ -1,12 +1,13 @@ version: "2" -linters-settings: - importas: - no-unaliased: true - alias: - - pkg: fmt - alias: fff - - pkg: os - alias: std_os - - pkg: golang.org/x/tools/go/analysis - alias: ananas +linters: + settings: + importas: + no-unaliased: true + alias: + - pkg: fmt + alias: fff + - pkg: os + alias: std_os + - pkg: golang.org/x/tools/go/analysis + alias: ananas diff --git a/pkg/golinters/inamedparam/testdata/inamedparam_skip_single_param.yml b/pkg/golinters/inamedparam/testdata/inamedparam_skip_single_param.yml index ce8cf550432b..78b17a0c0a47 100644 --- a/pkg/golinters/inamedparam/testdata/inamedparam_skip_single_param.yml +++ b/pkg/golinters/inamedparam/testdata/inamedparam_skip_single_param.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - inamedparam: - skip-single-param: true +linters: + settings: + inamedparam: + skip-single-param: true diff --git a/pkg/golinters/ireturn/testdata/ireturn_allow.yml b/pkg/golinters/ireturn/testdata/ireturn_allow.yml index 758e39559e79..6634e8f8e978 100644 --- a/pkg/golinters/ireturn/testdata/ireturn_allow.yml +++ b/pkg/golinters/ireturn/testdata/ireturn_allow.yml @@ -1,6 +1,7 @@ version: "2" -linters-settings: - ireturn: - allow: - - IreturnAllowDoer +linters: + settings: + ireturn: + allow: + - IreturnAllowDoer diff --git a/pkg/golinters/ireturn/testdata/ireturn_reject_generics.yml b/pkg/golinters/ireturn/testdata/ireturn_reject_generics.yml index 5d737162ea93..27c31f851905 100644 --- a/pkg/golinters/ireturn/testdata/ireturn_reject_generics.yml +++ b/pkg/golinters/ireturn/testdata/ireturn_reject_generics.yml @@ -1,6 +1,7 @@ version: "2" -linters-settings: - ireturn: - reject: - - generic +linters: + settings: + ireturn: + reject: + - generic diff --git a/pkg/golinters/ireturn/testdata/ireturn_reject_stdlib.yml b/pkg/golinters/ireturn/testdata/ireturn_reject_stdlib.yml index 7c3c5a253f80..1e2febf3b787 100644 --- a/pkg/golinters/ireturn/testdata/ireturn_reject_stdlib.yml +++ b/pkg/golinters/ireturn/testdata/ireturn_reject_stdlib.yml @@ -1,6 +1,7 @@ version: "2" -linters-settings: - ireturn: - reject: - - stdlib +linters: + settings: + ireturn: + reject: + - stdlib diff --git a/pkg/golinters/lll/testdata/lll.yml b/pkg/golinters/lll/testdata/lll.yml index f6f38b73c856..d34071ba4de1 100644 --- a/pkg/golinters/lll/testdata/lll.yml +++ b/pkg/golinters/lll/testdata/lll.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - lll: - tab-width: 4 +linters: + settings: + lll: + tab-width: 4 diff --git a/pkg/golinters/lll/testdata/lll_import.yml b/pkg/golinters/lll/testdata/lll_import.yml index a1db8c2d190c..e430506a25c4 100644 --- a/pkg/golinters/lll/testdata/lll_import.yml +++ b/pkg/golinters/lll/testdata/lll_import.yml @@ -1,6 +1,7 @@ version: "2" -linters-settings: - lll: - tab-width: 4 - line-length: 60 +linters: + settings: + lll: + tab-width: 4 + line-length: 60 diff --git a/pkg/golinters/loggercheck/testdata/loggercheck_custom.yml b/pkg/golinters/loggercheck/testdata/loggercheck_custom.yml index e9322f3901ef..22f94648636d 100644 --- a/pkg/golinters/loggercheck/testdata/loggercheck_custom.yml +++ b/pkg/golinters/loggercheck/testdata/loggercheck_custom.yml @@ -1,15 +1,16 @@ version: "2" -linters-settings: - loggercheck: - rules: - - (*command-line-arguments.Logger).Debugw - - (*command-line-arguments.Logger).Infow - - (*command-line-arguments.Logger).Warnw - - (*command-line-arguments.Logger).Errorw - - (*command-line-arguments.Logger).With - - command-line-arguments.Debugw - - command-line-arguments.Infow - - command-line-arguments.Warnw - - command-line-arguments.Errorw - - command-line-arguments.With +linters: + settings: + loggercheck: + rules: + - (*command-line-arguments.Logger).Debugw + - (*command-line-arguments.Logger).Infow + - (*command-line-arguments.Logger).Warnw + - (*command-line-arguments.Logger).Errorw + - (*command-line-arguments.Logger).With + - command-line-arguments.Debugw + - command-line-arguments.Infow + - command-line-arguments.Warnw + - command-line-arguments.Errorw + - command-line-arguments.With diff --git a/pkg/golinters/loggercheck/testdata/loggercheck_kitlogonly.yml b/pkg/golinters/loggercheck/testdata/loggercheck_kitlogonly.yml index bab187dec33f..d5dab72eb478 100644 --- a/pkg/golinters/loggercheck/testdata/loggercheck_kitlogonly.yml +++ b/pkg/golinters/loggercheck/testdata/loggercheck_kitlogonly.yml @@ -1,9 +1,10 @@ version: "2" -linters-settings: - loggercheck: - kitlog: true - klog: false - logr: false - slog: false - zap: false +linters: + settings: + loggercheck: + kitlog: true + klog: false + logr: false + slog: false + zap: false diff --git a/pkg/golinters/loggercheck/testdata/loggercheck_logronly.yml b/pkg/golinters/loggercheck/testdata/loggercheck_logronly.yml index 49a3f6d3e09b..0a8b6f71fece 100644 --- a/pkg/golinters/loggercheck/testdata/loggercheck_logronly.yml +++ b/pkg/golinters/loggercheck/testdata/loggercheck_logronly.yml @@ -1,8 +1,9 @@ version: "2" -linters-settings: - loggercheck: - logr: true - klog: false - slog: false - zap: false +linters: + settings: + loggercheck: + logr: true + klog: false + slog: false + zap: false diff --git a/pkg/golinters/loggercheck/testdata/loggercheck_noprintflike.yml b/pkg/golinters/loggercheck/testdata/loggercheck_noprintflike.yml index 6b1e68a20b99..77c3bfc7fc71 100644 --- a/pkg/golinters/loggercheck/testdata/loggercheck_noprintflike.yml +++ b/pkg/golinters/loggercheck/testdata/loggercheck_noprintflike.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - loggercheck: - no-printf-like: true +linters: + settings: + loggercheck: + no-printf-like: true diff --git a/pkg/golinters/loggercheck/testdata/loggercheck_requirestringkey.yml b/pkg/golinters/loggercheck/testdata/loggercheck_requirestringkey.yml index 5496a1f0fc43..594e568b4f92 100644 --- a/pkg/golinters/loggercheck/testdata/loggercheck_requirestringkey.yml +++ b/pkg/golinters/loggercheck/testdata/loggercheck_requirestringkey.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - loggercheck: - require-string-key: true +linters: + settings: + loggercheck: + require-string-key: true diff --git a/pkg/golinters/loggercheck/testdata/loggercheck_slogonly.yml b/pkg/golinters/loggercheck/testdata/loggercheck_slogonly.yml index 8b4a57f3884e..f10c81c8c3f9 100644 --- a/pkg/golinters/loggercheck/testdata/loggercheck_slogonly.yml +++ b/pkg/golinters/loggercheck/testdata/loggercheck_slogonly.yml @@ -1,8 +1,9 @@ version: "2" -linters-settings: - loggercheck: - logr: false - klog: false - slog: true - zap: false +linters: + settings: + loggercheck: + logr: false + klog: false + slog: true + zap: false diff --git a/pkg/golinters/loggercheck/testdata/loggercheck_zaponly.yml b/pkg/golinters/loggercheck/testdata/loggercheck_zaponly.yml index bc9bae967731..3648c8308b98 100644 --- a/pkg/golinters/loggercheck/testdata/loggercheck_zaponly.yml +++ b/pkg/golinters/loggercheck/testdata/loggercheck_zaponly.yml @@ -1,8 +1,9 @@ version: "2" -linters-settings: - loggercheck: - logr: false - klog: false - slog: false - zap: true +linters: + settings: + loggercheck: + logr: false + klog: false + slog: false + zap: true diff --git a/pkg/golinters/maintidx/testdata/maintidx_under_100.yml b/pkg/golinters/maintidx/testdata/maintidx_under_100.yml index 7f9f811d55ed..8c0adc202473 100644 --- a/pkg/golinters/maintidx/testdata/maintidx_under_100.yml +++ b/pkg/golinters/maintidx/testdata/maintidx_under_100.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - maintidx: - under: 100 +linters: + settings: + maintidx: + under: 100 diff --git a/pkg/golinters/makezero/testdata/makezero_always.yml b/pkg/golinters/makezero/testdata/makezero_always.yml index 13496e131b36..a33e452046ae 100644 --- a/pkg/golinters/makezero/testdata/makezero_always.yml +++ b/pkg/golinters/makezero/testdata/makezero_always.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - makezero: - always: true +linters: + settings: + makezero: + always: true diff --git a/pkg/golinters/misspell/testdata/misspell.yml b/pkg/golinters/misspell/testdata/misspell.yml index 2947e3905b1d..478039477b90 100644 --- a/pkg/golinters/misspell/testdata/misspell.yml +++ b/pkg/golinters/misspell/testdata/misspell.yml @@ -1,8 +1,9 @@ version: "2" -linters-settings: - misspell: - locale: US - ignore-rules: - - langauge - - Dialogue +linters: + settings: + misspell: + locale: US + ignore-rules: + - langauge + - Dialogue diff --git a/pkg/golinters/misspell/testdata/misspell_custom.yml b/pkg/golinters/misspell/testdata/misspell_custom.yml index 1d88b6cd10b4..b5ad219627d0 100644 --- a/pkg/golinters/misspell/testdata/misspell_custom.yml +++ b/pkg/golinters/misspell/testdata/misspell_custom.yml @@ -1,9 +1,10 @@ version: "2" -linters-settings: - misspell: - extra-words: - - typo: "iff" - correction: "if" - - typo: "cancelation" - correction: "cancellation" +linters: + settings: + misspell: + extra-words: + - typo: "iff" + correction: "if" + - typo: "cancelation" + correction: "cancellation" diff --git a/pkg/golinters/musttag/testdata/musttag.yml b/pkg/golinters/musttag/testdata/musttag.yml index 4d81b9b65eac..e08cd79c5470 100644 --- a/pkg/golinters/musttag/testdata/musttag.yml +++ b/pkg/golinters/musttag/testdata/musttag.yml @@ -1,11 +1,12 @@ version: "2" -linters-settings: - musttag: - functions: - - name: encoding/asn1.Marshal - tag: asn1 - arg-pos: 0 - - name: encoding/asn1.Unmarshal - tag: asn1 - arg-pos: 1 +linters: + settings: + musttag: + functions: + - name: encoding/asn1.Marshal + tag: asn1 + arg-pos: 0 + - name: encoding/asn1.Unmarshal + tag: asn1 + arg-pos: 1 diff --git a/pkg/golinters/nestif/testdata/nestif.yml b/pkg/golinters/nestif/testdata/nestif.yml index 21eefe5886f5..a961586f0818 100644 --- a/pkg/golinters/nestif/testdata/nestif.yml +++ b/pkg/golinters/nestif/testdata/nestif.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - nestif: - min-complexity: 1 +linters: + settings: + nestif: + min-complexity: 1 diff --git a/pkg/golinters/nilnil/testdata/nilnil_detect_opposite.yml b/pkg/golinters/nilnil/testdata/nilnil_detect_opposite.yml index 229bd33a280c..35b02a1d8b8a 100644 --- a/pkg/golinters/nilnil/testdata/nilnil_detect_opposite.yml +++ b/pkg/golinters/nilnil/testdata/nilnil_detect_opposite.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - nilnil: - detect-opposite: true +linters: + settings: + nilnil: + detect-opposite: true diff --git a/pkg/golinters/nilnil/testdata/nilnil_pointers_only.yml b/pkg/golinters/nilnil/testdata/nilnil_pointers_only.yml index 5d6d6d6711df..4591bfab621c 100644 --- a/pkg/golinters/nilnil/testdata/nilnil_pointers_only.yml +++ b/pkg/golinters/nilnil/testdata/nilnil_pointers_only.yml @@ -1,7 +1,8 @@ version: "2" -linters-settings: - nilnil: - checked-types: - - ptr - - uintptr +linters: + settings: + nilnil: + checked-types: + - ptr + - uintptr diff --git a/pkg/golinters/nlreturn/testdata/nlreturn-block-size.yml b/pkg/golinters/nlreturn/testdata/nlreturn-block-size.yml index d19799538959..340cb66e772d 100644 --- a/pkg/golinters/nlreturn/testdata/nlreturn-block-size.yml +++ b/pkg/golinters/nlreturn/testdata/nlreturn-block-size.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - nlreturn: - block-size: 2 +linters: + settings: + nlreturn: + block-size: 2 diff --git a/pkg/golinters/nolintlint/testdata/nolintlint.yml b/pkg/golinters/nolintlint/testdata/nolintlint.yml index de4cd8235666..18c64510bbc6 100644 --- a/pkg/golinters/nolintlint/testdata/nolintlint.yml +++ b/pkg/golinters/nolintlint/testdata/nolintlint.yml @@ -1,6 +1,7 @@ version: "2" -linters-settings: - nolintlint: - require-explanation: true - require-specific: true +linters: + settings: + nolintlint: + require-explanation: true + require-specific: true diff --git a/pkg/golinters/nolintlint/testdata/nolintlint_unused.yml b/pkg/golinters/nolintlint/testdata/nolintlint_unused.yml index 38d98f01bc9e..69216da63aec 100644 --- a/pkg/golinters/nolintlint/testdata/nolintlint_unused.yml +++ b/pkg/golinters/nolintlint/testdata/nolintlint_unused.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - nolintlint: - allow-unused: false +linters: + settings: + nolintlint: + allow-unused: false diff --git a/pkg/golinters/nonamedreturns/testdata/nonamedreturns_custom.yml b/pkg/golinters/nonamedreturns/testdata/nonamedreturns_custom.yml index 5564244c4c69..973d652dcb1b 100644 --- a/pkg/golinters/nonamedreturns/testdata/nonamedreturns_custom.yml +++ b/pkg/golinters/nonamedreturns/testdata/nonamedreturns_custom.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - nonamedreturns: - report-error-in-defer: true +linters: + settings: + nonamedreturns: + report-error-in-defer: true diff --git a/pkg/golinters/paralleltest/testdata/paralleltest_custom.yml b/pkg/golinters/paralleltest/testdata/paralleltest_custom.yml index 74231a5cd1c3..d6f20432aabd 100644 --- a/pkg/golinters/paralleltest/testdata/paralleltest_custom.yml +++ b/pkg/golinters/paralleltest/testdata/paralleltest_custom.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - paralleltest: - ignore-missing: true +linters: + settings: + paralleltest: + ignore-missing: true diff --git a/pkg/golinters/perfsprint/testdata/perfsprint_custom.yml b/pkg/golinters/perfsprint/testdata/perfsprint_custom.yml index 315c868e104f..2c5a8c7d5dc3 100644 --- a/pkg/golinters/perfsprint/testdata/perfsprint_custom.yml +++ b/pkg/golinters/perfsprint/testdata/perfsprint_custom.yml @@ -1,9 +1,9 @@ version: "2" -linters-settings: - perfsprint: - int-conversion: false - err-error: true - errorf: false - sprintf1: false - +linters: + settings: + perfsprint: + int-conversion: false + err-error: true + errorf: false + sprintf1: false diff --git a/pkg/golinters/predeclared/testdata/predeclared_custom.yml b/pkg/golinters/predeclared/testdata/predeclared_custom.yml index a7d42f583fb8..80862beafa56 100644 --- a/pkg/golinters/predeclared/testdata/predeclared_custom.yml +++ b/pkg/golinters/predeclared/testdata/predeclared_custom.yml @@ -1,8 +1,9 @@ version: "2" -linters-settings: - predeclared: - ignore: - - real - - recover - qualified-name: true +linters: + settings: + predeclared: + ignore: + - real + - recover + qualified-name: true diff --git a/pkg/golinters/reassign/testdata/reassign_patterns.yml b/pkg/golinters/reassign/testdata/reassign_patterns.yml index 5c0641e15740..e8ae8e307477 100644 --- a/pkg/golinters/reassign/testdata/reassign_patterns.yml +++ b/pkg/golinters/reassign/testdata/reassign_patterns.yml @@ -1,7 +1,8 @@ version: "2" -linters-settings: - reassign: - patterns: - - DefaultClient - - DefaultTransport +linters: + settings: + reassign: + patterns: + - DefaultClient + - DefaultTransport diff --git a/pkg/golinters/revive/testdata/revive-fix.yml b/pkg/golinters/revive/testdata/revive-fix.yml index 22e9b9c00d39..e96d9dc7ddae 100644 --- a/pkg/golinters/revive/testdata/revive-fix.yml +++ b/pkg/golinters/revive/testdata/revive-fix.yml @@ -1,8 +1,9 @@ version: "2" -linters-settings: - revive: - severity: warning - rules: - - name: errorf - - name: range +linters: + settings: + revive: + severity: warning + rules: + - name: errorf + - name: range diff --git a/pkg/golinters/revive/testdata/revive.yml b/pkg/golinters/revive/testdata/revive.yml index df281780ac08..772074b32012 100644 --- a/pkg/golinters/revive/testdata/revive.yml +++ b/pkg/golinters/revive/testdata/revive.yml @@ -1,19 +1,20 @@ version: "2" -linters-settings: - revive: - severity: warning - rules: - - name: exported - - name: cognitive-complexity - arguments: [ 7 ] - - name: line-length-limit - arguments: [ 130 ] - - name: function-result-limit - arguments: [ 3 ] - - name: argument-limit - arguments: [ 4 ] - - name: cyclomatic - arguments: [ 10 ] - - name: max-public-structs - arguments: [ 3 ] +linters: + settings: + revive: + severity: warning + rules: + - name: exported + - name: cognitive-complexity + arguments: [ 7 ] + - name: line-length-limit + arguments: [ 130 ] + - name: function-result-limit + arguments: [ 3 ] + - name: argument-limit + arguments: [ 4 ] + - name: cyclomatic + arguments: [ 10 ] + - name: max-public-structs + arguments: [ 3 ] diff --git a/pkg/golinters/sloglint/testdata/sloglint_args_on_sep_lines.yml b/pkg/golinters/sloglint/testdata/sloglint_args_on_sep_lines.yml index 9a143a1ab83a..2a87c2ab2ec9 100644 --- a/pkg/golinters/sloglint/testdata/sloglint_args_on_sep_lines.yml +++ b/pkg/golinters/sloglint/testdata/sloglint_args_on_sep_lines.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - sloglint: - args-on-sep-lines: true +linters: + settings: + sloglint: + args-on-sep-lines: true diff --git a/pkg/golinters/sloglint/testdata/sloglint_attr_only.yml b/pkg/golinters/sloglint/testdata/sloglint_attr_only.yml index fc36fff9ef14..dd8a19706812 100644 --- a/pkg/golinters/sloglint/testdata/sloglint_attr_only.yml +++ b/pkg/golinters/sloglint/testdata/sloglint_attr_only.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - sloglint: - attr-only: true +linters: + settings: + sloglint: + attr-only: true diff --git a/pkg/golinters/sloglint/testdata/sloglint_context_only.yml b/pkg/golinters/sloglint/testdata/sloglint_context_only.yml index 6ebe740d938b..018019d435da 100644 --- a/pkg/golinters/sloglint/testdata/sloglint_context_only.yml +++ b/pkg/golinters/sloglint/testdata/sloglint_context_only.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - sloglint: - context: "all" +linters: + settings: + sloglint: + context: "all" diff --git a/pkg/golinters/sloglint/testdata/sloglint_forbidden_keys.yml b/pkg/golinters/sloglint/testdata/sloglint_forbidden_keys.yml index e39c39c43f5e..e0b3f95e3ba2 100644 --- a/pkg/golinters/sloglint/testdata/sloglint_forbidden_keys.yml +++ b/pkg/golinters/sloglint/testdata/sloglint_forbidden_keys.yml @@ -1,6 +1,7 @@ version: "2" -linters-settings: - sloglint: - forbidden-keys: - - foo_bar +linters: + settings: + sloglint: + forbidden-keys: + - foo_bar diff --git a/pkg/golinters/sloglint/testdata/sloglint_key_naming_case.yml b/pkg/golinters/sloglint/testdata/sloglint_key_naming_case.yml index b53f3e7e0339..5f1908820ad8 100644 --- a/pkg/golinters/sloglint/testdata/sloglint_key_naming_case.yml +++ b/pkg/golinters/sloglint/testdata/sloglint_key_naming_case.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - sloglint: - key-naming-case: snake +linters: + settings: + sloglint: + key-naming-case: snake diff --git a/pkg/golinters/sloglint/testdata/sloglint_kv_only.yml b/pkg/golinters/sloglint/testdata/sloglint_kv_only.yml index 823539eb4f3a..33e1b29969f3 100644 --- a/pkg/golinters/sloglint/testdata/sloglint_kv_only.yml +++ b/pkg/golinters/sloglint/testdata/sloglint_kv_only.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - sloglint: - kv-only: true +linters: + settings: + sloglint: + kv-only: true diff --git a/pkg/golinters/sloglint/testdata/sloglint_no_raw_keys.yml b/pkg/golinters/sloglint/testdata/sloglint_no_raw_keys.yml index 5a2e11328975..63e1baa700f1 100644 --- a/pkg/golinters/sloglint/testdata/sloglint_no_raw_keys.yml +++ b/pkg/golinters/sloglint/testdata/sloglint_no_raw_keys.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - sloglint: - no-raw-keys: true +linters: + settings: + sloglint: + no-raw-keys: true diff --git a/pkg/golinters/sloglint/testdata/sloglint_static_msg.yml b/pkg/golinters/sloglint/testdata/sloglint_static_msg.yml index 8694822c69e7..060d45570452 100644 --- a/pkg/golinters/sloglint/testdata/sloglint_static_msg.yml +++ b/pkg/golinters/sloglint/testdata/sloglint_static_msg.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - sloglint: - static-msg: true +linters: + settings: + sloglint: + static-msg: true diff --git a/pkg/golinters/spancheck/testdata/spancheck_enable_all.yml b/pkg/golinters/spancheck/testdata/spancheck_enable_all.yml index ef90b1c54412..286613000511 100644 --- a/pkg/golinters/spancheck/testdata/spancheck_enable_all.yml +++ b/pkg/golinters/spancheck/testdata/spancheck_enable_all.yml @@ -1,10 +1,11 @@ version: "2" -linters-settings: - spancheck: - checks: - - "end" - - "record-error" - - "set-status" - ignore-check-signatures: - - "recordErr" +linters: + settings: + spancheck: + checks: + - "end" + - "record-error" + - "set-status" + ignore-check-signatures: + - "recordErr" diff --git a/pkg/golinters/spancheck/testdata/spancheck_keep_default.yml b/pkg/golinters/spancheck/testdata/spancheck_keep_default.yml index f10152005942..5f4b314b3c38 100644 --- a/pkg/golinters/spancheck/testdata/spancheck_keep_default.yml +++ b/pkg/golinters/spancheck/testdata/spancheck_keep_default.yml @@ -1,6 +1,7 @@ version: "2" -linters-settings: - spancheck: - extra-start-span-signatures: - - dummy:opentelemetry +linters: + settings: + spancheck: + extra-start-span-signatures: + - dummy:opentelemetry diff --git a/pkg/golinters/tagalign/testdata/tagalign_align_only.yml b/pkg/golinters/tagalign/testdata/tagalign_align_only.yml index 6f989840df48..690049adda80 100644 --- a/pkg/golinters/tagalign/testdata/tagalign_align_only.yml +++ b/pkg/golinters/tagalign/testdata/tagalign_align_only.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - tagalign: - sort: false +linters: + settings: + tagalign: + sort: false diff --git a/pkg/golinters/tagalign/testdata/tagalign_order_only.yml b/pkg/golinters/tagalign/testdata/tagalign_order_only.yml index 9943e1bead9f..e56ddf650c3f 100644 --- a/pkg/golinters/tagalign/testdata/tagalign_order_only.yml +++ b/pkg/golinters/tagalign/testdata/tagalign_order_only.yml @@ -1,9 +1,10 @@ version: "2" -linters-settings: - tagalign: - align: false - order: - - "xml" - - "json" - - "yaml" +linters: + settings: + tagalign: + align: false + order: + - "xml" + - "json" + - "yaml" diff --git a/pkg/golinters/tagalign/testdata/tagalign_sort_only.yml b/pkg/golinters/tagalign/testdata/tagalign_sort_only.yml index b77c94478097..687eda2cf8c1 100644 --- a/pkg/golinters/tagalign/testdata/tagalign_sort_only.yml +++ b/pkg/golinters/tagalign/testdata/tagalign_sort_only.yml @@ -1,6 +1,7 @@ version: "2" -linters-settings: - tagalign: - align: false - sort: true +linters: + settings: + tagalign: + align: false + sort: true diff --git a/pkg/golinters/tagalign/testdata/tagalign_strict.yml b/pkg/golinters/tagalign/testdata/tagalign_strict.yml index a1383326e8a7..93fd6a217656 100644 --- a/pkg/golinters/tagalign/testdata/tagalign_strict.yml +++ b/pkg/golinters/tagalign/testdata/tagalign_strict.yml @@ -1,7 +1,8 @@ version: "2" -linters-settings: - tagalign: - align: true - sort: true - strict: true +linters: + settings: + tagalign: + align: true + sort: true + strict: true diff --git a/pkg/golinters/tagliatelle/testdata/tagliatelle_ignored_fields.yml b/pkg/golinters/tagliatelle/testdata/tagliatelle_ignored_fields.yml index a907484250af..fc2175b23f96 100644 --- a/pkg/golinters/tagliatelle/testdata/tagliatelle_ignored_fields.yml +++ b/pkg/golinters/tagliatelle/testdata/tagliatelle_ignored_fields.yml @@ -1,9 +1,8 @@ version: "2" -linters-settings: - tagliatelle: - case: - ignored-fields: - - CommonServiceFooItem - - +linters: + settings: + tagliatelle: + case: + ignored-fields: + - CommonServiceFooItem diff --git a/pkg/golinters/testifylint/testdata/testifylint_bool_compare_only.yml b/pkg/golinters/testifylint/testdata/testifylint_bool_compare_only.yml index cddaa30b1edd..abbfd5bce7ca 100644 --- a/pkg/golinters/testifylint/testdata/testifylint_bool_compare_only.yml +++ b/pkg/golinters/testifylint/testdata/testifylint_bool_compare_only.yml @@ -1,9 +1,10 @@ version: "2" -linters-settings: - testifylint: - disable-all: true - enable: - - bool-compare - bool-compare: - ignore-custom-types: true +linters: + settings: + testifylint: + disable-all: true + enable: + - bool-compare + bool-compare: + ignore-custom-types: true diff --git a/pkg/golinters/testifylint/testdata/testifylint_formatter_only.yml b/pkg/golinters/testifylint/testdata/testifylint_formatter_only.yml index aca8ffaad304..c85e9fe7ad10 100644 --- a/pkg/golinters/testifylint/testdata/testifylint_formatter_only.yml +++ b/pkg/golinters/testifylint/testdata/testifylint_formatter_only.yml @@ -1,10 +1,11 @@ version: "2" -linters-settings: - testifylint: - disable-all: true - enable: - - formatter - formatter: - check-format-string: false - require-f-funcs: true +linters: + settings: + testifylint: + disable-all: true + enable: + - formatter + formatter: + check-format-string: false + require-f-funcs: true diff --git a/pkg/golinters/testifylint/testdata/testifylint_require_error_only.yml b/pkg/golinters/testifylint/testdata/testifylint_require_error_only.yml index 4ddf2b235745..29984113b554 100644 --- a/pkg/golinters/testifylint/testdata/testifylint_require_error_only.yml +++ b/pkg/golinters/testifylint/testdata/testifylint_require_error_only.yml @@ -1,9 +1,10 @@ version: "2" -linters-settings: - testifylint: - disable-all: true - enable: - - require-error - require-error: - fn-pattern: ^NoError$ +linters: + settings: + testifylint: + disable-all: true + enable: + - require-error + require-error: + fn-pattern: ^NoError$ diff --git a/pkg/golinters/thelper/testdata/thelper.yml b/pkg/golinters/thelper/testdata/thelper.yml index 6eeeb531596a..9550a3c4ae7c 100644 --- a/pkg/golinters/thelper/testdata/thelper.yml +++ b/pkg/golinters/thelper/testdata/thelper.yml @@ -1,7 +1,8 @@ version: "2" -linters-settings: - thelper: - test: - name: false - begin: true +linters: + settings: + thelper: + test: + name: false + begin: true diff --git a/pkg/golinters/unparam/unparam.go b/pkg/golinters/unparam/unparam.go index 04c9a223e512..986beaa9135c 100644 --- a/pkg/golinters/unparam/unparam.go +++ b/pkg/golinters/unparam/unparam.go @@ -34,8 +34,8 @@ func New(settings *config.UnparamSettings) *goanalysis.Linter { []*analysis.Analyzer{analyzer}, nil, ).WithContextSetter(func(lintCtx *linter.Context) { - if settings.Algo != "cha" { - lintCtx.Log.Warnf("`linters-settings.unparam.algo` isn't supported by the newest `unparam`") + if settings.Algo != "cha" { // TODO(ldez): is it deprecated? Remove? + lintCtx.Log.Warnf("`linters.settings.unparam.algo` isn't supported by the newest `unparam`") } }).WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/golinters/usestdlibvars/testdata/usestdlibvars_non_default.yml b/pkg/golinters/usestdlibvars/testdata/usestdlibvars_non_default.yml index 269bb85fb367..8100af59cdb1 100644 --- a/pkg/golinters/usestdlibvars/testdata/usestdlibvars_non_default.yml +++ b/pkg/golinters/usestdlibvars/testdata/usestdlibvars_non_default.yml @@ -1,14 +1,15 @@ version: "2" -linters-settings: - usestdlibvars: - http-method: false - http-status-code: false - time-weekday: true - time-month: true - time-layout: true - crypto-hash: true - default-rpc-path: true - sql-isolation-level: true - tls-signature-scheme: true - constant-kind: true +linters: + settings: + usestdlibvars: + http-method: false + http-status-code: false + time-weekday: true + time-month: true + time-layout: true + crypto-hash: true + default-rpc-path: true + sql-isolation-level: true + tls-signature-scheme: true + constant-kind: true diff --git a/pkg/golinters/usetesting/testdata/usetesting_configuration.yml b/pkg/golinters/usetesting/testdata/usetesting_configuration.yml index c100e213fa57..e848078d1097 100644 --- a/pkg/golinters/usetesting/testdata/usetesting_configuration.yml +++ b/pkg/golinters/usetesting/testdata/usetesting_configuration.yml @@ -1,11 +1,12 @@ version: "2" -linters-settings: - usetesting: - os-create-temp: false - os-mkdir-temp: false - os-setenv: true - os-temp-dir: true - os-chdir: false - context-background: false - context-todo: false +linters: + settings: + usetesting: + os-create-temp: false + os-mkdir-temp: false + os-setenv: true + os-temp-dir: true + os-chdir: false + context-background: false + context-todo: false diff --git a/pkg/golinters/usetesting/testdata/usetesting_go124_configuration.yml b/pkg/golinters/usetesting/testdata/usetesting_go124_configuration.yml index c100e213fa57..e848078d1097 100644 --- a/pkg/golinters/usetesting/testdata/usetesting_go124_configuration.yml +++ b/pkg/golinters/usetesting/testdata/usetesting_go124_configuration.yml @@ -1,11 +1,12 @@ version: "2" -linters-settings: - usetesting: - os-create-temp: false - os-mkdir-temp: false - os-setenv: true - os-temp-dir: true - os-chdir: false - context-background: false - context-todo: false +linters: + settings: + usetesting: + os-create-temp: false + os-mkdir-temp: false + os-setenv: true + os-temp-dir: true + os-chdir: false + context-background: false + context-todo: false diff --git a/pkg/golinters/whitespace/testdata/whitespace-fix.yml b/pkg/golinters/whitespace/testdata/whitespace-fix.yml index 2f047ff46988..766a51c31ec9 100644 --- a/pkg/golinters/whitespace/testdata/whitespace-fix.yml +++ b/pkg/golinters/whitespace/testdata/whitespace-fix.yml @@ -1,6 +1,7 @@ version: "2" -linters-settings: - whitespace: - multi-if: true - multi-func: true +linters: + settings: + whitespace: + multi-if: true + multi-func: true diff --git a/pkg/golinters/whitespace/testdata/whitespace.yml b/pkg/golinters/whitespace/testdata/whitespace.yml index 2f047ff46988..766a51c31ec9 100644 --- a/pkg/golinters/whitespace/testdata/whitespace.yml +++ b/pkg/golinters/whitespace/testdata/whitespace.yml @@ -1,6 +1,7 @@ version: "2" -linters-settings: - whitespace: - multi-if: true - multi-func: true +linters: + settings: + whitespace: + multi-if: true + multi-func: true diff --git a/pkg/golinters/wsl/testdata/wsl.yml b/pkg/golinters/wsl/testdata/wsl.yml index 2afb1c3f9c6c..e811517c876a 100644 --- a/pkg/golinters/wsl/testdata/wsl.yml +++ b/pkg/golinters/wsl/testdata/wsl.yml @@ -1,5 +1,6 @@ version: "2" -linters-settings: - wsl: - allow-cuddle-declarations: false +linters: + settings: + wsl: + allow-cuddle-declarations: false From ed47d6f48ee3507dbd33529c2b6ab6eefafe5296 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Tue, 25 Feb 2025 20:50:38 +0100 Subject: [PATCH 7/8] chore: remove unparam deprecated option --- pkg/config/linters_settings.go | 3 --- pkg/golinters/unparam/unparam.go | 7 +------ 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/pkg/config/linters_settings.go b/pkg/config/linters_settings.go index 359a62bb488c..48f3625150f7 100644 --- a/pkg/config/linters_settings.go +++ b/pkg/config/linters_settings.go @@ -152,9 +152,6 @@ var defaultLintersSettings = LintersSettings{ SkipRegexp: `(export|internal)_test\.go`, AllowPackages: []string{"main"}, }, - Unparam: UnparamSettings{ - Algo: "cha", - }, Unused: UnusedSettings{ FieldWritesAreUses: true, PostStatementsAreReads: false, diff --git a/pkg/golinters/unparam/unparam.go b/pkg/golinters/unparam/unparam.go index 986beaa9135c..49518cfaa302 100644 --- a/pkg/golinters/unparam/unparam.go +++ b/pkg/golinters/unparam/unparam.go @@ -8,7 +8,6 @@ import ( "github.com/golangci/golangci-lint/pkg/config" "github.com/golangci/golangci-lint/pkg/goanalysis" - "github.com/golangci/golangci-lint/pkg/lint/linter" ) const linterName = "unparam" @@ -33,11 +32,7 @@ func New(settings *config.UnparamSettings) *goanalysis.Linter { "Reports unused function parameters", []*analysis.Analyzer{analyzer}, nil, - ).WithContextSetter(func(lintCtx *linter.Context) { - if settings.Algo != "cha" { // TODO(ldez): is it deprecated? Remove? - lintCtx.Log.Warnf("`linters.settings.unparam.algo` isn't supported by the newest `unparam`") - } - }).WithLoadMode(goanalysis.LoadModeTypesInfo) + ).WithLoadMode(goanalysis.LoadModeTypesInfo) } func runUnparam(pass *analysis.Pass, settings *config.UnparamSettings) error { From 168a8df31fbc63fc44eaadc1f34a1955a6098396 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Wed, 26 Feb 2025 13:07:24 +0100 Subject: [PATCH 8/8] review --- pkg/config/linters_settings.go | 3 +-- pkg/lint/linter/config.go | 4 ---- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/pkg/config/linters_settings.go b/pkg/config/linters_settings.go index 48f3625150f7..b151f8f407b1 100644 --- a/pkg/config/linters_settings.go +++ b/pkg/config/linters_settings.go @@ -909,8 +909,7 @@ type UnconvertSettings struct { } type UnparamSettings struct { - CheckExported bool `mapstructure:"check-exported"` - Algo string `mapstructure:"algo"` + CheckExported bool `mapstructure:"check-exported"` } type UnusedSettings struct { diff --git a/pkg/lint/linter/config.go b/pkg/lint/linter/config.go index cd0ecdd79171..2c1e86fb5e14 100644 --- a/pkg/lint/linter/config.go +++ b/pkg/lint/linter/config.go @@ -90,10 +90,6 @@ func (lc *Config) WithGroups(names ...string) *Config { } func (lc *Config) FromGroup(name string) bool { - if lc.Groups == nil { - return false - } - _, ok := lc.Groups[name] return ok }