Skip to content

Commit 0bc1359

Browse files
committed
Update golangci-lint to 1.64.6 and update code to conform
1 parent ff5aa4c commit 0bc1359

File tree

12 files changed

+31
-42
lines changed

12 files changed

+31
-42
lines changed

Diff for: .golangci.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# v1.63.4
1+
# v1.64.6
22
# Please don't remove the first line. It uses in CI to determine the golangci version
33
run:
44
timeout: 5m
@@ -65,6 +65,8 @@ linters-settings:
6565
# Forbid everything in syscall except the uppercase constants
6666
- '^syscall\.[^A-Z_]+$(# Using anything except constants from the syscall package is forbidden )?'
6767
- '^logrus\.Logger$'
68+
usetesting:
69+
os-setenv: true
6870

6971
linters:
7072
disable-all: true
@@ -84,7 +86,6 @@ linters:
8486
- errname
8587
- errorlint
8688
- exhaustive
87-
- exportloopref
8889
- fatcontext
8990
- forbidigo
9091
- forcetypeassert
@@ -125,13 +126,13 @@ linters:
125126
- sqlclosecheck
126127
- staticcheck
127128
- stylecheck
128-
- tenv
129129
- tparallel
130130
- typecheck
131131
- unconvert
132132
- unparam
133133
- unused
134134
- usestdlibvars
135+
- usetesting
135136
- wastedassign
136137
- whitespace
137138
fast: false

