Skip to content

Commit

Permalink
integration-cli: SA5011: possible nil pointer dereference (staticcheck)
Browse files Browse the repository at this point in the history
I think the original intent here was to make passing t optional (62a856e),
but it looks like that's not done anywhere, so let's remove it.

    integration-cli/docker_utils_test.go:81:2: SA5011: possible nil pointer dereference (staticcheck)
        c.Helper()
        ^
    integration-cli/docker_utils_test.go:84:5: SA5011(related information): this check suggests that the pointer can be nil (staticcheck)
        if c != nil {
           ^
    integration-cli/docker_utils_test.go:106:2: SA5011: possible nil pointer dereference (staticcheck)
        c.Helper()
        ^
    integration-cli/docker_utils_test.go:108:5: SA5011(related information): this check suggests that the pointer can be nil (staticcheck)
        if c != nil {
           ^
    integration-cli/docker_utils_test.go:116:2: SA5011: possible nil pointer dereference (staticcheck)
        c.Helper()
        ^
    integration-cli/docker_utils_test.go:118:5: SA5011(related information): this check suggests that the pointer can be nil (staticcheck)
        if c != nil {
           ^
    integration-cli/docker_utils_test.go:126:2: SA5011: possible nil pointer dereference (staticcheck)
        c.Helper()
        ^
    integration-cli/docker_utils_test.go:128:5: SA5011(related information): this check suggests that the pointer can be nil (staticcheck)
        if c != nil {
           ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
  • Loading branch information
thaJeztah committed Feb 8, 2022
1 parent 85ed9b8 commit 89f63f4
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions integration-cli/docker_utils_test.go
Expand Up @@ -81,9 +81,7 @@ func inspectFieldAndUnmarshall(c *testing.T, name, field string, output interfac
c.Helper()
str := inspectFieldJSON(c, name, field)
err := json.Unmarshal([]byte(str), output)
if c != nil {
assert.Assert(c, err == nil, "failed to unmarshal: %v", err)
}
assert.Assert(c, err == nil, "failed to unmarshal: %v", err)
}

// Deprecated: use cli.Inspect
Expand All @@ -105,29 +103,23 @@ func inspectFieldWithError(name, field string) (string, error) {
func inspectField(c *testing.T, name, field string) string {
c.Helper()
out, err := inspectFilter(name, fmt.Sprintf(".%s", field))
if c != nil {
assert.NilError(c, err)
}
assert.NilError(c, err)
return out
}

// Deprecated: use cli.Inspect
func inspectFieldJSON(c *testing.T, name, field string) string {
c.Helper()
out, err := inspectFilter(name, fmt.Sprintf("json .%s", field))
if c != nil {
assert.NilError(c, err)
}
assert.NilError(c, err)
return out
}

// Deprecated: use cli.Inspect
func inspectFieldMap(c *testing.T, name, path, field string) string {
c.Helper()
out, err := inspectFilter(name, fmt.Sprintf("index .%s %q", path, field))
if c != nil {
assert.NilError(c, err)
}
assert.NilError(c, err)
return out
}

Expand Down

0 comments on commit 89f63f4

Please sign in to comment.