Skip to content

Commit d3ea0b7

Browse files
Unrelated: Fix nolint ping-pong
Nolintlint wants the //nolint directives without a leading space GoFmt wants them with a leading space, ... except if nolint has no space afterwards: // nolint:foo // <-- malformed //nolint :foo // <-- malformed //nolint: foo // <-- malformed //nolint:foo // <-- OK See golangci/golangci-lint#3110 (comment)
1 parent 46f91c2 commit d3ea0b7

File tree

11 files changed

+36
-20
lines changed

11 files changed

+36
-20
lines changed

windows-agent/internal/distros/database/database_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ const (
3333
badDbFileContents
3434
)
3535

36-
//nolint: tparallel
3736
// Subtests are parallel but the test itself is not due to the calls to RegisterDistro.
37+
//
38+
//nolint:tparallel
3839
func TestNew(t *testing.T) {
3940
ctx := context.Background()
4041
if wsl.MockAvailable() {
@@ -139,8 +140,9 @@ func TestDatabaseGetAll(t *testing.T) {
139140
}
140141
}
141142

142-
//nolint: tparallel
143143
// Subtests are parallel but the test itself is not due to the calls to RegisterDistro.
144+
//
145+
//nolint:tparallel
144146
func TestDatabaseGet(t *testing.T) {
145147
ctx := context.Background()
146148
if wsl.MockAvailable() {
@@ -195,8 +197,9 @@ func TestDatabaseGet(t *testing.T) {
195197
}
196198
}
197199

198-
//nolint: tparallel
199200
// Subtests are parallel but the test itself is not due to the calls to RegisterDistro.
201+
//
202+
//nolint:tparallel
200203
func TestDatabaseDump(t *testing.T) {
201204
ctx := context.Background()
202205
if wsl.MockAvailable() {

windows-agent/internal/distros/database/export_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ func (in SerializableDistro) NewDistro(ctx context.Context, storageDir string) (
1515

1616
// NewSerializableDistro is a wrapper around newSerializableDistro so as to make it accessible to tests.
1717
//
18-
// nolint: revive
1918
// unexported-return false positive! SerializableDistro is exported, even if it is an alias to an unexported type.
19+
//
20+
//nolint:revive
2021
func NewSerializableDistro(d *distro.Distro) SerializableDistro {
2122
return newSerializableDistro(d)
2223
}

windows-agent/internal/distros/database/serializable_distro_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ func TestSerializableDistroMarshallUnmarshall(t *testing.T) {
7070
}
7171
}
7272

73-
//nolint: tparallel
7473
// Subtests are parallel but the test itself is not due to the calls to RegisterDistro.
74+
//
75+
//nolint:tparallel
7576
func TestSerializableDistroNewDistro(t *testing.T) {
7677
ctx := context.Background()
7778
if wsl.MockAvailable() {

windows-agent/internal/distros/distro/distro_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,9 @@ func TestKeepAwake(t *testing.T) {
246246
}
247247
}
248248

249-
// nolint: tparallel
250249
// Subtests are parallel but the test itself is not due to the calls to RegisterDistro.
250+
//
251+
//nolint:tparallel
251252
func TestWorkerConstruction(t *testing.T) {
252253
ctx := context.Background()
253254
if wsl.MockAvailable() {
@@ -336,8 +337,9 @@ func TestInvalidateIdempotent(t *testing.T) {
336337
require.False(t, (*w).stopCalled, "worker Stop should not be called in subsequent invalidations")
337338
}
338339

339-
// nolint: tparallel
340340
// Subtests are parallel but the test itself is not due to the calls to RegisterDistro.
341+
//
342+
//nolint:tparallel
341343
func TestWorkerWrappers(t *testing.T) {
342344
ctx := context.Background()
343345
if wsl.MockAvailable() {

windows-agent/internal/distros/distro/export_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ type Identity = identity
2929

3030
// GetIdentity returns a reference to the distro's identity.
3131
//
32-
// nolint: revive
3332
// False positive, Identity is exported.
33+
//
34+
//nolint:revive
3435
func (d *Distro) GetIdentity() *Identity {
3536
return &d.identity
3637
}

windows-agent/internal/distros/task/task_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ func TestRegistry(t *testing.T) {
3535
require.ElementsMatch(t, want, got, "registry should contain only the registered tasks")
3636
}
3737

38-
//nolint: tparallel
3938
// Cannot make test parallel because of BackupRegistry.
39+
//
40+
//nolint:tparallel
4041
func TestMarshal(t *testing.T) {
4142
task.BackupRegistry(t)
4243
task.Register[testTask]()
@@ -69,8 +70,9 @@ func TestMarshal(t *testing.T) {
6970
}
7071
}
7172

72-
//nolint: tparallel
7373
// Cannot make test parallel because of BackupRegistry.
74+
//
75+
//nolint:tparallel
7476
func TestUnmarshal(t *testing.T) {
7577
task.BackupRegistry(t)
7678
task.Register[testTask]()
@@ -116,8 +118,9 @@ func TestUnmarshal(t *testing.T) {
116118
}
117119
}
118120

119-
//nolint: tparallel
120121
// Cannot make test parallel because of BackupRegistry.
122+
//
123+
//nolint:tparallel
121124
func TestMarsallUnmarshall(t *testing.T) {
122125
task.BackupRegistry(t)
123126
task.Register[testTask]()

windows-agent/internal/proservices/wslinstance/wslinstance.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func (s *Service) Connected(stream agentapi.WSLInstance_ConnectedServer) error {
6666
return fmt.Errorf("connection from %q: %v", info.WslName, err)
6767
}
6868

69-
//nolint: errcheck // We don't care about this error because we're cleaning up
69+
//nolint:errcheck // We don't care about this error because we're cleaning up
7070
defer d.SetConnection(nil)
7171

7272
log.Debugf(context.TODO(), "Connection to Linux-side service established")

windows-agent/internal/proservices/wslinstance/wslinstance_test.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ func (w step) String() string {
7878
return fmt.Sprintf("Unknown when (%d)", int(w))
7979
}
8080

81-
// nolint: tparallel
8281
// Subtests are parallel but the test itself is not due to the calls to RegisterDistro.
82+
//
83+
//nolint:tparallel
8384
func TestConnected(t *testing.T) {
8485
ctx := context.Background()
8586
if wsl.MockAvailable() {
@@ -245,9 +246,10 @@ func TestConnected(t *testing.T) {
245246
// testLoggerInterceptor replaces the logging middleware by printing the return
246247
// error of Connected to the test Log.
247248
//
248-
// nolint: thelper
249249
// The logs would be reported to come from the entrails of the GRPC module. It's more helpful to reference this function to
250250
// see that it is the middleware reporting.
251+
//
252+
//nolint:thelper
251253
func testLoggerInterceptor(t *testing.T) grpc.StreamServerInterceptor {
252254
return func(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
253255
if err := handler(srv, stream); err != nil {
@@ -286,9 +288,10 @@ func (s *wrappedService) Connected(stream agentapi.WSLInstance_ConnectedServer)
286288
// - if ok is true, returnErr is the return value of Connected.
287289
// - if ok is false, the wait times out hence Connected has not returned yet. returnedErr is therefore not valid.
288290
//
289-
// nolint: revive
290291
// Returning the error as first argument is strange but it makes sense here, we mimic the
291292
// (value, ok) return type of a map access.
293+
//
294+
//nolint:revive
292295
func (s *wrappedService) wait(timeout time.Duration) (returnedErr error, connectedHasReturned bool) {
293296
select {
294297
case returnedErr = <-s.Errch:
@@ -298,8 +301,9 @@ func (s *wrappedService) wait(timeout time.Duration) (returnedErr error, connect
298301
}
299302
}
300303

301-
// nolint: revive
302304
// testing.T should go before context, I won't listen to anyone arguing the contrary.
305+
//
306+
//nolint:revive
303307
func serveWSLInstance(t *testing.T, ctx context.Context, srv wrappedService) (server *grpc.Server, address string) {
304308
t.Helper()
305309

@@ -327,8 +331,9 @@ type wslDistroMock struct {
327331

328332
// newWslDistroMock creates a wslDistroMock, establishing a connection to the control stream.
329333
//
330-
// nolint: revive
331334
// testing.T should go before context, regardless of what these linters say.
335+
//
336+
//nolint:revive
332337
func newWslDistroMock(t *testing.T, ctx context.Context, ctrlAddr string) (mock *wslDistroMock) {
333338
t.Helper()
334339

windows-agent/internal/testutils/wsl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func RandomDistroName(t *testing.T) (name string) {
3737

3838
testFullNormalized := normalizeName(t, strings.ReplaceAll(t.Name(), "/", "--"))
3939

40-
//nolint: gosec // No need to be cryptographically secure
40+
//nolint:gosec // No need to be cryptographically secure
4141
return fmt.Sprintf("%s_%s_%d", testDistroPrefix, testFullNormalized, rand.Uint64())
4242
}
4343

windows-agent/internal/testutils/wsl_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func powershellOutputf(t *testing.T, command string, args ...any) string {
5858

5959
cmd := fmt.Sprintf(command, args...)
6060

61-
//nolint: gosec // This function is only used in tests so no arbitrary code execution here
61+
//nolint:gosec // This function is only used in tests so no arbitrary code execution here
6262
out, err := exec.Command("powershell", "-Command", cmd).CombinedOutput()
6363
require.NoError(t, err, "Non-zero return code for command:\n%s\nOutput:%s", cmd, out)
6464

wsl-pro-service/internal/systeminfo/systeminfo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func fillOsRelease(info *agentapi.DistroInfo) error {
4747
}
4848

4949
var marshaller struct {
50-
//nolint: revive
50+
//nolint:revive
5151
// ini mapper is strict with naming, so we cannot rename Id -> ID as the linter suggests
5252
Id, VersionId, PrettyName string
5353
}

0 commit comments

Comments
 (0)