Skip to content

Commit ad3b7bc

Browse files
authored
chore: bump Go to 1.27 and golangci-lint to v2.13.2 (#50)
* chore: bump Go to 1.27 and golangci-lint to v2.13.2 Raise the module Go version to 1.27 and update the Makefile linter pin to v2.13.2 (Go 1.27 support). Fixes #49 * chore: migrate .golangci.yml to v2 config format Required for golangci-lint v2.13.x after the Makefile pin bump. * chore: fix golangci-lint v2 install and address new lint findings The official install.sh checksum lookup matches *.tar.gz.sbom.json on v2.13.x, so install the release tarball directly. Also satisfy staticcheck QF1008 and keep noisy test-only linters excluded. * chore: shrink .golangci.yml under 100 lines (keep strength) * chore: simplify lint to a one-line go run toolchain invoke * chore: simplify lint config and Makefile for Go 1.27 Use golangci-lint via go tool with a dedicated tools.mod so the package go.mod stays dependency-free. Shrink .golangci.yml with default: all plus a short disable list. * chore: add tools.mod for go tool golangci-lint Keep package go.mod dependency-free while pinning the linter via the Go 1.24 tool directive in a dedicated tools.mod. * Simplify lint config and Makefile Shrink .golangci.yml by using default: all instead of an explicit enable list, keeping the existing thresholds. Run golangci-lint with go run so the lint target is one line and go.mod stays dependency-free.
1 parent 6891287 commit ad3b7bc

10 files changed

Lines changed: 116 additions & 232 deletions

File tree

.golangci.yml

Lines changed: 81 additions & 191 deletions
Original file line numberDiff line numberDiff line change
@@ -1,198 +1,88 @@
1-
run:
2-
timeout: 1m
3-
4-
linters-settings:
5-
errcheck:
6-
# report about not checking of errors in type assetions: `a := b.(MyStruct)`;
7-
# default is false: such cases aren't reported by default.
8-
check-type-assertions: true
9-
10-
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
11-
# default is false: such cases aren't reported by default.
12-
check-blank: false
13-
14-
# [deprecated] comma-separated list of pairs of the form pkg:regex
15-
# the regex is used to ignore names within pkg. (default "fmt:.*").
16-
# see https://github.com/kisielk/errcheck#the-deprecated-method for details
17-
# ignore: fmt:.*,io/ioutil:^Read.*
18-
19-
# path to a file containing a list of functions to exclude from checking
20-
# see https://github.com/kisielk/errcheck#excluding-functions for details
21-
# exclude: /path/to/file.txt
22-
23-
funlen:
24-
lines: 50
25-
statements: 40
26-
27-
govet:
28-
# report about shadowed variables
29-
shadow: true
30-
31-
# enable or disable analyzers by name
32-
# enable:
33-
# - atomicalign
34-
enable-all: true
35-
disable:
36-
- fieldalignment
37-
# disable-all: false
38-
revive:
39-
# minimal confidence for issues, default is 0.8
40-
min-confidence: 0.8
41-
gofmt:
42-
# simplify code: gofmt with `-s` option, true by default
43-
simplify: true
44-
goimports:
45-
# put imports beginning with prefix after 3rd-party packages;
46-
# it's a comma-separated list of prefixes
47-
local-prefixes: github.com/kinbiko/bugsnag
48-
gocyclo:
49-
# minimal code complexity to report, 30 by default (but we recommend 10-20)
50-
# This check is set to an unreasonably low number by most developers'
51-
# standards to track the code standard over time
52-
min-complexity: 10
53-
gocognit:
54-
# minimal code complexity to report, 30 by default (but we recommend 10-20)
55-
# This check is a more useful cyclomatic complexity called cognitive complexity,
56-
# where nested if/for is weighted more, and only one point regardless of
57-
# cases in a switch.
58-
min-complexity: 11
59-
dupl:
60-
# tokens count to trigger issue, 150 by default
61-
threshold: 100
62-
goconst:
63-
# minimal length of string constant, 3 by default
64-
min-len: 10
65-
# minimal occurrences count to trigger, 3 by default
66-
min-occurrences: 3
67-
68-
# packages-with-error-messages:
69-
# specify an error message to output when a blacklisted package is used
70-
# github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
71-
misspell:
72-
# Correct spellings using locale preferences for US or UK.
73-
# Default is to use a neutral variety of English.
74-
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
75-
locale: US
76-
# ignore-words:
77-
# - someword
78-
lll:
79-
# max line length, lines longer will be reported. Default is 120.
80-
# '\t' is counted as 1 character by default, and can be changed with the tab-width option
81-
line-length: 165
82-
# tab width in spaces. Default to 1.
83-
tab-width: 4
84-
unused:
85-
# treat code as a program (not a library) and report unused exported identifiers; default is false.
86-
# XXX: if you enable this setting, unused will report a lot of false-positives in text editors:
87-
# if it's called for subdir of a project it can't find funcs usages. All text editor integrations
88-
# with golangci-lint call it on a directory with the changed file.
89-
check-exported: false
90-
unparam:
91-
# Inspect exported functions, default is false. Set to true if no external program/library imports your code.
92-
# XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
93-
# if it's called for subdir of a project it can't find external interfaces. All text editor integrations
94-
# with golangci-lint call it on a directory with the changed file.
95-
check-exported: true
96-
nakedret:
97-
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
98-
# Naked returns can go plop itself
99-
max-func-lines: 0
100-
prealloc:
101-
# XXX: we don't recommend using this linter before doing performance profiling.
102-
# For most programs usage of prealloc will be a premature optimization.
103-
104-
# Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
105-
# True by default.
106-
simple: true
107-
range-loops: true # Report preallocation suggestions on range loops, true by default
108-
for-loops: false # Report preallocation suggestions on for loops, false by default
109-
gocritic:
110-
# Which checks should be enabled; can't be combined with 'disabled-checks';
111-
# See https://go-critic.github.io/overview#checks-overview
112-
# To check which checks are enabled run `GL_DEBUG=gocritic golangci-lint run`
113-
# By default list of stable checks is used.
114-
# enabled-checks:
115-
# - badCond
116-
117-
# Which checks should be disabled; can't be combined with 'enabled-checks'; default is empty
118-
# disabled-checks:
119-
120-
# Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.
121-
# Empty list by default. See https://github.com/go-critic/go-critic#usage -> section "Tags".
122-
enabled-tags:
123-
- diagnostic
124-
- style
125-
- performance
126-
127-
settings: # settings passed to gocritic
128-
captLocal: # must be valid enabled check name
129-
paramsOnly: true
130-
rangeValCopy:
131-
sizeThreshold: 64
132-
godox:
133-
# report any comments starting with keywords, this is useful for TODO or FIXME comments that
134-
# might be left in the code accidentally and should be resolved before merging
135-
keywords: # default keywords are TODO, BUG, and FIXME, these can be overwritten by this setting
136-
- TODO
137-
- FIXME
138-
dogsled:
139-
# checks assignments with too many blank identifiers; default is 2
140-
max-blank-identifiers: 2
141-
142-
whitespace:
143-
multi-if: false # Enforces newlines (or comments) after every multi-line if statement
144-
multi-func: false # Enforces newlines (or comments) after every multi-line function signature
145-
1+
version: "2"
1462
linters:
3+
default: all
1474
disable:
148-
- wsl
5+
- depguard
6+
- exhaustruct # replaced by exhaustruct_v5
1497
- godot
8+
- gomodguard # replaced by gomodguard_v2
9+
- modernize
15010
- nlreturn
151-
152-
- depguard
153-
154-
- gci # This conflicts with goimports
155-
- varnamelen # This has too many false positives around indexes etc to be useful
156-
presets:
157-
- bugs
158-
- complexity
159-
- format
160-
- performance
161-
- style
162-
- unused
163-
fast: false
164-
11+
- noinlineerr
12+
- testableexamples
13+
- varnamelen
14+
- wsl
15+
- wsl_v5
16+
settings:
17+
dupl:
18+
threshold: 100
19+
errcheck:
20+
check-type-assertions: true
21+
funlen:
22+
lines: 50
23+
statements: 40
24+
gocognit:
25+
min-complexity: 11
26+
goconst:
27+
min-len: 10
28+
min-occurrences: 3
29+
gocritic:
30+
enabled-tags:
31+
- diagnostic
32+
- style
33+
- performance
34+
settings:
35+
captLocal:
36+
paramsOnly: true
37+
rangeValCopy:
38+
sizeThreshold: 64
39+
gocyclo:
40+
min-complexity: 10
41+
govet:
42+
enable-all: true
43+
disable:
44+
- fieldalignment
45+
lll:
46+
line-length: 165
47+
tab-width: 4
48+
misspell:
49+
locale: US
50+
nakedret:
51+
max-func-lines: 0
52+
unparam:
53+
check-exported: true
54+
exclusions:
55+
rules:
56+
- path: _test\.go
57+
linters:
58+
- cyclop
59+
- dupl
60+
- errcheck
61+
- errchkjson
62+
- forbidigo
63+
- funlen
64+
- gocognit
65+
- goconst
66+
- gocyclo
67+
- gosmopolitan
68+
- lll
69+
- maintidx
70+
- mnd
71+
- paralleltest
72+
- staticcheck
73+
- testpackage
74+
- varnamelen
75+
- path: \.go
76+
linters:
77+
- err113
16578
issues:
166-
# Excluding configuration per-path, per-linter, per-text and per-source
167-
exclude-rules:
168-
# Exclude some linters from running on tests files.
169-
- path: _test\.go
170-
linters:
171-
- cyclop
172-
- dupl
173-
- errcheck
174-
- errchkjson
175-
- exhaustivestruct
176-
- forbidigo
177-
- funlen
178-
- gocognit
179-
- gocyclo
180-
- gomnd
181-
- lll
182-
- stylecheck
183-
- testpackage
184-
- varnamelen
185-
- maintidx
186-
- path: \.go
187-
linters:
188-
- err113
189-
190-
# Independently from option `exclude` we use default exclude patterns,
191-
# it can be disabled by this option. To list all
192-
# excluded by default patterns execute `golangci-lint run --help`.
193-
# Default value for this option is true.
194-
exclude-use-default: false
195-
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
19679
max-issues-per-linter: 0
197-
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
19880
max-same-issues: 0
81+
formatters:
82+
enable:
83+
- gofumpt
84+
- goimports
85+
settings:
86+
goimports:
87+
local-prefixes:
88+
- github.com/kinbiko/bugsnag

Makefile

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
LINTER_VERSION := v1.61.0
2-
31
.PHONY: check
42
check: lint test
53

@@ -8,17 +6,13 @@ get-deps:
86
go get -v -t -d ./...
97

108
.PHONY: lint
11-
lint: ./bin/linter
12-
./bin/linter run ./...
9+
lint:
10+
go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.13.2 run ./...
1311

1412
.PHONY: test
1513
test:
1614
go test -race -count=1 ./...
1715

1816
.PHONY: coverage
1917
coverage:
20-
go test -race -v -coverprofile=profile.cov -covermode=atomic ./...
21-
22-
bin/linter: Makefile
23-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./bin $(LINTER_VERSION)
24-
mv ./bin/golangci-lint ./bin/linter
18+
go test -race -v -coverprofile=profile.cov -covermode=atomic ./...

array.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
)
88

