From dfde3797d547300bf1b934f2f8728a621eaec4c8 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Sat, 27 Apr 2024 14:29:42 +0200 Subject: [PATCH] dev: clean deprecated options (#4673) --- .golangci.next.reference.yml | 35 +--- jsonschema/golangci.next.jsonschema.json | 198 +++++++++++++----- pkg/config/linters_settings.go | 4 +- pkg/config/loader.go | 12 +- .../errcheck/testdata/errcheck_exclude.go | 17 -- .../errcheck/testdata/errcheck_exclude.txt | 1 - .../errcheck/testdata/errcheck_exclude.yml | 4 - .../errcheck/testdata/errcheck_ignore.go | 28 --- .../testdata/errcheck_ignore_config.yml | 7 - 9 files changed, 165 insertions(+), 141 deletions(-) delete mode 100644 pkg/golinters/errcheck/testdata/errcheck_exclude.go delete mode 100644 pkg/golinters/errcheck/testdata/errcheck_exclude.txt delete mode 100644 pkg/golinters/errcheck/testdata/errcheck_exclude.yml delete mode 100644 pkg/golinters/errcheck/testdata/errcheck_ignore.go delete mode 100644 pkg/golinters/errcheck/testdata/errcheck_ignore_config.yml diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index fad038571422..e79354fcd545 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -279,23 +279,11 @@ linters-settings: # Default: false check-blank: true - # DEPRECATED comma-separated list of pairs of the form pkg:regex - # - # the regex is used to ignore names within pkg. (default "fmt:.*"). - # see https://github.com/kisielk/errcheck#the-deprecated-method for details - ignore: fmt:.*,io/ioutil:^Read.* - # 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 - # DEPRECATED use exclude-functions instead. - # - # Path to a file containing a list of functions to exclude from checking. - # See https://github.com/kisielk/errcheck#excluding-functions for details. - exclude: /path/to/file.txt - # 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: @@ -431,9 +419,6 @@ linters-settings: ignore-comments: true gci: - # DEPRECATED: use `sections` and `prefix(github.com/org/project)` instead. - local-prefixes: github.com/org/project - # 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`, @@ -637,9 +622,6 @@ linters-settings: # The option is passed to the ruleguard 'debug-group' argument. # Default: "" debug: 'emptyDecl' - # Deprecated, use 'failOn' param. - # If set to true, identical to failOn='all', otherwise failOn='' - failOnError: false # 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. @@ -647,7 +629,7 @@ linters-settings: # - 'import': ruleguard rule imports a package that cannot be found. # - 'dsl': gorule file does not comply with the ruleguard DSL. # Default: "" - failOn: dsl + failOn: dsl,import # Comma-separated list of file paths containing ruleguard rules. # If a path is relative, it is relative to the directory where the golangci-lint command is executed. # The special '${configDir}' variable is substituted with the absolute directory containing the golangci config file. @@ -724,9 +706,6 @@ linters-settings: replacement: 'a[b:]' gofumpt: - # Deprecated: use the global `run.go` instead. - lang-version: "1.17" - # Module path which contains the source code being formatted. # Default: "" module-path: github.com/org/project @@ -830,8 +809,6 @@ linters-settings: local_replace_directives: false gosimple: - # Deprecated: use the global `run.go` instead. - go: "1.15" # Sxxxx checks in https://staticcheck.io/docs/configuration/options/#checks # Default: ["*"] checks: [ "all" ] @@ -2059,15 +2036,11 @@ linters-settings: extra-start-span-signatures: - "github.com/user/repo/telemetry/trace.Start:opentelemetry" staticcheck: - # Deprecated: use the global `run.go` instead. - go: "1.15" # SAxxxx checks in https://staticcheck.io/docs/configuration/options/#checks # Default: ["*"] checks: [ "all" ] stylecheck: - # Deprecated: use the global `run.go` instead. - go: "1.15" # STxxxx checks in https://staticcheck.io/docs/configuration/options/#checks # Default: ["*"] checks: [ "all", "-ST1000", "-ST1003", "-ST1016", "-ST1020", "-ST1021", "-ST1022" ] @@ -2291,9 +2264,6 @@ linters-settings: # Suggest the use of rpc.DefaultXXPath. # Default: false default-rpc-path: true - # DEPRECATED Suggest the use of os.DevNull. - # Default: false - os-dev-null: true # Suggest the use of sql.LevelXX.String(). # Default: false sql-isolation-level: true @@ -2303,9 +2273,6 @@ linters-settings: # Suggest the use of constant.Kind.String(). # Default: false constant-kind: true - # DEPRECATED Suggest the use of syslog.Priority. - # Default: false - syslog-priority: true unconvert: # Remove conversions that force intermediate rounding. diff --git a/jsonschema/golangci.next.jsonschema.json b/jsonschema/golangci.next.jsonschema.json index 30569bbdee81..b6a5833c0e02 100644 --- a/jsonschema/golangci.next.jsonschema.json +++ b/jsonschema/golangci.next.jsonschema.json @@ -750,16 +750,6 @@ "type": "boolean", "default": false }, - "ignore": { - "description": "DEPRECATED: use `exclude-functions` instead. Comma-separated list of pairs of the form \"pkg:regex\".", - "type": "string", - "default": "fmt:.*" - }, - "exclude": { - "description": "DEPRECATED: use `exclude-functions` instead. Path to a file containing a list of functions to exclude from checking.", - "type": "string", - "examples": ["/path/to/file.txt"] - }, "exclude-functions": { "description": "List of functions to exclude from checking, where each entry is a single function to exclude", "type": "array", @@ -962,11 +952,6 @@ "type": "object", "additionalProperties": false, "properties": { - "local-prefixes": { - "description": "DEPRECATED: use 'sections' and 'prefix(github.com/org/project)' instead.", - "type": "string", - "examples": ["github.com/org/project"] - }, "sections": { "description": "Section configuration to compare against.", "type": "array", @@ -1159,8 +1144,157 @@ "settings": { "description": "Settings passed to gocritic. Properties must be valid and enabled check names.", "type": "object", - "propertyNames": { - "$ref": "#/definitions/gocritic-checks" + "additionalProperties": false, + "properties": { + "captLocal": { + "type": "object", + "additionalProperties": false, + "properties": { + "paramsOnly" : { + "type": "boolean", + "default": true + } + } + }, + "commentedOutCode": { + "type": "object", + "additionalProperties": false, + "properties": { + "minLength" : { + "type": "number", + "default": 15 + } + } + }, + "elseif": { + "type": "object", + "additionalProperties": false, + "properties": { + "skipBalanced" : { + "type": "boolean", + "default": true + } + } + }, + "hugeParam": { + "type": "object", + "additionalProperties": false, + "properties": { + "sizeThreshold" : { + "type": "number", + "default": 80 + } + } + }, + "ifElseChain": { + "type": "object", + "additionalProperties": false, + "properties": { + "minThreshold" : { + "type": "number", + "default": 2 + } + } + }, + "nestingReduce": { + "type": "object", + "additionalProperties": false, + "properties": { + "bodyWidth" : { + "type": "number", + "default": 5 + } + } + }, + "rangeExprCopy": { + "type": "object", + "additionalProperties": false, + "properties": { + "sizeThreshold" : { + "type": "number", + "default": 512 + }, + "skipTestFuncs" : { + "type": "boolean", + "default": true + } + } + }, + "rangeValCopy": { + "type": "object", + "additionalProperties": false, + "properties": { + "sizeThreshold" : { + "type": "number", + "default": 128 + }, + "skipTestFuncs" : { + "type": "boolean", + "default": true + } + } + }, + "ruleguard": { + "type": "object", + "additionalProperties": false, + "properties": { + "debug" : { + "type": "string" + }, + "enable" : { + "type": "string" + }, + "disable" : { + "type": "string" + }, + "failOn" : { + "type": "string" + }, + "rules" : { + "type": "string" + } + } + }, + "tooManyResultsChecker": { + "type": "object", + "additionalProperties": false, + "properties": { + "maxResults" : { + "type": "number", + "default": 5 + } + } + }, + "truncateCmp": { + "type": "object", + "additionalProperties": false, + "properties": { + "skipArchDependent" : { + "type": "boolean", + "default": true + } + } + }, + "underef": { + "type": "object", + "additionalProperties": false, + "properties": { + "skipRecvDeref" : { + "type": "boolean", + "default": true + } + } + }, + "unnamedResult": { + "type": "object", + "additionalProperties": false, + "properties": { + "checkExported" : { + "type": "boolean", + "default": false + } + } + } } }, "disable-all": { @@ -1277,11 +1411,6 @@ "type": "boolean", "default": false }, - "lang-version": { - "description": "Select the Go version to target.", - "type": "string", - "default": "1.15" - }, "module-path": { "description": " Module path which contains the source code being formatted.", "type": "string" @@ -1481,11 +1610,6 @@ "type": "object", "additionalProperties": false, "properties": { - "go": { - "description": "Targeted Go version", - "type": "string", - "default": "1.13" - }, "checks": { "type": "array", "items": { @@ -2352,11 +2476,6 @@ "type": "object", "additionalProperties": false, "properties": { - "go": { - "description": "Targeted Go version", - "type": "string", - "default": "1.13" - }, "checks": { "type": "array", "items": { @@ -2376,11 +2495,6 @@ "type": "object", "additionalProperties": false, "properties": { - "go": { - "description": "Targeted Go version", - "type": "string", - "default": "1.13" - }, "checks": { "type": "array", "items": { @@ -2878,11 +2992,6 @@ "type": "boolean", "default": false }, - "os-dev-null": { - "description": "Suggest the use of os.DevNull.", - "type": "boolean", - "default": false - }, "sql-isolation-level": { "description": "Suggest the use of sql.LevelXX.String().", "type": "boolean", @@ -2897,11 +3006,6 @@ "description": "Suggest the use of constant.Kind.String().", "type": "boolean", "default": false - }, - "syslog-priority": { - "description": "Suggest the use of syslog.Priority.", - "type": "boolean", - "default": false } } }, diff --git a/pkg/config/linters_settings.go b/pkg/config/linters_settings.go index 01894ddff29e..6f02050a639a 100644 --- a/pkg/config/linters_settings.go +++ b/pkg/config/linters_settings.go @@ -909,11 +909,11 @@ type UseStdlibVarsSettings struct { TimeLayout bool `mapstructure:"time-layout"` CryptoHash bool `mapstructure:"crypto-hash"` DefaultRPCPath bool `mapstructure:"default-rpc-path"` - OSDevNull bool `mapstructure:"os-dev-null"` + OSDevNull bool `mapstructure:"os-dev-null"` // Deprecated SQLIsolationLevel bool `mapstructure:"sql-isolation-level"` TLSSignatureScheme bool `mapstructure:"tls-signature-scheme"` ConstantKind bool `mapstructure:"constant-kind"` - SyslogPriority bool `mapstructure:"syslog-priority"` + SyslogPriority bool `mapstructure:"syslog-priority"` // Deprecated } type UnconvertSettings struct { diff --git a/pkg/config/loader.go b/pkg/config/loader.go index 57ec4d4ee811..db23048b2dfc 100644 --- a/pkg/config/loader.go +++ b/pkg/config/loader.go @@ -411,11 +411,21 @@ func (l *Loader) handleLinterOptionDeprecations() { // Deprecated since v1.58.0 if l.cfg.LintersSettings.SlogLint.ContextOnly { - l.log.Warnf("The configuration option `linters.sloglint.context-only` is deprecated, please use `linters.sloglint.context`") + l.log.Warnf("The configuration option `linters.sloglint.context-only` is deprecated, please use `linters.sloglint.context`.") if l.cfg.LintersSettings.SlogLint.Context == "" { l.cfg.LintersSettings.SlogLint.Context = "all" } } + + // Deprecated since v1.51.0 + if l.cfg.LintersSettings.UseStdlibVars.OSDevNull { + l.log.Warnf("The configuration option `linters.usestdlibvars.os-dev-null` is deprecated.") + } + + // Deprecated since v1.51.0 + if l.cfg.LintersSettings.UseStdlibVars.SyslogPriority { + l.log.Warnf("The configuration option `linters.usestdlibvars.syslog-priority` is deprecated.") + } } func (l *Loader) handleEnableOnlyOption() error { diff --git a/pkg/golinters/errcheck/testdata/errcheck_exclude.go b/pkg/golinters/errcheck/testdata/errcheck_exclude.go deleted file mode 100644 index 427e33d6fd44..000000000000 --- a/pkg/golinters/errcheck/testdata/errcheck_exclude.go +++ /dev/null @@ -1,17 +0,0 @@ -//golangcitest:args -Eerrcheck -//golangcitest:config_path testdata/errcheck_exclude.yml -package testdata - -import ( - "io/ioutil" -) - -func TestErrcheckExclude() []byte { - ret, _ := ioutil.ReadFile("f.txt") - return ret -} - -func TestErrcheckNoExclude() []byte { - ret, _ := ioutil.ReadAll(nil) // want "Error return value of `ioutil.ReadAll` is not checked" - return ret -} diff --git a/pkg/golinters/errcheck/testdata/errcheck_exclude.txt b/pkg/golinters/errcheck/testdata/errcheck_exclude.txt deleted file mode 100644 index f3898d8eb214..000000000000 --- a/pkg/golinters/errcheck/testdata/errcheck_exclude.txt +++ /dev/null @@ -1 +0,0 @@ -io/ioutil.ReadFile diff --git a/pkg/golinters/errcheck/testdata/errcheck_exclude.yml b/pkg/golinters/errcheck/testdata/errcheck_exclude.yml deleted file mode 100644 index 28c60f26baae..000000000000 --- a/pkg/golinters/errcheck/testdata/errcheck_exclude.yml +++ /dev/null @@ -1,4 +0,0 @@ -linters-settings: - errcheck: - check-blank: true - exclude: errcheck_exclude.txt diff --git a/pkg/golinters/errcheck/testdata/errcheck_ignore.go b/pkg/golinters/errcheck/testdata/errcheck_ignore.go deleted file mode 100644 index 7919de145502..000000000000 --- a/pkg/golinters/errcheck/testdata/errcheck_ignore.go +++ /dev/null @@ -1,28 +0,0 @@ -//golangcitest:args -Eerrcheck -//golangcitest:config_path testdata/errcheck_ignore_config.yml -package testdata - -import ( - "fmt" - "io/ioutil" - "os" -) - -func TestErrcheckIgnoreOs() { - _, _ = os.Open("f.txt") -} - -func TestErrcheckIgnoreFmt(s string) int { - n, _ := fmt.Println(s) - return n -} - -func TestErrcheckIgnoreIoutil() []byte { - ret, _ := ioutil.ReadFile("f.txt") - return ret -} - -func TestErrcheckNoIgnoreIoutil() []byte { - ret, _ := ioutil.ReadAll(nil) // want "Error return value of `ioutil.ReadAll` is not checked" - return ret -} diff --git a/pkg/golinters/errcheck/testdata/errcheck_ignore_config.yml b/pkg/golinters/errcheck/testdata/errcheck_ignore_config.yml deleted file mode 100644 index 94fdcd166cdd..000000000000 --- a/pkg/golinters/errcheck/testdata/errcheck_ignore_config.yml +++ /dev/null @@ -1,7 +0,0 @@ -linters-settings: - errcheck: - check-blank: true - ignore: os:.*,io/ioutil:^ReadF.* -issues: - include: - - EXC0001