Skip to content

Commit ca2ff90

Browse files
Upgrade golangci lint to v2 (#562)
* upgrade golangci-lint to v2 * refactor: remove embeddedstructfieldcheck linter and reorder ScheduleConfig fields * feat: introduce DefaultTestTimeout constant and refactor timeout usage in tests * chore: upgrade golangci-lint to v2.5.0 and remove backup configuration file * chore: upgrade golangci-lint action from v6 to v8 in build workflow
1 parent c12b94f commit ca2ff90

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+253
-121
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ jobs:
4242
node-version: "22"
4343

4444
- name: golangci-lint
45-
uses: golangci/golangci-lint-action@v6
45+
uses: golangci/golangci-lint-action@v8
4646
with:
47-
version: v1.64.8
47+
version: v2.5.0
4848
args: --timeout=30m
4949

5050
- name: Test

.golangci.yml

Lines changed: 69 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,89 @@
1+
version: "2"
12
linters:
23
enable:
34
- asasalint
45
- asciicheck
56
- bidichk
67
- bodyclose
8+
- canonicalheader
9+
- containedctx
710
- contextcheck
11+
- copyloopvar
12+
- decorder
13+
- durationcheck
14+
# - err113
15+
- errcheck
16+
- errchkjson
817
- errname
18+
# - errorlint
19+
- exptostd
20+
- fatcontext
21+
# - forcetypeassert
922
- gocheckcompilerdirectives
23+
- gochecksumtype
24+
# - gocritic
25+
# - godoclint
26+
- goheader
27+
- gomoddirectives
1028
- gosec
11-
# - maintidx
29+
- govet
30+
- grouper
31+
- iface
32+
- importas
33+
- inamedparam
34+
- ineffassign
35+
# - intrange
36+
# - ireturn
37+
- loggercheck
38+
- makezero
39+
- mirror
1240
- misspell
41+
- nilerr
42+
- nilnesserr
1343
- nilnil
14-
- noctx
44+
# - nlreturn
45+
# - noctx
1546
- nolintlint
47+
- nosprintfhostport
48+
# - perfsprint
49+
- prealloc
1650
- predeclared
51+
- promlinter
1752
- reassign
53+
# - revive
54+
- rowserrcheck
1855
- sloglint
1956
- spancheck
57+
- staticcheck
58+
- testableexamples
59+
# - testifylint
60+
- thelper
2061
- unconvert
2162
- unparam
63+
- unused
2264
- usestdlibvars
23-
24-
linters-settings:
25-
gosec:
26-
excludes:
27-
- G204 # Audit the use of command execution
28-
- G404 # Insecure random number source (rand)
65+
# - usetesting
66+
- wastedassign
67+
settings:
68+
gosec:
69+
excludes:
70+
- G204 # Audit use of command execution
71+
- G404 # Insecure random number source (rand)
72+
exclusions:
73+
generated: lax
74+
presets:
75+
- comments
76+
- common-false-positives
77+
- legacy
78+
- std-error-handling
79+
paths:
80+
- third_party$
81+
- builtin$
82+
- examples$
83+
formatters:
84+
exclusions:
85+
generated: lax
86+
paths:
87+
- third_party$
88+
- builtin$
89+
- examples$

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@
1818
"go.lintTool": "golangci-lint",
1919
"githubPullRequests.ignoredPullRequestBranches": [
2020
"master"
21-
]
21+
],
22+
"makefile.configureOnOpen": false
2223
}

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ $(GOBIN)/github-markdown-toc.go: verify $(GOBIN)/eget
9494

9595
$(GOBIN)/mockery: verify $(GOBIN)/eget
9696
@echo "[*] $@"
97-
"$(GOBIN)/eget" vektra/mockery --upgrade-only --to '$(GOBIN)'
97+
"$(GOBIN)/eget" vektra/mockery --tag v3.5.5 --upgrade-only --to '$(GOBIN)'
9898

9999
$(GOBIN)/golangci-lint: verify $(GOBIN)/eget
100100
@echo "[*] $@"
101-
"$(GOBIN)/eget" golangci/golangci-lint --tag v1.64.8 --asset=tar.gz --upgrade-only --to '$(GOBIN)'
101+
"$(GOBIN)/eget" golangci/golangci-lint --tag v2.5.0 --asset=tar.gz --upgrade-only --to '$(GOBIN)'
102102

103103
$(GOBIN)/hugo: $(GOBIN)/eget
104104
@echo "[*] $@"

batt/battery.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,10 @@ func detectRunningOnBattery(batteries []battery.Battery) bool {
7878
pluggedIn := false
7979
discharging := false
8080
for _, bat := range batteries {
81-
if bat.State.Raw == battery.Discharging || bat.State.Raw == battery.Empty {
81+
switch bat.State.Raw {
82+
case battery.Discharging, battery.Empty:
8283
discharging = true
83-
} else if bat.State.Raw == battery.Charging || bat.State.Raw == battery.Full || bat.State.Raw == battery.Idle || bat.State.Raw == battery.Unknown {
84+
case battery.Charging, battery.Full, battery.Idle, battery.Unknown:
8485
pluggedIn = true
8586
}
8687
}

commands_display.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ func newLineLengthWriter(writer io.Writer, maxLineLength int) *lineLengthWriter
367367
}
368368

369369
func (l *lineLengthWriter) Write(p []byte) (n int, err error) {
370-
written := 0
370+
var written int
371371
inAnsi := false
372372
offset := l.lineLength
373373
lineLength := func() int { return l.lineLength - l.ansiLength }

commands_generate.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ func generateJsonSchema(output io.Writer, args []string) (err error) {
206206
// SectionInfoData is used as data for go templates that render profile section references
207207
type SectionInfoData struct {
208208
templates.DefaultData
209+
209210
Section config.SectionInfo
210211
Weight int
211212
}

complete_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ func TestCompleter(t *testing.T) {
111111

112112
testValues := func(flagName string, expected []string) func(t *testing.T) {
113113
return func(t *testing.T) {
114+
t.Helper()
114115

115116
t.Run("ReturnsAllValues", func(t *testing.T) {
116117
actual := completer.Complete(newArgs(fmt.Sprintf("--%s", flagName), ""))

config/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ func (c *Config) applyMixinsToProfile(profileName string) error {
247247
}
248248

249249
func (c *Config) applyMatchingMixinsOnce(matcher func(useKey string) bool) error {
250-
var matchingUses []map[string][]*mixinUse
250+
matchingUses := make([]map[string][]*mixinUse, 0, len(c.mixinUses))
251251

252252
for _, allUses := range c.mixinUses {
253253
usesToApply := make(map[string][]*mixinUse)
@@ -756,7 +756,7 @@ func traceConfig(profileName, name string, replace bool, config *bytes.Buffer) {
756756
gutter = "%4d: "
757757
}
758758
for i := 0; i < len(lines); i++ {
759-
output.WriteString(fmt.Sprintf(gutter, i+1))
759+
fmt.Fprintf(output, gutter, i+1)
760760
output.Write(lines[i])
761761
output.WriteString("\n")
762762
}

config/config_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ profile:
201201
func TestBoolPointer(t *testing.T) {
202202
fixtures := []struct {
203203
testTemplate
204+
204205
continueOnError maybe.Bool
205206
}{
206207
{

0 commit comments

Comments
 (0)