Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 83568ec

Browse files
author
Ian Campbell
committed
ci: add all default-enabled golangci-lint linters
This adds the enabled by default ones not in the current list. Note that `govet` is a synonym for `vet`, use `govet` since it is the one used in the list. This brings up several issues: internal/commands/cnab_test.go:19:22: Error return value of `dockerCli.Initialize` is not checked (errcheck) dockerCli.Initialize(cliflags.NewClientOptions()) ^ internal/commands/completion.go:183:27: Error return value of `rootCmd.GenBashCompletion` is not checked (errcheck) rootCmd.GenBashCompletion(buf) ^ internal/commands/push.go:186:13: Error return value of `r.out.Write` is not checked (errcheck) r.out.Write(out.Bytes()) ^ internal/commands/root.go:52:17: Error return value of `dockerCli.Apply` is not checked (errcheck) dockerCli.Apply(command.WithCombinedStreams(ioutil.Discard)) ^ internal/commands/root.go:54:18: Error return value of `dockerCli.Apply` is not checked (errcheck) dockerCli.Apply(command.WithOutputStream(stdout), command.WithErrorStream(stderr)) ^ cmd/cnab-run/render.go:42:13: SA1006: printf-style function with dynamic first argument and no further arguments should use print-style function instead (staticcheck) fmt.Printf(res) ^ e2e/commands_test.go:74:3: SA4006: this value of `result` is never used (staticcheck) result = icmd.RunCmd(cmd).Assert(t, icmd.Success) ^ Fix them all. Signed-off-by: Ian Campbell <ijc@docker.com>
1 parent 83e60a2 commit 83568ec

7 files changed

Lines changed: 18 additions & 8 deletions

File tree

.golangci.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,25 @@ linters:
33
disable-all: true
44
enable:
55
- deadcode
6+
- errcheck
67
- gocyclo
78
- gofmt
89
- goimports
910
- golint
1011
- gosimple
12+
- govet
1113
- ineffassign
1214
- interfacer
1315
- lll
1416
- misspell
1517
- nakedret
18+
- staticcheck
19+
- structcheck
20+
- typecheck
1621
- unconvert
1722
- unparam
1823
- unused
19-
- vet
24+
- varcheck
2025
linters-settings:
2126
gocyclo:
2227
min-complexity: 16

cmd/cnab-run/render.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func renderAction(instanceName string) error {
3939
if err != nil {
4040
return err
4141
}
42-
fmt.Printf(res)
42+
fmt.Print(res)
4343

4444
return nil
4545
}

e2e/commands_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func testRenderApp(appPath string, env ...string) func(*testing.T) {
7171
assert.Assert(t, is.Equal(readFile(t, filepath.Join(appPath, "expected.txt")), result.Stdout()), "rendering mismatch")
7272
// Checks rendering to a file
7373
cmd.Command = append(cmd.Command, "--output="+dir.Join("actual.yaml"))
74-
result = icmd.RunCmd(cmd).Assert(t, icmd.Success)
74+
icmd.RunCmd(cmd).Assert(t, icmd.Success)
7575

7676
assert.Assert(t, is.Equal(readFile(t, filepath.Join(appPath, "expected.txt")), readFile(t, dir.Join("actual.yaml"))), "rendering mismatch")
7777
}

internal/commands/cnab_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ import (
1616
func TestRequiresBindMount(t *testing.T) {
1717
dockerCli, err := command.NewDockerCli()
1818
assert.NilError(t, err)
19-
dockerCli.Initialize(cliflags.NewClientOptions())
19+
err = dockerCli.Initialize(cliflags.NewClientOptions())
20+
assert.NilError(t, err)
2021

2122
testCases := []struct {
2223
name string

internal/commands/completion.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,9 @@ _complete dockerapp 2>/dev/null
180180
func runCompletionZsh(out io.Writer, rootCmd *cobra.Command) error {
181181
fmt.Fprint(out, zshHead)
182182
buf := new(bytes.Buffer)
183-
rootCmd.GenBashCompletion(buf)
183+
if err := rootCmd.GenBashCompletion(buf); err != nil {
184+
return err
185+
}
184186
fmt.Fprint(out, buf.String())
185187
fmt.Fprint(out, zshTail)
186188
return nil

internal/commands/push.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ func (r *interactiveDisplay) onEvent(ev remotes.FixupEvent) {
183183
for _, s := range r.images {
184184
r.previousLineCount += s.print(out)
185185
}
186-
r.out.Write(out.Bytes())
186+
// nolint because there is nothing much we can do with an error to write to our output.
187+
r.out.Write(out.Bytes()) //nolint:errcheck
187188
}
188189

189190
func (r *interactiveDisplay) imageIndex(name string) int {

internal/commands/root.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ func firstOrEmpty(list []string) string {
4949
func muteDockerCli(dockerCli command.Cli) func() {
5050
stdout := dockerCli.Out()
5151
stderr := dockerCli.Err()
52-
dockerCli.Apply(command.WithCombinedStreams(ioutil.Discard))
52+
// nolint because WithCombinedStreams cannot error
53+
dockerCli.Apply(command.WithCombinedStreams(ioutil.Discard)) //nolint:errcheck
5354
return func() {
54-
dockerCli.Apply(command.WithOutputStream(stdout), command.WithErrorStream(stderr))
55+
dockerCli.Apply(command.WithOutputStream(stdout), command.WithErrorStream(stderr)) //nolint:errcheck
5556
}
5657
}
5758

0 commit comments

Comments
 (0)