Skip to content

Commit 0a847a5

Browse files
Upgraded to 1.23 (#89)
* adjustments for go 1.23 following changes in how certain types are handled in reflect * remove dev todo comment * upgrade workflow (#1) fixed linter issues
1 parent c2e2a4a commit 0a847a5

File tree

14 files changed

+34
-34
lines changed

14 files changed

+34
-34
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
go: ['1.21']
14+
go: ['1.23']
1515
steps:
1616
- uses: actions/checkout@v4
1717
- name: Set up Go

.github/workflows/lint.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,9 @@ jobs:
1515
- name: Set up Go
1616
uses: actions/setup-go@v4
1717
with:
18-
go-version: '1.21'
18+
go-version: '1.23'
1919

2020
- name: Run golangci-lint
21-
uses: golangci/golangci-lint-action@v3.7.0
21+
uses: golangci/golangci-lint-action@v6.1.1
2222
with:
23-
version: v1.54.0
24-
# skip cache becausez of flaky behaviors
25-
skip-build-cache: true
26-
skip-pkg-cache: true
23+
version: latest

.github/workflows/tag.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- name: Install Go
1313
uses: actions/setup-go@v4
1414
with:
15-
go-version: 1.21
15+
go-version: 1.23
1616
- name: Unshallow
1717
run: git fetch --prune --unshallow
1818
- name: Create release

.golangci.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ linters-settings:
2020
min-complexity: 15
2121
goimports:
2222
local-prefixes: github.com/timonwong/loggercheck
23-
gomnd:
23+
mnd:
2424
# don't include the "operation" and "assign"
2525
checks:
2626
- argument
@@ -36,7 +36,7 @@ linters-settings:
3636
- strings.SplitN
3737
- strconv.ParseInt
3838
govet:
39-
check-shadowing: true
39+
shadow: true
4040
lll:
4141
line-length: 140
4242
misspell:
@@ -52,15 +52,15 @@ linters:
5252
- dogsled
5353
- dupl
5454
- errcheck
55-
- exportloopref
55+
- copyloopvar
5656
- funlen
5757
- gochecknoinits
5858
- goconst
5959
- gocritic
6060
- gocyclo
6161
- gofumpt
6262
- goimports
63-
- gomnd
63+
- mnd
6464
- goprintffuncname
6565
- gosec
6666
- gosimple
@@ -85,10 +85,10 @@ issues:
8585
exclude-rules:
8686
- path: _test\.go
8787
linters:
88-
- gomnd
88+
- mnd
89+
exclude-dirs:
90+
- testdata
8991

9092
run:
9193
timeout: 5m
92-
go: '1.17'
93-
skip-dirs:
94-
- testdata
94+
go: '1.23'

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
module github.com/timonwong/loggercheck
22

3-
go 1.21
3+
go 1.23
44

55
require (
66
github.com/stretchr/testify v1.9.0
7-
golang.org/x/tools v0.24.0
7+
golang.org/x/tools v0.25.0
88
)
99

1010
require (
1111
github.com/davecgh/go-spew v1.1.1 // indirect
1212
github.com/pmezard/go-difflib v1.0.0 // indirect
13-
golang.org/x/mod v0.20.0 // indirect
13+
golang.org/x/mod v0.21.0 // indirect
1414
golang.org/x/sync v0.8.0 // indirect
1515
gopkg.in/yaml.v3 v3.0.1 // indirect
1616
)

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
66
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
77
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
88
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
9-
golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0=
10-
golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
9+
golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0=
10+
golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
1111
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
1212
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
13-
golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24=
14-
golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ=
13+
golang.org/x/tools v0.25.0 h1:oFU9pkj/iJgs+0DT+VMHrx+oBKs/LJMV+Uvg78sl+fE=
14+
golang.org/x/tools v0.25.0/go.mod h1:/vtpO8WL1N9cQC3FN5zPqb//fRXskFHbLKk4OW1Q7rg=
1515
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
1616
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
1717
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

internal/checkers/checker.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,12 @@ func ExecuteChecker(c Checker, pass *analysis.Pass, call CallContext, cfg Config
3030
startIndex := nparams - 1
3131

3232
lastArg := params.At(nparams - 1)
33-
iface, ok := lastArg.Type().(*types.Slice).Elem().(*types.Interface)
34-
if !ok || !iface.Empty() {
33+
if iface, ok := lastArg.Type().(*types.Slice).Elem().(*types.Interface); !ok {
34+
aface, ok := lastArg.Type().(*types.Slice).Elem().(*types.Alias) // slog uses any - an Alias not strictly an interface
35+
if !ok || !aface.Underlying().(*types.Interface).Empty() {
36+
return // final (args) param is not ...interface{}
37+
}
38+
} else if !iface.Empty() {
3539
return // final (args) param is not ...interface{}
3640
}
3741

internal/checkers/filter.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,13 @@ func filterKeyAndValues(pass *analysis.Pass, keyAndValues []ast.Expr, objName st
1616
case *ast.CallExpr, *ast.Ident:
1717
typ := pass.TypesInfo.TypeOf(arg)
1818
switch typ := typ.(type) {
19-
case *types.Named:
20-
obj := typ.Obj()
19+
case *types.Alias, *types.Named:
20+
var obj *types.TypeName
21+
if cTyp, ok := typ.(*types.Alias); ok {
22+
obj = cTyp.Obj()
23+
} else {
24+
obj = typ.(*types.Named).Obj()
25+
}
2126
if obj != nil && obj.Name() == objName {
2227
continue
2328
}

internal/checkers/printf/printf.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ func (s *formatState) parsePrecision() bool {
157157
func parsePrintfVerb(format string) *formatState {
158158
state := &formatState{
159159
format: format,
160-
flags: make([]byte, 0, 5), //nolint:gomnd
160+
flags: make([]byte, 0, 5), //nolint:mnd
161161
nbytes: 1, // There's guaranteed to be a percent sign.
162162
}
163163

internal/rules/rules_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ func TestParseFuncRule(t *testing.T) {
7070
}
7171

7272
for _, tc := range testCases {
73-
tc := tc
7473
t.Run(tc.name, func(t *testing.T) {
7574
t.Parallel()
7675

internal/sets/string_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ func TestString_Flag(t *testing.T) {
4444
}
4545

4646
for _, tc := range testCases {
47-
tc := tc
4847
t.Run(tc.name, func(t *testing.T) {
4948
t.Parallel()
5049

internal/stringutil/is_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ func TestIsASCII(t *testing.T) {
3535
}
3636

3737
for _, tc := range testCases {
38-
tc := tc
3938
t.Run(tc.name, func(t *testing.T) {
4039
t.Parallel()
4140

loggercheck_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ func TestLinter(t *testing.T) {
8484
}
8585

8686
for _, tc := range testCases {
87-
tc := tc
8887
t.Run(tc.name, func(t *testing.T) {
8988
a := loggercheck.NewAnalyzer()
9089
err := a.Flags.Parse(tc.flags)
@@ -177,7 +176,6 @@ func TestOptions(t *testing.T) {
177176
}
178177

179178
for _, tc := range testCases {
180-
tc := tc
181179
t.Run(tc.name, func(t *testing.T) {
182180
a := loggercheck.NewAnalyzer(tc.options...)
183181

staticrules_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ func Test_mustNewStaticRuleSet_failCase(t *testing.T) {
4242
},
4343
}
4444
for _, tc := range testCases {
45-
tc := tc
4645
t.Run(tc.name, func(t *testing.T) {
4746
t.Parallel()
4847
assert.PanicsWithError(t, tc.wantError, func() {

0 commit comments

Comments
 (0)