Skip to content

Commit f58efdc

Browse files
committed
Merge branch 'lint'
2 parents a2115fe + 7101d30 commit f58efdc

File tree

8 files changed

+9
-44
lines changed

8 files changed

+9
-44
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
name: ci
44
on: [push, pull_request]
55
env:
6-
GO_VERSION: "^1.20"
7-
GOLANGCI_LINT_VERSION: "v1.55.2"
6+
GO_VERSION: "^1.22"
7+
GOLANGCI_LINT_VERSION: "v1.62.0"
88

99
jobs:
1010
lint:

.golangci.yml

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ run:
1717

1818
# output configuration options
1919
output:
20-
# colored-line-number|line-number|json|tab|checkstyle, default is "colored-line-number"
21-
format: colored-line-number
22-
2320
# print lines of code with issue, default is true
2421
print-issued-lines: true
2522

@@ -31,28 +28,11 @@ output:
3128
linters-settings:
3229
gocritic:
3330
enabled-checks:
34-
- assignOp
3531
- builtinShadow
36-
- captLocal
37-
- caseOrder
38-
- defaultCaseOrder
39-
- dupArg
40-
- dupBranchBody
41-
- dupCase
42-
- elseif
43-
- flagDeref
44-
- ifElseChain
4532
- nilValReturn
4633
- rangeExprCopy
4734
- rangeValCopy
48-
- regexpMust
49-
- sloppyLen
50-
- switchTrue
51-
- typeSwitchVar
5235
- typeUnparen
53-
- underef
54-
- unlambda
55-
- unslice
5636
gocyclo:
5737
min-complexity: 29
5838
maligned:
@@ -81,9 +61,6 @@ linters-settings:
8161
linters:
8262
enable-all: true
8363
disable:
84-
- golint
85-
- scopelint
86-
- interfacer
8764
- gosec
8865
- bodyclose
8966
- dogsled
@@ -93,17 +70,14 @@ linters:
9370
- gochecknoinits
9471
- gocognit
9572
- godox
96-
- goerr113 # can't switch to errors.Is due to GopherJS still on go1.12
97-
- gomnd
9873
- lll
99-
- maligned
10074
- nestif
10175
- prealloc
10276
- stylecheck
10377
- whitespace
10478
- wsl
105-
- execinquery
10679
- ireturn
80+
- err113
10781
- wrapcheck
10882
- varnamelen
10983
- tagliatelle
@@ -112,12 +86,10 @@ linters:
11286
- noctx
11387
- nlreturn
11488
- cyclop
115-
- ifshort
11689
- exhaustive
11790
- nilnil
11891
- nilerr
11992
- forcetypeassert
120-
- exhaustivestruct
12193
- exhaustruct
12294
- maintidx
12395
- errorlint
@@ -128,19 +100,16 @@ linters:
128100
- makezero
129101
- nolintlint
130102
- gocyclo
131-
- nosnakecase
132103
- interfacebloat
133104
- revive
134105
- musttag
135-
- structcheck
136-
- deadcode
137-
- varcheck
138106
- depguard
139107
- protogetter
140108
- gosmopolitan
141109
- inamedparam
142110
# could not find a way to disable float-compare: https://github.com/golangci/golangci-lint/issues/4187
143111
- testifylint
112+
- mnd
144113
disable-all: false
145114

146115
issues:

api/bootloader/device_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ func TestVersions(t *testing.T) {
126126
"x\x00aaaaaaaa", // wrong cmd, good len
127127
"v\x01aaaaaaaa", // wrong op status
128128
} {
129-
testResponse := testResponse
130129
env.communication.query = func([]byte) ([]byte, error) {
131130
return []byte(testResponse), nil
132131
}
@@ -149,7 +148,6 @@ func TestGetHashes(t *testing.T) {
149148
{true, false, "h\x01\x00"},
150149
{true, true, "h\x01\x01"},
151150
} {
152-
test := test
153151
t.Run("happy", func(t *testing.T) {
154152
h1 := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
155153
h2 := "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
@@ -279,7 +277,7 @@ func TestUpgradeFirmware(t *testing.T) {
279277
require.Equal(t, []byte("ed"), msg)
280278

281279
// flash chunks
282-
for chunkIndex := 0; chunkIndex < numChunks; chunkIndex++ {
280+
for chunkIndex := range numChunks {
283281
msg, status = takeOne()
284282

285283
require.True(t, status.Upgrading)

api/firmware/device_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func runSimulator(filename string) (func() error, *Device, error) {
5252
}
5353
var conn net.Conn
5454
var err error
55-
for i := 0; i < 200; i++ {
55+
for range 200 {
5656
conn, err = net.Dial("tcp", "localhost:15423")
5757
if err == nil {
5858
break

api/firmware/query.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func (device *Device) rawQueryV7(msg []byte) ([]byte, error) {
9090
device.log.Debug("unexpected NACK response in first loop iteration")
9191
} else {
9292
logStr := "unexpected NACK response; last successful retry query intervals (newest first) were: "
93-
for i := 0; i < lastQueryTimes.Len()-1; i++ {
93+
for range lastQueryTimes.Len() - 1 {
9494
if lastQueryTimes.Value == nil || lastQueryTimes.Prev().Value == nil {
9595
break
9696
}

communication/usart/usart_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ func TestReadWrite(t *testing.T) {
9595

9696
func TestWrite(t *testing.T) {
9797
for _, test := range tests {
98-
test := test
9998
t.Run("", func(t *testing.T) {
10099
buf := new(bytes.Buffer)
101100
err := usart.NewCommunication(
@@ -110,7 +109,6 @@ func TestWrite(t *testing.T) {
110109

111110
func TestRead(t *testing.T) {
112111
for _, test := range tests {
113-
test := test
114112
t.Run("", func(t *testing.T) {
115113
communication := usart.NewCommunication(
116114
&deviceMock{

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/BitBoxSwiss/bitbox02-api-go
22

3-
go 1.21
3+
go 1.22
44

55
require (
66
github.com/benma/miniscript-go v0.0.0-20240226152043-f7c34099edf9

util/semver/semver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func (version *SemVer) String() string {
8181
}
8282

8383
// MarshalJSON implements json.Marshaler.
84-
func (version SemVer) MarshalJSON() ([]byte, error) {
84+
func (version *SemVer) MarshalJSON() ([]byte, error) {
8585
return json.Marshal(version.String())
8686
}
8787

0 commit comments

Comments
 (0)