Skip to content

Commit f4b5d56

Browse files
committed
lint: bump golangci-lint to v1.63
Enable exptostd, nilnesserr and usetesting linters.
1 parent 6d066aa commit f4b5d56

File tree

7 files changed

+25
-47
lines changed

7 files changed

+25
-47
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ executors:
99
- image: node:22-slim
1010
golangci-lint:
1111
docker:
12-
- image: golangci/golangci-lint:v1.62
12+
- image: golangci/golangci-lint:v1.63
1313
golang-previous:
1414
docker:
1515
- image: golang:1.22

.golangci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ linters:
1616
- errchkjson
1717
- errname
1818
- errorlint
19+
- exptostd
1920
- forcetypeassert
2021
- gochecknoinits
2122
- gocritic
@@ -38,6 +39,7 @@ linters:
3839
- maintidx
3940
- mirror
4041
- misspell
42+
- nilnesserr
4143
- nilnil
4244
- nolintlint
4345
- nonamedreturns
@@ -51,6 +53,7 @@ linters:
5153
- unconvert
5254
- unparam
5355
- unused
56+
- usetesting
5457
- whitespace
5558

5659
linters-settings:

internal/app/siftool/modif_test.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@ func TestApp_New(t *testing.T) {
2121
t.Fatalf("failed to create app: %v", err)
2222
}
2323

24-
tf, err := os.CreateTemp("", "sif-test-*")
24+
tf, err := os.CreateTemp(t.TempDir(), "sif-test-*")
2525
if err != nil {
2626
t.Fatal(err)
2727
}
28-
defer os.Remove(tf.Name())
2928
tf.Close()
3029

