diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index 29a3cc755796..44ce5c4a9db8 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -2518,6 +2518,26 @@ linters: severity: warning disabled: false exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#identical-ifelseif-branches + - name: identical-ifelseif-branches + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#identical-ifelseif-conditions + - name: identical-ifelseif-conditions + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#identical-switch-branches + - name: identical-switch-branches + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#identical-switch-conditions + - name: identical-switch-conditions + severity: warning + disabled: false + exclude: [""] # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#if-return - name: if-return severity: warning @@ -2601,6 +2621,13 @@ linters: severity: warning disabled: false exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#package-directory-mismatch + - name: package-directory-mismatch + severity: warning + disabled: false + exclude: [""] + arguments: + - ignore-directories: ["testcases", "testinfo"] # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#range - name: range severity: warning @@ -2738,6 +2765,11 @@ linters: severity: warning disabled: false exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#unsecure-url-scheme + - name: unsecure-url-scheme + severity: warning + disabled: false + exclude: [""] # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#unused-parameter - name: unused-parameter severity: warning @@ -2767,11 +2799,21 @@ linters: severity: warning disabled: false exclude: [""] + # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#use-waitgroup-go + - name: use-waitgroup-go + 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#useless-fallthrough + - name: useless-fallthrough + severity: warning + disabled: false + exclude: [""] # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#var-declaration - name: var-declaration severity: warning diff --git a/go.mod b/go.mod index 058cea4fd39e..01877f123cc7 100644 --- a/go.mod +++ b/go.mod @@ -83,7 +83,7 @@ require ( github.com/maratori/testpackage v1.1.1 github.com/matoous/godox v1.1.0 github.com/mattn/go-colorable v0.1.14 - github.com/mgechev/revive v1.11.0 + github.com/mgechev/revive v1.12.0 github.com/mitchellh/go-homedir v1.1.0 github.com/moricho/tparallel v0.3.2 github.com/nakabonne/nestif v0.3.1 diff --git a/go.sum b/go.sum index 40dba14de58d..9abdbd0a518e 100644 --- a/go.sum +++ b/go.sum @@ -419,8 +419,8 @@ github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6T github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/mgechev/revive v1.11.0 h1:b/gLLpBE427o+Xmd8G58gSA+KtBwxWinH/A565Awh0w= -github.com/mgechev/revive v1.11.0/go.mod h1:tI0oLF/2uj+InHCBLrrqfTKfjtFTBCFFfG05auyzgdw= +github.com/mgechev/revive v1.12.0 h1:Q+/kkbbwerrVYPv9d9efaPGmAO/NsxwW/nE6ahpQaCU= +github.com/mgechev/revive v1.12.0/go.mod h1:VXsY2LsTigk8XU9BpZauVLjVrhICMOV3k1lpB3CXrp8= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= diff --git a/jsonschema/golangci.next.jsonschema.json b/jsonschema/golangci.next.jsonschema.json index adc836282896..9221df3feb96 100644 --- a/jsonschema/golangci.next.jsonschema.json +++ b/jsonschema/golangci.next.jsonschema.json @@ -613,6 +613,10 @@ "function-result-limit", "get-return", "identical-branches", + "identical-ifelseif-branches", + "identical-ifelseif-conditions", + "identical-switch-branches", + "identical-switch-conditions", "if-return", "import-alias-naming", "import-shadowing", @@ -627,6 +631,7 @@ "nested-structs", "optimize-operands-order", "package-comments", + "package-directory-mismatch", "range-val-address", "range-val-in-closure", "range", @@ -650,12 +655,15 @@ "unnecessary-format", "unnecessary-stmt", "unreachable-code", + "unsecure-url-scheme", "unused-parameter", "unused-receiver", "use-any", "use-errors-new", "use-fmt-print", + "use-waitgroup-go", "useless-break", + "useless-fallthrough", "var-declaration", "var-naming", "waitgroup-by-value" diff --git a/pkg/golinters/revive/revive.go b/pkg/golinters/revive/revive.go index fc80e5697218..8e5a7835defc 100644 --- a/pkg/golinters/revive/revive.go +++ b/pkg/golinters/revive/revive.go @@ -269,7 +269,7 @@ func safeTomlSlice(r []any) []any { } // This element is not exported by revive, so we need copy the code. -// Extracted from https://github.com/mgechev/revive/blob/v1.11.0/config/config.go#L166 +// Extracted from https://github.com/mgechev/revive/blob/v1.12.0/config/config.go#L16 var defaultRules = []lint.Rule{ &rule.VarDeclarationsRule{}, &rule.PackageCommentsRule{}, @@ -329,6 +329,10 @@ var allRules = append([]lint.Rule{ &rule.FunctionResultsLimitRule{}, &rule.GetReturnRule{}, &rule.IdenticalBranchesRule{}, + &rule.IdenticalIfElseIfBranchesRule{}, + &rule.IdenticalIfElseIfConditionsRule{}, + &rule.IdenticalSwitchBranchesRule{}, + &rule.IdenticalSwitchConditionsRule{}, &rule.IfReturnRule{}, &rule.ImportAliasNamingRule{}, &rule.ImportsBlocklistRule{}, @@ -340,6 +344,7 @@ var allRules = append([]lint.Rule{ &rule.ModifiesValRecRule{}, &rule.NestedStructs{}, &rule.OptimizeOperandsOrderRule{}, + &rule.PackageDirectoryMismatchRule{}, &rule.RangeValAddress{}, &rule.RangeValInClosureRule{}, &rule.RedundantBuildTagRule{}, @@ -356,18 +361,21 @@ var allRules = append([]lint.Rule{ &rule.UnhandledErrorRule{}, &rule.UnnecessaryFormatRule{}, &rule.UnnecessaryStmtRule{}, + &rule.UnsecureURLSchemeRule{}, &rule.UnusedReceiverRule{}, &rule.UseAnyRule{}, &rule.UseErrorsNewRule{}, &rule.UseFmtPrintRule{}, &rule.UselessBreak{}, + &rule.UselessFallthroughRule{}, + &rule.UseWaitGroupGoRule{}, &rule.WaitGroupByValueRule{}, }, defaultRules...) const defaultConfidence = 0.8 // This element is not exported by revive, so we need copy the code. -// Extracted from https://github.com/mgechev/revive/blob/v1.11.0/config/config.go#L198 +// Extracted from https://github.com/mgechev/revive/blob/v1.12.0/config/config.go#L206 func normalizeConfig(cfg *lint.Config) { // NOTE(ldez): this custom section for golangci-lint should be kept. // --- @@ -409,7 +417,7 @@ func normalizeConfig(cfg *lint.Config) { } // This element is not exported by revive, so we need copy the code. -// Extracted from https://github.com/mgechev/revive/blob/v1.11.0/config/config.go#L266 +// Extracted from https://github.com/mgechev/revive/blob/v1.12.0/config/config.go#L274 func defaultConfig() *lint.Config { defaultConfig := lint.Config{ Confidence: defaultConfidence, @@ -455,7 +463,7 @@ func extractRulesName(rules []lint.Rule) []string { return names } -// Extracted from https://github.com/mgechev/revive/blob/v1.11.0/formatter/severity.go +// Extracted from https://github.com/mgechev/revive/blob/v1.12.0/formatter/severity.go // Modified to use pointers (related to hugeParam rule). func severity(cfg *lint.Config, failure *lint.Failure) lint.Severity { if cfg, ok := cfg.Rules[failure.RuleName]; ok && cfg.Severity == lint.SeverityError {