99
func (a *Asserter) checkArray(path string, act, exp []interface{}) {
10-
a.tt.Helper()
10+
a.Helper()
1111
if len(exp) > 0 && exp[0] == "<<UNORDERED>>" {
1212
a.checkArrayUnordered(path, act, exp[1:])
1313
} else {
@@ -17,14 +17,14 @@ func (a *Asserter) checkArray(path string, act, exp []interface{}) {
1717

1818
//nolint:gocognit,gocyclo,cyclop // function is actually still readable
1919
func (a *Asserter) checkArrayUnordered(path string, act, exp []interface{}) {
20-
a.tt.Helper()
20+
a.Helper()
2121
if len(act) != len(exp) {
22-
a.tt.Errorf("length of arrays at '%s' were different. Expected array to be of length %d, but contained %d element(s)", path, len(exp), len(act))
22+
a.Errorf("length of arrays at '%s' were different. Expected array to be of length %d, but contained %d element(s)", path, len(exp), len(act))
2323
serializedAct, serializedExp := serialize(act), serialize(exp)
2424
if len(serializedAct+serializedExp) < maxMsgCharCount {
25-
a.tt.Errorf("actual JSON at '%s' was: %+v, but expected JSON was: %+v, potentially in a different order", path, serializedAct, serializedExp)
25+
a.Errorf("actual JSON at '%s' was: %+v, but expected JSON was: %+v, potentially in a different order", path, serializedAct, serializedExp)
2626
} else {
27-
a.tt.Errorf("actual JSON at '%s' was:\n%+v\nbut expected JSON was:\n%+v,\npotentially in a different order", path, serializedAct, serializedExp)
27+
a.Errorf("actual JSON at '%s' was:\n%+v\nbut expected JSON was:\n%+v,\npotentially in a different order", path, serializedAct, serializedExp)
2828
}
2929
return
3030
}
@@ -39,9 +39,9 @@ func (a *Asserter) checkArrayUnordered(path string, act, exp []interface{}) {
3939
if !found {
4040
serializedEl := serialize(actEl)
4141
if len(serializedEl) < maxMsgCharCount {
42-
a.tt.Errorf("actual JSON at '%s[%d]' contained an unexpected element: %s", path, i, serializedEl)
42+
a.Errorf("actual JSON at '%s[%d]' contained an unexpected element: %s", path, i, serializedEl)
4343
} else {
44-
a.tt.Errorf("actual JSON at '%s[%d]' contained an unexpected element:\n%s", path, i, serializedEl)
44+
a.Errorf("actual JSON at '%s[%d]' contained an unexpected element:\n%s", path, i, serializedEl)
4545
}
4646
}
4747
}
@@ -54,23 +54,23 @@ func (a *Asserter) checkArrayUnordered(path string, act, exp []interface{}) {
5454
if !found {
5555
serializedEl := serialize(expEl)
5656
if len(serializedEl) < maxMsgCharCount {
57-
a.tt.Errorf("expected JSON at '%s[%d]': %s was missing from actual payload", path, i, serializedEl)
57+
a.Errorf("expected JSON at '%s[%d]': %s was missing from actual payload", path, i, serializedEl)
5858
} else {
59-
a.tt.Errorf("expected JSON at '%s[%d]':\n%s\nwas missing from actual payload", path, i, serializedEl)
59+
a.Errorf("expected JSON at '%s[%d]':\n%s\nwas missing from actual payload", path, i, serializedEl)
6060
}
6161
}
6262
}
6363
}
6464

6565
func (a *Asserter) checkArrayOrdered(path string, act, exp []interface{}) {
66-
a.tt.Helper()
66+
a.Helper()
6767
if len(act) != len(exp) {
68-
a.tt.Errorf("length of arrays at '%s' were different. Expected array to be of length %d, but contained %d element(s)", path, len(exp), len(act))
68+
a.Errorf("length of arrays at '%s' were different. Expected array to be of length %d, but contained %d element(s)", path, len(exp), len(act))
6969
serializedAct, serializedExp := serialize(act), serialize(exp)
7070
if len(serializedAct+serializedExp) < maxMsgCharCount {
71-
a.tt.Errorf("actual JSON at '%s' was: %+v, but expected JSON was: %+v", path, serializedAct, serializedExp)
71+
a.Errorf("actual JSON at '%s' was: %+v, but expected JSON was: %+v", path, serializedAct, serializedExp)
7272
} else {
73-
a.tt.Errorf("actual JSON at '%s' was:\n%+v\nbut expected JSON was:\n%+v", path, serializedAct, serializedExp)
73+
a.Errorf("actual JSON at '%s' was:\n%+v\nbut expected JSON was:\n%+v", path, serializedAct, serializedExp)
7474
}
7575
return
7676
}

boolean.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ func extractBoolean(b string) (bool, error) {
1313
}
1414

1515
func (a *Asserter) checkBoolean(path string, act, exp bool) {
16-
a.tt.Helper()
16+
a.Helper()
1717
if act != exp {
18-
a.tt.Errorf("expected boolean at '%s' to be %v but was %v", path, exp, act)
18+
a.Errorf("expected boolean at '%s' to be %v but was %v", path, exp, act)
1919
}
2020
}

0 commit comments

Comments
 (0)