Skip to content

Commit 9da04f5

Browse files
dependabot[bot]ldez
andauthoredAug 14, 2022
build(deps): bump github.com/go-critic/go-critic from 0.6.3 to 0.6.4 (#3089)
Co-authored-by: Fernandez Ludovic <[email protected]>
1 parent edeaa17 commit 9da04f5

File tree

16 files changed

+486
-423
lines changed

16 files changed

+486
-423
lines changed
 

‎.golangci.reference.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1113,7 +1113,7 @@ linters-settings:
11131113
makezero:
11141114
# Allow only slices initialized with a length of zero.
11151115
# Default: false
1116-
always: false
1116+
always: true
11171117

11181118
maligned:
11191119
# Print struct with more effective memory layout or not.

‎.golangci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ linters-settings:
2727
- ifElseChain
2828
- octalLiteral
2929
- whyNoLint
30-
- wrapperFunc
3130
gocyclo:
3231
min-complexity: 15
3332
goimports:

‎go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ require (
2727
github.com/fatih/color v1.13.0
2828
github.com/firefart/nonamedreturns v1.0.4
2929
github.com/fzipp/gocyclo v0.6.0
30-
github.com/go-critic/go-critic v0.6.3
30+
github.com/go-critic/go-critic v0.6.4
3131
github.com/go-xmlfmt/xmlfmt v0.0.0-20191208150333-d5b6f63a941b
3232
github.com/gofrs/flock v0.8.1
3333
github.com/golangci/check v0.0.0-20180506172741-cfe4005ccda2
@@ -121,8 +121,8 @@ require (
121121
github.com/fsnotify/fsnotify v1.5.4 // indirect
122122
github.com/go-ole/go-ole v1.2.6 // indirect
123123
github.com/go-toolsmith/astcast v1.0.0 // indirect
124-
github.com/go-toolsmith/astcopy v1.0.0 // indirect
125-
github.com/go-toolsmith/astequal v1.0.1 // indirect
124+
github.com/go-toolsmith/astcopy v1.0.1 // indirect
125+
github.com/go-toolsmith/astequal v1.0.2 // indirect
126126
github.com/go-toolsmith/astfmt v1.0.0 // indirect
127127
github.com/go-toolsmith/astp v1.0.0 // indirect
128128
github.com/go-toolsmith/strparse v1.0.0 // indirect
@@ -153,7 +153,7 @@ require (
153153
github.com/prometheus/client_model v0.2.0 // indirect
154154
github.com/prometheus/common v0.32.1 // indirect
155155
github.com/prometheus/procfs v0.7.3 // indirect
156-
github.com/quasilyte/go-ruleguard v0.3.16-0.20220213074421-6aa060fab41a // indirect
156+
github.com/quasilyte/go-ruleguard v0.3.17 // indirect
157157
github.com/quasilyte/gogrep v0.0.0-20220120141003-628d8b3623b5 // indirect
158158
github.com/quasilyte/regex/syntax v0.0.0-20200407221936-30656e2c4a95 // indirect
159159
github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect

‎go.sum

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

‎pkg/commands/executor.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,6 @@ func NewExecutor(version, commit, date string) *Executor {
117117
// recreate after getting config
118118
e.DBManager = lintersdb.NewManager(e.cfg, e.log).WithCustomLinters()
119119

120-
e.cfg.LintersSettings.Gocritic.InferEnabledChecks(e.log)
121-
if err = e.cfg.LintersSettings.Gocritic.Validate(e.log); err != nil {
122-
e.log.Fatalf("Invalid gocritic settings: %s", err)
123-
}
124-
125120
// Slice options must be explicitly set for proper merging of config and command-line options.
126121
fixSlicesFlags(e.runCmd.Flags())
127122
fixSlicesFlags(e.lintersCmd.Flags())

‎pkg/config/linters_settings.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ var defaultLintersSettings = LintersSettings{
4040
Gocognit: GocognitSettings{
4141
MinComplexity: 30,
4242
},
43-
Gocritic: GocriticSettings{
44-
SettingsPerCheck: map[string]GocriticCheckSettings{},
43+
Gocritic: GoCriticSettings{
44+
SettingsPerCheck: map[string]GoCriticCheckSettings{},
4545
},
4646
Godox: GodoxSettings{
4747
Keywords: []string{},
@@ -133,7 +133,7 @@ type LintersSettings struct {
133133
Gci GciSettings
134134
Gocognit GocognitSettings
135135
Goconst GoConstSettings
136-
Gocritic GocriticSettings
136+
Gocritic GoCriticSettings
137137
Gocyclo GoCycloSettings
138138
Godot GodotSettings
139139
Godox GodoxSettings
@@ -306,6 +306,16 @@ type GoConstSettings struct {
306306
IgnoreCalls bool `mapstructure:"ignore-calls"`
307307
}
308308

309+
type GoCriticSettings struct {
310+
EnabledChecks []string `mapstructure:"enabled-checks"`
311+
DisabledChecks []string `mapstructure:"disabled-checks"`
312+
EnabledTags []string `mapstructure:"enabled-tags"`
313+
DisabledTags []string `mapstructure:"disabled-tags"`
314+
SettingsPerCheck map[string]GoCriticCheckSettings `mapstructure:"settings"`
315+
}
316+
317+
type GoCriticCheckSettings map[string]interface{}
318+
309319
type GoCycloSettings struct {
310320
MinComplexity int `mapstructure:"min-complexity"`
311321
}

‎pkg/config/linters_settings_gocritic.go

Lines changed: 0 additions & 366 deletions
This file was deleted.

‎pkg/golinters/gocritic.go

Lines changed: 440 additions & 25 deletions
Large diffs are not rendered by default.

‎pkg/config/linters_settings_gocritic_test.go renamed to ‎pkg/golinters/gocritic_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package config
1+
package golinters
22

33
import (
44
"log"
@@ -25,7 +25,9 @@ func Test_filterByDisableTags(t *testing.T) {
2525
disabledTags := []string{"experimental", "opinionated"}
2626
enabledChecks := []string{"appendAssign", "sortSlice", "caseOrder", "dupImport"}
2727

28-
filterEnabledChecks := filterByDisableTags(enabledChecks, disabledTags, &tLog{})
28+
settingsWrapper := newGoCriticSettingsWrapper(nil)
29+
30+
filterEnabledChecks := settingsWrapper.filterByDisableTags(enabledChecks, disabledTags, &tLog{})
2931

3032
sort.Strings(filterEnabledChecks)
3133

‎pkg/golinters/lll.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func getLLLIssuesForFile(filename string, maxLineLen int, tabSpaces string) ([]r
8888
scanner := bufio.NewScanner(f)
8989
for scanner.Scan() {
9090
line := scanner.Text()
91-
line = strings.Replace(line, "\t", tabSpaces, -1)
91+
line = strings.ReplaceAll(line, "\t", tabSpaces)
9292
lineLen := utf8.RuneCountInString(line)
9393
if lineLen > maxLineLen {
9494
res = append(res, result.Issue{

‎pkg/lint/lintersdb/manager.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
119119
gciCfg *config.GciSettings
120120
gocognitCfg *config.GocognitSettings
121121
goconstCfg *config.GoConstSettings
122-
gocriticCfg *config.GocriticSettings
122+
gocriticCfg *config.GoCriticSettings
123123
gocycloCfg *config.GoCycloSettings
124124
godotCfg *config.GodotSettings
125125
godoxCfg *config.GodoxSettings
@@ -436,7 +436,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
436436
WithPresets(linter.PresetStyle).
437437
WithURL("https://github.com/jgautheron/goconst"),
438438

439-
linter.NewConfig(golinters.NewGocritic(gocriticCfg, m.cfg)).
439+
linter.NewConfig(golinters.NewGoCritic(gocriticCfg, m.cfg)).
440440
WithSince("v1.12.0").
441441
WithPresets(linter.PresetStyle, linter.PresetMetaLinter).
442442
WithLoadForGoAnalysis().

‎pkg/result/processors/path_shortener.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ func (p PathShortener) Name() string {
3131
func (p PathShortener) Process(issues []result.Issue) ([]result.Issue, error) {
3232
return transformIssues(issues, func(i *result.Issue) *result.Issue {
3333
newI := i
34-
newI.Text = strings.Replace(newI.Text, p.wd+"/", "", -1)
35-
newI.Text = strings.Replace(newI.Text, p.wd, "", -1)
34+
newI.Text = strings.ReplaceAll(newI.Text, p.wd+"/", "")
35+
newI.Text = strings.ReplaceAll(newI.Text, p.wd, "")
3636
return newI
3737
}), nil
3838
}

‎test/errchk.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func errorCheck(outStr string, wantAuto bool, defaultWantedLinter string, fullsh
3333
for i := range out {
3434
for j := 0; j < len(fullshort); j += 2 {
3535
full, short := fullshort[j], fullshort[j+1]
36-
out[i] = strings.Replace(out[i], full, short, -1)
36+
out[i] = strings.ReplaceAll(out[i], full, short)
3737
}
3838
}
3939

‎test/testdata/configs/gocritic.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ linters-settings:
33
enabled-checks:
44
- rangeValCopy
55
- flagDeref
6+
- wrapperFunc
67
- ruleguard
78
settings:
8-
rangevalcopy:
9-
sizethreshold: 2
9+
rangeValCopy:
10+
sizeThreshold: 2
1011
ruleguard:
1112
debug: dupSubExpr
1213
failOn: dsl,import

‎test/testdata/gocritic.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,7 @@ func gocriticDup(x bool) {
4242
log.Print("x is true")
4343
}
4444
}
45+
46+
func gocriticRuleWrapperFunc() {
47+
strings.Replace("abcabc", "a", "d", -1) // ERROR "ruleguard: this Replace call can be simplified.*"
48+
}

‎test/testshared/testshared.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ func (r *LintRunner) RunCommandWithYamlConfig(cfg, command string, args ...strin
154154
}
155155

156156
cfg = strings.TrimSpace(cfg)
157-
cfg = strings.Replace(cfg, "\t", " ", -1)
157+
cfg = strings.ReplaceAll(cfg, "\t", " ")
158158

159159
err = os.WriteFile(cfgPath, []byte(cfg), os.ModePerm)
160160
assert.NoError(r.t, err)

0 commit comments

Comments
 (0)
Please sign in to comment.