Skip to content

Commit 9ab31fc

Browse files
authored
chore: migrate to golangci-lint v2 (#168)
* chore: migrate to golangci-lint v2 * chore: improve gofmt configuration
1 parent da63f07 commit 9ab31fc

File tree

4 files changed

+50
-42
lines changed

4 files changed

+50
-42
lines changed

.github/workflows/go.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ jobs:
1515
- uses: actions/setup-go@v5
1616
with:
1717
go-version: stable
18-
- uses: golangci/golangci-lint-action@v6
18+
- uses: golangci/golangci-lint-action@v7
1919
with:
20-
version: v1.63.4
20+
version: v2.0.2
2121

2222
tests:
2323
# run after golangci-lint action to not produce duplicated errors

.golangci.yml

Lines changed: 45 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,28 @@
11
---
2-
run:
3-
timeout: 1m
4-
issues-exit-code: 1
5-
tests: true
2+
version: "2"
63

74
output:
8-
print-issued-lines: false
9-
sort-results: true
105
formats:
11-
- format: colored-line-number
12-
13-
linters-settings:
14-
gocognit:
15-
min-complexity: 10
16-
17-
depguard:
18-
rules:
19-
main:
20-
deny:
21-
- pkg: "github.com/davecgh/go-spew/spew"
22-
desc: not allowed
23-
24-
misspell:
25-
locale: US
26-
27-
gocritic:
28-
# Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run`
29-
# to see all tags and checks. Empty list by default. See
30-
# https://github.com/go-critic/go-critic#usage -> section "Tags".
31-
enabled-tags:
32-
- diagnostic
33-
- experimental
34-
- opinionated
35-
- performance
36-
- style
6+
text:
7+
path: stdout
8+
print-issued-lines: false
379

3810
linters:
39-
enable-all: true
11+
default: all
4012
disable:
4113
- cyclop
4214
- depguard
4315
- dupl
4416
- dupword
4517
- exhaustruct
46-
- exportloopref
4718
- forbidigo
4819
- funlen
49-
- gci
5020
- gocognit
5121
- gocyclo
5222
- godox
53-
- mnd
5423
- lll
5524
- maintidx
25+
- mnd
5626
- nakedret
5727
- nestif
5828
- nlreturn
@@ -64,8 +34,46 @@ linters:
6434
- varnamelen
6535
- wastedassign
6636

37+
settings:
38+
depguard:
39+
rules:
40+
main:
41+
deny:
42+
- pkg: github.com/davecgh/go-spew/spew
43+
desc: not allowed
44+
gocognit:
45+
min-complexity: 10
46+
gocritic:
47+
# Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run`
48+
# to see all tags and checks. Empty list by default. See
49+
# https://github.com/go-critic/go-critic#usage -> section "Tags".
50+
enabled-tags:
51+
- diagnostic
52+
- experimental
53+
- opinionated
54+
- performance
55+
- style
56+
misspell:
57+
locale: US
58+
59+
exclusions:
60+
presets:
61+
- comments
62+
- common-false-positives
63+
- std-error-handling
64+
6765
issues:
68-
exclude-use-default: true
6966
max-issues-per-linter: 0
7067
max-same-issues: 0
68+
formatters:
69+
enable:
70+
- gofmt
71+
- gofumpt
72+
- goimports
73+
settings:
74+
gofmt:
75+
rewrite-rules:
76+
- pattern: 'interface{}'
77+
replacement: 'any'
78+
7179
# vim: set sw=2 ts=2 et:

analyzer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func (wa *wslAnalyzer) flags() flag.FlagSet {
7979
return *flags
8080
}
8181

82-
func (wa *wslAnalyzer) run(pass *analysis.Pass) (interface{}, error) {
82+
func (wa *wslAnalyzer) run(pass *analysis.Pass) (any, error) {
8383
for _, file := range pass.Files {
8484
filename := getFilename(pass.Fset, file)
8585
if !strings.HasSuffix(filename, ".go") {

wsl.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,7 @@ func (p *processor) findBlockStmt(node ast.Node) []*ast.BlockStmt {
10781078
// Known fields with X that are handled:
10791079
// IndexExpr, ExprStmt, SelectorExpr, StarExpr, ParentExpr, TypeAssertExpr,
10801080
// RangeStmt, UnaryExpr, ParenExpr, SliceExpr, IncDecStmt.
1081-
func maybeX(node interface{}) (ast.Node, bool) {
1081+
func maybeX(node any) (ast.Node, bool) {
10821082
maybeHasX := reflect.Indirect(reflect.ValueOf(node)).FieldByName("X")
10831083
if !maybeHasX.IsValid() {
10841084
return nil, false
@@ -1455,7 +1455,7 @@ func (p *processor) addErrorRange(reportAt, start, end token.Pos, reason string)
14551455
p.result[reportAt] = report
14561456
}
14571457

1458-
func (p *processor) addWarning(w string, pos token.Pos, t interface{}) {
1458+
func (p *processor) addWarning(w string, pos token.Pos, t any) {
14591459
position := p.fileSet.Position(pos)
14601460

14611461
p.warnings = append(p.warnings,

0 commit comments

Comments
 (0)