Diff for: internal/js/bundle_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -687,8 +687,7 @@ func TestOpen(t *testing.T) {
687687
return fs, "", func() {}
688688
},
689689
"OsFS": func() (fsext.Fs, string, func()) {
690-
prefix, err := os.MkdirTemp("", "k6_open_test") //nolint:forbidigo
691-
require.NoError(t, err)
690+
prefix := t.TempDir()
692691
fs := fsext.NewOsFs()
693692
filePath := filepath.Join(prefix, "/path/to/file.txt")
694693
require.NoError(t, fs.MkdirAll(filepath.Join(prefix, "/path/to"), 0o755))

Diff for: internal/js/console_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ func TestFileConsole(t *testing.T) {
375375
msg, deleteFile := msg, deleteFile
376376
t.Run(msg, func(t *testing.T) {
377377
t.Parallel()
378-
f, err := os.CreateTemp("", "") //nolint:forbidigo // fix with https://github.com/grafana/k6/issues/2565
378+
f, err := os.CreateTemp(t.TempDir(), "") //nolint:forbidigo // fix with https://github.com/grafana/k6/issues/2565
379379
require.NoError(t, err)
380380
logFilename := f.Name()
381381
defer os.Remove(logFilename) //nolint:errcheck,forbidigo // fix with https://github.com/grafana/k6/issues/2565

Diff for: internal/js/modules/k6/browser/browser/registry_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ func TestBrowserRegistry(t *testing.T) {
290290

291291
vu := k6test.NewVU(t)
292292
var cancel context.CancelFunc
293-
vu.CtxField, cancel = context.WithCancel(vu.CtxField) //nolint:fatcontext
293+
vu.CtxField, cancel = context.WithCancel(vu.CtxField)
294294
browserRegistry := newBrowserRegistry(context.Background(), vu, remoteRegistry, &pidRegistry{}, nil)
295295

296296
vu.ActivateVU()

Diff for: internal/js/modules/k6/browser/common/browser_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ func TestBrowserNewPageInContext(t *testing.T) {
171171
}
172172

173173
var cancel func()
174-
tc.b.vuCtx, cancel = context.WithCancel(tc.b.vuCtx) //nolint:fatcontext
174+
tc.b.vuCtx, cancel = context.WithCancel(tc.b.vuCtx)
175175
// let newPageInContext return a context cancelation error by canceling the context before
176176
// running the method.
177177
cancel()

Diff for: internal/js/modules/k6/browser/common/element_handle.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ func (h *ElementHandle) selectOption(apiCtx context.Context, values []any) (any,
565565
forceCallable: true,
566566
returnByValue: false,
567567
}
568-
result, err := h.evalWithScript(apiCtx, opts, fn, values) //nolint:asasalint
568+
result, err := h.evalWithScript(apiCtx, opts, fn, values)
569569
if err != nil {
570570
return nil, err
571571
}

Diff for: internal/js/modules/k6/browser/storage/storage_test.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ func TestDirMake(t *testing.T) {
1818
t.Run("dir_provided", func(t *testing.T) {
1919
t.Parallel()
2020

21-
dir, err := os.MkdirTemp("", "*") //nolint:forbidigo
22-
require.NoError(t, err)
23-
t.Cleanup(func() { _ = os.RemoveAll(dir) }) //nolint:forbidigo
21+
dir := t.TempDir()
2422

2523
var s Dir
2624
require.NoError(t, s.Make("", dir))

Diff for: internal/js/modules/k6/browser/tests/browser_test.go

+3-18
Original file line numberDiff line numberDiff line change
@@ -76,23 +76,15 @@ func TestBrowserNewContext(t *testing.T) {
7676
func TestTmpDirCleanup(t *testing.T) {
7777
t.Parallel()
7878

79-
tmpDirPath, err := os.MkdirTemp("./", "") //nolint:forbidigo
80-
t.Cleanup(
81-
func() {
82-
err := os.RemoveAll(tmpDirPath) //nolint:forbidigo
83-
require.NoError(t, err)
84-
},
85-
)
86-
require.NoError(t, err)
79+
tmpDirPath := t.TempDir()
8780

8881
b := newTestBrowser(
8982
t,
9083
withSkipClose(),
9184
withEnvLookup(env.ConstLookup("TMPDIR", tmpDirPath)),
9285
)
9386
p := b.NewPage(nil)
94-
err = p.Close()
95-
require.NoError(t, err)
87+
require.NoError(t, p.Close())
9688

9789
matches, err := filepath.Glob(filepath.Join(tmpDirPath, storage.K6BrowserDataDirPattern))
9890
assert.NoError(t, err)
@@ -119,14 +111,7 @@ func TestTmpDirCleanup(t *testing.T) {
119111
func TestTmpDirCleanupOnContextClose(t *testing.T) {
120112
t.Parallel()
121113

122-
tmpDirPath, err := os.MkdirTemp("./", "") //nolint:forbidigo
123-
t.Cleanup(
124-
func() {
125-
err := os.RemoveAll(tmpDirPath) //nolint:forbidigo
126-
require.NoError(t, err)
127-
},
128-
)
129-
require.NoError(t, err)
114+
tmpDirPath := t.TempDir()
130115

131116
b := newTestBrowser(
132117
t,

Diff for: internal/js/modules/k6/experimental/fs/file.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ var _ io.Reader = (*file)(nil)
8282
//
8383
// When using SeekModeStart, the offset must be positive.
8484
// Negative offsets are allowed when using `SeekModeCurrent` or `SeekModeEnd`.
85-
func (f *file) Seek(offset int64, whence SeekMode) (int64, error) {
85+
func (f *file) Seek(offset int64, whence SeekMode) (int64, error) { //nolint:govet
8686
startingOffset := f.offset.Load()
8787

8888
newOffset := startingOffset

Diff for: internal/js/modules/k6/experimental/websockets/blob.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func (r *WebSocketsAPI) fillData(b *blob, blobParts []interface{}, call sobek.Co
123123
obj := call.Arguments[0].ToObject(rt).Get(strconv.FormatInt(int64(n), 10)).ToObject(rt)
124124
switch {
125125
case isDataView(obj, rt):
126-
_, err = b.data.Write(obj.Get("buffer").Export().(sobek.ArrayBuffer).Bytes())
126+
_, err = b.data.Write(obj.Get("buffer").Export().(sobek.ArrayBuffer).Bytes()) //nolint:forcetypeassert
127127
case isBlob(obj, r.blobConstructor):
128128
_, err = b.data.Write(extractBytes(obj, rt))
129129
default:

Diff for: internal/lib/testutils/httpmultibin/grpc_wrappers_testing/service.go

+16-9
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@ import (
1212
//go:generate protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative test.proto
1313

1414
// Register registers a test service that could be used for the testing gRPC wrappers
15-
func Register(r grpc.ServiceRegistrar) *service { //nolint:revive // this is a test service
16-
s := &service{}
15+
func Register(r grpc.ServiceRegistrar) *Service {
16+
s := &Service{}
1717

1818
RegisterServiceServer(r, s)
1919

2020
return s
2121
}
2222

23-
type service struct {
23+
// Service is the test service for different grpc values and how they are handled
24+
type Service struct {
2425
UnimplementedServiceServer
2526

2627
TestStringImplementation func(context.Context, *wrappers.StringValue) (*wrappers.StringValue, error)
@@ -31,47 +32,53 @@ type service struct {
3132
TestStreamImplementation func(Service_TestStreamServer) error
3233
}
3334

34-
func (s *service) TestString(ctx context.Context, in *wrappers.StringValue) (*wrappers.StringValue, error) {
35+
// TestString is getting and returning a string value
36+
func (s *Service) TestString(ctx context.Context, in *wrappers.StringValue) (*wrappers.StringValue, error) {
3537
if s.TestStringImplementation != nil {
3638
return s.TestStringImplementation(ctx, in)
3739
}
3840

3941
return s.UnimplementedServiceServer.TestString(ctx, in)
4042
}
4143

42-
func (s *service) TestInteger(ctx context.Context, in *wrappers.Int64Value) (*wrappers.Int64Value, error) {
44+
// TestInteger is getting and returning a integer value
45+
func (s *Service) TestInteger(ctx context.Context, in *wrappers.Int64Value) (*wrappers.Int64Value, error) {
4346
if s.TestIntegerImplementation != nil {
4447
return s.TestIntegerImplementation(ctx, in)
4548
}
4649

4750
return s.UnimplementedServiceServer.TestInteger(ctx, in)
4851
}
4952

50-
func (s *service) TestBoolean(ctx context.Context, in *wrappers.BoolValue) (*wrappers.BoolValue, error) {
53+
// TestBoolean is getting and returning a boolean value
54+
func (s *Service) TestBoolean(ctx context.Context, in *wrappers.BoolValue) (*wrappers.BoolValue, error) {
5155
if s.TestBooleanImplementation != nil {
5256
return s.TestBooleanImplementation(ctx, in)
5357
}
5458

5559
return s.UnimplementedServiceServer.TestBoolean(ctx, in)
5660
}
5761

58-
func (s *service) TestDouble(ctx context.Context, in *wrappers.DoubleValue) (*wrappers.DoubleValue, error) {
62+
// TestDouble is getting and returning a double value
63+
func (s *Service) TestDouble(ctx context.Context, in *wrappers.DoubleValue) (*wrappers.DoubleValue, error) {
5964
if s.TestDoubleImplementation != nil {
6065
return s.TestDoubleImplementation(ctx, in)
6166
}
6267

6368
return s.UnimplementedServiceServer.TestDouble(ctx, in)
6469
}
6570

66-
func (s *service) TestValue(ctx context.Context, in *_struct.Value) (*_struct.Value, error) {
71+
// TestValue is getting and returning a generic value
72+
func (s *Service) TestValue(ctx context.Context, in *_struct.Value) (*_struct.Value, error) {
6773
if s.TestValueImplementation != nil {
6874
return s.TestValueImplementation(ctx, in)
6975
}
7076

7177
return s.UnimplementedServiceServer.TestValue(ctx, in)
7278
}
7379

74-
func (s *service) TestStream(stream Service_TestStreamServer) error {
80+
// TestStream is testing a stream of values
81+
func (s *Service) TestStream(stream Service_TestStreamServer) error {
7582
if s.TestStreamImplementation != nil {
7683
return s.TestStreamImplementation(stream)
7784
}

Diff for: metrics/builtin.go

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package metrics
22

3-
//nolint:nolintlint // unfortunately it is having a false possitive
43
//nolint:revive
54
const (
65
VUsName = "vus"

0 commit comments

Comments
 (0)