diff --git a/.golangci.reference.yml b/.golangci.reference.yml index 51a29cf42460..cfc88f7f3937 100644 --- a/.golangci.reference.yml +++ b/.golangci.reference.yml @@ -1529,6 +1529,8 @@ linters-settings: - name: early-return severity: warning disabled: false + arguments: + - "preserveScope" # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#empty-block - name: empty-block severity: warning @@ -1537,6 +1539,12 @@ linters-settings: - name: empty-lines severity: warning disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#enforce-map-style + - name: enforce-map-style + severity: warning + disabled: false + arguments: + - "make" # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#error-naming - name: error-naming severity: warning @@ -1558,6 +1566,7 @@ linters-settings: severity: warning disabled: false arguments: + - "preserveScope" - "checkPrivateReceivers" - "sayRepetitiveInsteadOfStutters" # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#file-header @@ -1600,6 +1609,14 @@ linters-settings: - name: indent-error-flow severity: warning disabled: false + arguments: + - "preserveScope" + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#import-alias-naming + - name: import-alias-naming + severity: warning + disabled: false + arguments: + - "^[a-z][a-z0-9]{0,}$" # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#imports-blacklist - name: imports-blacklist severity: warning @@ -1657,6 +1674,10 @@ linters-settings: - name: receiver-naming severity: warning disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#redundant-import-alias + - name: redundant-import-alias + severity: warning + disabled: false # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#redefines-builtin-id - name: redefines-builtin-id severity: warning @@ -1690,6 +1711,8 @@ linters-settings: - name: superfluous-else severity: warning disabled: false + arguments: + - "preserveScope" # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#time-equal - name: time-equal severity: warning @@ -1705,6 +1728,7 @@ linters-settings: arguments: - [ "ID" ] # AllowList - [ "VM" ] # DenyList + - - upperCaseConst: true # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#var-declaration - name: var-declaration severity: warning @@ -1740,10 +1764,14 @@ linters-settings: - name: unused-parameter severity: warning disabled: false + arguments: + - allowRegex: "^_" # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-receiver - name: unused-receiver severity: warning disabled: false + arguments: + - allowRegex: "^_" # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#useless-break - name: useless-break severity: warning diff --git a/go.mod b/go.mod index 87d6bd36e986..4da1337d7930 100644 --- a/go.mod +++ b/go.mod @@ -69,7 +69,7 @@ require ( github.com/matoous/godox v0.0.0-20230222163458-006bad1f9d26 github.com/mattn/go-colorable v0.1.13 github.com/mbilski/exhaustivestruct v1.2.0 - github.com/mgechev/revive v1.3.3 + github.com/mgechev/revive v1.3.4 github.com/mitchellh/go-homedir v1.1.0 github.com/mitchellh/go-ps v1.0.0 github.com/mitchellh/mapstructure v1.5.0 @@ -130,7 +130,7 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/ccojocar/zxcvbn-go v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.1.2 // indirect - github.com/chavacava/garif v0.0.0-20230608123814-4bd63c2919ab // indirect + github.com/chavacava/garif v0.1.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/ettle/strcase v0.1.1 // indirect github.com/fatih/structtag v1.2.0 // indirect diff --git a/go.sum b/go.sum index f583ec235dc7..070f1b161d18 100644 --- a/go.sum +++ b/go.sum @@ -104,8 +104,8 @@ github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cb github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/charithe/durationcheck v0.0.10 h1:wgw73BiocdBDQPik+zcEoBG/ob8uyBHf2iyoHGPf5w4= github.com/charithe/durationcheck v0.0.10/go.mod h1:bCWXb7gYRysD1CU3C+u4ceO49LoGOY1C1L6uouGNreQ= -github.com/chavacava/garif v0.0.0-20230608123814-4bd63c2919ab h1:5JxePczlyGAtj6R1MUEFZ/UFud6FfsOejq7xLC2ZIb0= -github.com/chavacava/garif v0.0.0-20230608123814-4bd63c2919ab/go.mod h1:XMyYCkEL58DF0oyW4qDjjnPWONs2HBqYKI+UIPD+Gww= +github.com/chavacava/garif v0.1.0 h1:2JHa3hbYf5D9dsgseMKAmc/MZ109otzgNFk5s87H9Pc= +github.com/chavacava/garif v0.1.0/go.mod h1:XMyYCkEL58DF0oyW4qDjjnPWONs2HBqYKI+UIPD+Gww= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= @@ -368,8 +368,8 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0j github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/mbilski/exhaustivestruct v1.2.0 h1:wCBmUnSYufAHO6J4AVWY6ff+oxWxsVFrwgOdMUQePUo= github.com/mbilski/exhaustivestruct v1.2.0/go.mod h1:OeTBVxQWoEmB2J2JCHmXWPJ0aksxSUOUy+nvtVEfzXc= -github.com/mgechev/revive v1.3.3 h1:GUWzV3g185agbHN4ZdaQvR6zrLVYTUSA2ktvIinivK0= -github.com/mgechev/revive v1.3.3/go.mod h1:NhpOtVtDbjYNDj697eDUBTobijCDHQKar4HDKc0TuTo= +github.com/mgechev/revive v1.3.4 h1:k/tO3XTaWY4DEHal9tWBkkUMJYO/dLDVyMmAQxmIMDc= +github.com/mgechev/revive v1.3.4/go.mod h1:W+pZCMu9qj8Uhfs1iJMQsEFLRozUfvwFwqVvRbSNLVw= 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/go-ps v1.0.0 h1:i6ampVEEF4wQFF+bkYfwYgY+F/uYJDktmvLPf7qIgjc= diff --git a/pkg/golinters/revive.go b/pkg/golinters/revive.go index b57566e7aff2..28231957c4bc 100644 --- a/pkg/golinters/revive.go +++ b/pkg/golinters/revive.go @@ -247,7 +247,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.3.0/config/config.go#L15 +// Extracted from https://github.com/mgechev/revive/blob/v1.3.4/config/config.go#L15 var defaultRules = []lint.Rule{ &rule.VarDeclarationsRule{}, &rule.PackageCommentsRule{}, @@ -267,7 +267,6 @@ var defaultRules = []lint.Rule{ &rule.TimeNamingRule{}, &rule.ContextKeysType{}, &rule.ContextAsArgumentRule{}, - &rule.IfReturnRule{}, &rule.EmptyBlockRule{}, &rule.SuperfluousElseRule{}, &rule.UnusedParamRule{}, @@ -317,12 +316,17 @@ var allRules = append([]lint.Rule{ &rule.FunctionLength{}, &rule.NestedStructs{}, &rule.UselessBreak{}, + &rule.UncheckedTypeAssertionRule{}, &rule.TimeEqualRule{}, &rule.BannedCharsRule{}, &rule.OptimizeOperandsOrderRule{}, &rule.UseAnyRule{}, &rule.DataRaceRule{}, &rule.CommentSpacingsRule{}, + &rule.IfReturnRule{}, + &rule.RedundantImportAlias{}, + &rule.ImportAliasNamingRule{}, + &rule.EnforceMapStyleRule{}, }, defaultRules...) const defaultConfidence = 0.8