Skip to content

Commit ffb17b9

Browse files
Stopped nolintlint and gofmt from fighting each other
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 dd62b58 commit ffb17b9

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

backend_with_mock.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ func selectBackend(ctx context.Context) interfaces.Backend {
2626
return windows.Backend{}
2727
}
2828

29-
//nolint: forcetypeassert // The panic is expected and welcome
29+
//nolint:forcetypeassert // The panic is expected and welcome
3030
return v.(interfaces.Backend)
3131
}

exec.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func (c *Cmd) Start() (err error) {
145145
go func() {
146146
select {
147147
case <-c.ctx.Done():
148-
//nolint: errcheck // Mimicking behaviour from stdlib
148+
//nolint:errcheck // Mimicking behaviour from stdlib
149149
c.Process.Kill()
150150
// We deviate from the stdlib: "context cancelled" is more useful than "exit code 1"
151151
c.ctxErr = c.ctx.Err()
@@ -178,7 +178,7 @@ func (c *Cmd) Output() (out []byte, err error) {
178178
if err != nil && captureErr {
179179
target := &exec.ExitError{}
180180
if errors.As(err, &target) {
181-
//nolint: forcetypeassert
181+
//nolint:forcetypeassert
182182
// copied from stdlib. We know this to be true because it is set further up in this same function
183183
target.Stderr = c.Stderr.(*prefixSuffixSaver).Bytes()
184184
}

exec_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ print("Your text was", v)
612612
// - In the happy path (all checks pass) we'll have waited on the command already, so
613613
// this second wait is superfluous.
614614
// - If a check fails, we don't really care about any subsequent errors like this one.
615-
defer cmd.Wait() //nolint: errcheck
615+
defer cmd.Wait() //nolint:errcheck
616616

617617
buffer := make([]byte, 1024)
618618

@@ -642,7 +642,7 @@ print("Your text was", v)
642642
require.NoError(t, err, "Unexpected error on command wait")
643643

644644
if tc.readFrom == readFromPipe {
645-
err = stdin.(io.WriteCloser).Close() //nolint: forcetypeassert
645+
err = stdin.(io.WriteCloser).Close() //nolint:forcetypeassert
646646
require.NoError(t, err, "Failed to close stdin pipe multiple times")
647647
}
648648
})

internal/flags/flags.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ const (
1313
// All nolints are regarding the use of UPPPER_CASE.
1414

1515
NONE WslFlags = 0x0
16-
ENABLE_INTEROP WslFlags = 0x1 //nolint: revive
17-
APPEND_NT_PATH WslFlags = 0x2 //nolint: revive
18-
ENABLE_DRIVE_MOUNTING WslFlags = 0x4 //nolint: revive
16+
ENABLE_INTEROP WslFlags = 0x1 //nolint:revive
17+
APPEND_NT_PATH WslFlags = 0x2 //nolint:revive
18+
ENABLE_DRIVE_MOUNTING WslFlags = 0x4 //nolint:revive
1919

2020
// Per the conversation at https://github.com/microsoft/WSL-DistroLauncher/issues/96
2121
// the information about version 1 or 2 is on the 4th bit of the flags, which is
2222
// currently referenced neither by the API nor the documentation.
23-
Undocumented_WSL_VERSION WslFlags = 0x8 //nolint: revive
23+
Undocumented_WSL_VERSION WslFlags = 0x8 //nolint:revive
2424
)

main_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func uniqueDistroName(t *testing.T) string {
8686

8787
// newTestDistro creates and registers a new distro with a mangled name and adds it to list of distros to remove.
8888
//
89-
//nolint: revive // No, I wont' put the context before the *testing.T.
89+
//nolint:revive // No, I wont' put the context before the *testing.T.
9090
func newTestDistro(t *testing.T, ctx context.Context, rootfs string) wsl.Distro {
9191
t.Helper()
9292

@@ -183,7 +183,7 @@ func cleanUpWslInstance(distro wsl.Distro) error {
183183
return nil
184184
}
185185
cmd := fmt.Sprintf("$env:WSL_UTF8=1 ; wsl.exe --unregister %s", distro.Name())
186-
_, err := exec.Command("powershell.exe", "-command", cmd).CombinedOutput() //nolint: gosec
186+
_, err := exec.Command("powershell.exe", "-command", cmd).CombinedOutput() //nolint:gosec
187187
if err != nil {
188188
return fmt.Errorf("failed to clean up test WSL distro %q: %v", distro.Name(), err)
189189
}
@@ -256,7 +256,7 @@ func backUpDefaultDistro() (func(), error) {
256256
return func() {}, nil // No distros registered: no backup needed
257257
}
258258
restore := func() {
259-
//nolint: gosec // G204: Subprocess launched with a potential tainted input or cmd arguments
259+
//nolint:gosec // G204: Subprocess launched with a potential tainted input or cmd arguments
260260
// No threat of code injection, wsl.exe will only interpret this text as a distro name
261261
// and throw Wsl/Service/WSL_E_DISTRO_NOT_FOUND if it does not exist.
262262
out, err := exec.Command("wsl.exe", "--set-default", distro).CombinedOutput()
@@ -289,7 +289,7 @@ func keepAwake(t *testing.T, ctx context.Context, d *wsl.Distro) context.CancelF
289289

290290
return func() {
291291
cancel()
292-
//nolint: errcheck
292+
//nolint:errcheck
293293
// not checking error because it is guaranteed to fail: it can only
294294
// finish by being interrupted. This is the intended behaviour.
295295
cmd.Wait()

registration_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ func TestUnregister(t *testing.T) {
165165
// called in order to deallocate resources. You can call cancel multiple times without
166166
// adverse effect.
167167
//
168-
//nolint: revive // No, I wont' put the context before the *testing.T.
168+
//nolint:revive // No, I wont' put the context before the *testing.T.
169169
func wslShutdownTimeout(t *testing.T, ctx context.Context, timeout time.Duration) (cancel func()) {
170170
t.Helper()
171171

0 commit comments

Comments
 (0)