diff --git a/windows-agent/internal/distros/database/database_test.go b/windows-agent/internal/distros/database/database_test.go index 5d82b8961..0295f29d9 100644 --- a/windows-agent/internal/distros/database/database_test.go +++ b/windows-agent/internal/distros/database/database_test.go @@ -33,8 +33,9 @@ const ( badDbFileContents ) -//nolint: tparallel // Subtests are parallel but the test itself is not due to the calls to RegisterDistro. +// +//nolint:tparallel func TestNew(t *testing.T) { ctx := context.Background() if wsl.MockAvailable() { @@ -139,8 +140,9 @@ func TestDatabaseGetAll(t *testing.T) { } } -//nolint: tparallel // Subtests are parallel but the test itself is not due to the calls to RegisterDistro. +// +//nolint:tparallel func TestDatabaseGet(t *testing.T) { ctx := context.Background() if wsl.MockAvailable() { @@ -195,8 +197,9 @@ func TestDatabaseGet(t *testing.T) { } } -//nolint: tparallel // Subtests are parallel but the test itself is not due to the calls to RegisterDistro. +// +//nolint:tparallel func TestDatabaseDump(t *testing.T) { ctx := context.Background() if wsl.MockAvailable() { diff --git a/windows-agent/internal/distros/database/export_test.go b/windows-agent/internal/distros/database/export_test.go index 731862fee..991362e74 100644 --- a/windows-agent/internal/distros/database/export_test.go +++ b/windows-agent/internal/distros/database/export_test.go @@ -15,8 +15,9 @@ func (in SerializableDistro) NewDistro(ctx context.Context, storageDir string) ( // NewSerializableDistro is a wrapper around newSerializableDistro so as to make it accessible to tests. // -// nolint: revive // unexported-return false positive! SerializableDistro is exported, even if it is an alias to an unexported type. +// +//nolint:revive func NewSerializableDistro(d *distro.Distro) SerializableDistro { return newSerializableDistro(d) } diff --git a/windows-agent/internal/distros/database/serializable_distro_test.go b/windows-agent/internal/distros/database/serializable_distro_test.go index f2584bf68..6ba27644f 100644 --- a/windows-agent/internal/distros/database/serializable_distro_test.go +++ b/windows-agent/internal/distros/database/serializable_distro_test.go @@ -70,8 +70,9 @@ func TestSerializableDistroMarshallUnmarshall(t *testing.T) { } } -//nolint: tparallel // Subtests are parallel but the test itself is not due to the calls to RegisterDistro. +// +//nolint:tparallel func TestSerializableDistroNewDistro(t *testing.T) { ctx := context.Background() if wsl.MockAvailable() { diff --git a/windows-agent/internal/distros/distro/distro_test.go b/windows-agent/internal/distros/distro/distro_test.go index 8ba324579..4480d85b8 100644 --- a/windows-agent/internal/distros/distro/distro_test.go +++ b/windows-agent/internal/distros/distro/distro_test.go @@ -246,8 +246,9 @@ func TestKeepAwake(t *testing.T) { } } -// nolint: tparallel // Subtests are parallel but the test itself is not due to the calls to RegisterDistro. +// +//nolint:tparallel func TestWorkerConstruction(t *testing.T) { ctx := context.Background() if wsl.MockAvailable() { @@ -336,8 +337,9 @@ func TestInvalidateIdempotent(t *testing.T) { require.False(t, (*w).stopCalled, "worker Stop should not be called in subsequent invalidations") } -// nolint: tparallel // Subtests are parallel but the test itself is not due to the calls to RegisterDistro. +// +//nolint:tparallel func TestWorkerWrappers(t *testing.T) { ctx := context.Background() if wsl.MockAvailable() { diff --git a/windows-agent/internal/distros/distro/export_test.go b/windows-agent/internal/distros/distro/export_test.go index ae5e541c0..0135bbc60 100644 --- a/windows-agent/internal/distros/distro/export_test.go +++ b/windows-agent/internal/distros/distro/export_test.go @@ -29,8 +29,9 @@ type Identity = identity // GetIdentity returns a reference to the distro's identity. // -// nolint: revive // False positive, Identity is exported. +// +//nolint:revive func (d *Distro) GetIdentity() *Identity { return &d.identity } diff --git a/windows-agent/internal/distros/task/task_test.go b/windows-agent/internal/distros/task/task_test.go index 359fcd43a..ae3b31ec1 100644 --- a/windows-agent/internal/distros/task/task_test.go +++ b/windows-agent/internal/distros/task/task_test.go @@ -35,8 +35,9 @@ func TestRegistry(t *testing.T) { require.ElementsMatch(t, want, got, "registry should contain only the registered tasks") } -//nolint: tparallel // Cannot make test parallel because of BackupRegistry. +// +//nolint:tparallel func TestMarshal(t *testing.T) { task.BackupRegistry(t) task.Register[testTask]() @@ -69,8 +70,9 @@ func TestMarshal(t *testing.T) { } } -//nolint: tparallel // Cannot make test parallel because of BackupRegistry. +// +//nolint:tparallel func TestUnmarshal(t *testing.T) { task.BackupRegistry(t) task.Register[testTask]() @@ -116,8 +118,9 @@ func TestUnmarshal(t *testing.T) { } } -//nolint: tparallel // Cannot make test parallel because of BackupRegistry. +// +//nolint:tparallel func TestMarsallUnmarshall(t *testing.T) { task.BackupRegistry(t) task.Register[testTask]() diff --git a/windows-agent/internal/proservices/wslinstance/wslinstance.go b/windows-agent/internal/proservices/wslinstance/wslinstance.go index c7935c953..73c26b467 100644 --- a/windows-agent/internal/proservices/wslinstance/wslinstance.go +++ b/windows-agent/internal/proservices/wslinstance/wslinstance.go @@ -66,7 +66,7 @@ func (s *Service) Connected(stream agentapi.WSLInstance_ConnectedServer) error { return fmt.Errorf("connection from %q: %v", info.WslName, err) } - //nolint: errcheck // We don't care about this error because we're cleaning up + //nolint:errcheck // We don't care about this error because we're cleaning up defer d.SetConnection(nil) log.Debugf(context.TODO(), "Connection to Linux-side service established") diff --git a/windows-agent/internal/proservices/wslinstance/wslinstance_test.go b/windows-agent/internal/proservices/wslinstance/wslinstance_test.go index 4586d19fd..b70c3f7f3 100644 --- a/windows-agent/internal/proservices/wslinstance/wslinstance_test.go +++ b/windows-agent/internal/proservices/wslinstance/wslinstance_test.go @@ -78,8 +78,9 @@ func (w step) String() string { return fmt.Sprintf("Unknown when (%d)", int(w)) } -// nolint: tparallel // Subtests are parallel but the test itself is not due to the calls to RegisterDistro. +// +//nolint:tparallel func TestConnected(t *testing.T) { ctx := context.Background() if wsl.MockAvailable() { @@ -245,9 +246,10 @@ func TestConnected(t *testing.T) { // testLoggerInterceptor replaces the logging middleware by printing the return // error of Connected to the test Log. // -// nolint: thelper // The logs would be reported to come from the entrails of the GRPC module. It's more helpful to reference this function to // see that it is the middleware reporting. +// +//nolint:thelper func testLoggerInterceptor(t *testing.T) grpc.StreamServerInterceptor { return func(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { if err := handler(srv, stream); err != nil { @@ -286,9 +288,10 @@ func (s *wrappedService) Connected(stream agentapi.WSLInstance_ConnectedServer) // - if ok is true, returnErr is the return value of Connected. // - if ok is false, the wait times out hence Connected has not returned yet. returnedErr is therefore not valid. // -// nolint: revive // Returning the error as first argument is strange but it makes sense here, we mimic the // (value, ok) return type of a map access. +// +//nolint:revive func (s *wrappedService) wait(timeout time.Duration) (returnedErr error, connectedHasReturned bool) { select { case returnedErr = <-s.Errch: @@ -298,8 +301,9 @@ func (s *wrappedService) wait(timeout time.Duration) (returnedErr error, connect } } -// nolint: revive // testing.T should go before context, I won't listen to anyone arguing the contrary. +// +//nolint:revive func serveWSLInstance(t *testing.T, ctx context.Context, srv wrappedService) (server *grpc.Server, address string) { t.Helper() @@ -327,8 +331,9 @@ type wslDistroMock struct { // newWslDistroMock creates a wslDistroMock, establishing a connection to the control stream. // -// nolint: revive // testing.T should go before context, regardless of what these linters say. +// +//nolint:revive func newWslDistroMock(t *testing.T, ctx context.Context, ctrlAddr string) (mock *wslDistroMock) { t.Helper() diff --git a/windows-agent/internal/testutils/wsl.go b/windows-agent/internal/testutils/wsl.go index 0d9a41c16..4088d017d 100644 --- a/windows-agent/internal/testutils/wsl.go +++ b/windows-agent/internal/testutils/wsl.go @@ -37,7 +37,7 @@ func RandomDistroName(t *testing.T) (name string) { testFullNormalized := normalizeName(t, strings.ReplaceAll(t.Name(), "/", "--")) - //nolint: gosec // No need to be cryptographically secure + //nolint:gosec // No need to be cryptographically secure return fmt.Sprintf("%s_%s_%d", testDistroPrefix, testFullNormalized, rand.Uint64()) } diff --git a/windows-agent/internal/testutils/wsl_windows.go b/windows-agent/internal/testutils/wsl_windows.go index a1fe7c5c0..5ef668669 100644 --- a/windows-agent/internal/testutils/wsl_windows.go +++ b/windows-agent/internal/testutils/wsl_windows.go @@ -58,7 +58,7 @@ func powershellOutputf(t *testing.T, command string, args ...any) string { cmd := fmt.Sprintf(command, args...) - //nolint: gosec // This function is only used in tests so no arbitrary code execution here + //nolint:gosec // This function is only used in tests so no arbitrary code execution here out, err := exec.Command("powershell", "-Command", cmd).CombinedOutput() require.NoError(t, err, "Non-zero return code for command:\n%s\nOutput:%s", cmd, out) diff --git a/wsl-pro-service/internal/systeminfo/systeminfo.go b/wsl-pro-service/internal/systeminfo/systeminfo.go index 785b247cd..b07529395 100644 --- a/wsl-pro-service/internal/systeminfo/systeminfo.go +++ b/wsl-pro-service/internal/systeminfo/systeminfo.go @@ -47,7 +47,7 @@ func fillOsRelease(info *agentapi.DistroInfo) error { } var marshaller struct { - //nolint: revive + //nolint:revive // ini mapper is strict with naming, so we cannot rename Id -> ID as the linter suggests Id, VersionId, PrettyName string }