3130
if err := a.New(tf.Name()); err != nil {
@@ -94,11 +93,10 @@ func TestApp_Add(t *testing.T) {
9493
}
9594
for _, tt := range tests {
9695
t.Run(tt.name, func(t *testing.T) {
97-
tf, err := os.CreateTemp("", "sif-test-*")
96+
tf, err := os.CreateTemp(t.TempDir(), "sif-test-*")
9897
if err != nil {
9998
t.Fatal(err)
10099
}
101-
defer os.Remove(tf.Name())
102100
tf.Close()
103101

104102
if err := a.New(tf.Name()); err != nil {
@@ -119,11 +117,10 @@ func TestApp_Del(t *testing.T) {
119117
t.Fatalf("failed to create app: %v", err)
120118
}
121119

122-
tf, err := os.CreateTemp("", "sif-test-*")
120+
tf, err := os.CreateTemp(t.TempDir(), "sif-test-*")
123121
if err != nil {
124122
t.Fatal(err)
125123
}
126-
defer os.Remove(tf.Name())
127124
tf.Close()
128125

129126
if err := a.New(tf.Name()); err != nil {
@@ -146,11 +143,10 @@ func TestApp_Setprim(t *testing.T) {
146143
t.Fatalf("failed to create app: %v", err)
147144
}
148145

149-
tf, err := os.CreateTemp("", "sif-test-*")
146+
tf, err := os.CreateTemp(t.TempDir(), "sif-test-*")
150147
if err != nil {
151148
t.Fatal(err)
152149
}
153-
defer os.Remove(tf.Name())
154150
tf.Close()
155151

156152
if err := a.New(tf.Name()); err != nil {

pkg/sif/create_test.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2018-2024, Sylabs Inc. All rights reserved.
1+
// Copyright (c) 2018-2025, Sylabs Inc. All rights reserved.
22
// This software is licensed under a 3-clause BSD license. Please consult the
33
// LICENSE file distributed with the sources of this project regarding your
44
// rights to use or distribute this software.
@@ -9,6 +9,7 @@ import (
99
"errors"
1010
"math"
1111
"os"
12+
"path/filepath"
1213
"testing"
1314
"time"
1415

@@ -272,14 +273,9 @@ func TestCreateContainerAtPath(t *testing.T) {
272273

273274
for _, tt := range tests {
274275
t.Run(tt.name, func(t *testing.T) {
275-
tf, err := os.CreateTemp("", "sif-test-*")
276-
if err != nil {
277-
t.Fatal(err)
278-
}
279-
defer os.Remove(tf.Name())
280-
tf.Close()
276+
path := filepath.Join(t.TempDir(), "sif")
281277

282-
f, err := CreateContainerAtPath(tf.Name(), tt.opts...)
278+
f, err := CreateContainerAtPath(path, tt.opts...)
283279

284280
if got, want := err, tt.wantErr; !errors.Is(got, want) {
285281
t.Fatalf("got error %v, want %v", got, want)
@@ -290,7 +286,7 @@ func TestCreateContainerAtPath(t *testing.T) {
290286
t.Error(err)
291287
}
292288

293-
b, err := os.ReadFile(tf.Name())
289+
b, err := os.ReadFile(path)
294290
if err != nil {
295291
t.Fatal(err)
296292
}

pkg/siftool/new_test.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
// Copyright (c) 2021-2022, Sylabs Inc. All rights reserved.
1+
// Copyright (c) 2021-2025, Sylabs Inc. All rights reserved.
22
// This software is licensed under a 3-clause BSD license. Please consult the
33
// LICENSE file distributed with the sources of this project regarding your
44
// rights to use or distribute this software.
55

66
package siftool
77

88
import (
9-
"os"
9+
"path/filepath"
1010
"testing"
1111
)
1212

@@ -21,18 +21,13 @@ func Test_command_getNew(t *testing.T) {
2121
}
2222
for _, tt := range tests {
2323
t.Run(tt.name, func(t *testing.T) {
24-
tf, err := os.CreateTemp("", "sif-test-*")
25-
if err != nil {
26-
t.Fatal(err)
27-
}
28-
defer os.Remove(tf.Name())
29-
tf.Close()
24+
path := filepath.Join(t.TempDir(), "sif")
3025

3126
c := &command{opts: tt.opts}
3227

3328
cmd := c.getNew()
3429

35-
runCommand(t, cmd, []string{tf.Name()}, nil)
30+
runCommand(t, cmd, []string{path}, nil)
3631
})
3732
}
3833
}

pkg/siftool/siftool_test.go

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2021-2023, Sylabs Inc. All rights reserved.
1+
// Copyright (c) 2021-2025, Sylabs Inc. All rights reserved.
22
// This software is licensed under a 3-clause BSD license. Please consult the
33
// LICENSE file distributed with the sources of this project regarding your
44
// rights to use or distribute this software.
@@ -7,7 +7,6 @@ package siftool
77
import (
88
"bytes"
99
"errors"
10-
"os"
1110
"path/filepath"
1211
"testing"
1312

@@ -21,32 +20,27 @@ var corpus = filepath.Join("..", "..", "test", "images")
2120

2221
//nolint:thelper // Complex enough to justify keeping file/line information on error.
2322
func makeTestSIF(t *testing.T, withDataObject bool) string {
24-
tf, err := os.CreateTemp("", "sif-test-*")
25-
if err != nil {
26-
t.Fatal(err)
27-
}
28-
t.Cleanup(func() { os.Remove(tf.Name()) })
29-
tf.Close()
30-
3123
app, err := siftool.New()
3224
if err != nil {
3325
t.Fatal(err)
3426
}
3527

36-
if err := app.New(tf.Name()); err != nil {
28+
path := filepath.Join(t.TempDir(), "sif")
29+
30+
if err := app.New(path); err != nil {
3731
t.Fatal(err)
3832
}
3933

4034
if withDataObject {
41-
err := app.Add(tf.Name(), sif.DataPartition, bytes.NewReader([]byte{0xde, 0xad, 0xbe, 0xef}),
35+
err := app.Add(path, sif.DataPartition, bytes.NewReader([]byte{0xde, 0xad, 0xbe, 0xef}),
4236
sif.OptPartitionMetadata(sif.FsSquash, sif.PartSystem, "386"),
4337
)
4438
if err != nil {
4539
t.Fatal(err)
4640
}
4741
}
4842

49-
return tf.Name()
43+
return path
5044
}
5145

5246
//nolint:unparam

pkg/user/unmount_test.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2022, Sylabs Inc. All rights reserved.
1+
// Copyright (c) 2022-2025, Sylabs Inc. All rights reserved.
22
// This software is licensed under a 3-clause BSD license. Please consult the
33
// LICENSE file distributed with the sources of this project regarding your
44
// rights to use or distribute this software.
@@ -28,13 +28,7 @@ func Test_Unmount(t *testing.T) {
2828
t.Skip(" not found, skipping mount tests")
2929
}
3030

31-
path, err := os.MkdirTemp("", "siftool-mount-*")
32-
if err != nil {
33-
t.Fatal(err)
34-
}
35-
t.Cleanup(func() {
36-
os.RemoveAll(path)
37-
})
31+
path := t.TempDir()
3832

3933
tests := []struct {
4034
name string

0 commit comments

Comments
 (0)