Skip to content

Commit 932f5ae

Browse files
committed
Resolve lint warnings for golangci-lint v1.64.2
Signed-off-by: Austin Vazquez <[email protected]>
1 parent 2ba7026 commit 932f5ae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+147
-143
lines changed

.golangci.yml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ linters:
55
disable-all: true
66
enable:
77
- govet
8+
- copyloopvar
89
- staticcheck
9-
# - unused
1010
- gosimple
1111
- ineffassign
1212
- typecheck
@@ -19,15 +19,29 @@ linters:
1919
- gocritic
2020
- gofmt
2121
- revive
22-
- exportloopref
2322

2423
issues:
2524
exclude-use-default: false
2625
exclude:
2726
- G104 # Errors unhandled
2827
- G103 # Use of unsafe calls should be audited
28+
- G114 # Use of net/http serve function without timeouts.
29+
- G115 # Integer overflow conversion should be audited
2930
- G204 # Subprocess launched with variable
31+
- G301 # Expect directory permissions to be 0750 or less
3032
- G304 # Potential file inclusion via variable
3133
- G306 # WriteFile permissions 0600 or less to be audited
3234
- G307 # Deferring unsafe method "Close" on type "*os.File" to be audited
33-
-
35+
- G404 # Use of weak random number generator
36+
exclude-rules:
37+
- linters:
38+
- govet
39+
text: "copylocks"
40+
- linters:
41+
- revive
42+
text: package-comments
43+
- linters:
44+
- staticcheck
45+
text: "Do not rely on the global seed"
46+
exclude-dirs:
47+
- snapshotter/internal/integtest/stargz # Code copied from upstream stargz

agent/drive_handler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ import (
2121
"strings"
2222
"time"
2323

24-
"github.com/containerd/containerd/log"
2524
"github.com/containerd/containerd/mount"
2625
"github.com/containerd/containerd/protobuf/types"
26+
"github.com/containerd/log"
2727
"github.com/firecracker-microvm/firecracker-containerd/internal"
2828
drivemount "github.com/firecracker-microvm/firecracker-containerd/proto/service/drivemount/ttrpc"
2929
)
@@ -214,7 +214,7 @@ func (dh driveHandler) MountDrive(ctx context.Context, req *drivemount.MountDriv
214214
return nil, fmt.Errorf("exhausted retries mounting drive from %q to %q", drive.Path(), req.DestinationPath)
215215
}
216216

217-
func (dh driveHandler) UnmountDrive(ctx context.Context, req *drivemount.UnmountDriveRequest) (*types.Empty, error) {
217+
func (dh driveHandler) UnmountDrive(_ context.Context, req *drivemount.UnmountDriveRequest) (*types.Empty, error) {
218218
drive, ok := dh.GetDrive(req.DriveID)
219219
if !ok {
220220
return nil, fmt.Errorf("drive %q could not be found", req.DriveID)

agent/error_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ func TestIsRetryableMountError(t *testing.T) {
5555
}
5656

5757
for _, c := range cases {
58-
c := c // see https://github.com/kyoh86/scopelint/issues/4
5958
t.Run(c.Name, func(t *testing.T) {
6059
assert.Equal(t, c.Expected, isRetryableMountError(c.Error))
6160
})

agent/ioproxy_handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ import (
1717
"context"
1818

1919
task "github.com/containerd/containerd/api/runtime/task/v2"
20-
"github.com/containerd/containerd/log"
2120
"github.com/containerd/containerd/protobuf/types"
21+
"github.com/containerd/log"
2222
"github.com/firecracker-microvm/firecracker-containerd/internal/vm"
2323
ioproxy "github.com/firecracker-microvm/firecracker-containerd/proto/service/ioproxy/ttrpc"
2424
)

agent/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ import (
2323

2424
taskAPI "github.com/containerd/containerd/api/runtime/task/v2"
2525
"github.com/containerd/containerd/events/exchange"
26-
"github.com/containerd/containerd/log"
2726
"github.com/containerd/containerd/namespaces"
2827
"github.com/containerd/containerd/sys/reaper"
28+
"github.com/containerd/log"
2929
"github.com/containerd/ttrpc"
3030
"github.com/firecracker-microvm/firecracker-go-sdk/vsock"
3131
"github.com/opencontainers/runc/libcontainer/system"

agent/service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ import (
2525
taskAPI "github.com/containerd/containerd/api/runtime/task/v2"
2626
"github.com/containerd/containerd/cio"
2727
"github.com/containerd/containerd/identifiers"
28-
"github.com/containerd/containerd/log"
2928
"github.com/containerd/containerd/mount"
3029
"github.com/containerd/containerd/protobuf/types"
3130
runc "github.com/containerd/containerd/runtime/v2/runc/v2"
3231
"github.com/containerd/containerd/runtime/v2/shim"
32+
"github.com/containerd/log"
3333
"github.com/hashicorp/go-multierror"
3434
"github.com/sirupsen/logrus"
3535
"golang.org/x/sys/unix"

eventbridge/eventbridge.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func (s *getterService) GetEvent(ctx context.Context) (*eventapi.Envelope, error
8989
// RegisterGetterService adds the Getter service as a method to the provided TTRPC server.
9090
func RegisterGetterService(srv *ttrpc.Server, svc Getter) {
9191
srv.Register(getterServiceName, map[string]ttrpc.Method{
92-
getEventMethodName: func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) {
92+
getEventMethodName: func(ctx context.Context, _ func(any) error) (any, error) {
9393
return svc.GetEvent(ctx)
9494
},
9595
})

eventbridge/eventbridge_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,13 @@ func verifyPublishAndReceive(ctx context.Context, t *testing.T, source eventtype
7979
topic := "/just/container/things"
8080
sinkEventCh, sinkErrorCh := sink.Subscribe(ctx, fmt.Sprintf(`topic=="%s"`, topic))
8181

82-
for i := 0; i < 100; i++ {
82+
const taskLimit uint32 = 100
83+
for i := range taskLimit {
8384
taskExitEvent := &events.TaskExit{
8485
ContainerID: fmt.Sprintf("container-%d", i),
8586
ID: fmt.Sprintf("id-%d", i),
86-
Pid: uint32(i),
87-
ExitStatus: uint32(i + 1),
87+
Pid: i,
88+
ExitStatus: i + 1,
8889
ExitedAt: protobuf.ToTimestamp(time.Now().UTC()),
8990
}
9091

examples/cmd/remote-snapshotter/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ require (
4848
golang.org/x/mod v0.18.0 // indirect
4949
golang.org/x/net v0.33.0 // indirect
5050
golang.org/x/sync v0.10.0 // indirect
51-
golang.org/x/sys v0.28.0 // indirect
51+
golang.org/x/sys v0.31.0 // indirect
5252
golang.org/x/text v0.21.0 // indirect
5353
golang.org/x/tools v0.22.0 // indirect
5454
google.golang.org/genproto v0.0.0-20240123012728-ef4313101c80 // indirect

examples/cmd/remote-snapshotter/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,8 +1167,8 @@ golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBc
11671167
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
11681168
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
11691169
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
1170-
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
1171-
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
1170+
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
1171+
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
11721172
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
11731173
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
11741174
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=

0 commit comments

Comments
 (0)