Skip to content

Commit 3a04631

Browse files
build(deps): bump github.com/mgechev/revive from 1.12.0 to 1.13.0 (#6195)
Co-authored-by: Fernandez Ludovic <[email protected]>
1 parent 9da4c1d commit 3a04631

File tree

7 files changed

+68
-31
lines changed

7 files changed

+68
-31
lines changed

.golangci.next.reference.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2382,6 +2382,12 @@ linters:
23822382
# Default: false
23832383
enable-all-rules: true
23842384

2385+
# By default, the default rules are enabled,
2386+
# but if you provide a custom configuration, the default rules will be disabled.
2387+
# This option allows you to not explicitly enable the default rules.
2388+
# Default: false
2389+
enable-default-rules: true
2390+
23852391
# Enable validation of comment directives.
23862392
# See https://github.com/mgechev/revive#comment-directives
23872393
directives:
@@ -2644,6 +2650,11 @@ linters:
26442650
severity: warning
26452651
disabled: false
26462652
exclude: [""]
2653+
# https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#forbidden-call-in-wg-go
2654+
- name: forbidden-call-in-wg-go
2655+
severity: warning
2656+
disabled: false
2657+
exclude: [""]
26472658
# https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#function-length
26482659
- name: function-length
26492660
severity: warning
@@ -2726,6 +2737,11 @@ linters:
27262737
exclude: [""]
27272738
arguments:
27282739
- "preserve-scope"
2740+
# https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#inefficient-map-lookup
2741+
- name: inefficient-map-lookup
2742+
severity: warning
2743+
disabled: false
2744+
exclude: [""]
27292745
# https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#line-length-limit
27302746
- name: line-length-limit
27312747
severity: warning
@@ -2844,6 +2860,7 @@ linters:
28442860
disabled: false
28452861
exclude: [""]
28462862
arguments:
2863+
- "!validate"
28472864
- "json,inline"
28482865
- "bson,outline,gnu"
28492866
# https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#superfluous-else
@@ -2903,6 +2920,11 @@ linters:
29032920
severity: warning
29042921
disabled: false
29052922
exclude: [""]
2923+
# https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#unnecessary-if
2924+
- name: unnecessary-if
2925+
severity: warning
2926+
disabled: false
2927+
exclude: [""]
29062928
# https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#unnecessary-stmt
29072929
- name: unnecessary-stmt
29082930
severity: warning
@@ -2978,6 +3000,7 @@ linters:
29783000
- - skip-initialism-name-checks: true
29793001
upper-case-const: true
29803002
skip-package-name-checks: true
3003+
skip-package-name-collision-with-go-std: true
29813004
extra-bad-package-names:
29823005
- helpers
29833006
- models

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ require (
8686
github.com/maratori/testpackage v1.1.2
8787
github.com/matoous/godox v1.1.0
8888
github.com/mattn/go-colorable v0.1.14
89-
github.com/mgechev/revive v1.12.0
89+
github.com/mgechev/revive v1.13.0
9090
github.com/mitchellh/go-homedir v1.1.0
9191
github.com/moricho/tparallel v0.3.2
9292
github.com/nakabonne/nestif v0.3.1
@@ -204,7 +204,7 @@ require (
204204
github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727 // indirect
205205
github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect
206206
github.com/rivo/uniseg v0.4.7 // indirect
207-
github.com/spf13/afero v1.14.0 // indirect
207+
github.com/spf13/afero v1.15.0 // indirect
208208
github.com/spf13/cast v1.5.0 // indirect
209209
github.com/spf13/jwalterweatherman v1.1.0 // indirect
210210
github.com/stretchr/objx v0.5.2 // indirect

go.sum

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jsonschema/golangci.next.jsonschema.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,7 @@
622622
"file-length-limit",
623623
"filename-format",
624624
"flag-parameter",
625+
"forbidden-call-in-wg-go",
625626
"function-length",
626627
"function-result-limit",
627628
"get-return",
@@ -636,6 +637,7 @@
636637
"imports-blocklist",
637638
"increment-decrement",
638639
"indent-error-flow",
640+
"inefficient-map-lookup",
639641
"line-length-limit",
640642
"max-control-nesting",
641643
"max-public-structs",
@@ -666,6 +668,7 @@
666668
"unexported-return",
667669
"unhandled-error",
668670
"unnecessary-format",
671+
"unnecessary-if",
669672
"unnecessary-stmt",
670673
"unreachable-code",
671674
"unsecure-url-scheme",
@@ -3159,6 +3162,10 @@
31593162
"type": "boolean",
31603163
"default": false
31613164
},
3165+
"enable-default-rules": {
3166+
"type": "boolean",
3167+
"default": false
3168+
},
31623169
"directives": {
31633170
"type": "array",
31643171
"items": {

pkg/config/linters_settings.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -834,15 +834,16 @@ type RecvcheckSettings struct {
834834
}
835835

836836
type ReviveSettings struct {
837-
Go string `mapstructure:"-"`
838-
MaxOpenFiles int `mapstructure:"max-open-files"`
839-
Confidence float64 `mapstructure:"confidence"`
840-
Severity string `mapstructure:"severity"`
841-
EnableAllRules bool `mapstructure:"enable-all-rules"`
842-
Rules []ReviveRule `mapstructure:"rules"`
843-
ErrorCode int `mapstructure:"error-code"`
844-
WarningCode int `mapstructure:"warning-code"`
845-
Directives []ReviveDirective `mapstructure:"directives"`
837+
Go string `mapstructure:"-"`
838+
MaxOpenFiles int `mapstructure:"max-open-files"`
839+
Confidence float64 `mapstructure:"confidence"`
840+
Severity string `mapstructure:"severity"`
841+
EnableAllRules bool `mapstructure:"enable-all-rules"`
842+
EnableDefaultRules bool `mapstructure:"enable-default-rules"`
843+
Rules []ReviveRule `mapstructure:"rules"`
844+
ErrorCode int `mapstructure:"error-code"`
845+
WarningCode int `mapstructure:"warning-code"`
846+
Directives []ReviveDirective `mapstructure:"directives"`
846847
}
847848

848849
type ReviveRule struct {

pkg/golinters/revive/revive.go

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ func (w *wrapper) toIssue(pass *analysis.Pass, failure *lint.Failure) *goanalysi
169169
// This function mimics the GetConfig function of revive.
170170
// This allows to get default values and right types.
171171
// https://github.com/golangci/golangci-lint/issues/1745
172-
// https://github.com/mgechev/revive/blob/v1.6.0/config/config.go#L230
173-
// https://github.com/mgechev/revive/blob/v1.6.0/config/config.go#L182-L188
172+
// https://github.com/mgechev/revive/blob/v1.13.0/config/config.go#L249
173+
// https://github.com/mgechev/revive/blob/v1.13.0/config/config.go#L198-L204
174174
func getConfig(cfg *config.ReviveSettings) (*lint.Config, error) {
175175
conf := defaultConfig()
176176

@@ -269,7 +269,7 @@ func safeTomlSlice(r []any) []any {
269269
}
270270

271271
// This element is not exported by revive, so we need copy the code.
272-
// Extracted from https://github.com/mgechev/revive/blob/v1.12.0/config/config.go#L16
272+
// Extracted from https://github.com/mgechev/revive/blob/v1.13.0/config/config.go#L16
273273
var defaultRules = []lint.Rule{
274274
&rule.VarDeclarationsRule{},
275275
&rule.PackageCommentsRule{},
@@ -325,6 +325,7 @@ var allRules = append([]lint.Rule{
325325
&rule.FileLengthLimitRule{},
326326
&rule.FilenameFormatRule{},
327327
&rule.FlagParamRule{},
328+
&rule.ForbiddenCallInWgGoRule{},
328329
&rule.FunctionLength{},
329330
&rule.FunctionResultsLimitRule{},
330331
&rule.GetReturnRule{},
@@ -337,6 +338,7 @@ var allRules = append([]lint.Rule{
337338
&rule.ImportAliasNamingRule{},
338339
&rule.ImportsBlocklistRule{},
339340
&rule.ImportShadowingRule{},
341+
&rule.InefficientMapLookupRule{},
340342
&rule.LineLengthLimitRule{},
341343
&rule.MaxControlNestingRule{},
342344
&rule.MaxPublicStructsRule{},
@@ -360,6 +362,7 @@ var allRules = append([]lint.Rule{
360362
&rule.UnexportedNamingRule{},
361363
&rule.UnhandledErrorRule{},
362364
&rule.UnnecessaryFormatRule{},
365+
&rule.UnnecessaryIfRule{},
363366
&rule.UnnecessaryStmtRule{},
364367
&rule.UnsecureURLSchemeRule{},
365368
&rule.UnusedReceiverRule{},
@@ -375,7 +378,7 @@ var allRules = append([]lint.Rule{
375378
const defaultConfidence = 0.8
376379

377380
// This element is not exported by revive, so we need copy the code.
378-
// Extracted from https://github.com/mgechev/revive/blob/v1.12.0/config/config.go#L206
381+
// Extracted from https://github.com/mgechev/revive/blob/v1.13.0/config/config.go#L209
379382
func normalizeConfig(cfg *lint.Config) {
380383
// NOTE(ldez): this custom section for golangci-lint should be kept.
381384
// ---
@@ -386,19 +389,22 @@ func normalizeConfig(cfg *lint.Config) {
386389
if len(cfg.Rules) == 0 {
387390
cfg.Rules = map[string]lint.RuleConfig{}
388391
}
389-
if cfg.EnableAllRules {
390-
// Add to the configuration all rules not yet present in it
391-
for _, r := range allRules {
392+
393+
addRules := func(config *lint.Config, rules []lint.Rule) {
394+
for _, r := range rules {
392395
ruleName := r.Name()
393-
_, alreadyInConf := cfg.Rules[ruleName]
394-
if alreadyInConf {
395-
continue
396+
if _, ok := config.Rules[ruleName]; !ok {
397+
config.Rules[ruleName] = lint.RuleConfig{}
396398
}
397-
// Add the rule with an empty conf for
398-
cfg.Rules[ruleName] = lint.RuleConfig{}
399399
}
400400
}
401401

402+
if cfg.EnableAllRules {
403+
addRules(cfg, allRules)
404+
} else if cfg.EnableDefaultRules {
405+
addRules(cfg, defaultRules)
406+
}
407+
402408
severity := cfg.Severity
403409
if severity != "" {
404410
for k, v := range cfg.Rules {
@@ -417,7 +423,7 @@ func normalizeConfig(cfg *lint.Config) {
417423
}
418424

419425
// This element is not exported by revive, so we need copy the code.
420-
// Extracted from https://github.com/mgechev/revive/blob/v1.12.0/config/config.go#L274
426+
// Extracted from https://github.com/mgechev/revive/blob/v1.13.0/config/config.go#L280
421427
func defaultConfig() *lint.Config {
422428
defaultConfig := lint.Config{
423429
Confidence: defaultConfidence,
@@ -463,7 +469,7 @@ func extractRulesName(rules []lint.Rule) []string {
463469
return names
464470
}
465471

466-
// Extracted from https://github.com/mgechev/revive/blob/v1.12.0/formatter/severity.go
472+
// Extracted from https://github.com/mgechev/revive/blob/v1.13.0/formatter/severity.go
467473
// Modified to use pointers (related to hugeParam rule).
468474
func severity(cfg *lint.Config, failure *lint.Failure) lint.Severity {
469475
if cfg, ok := cfg.Rules[failure.RuleName]; ok && cfg.Severity == lint.SeverityError {

test/testdata/unsafe/pkg.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// Package pkg ...
2-
package pkg
1+
// Package pkgunsafe ...
2+
package pkgunsafe
33

44
import (
55
"log"

0 commit comments

Comments
 (0)