Skip to content

Commit

Permalink
Add nilness linter from govet (#7335)
Browse files Browse the repository at this point in the history
Seeing @thevilledev adding this in conftest, and thinking we
had it here already. We didn't! Fixing the two issues it reported
where we checked for conditions that couldn't possibly be met.

Signed-off-by: Anders Eknert <anders@styra.com>
  • Loading branch information
anderseknert authored Feb 1, 2025
1 parent 7ddaff2 commit da69c32
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
1 change: 1 addition & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ linters-settings:
govet:
enable:
- deepequalerrors
- nilness
perfsprint:
# only rule disabled by default, but it's a good one
err-error: true
Expand Down
4 changes: 0 additions & 4 deletions cmd/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,6 @@ func parse(args []string, params *parseParams, stdout io.Writer, stderr io.Write

_, _ = fmt.Fprint(stdout, string(bs)+"\n")
default:
if err != nil {
_, _ = fmt.Fprintln(stderr, err)
return 1
}
ast.Pretty(stdout, result.Parsed)
}

Expand Down
4 changes: 3 additions & 1 deletion v1/storage/inmem/inmem.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@ func (db *store) Truncate(ctx context.Context, txn storage.Transaction, params s
}
}

if err != nil && err != io.EOF {
// err is known not to be nil at this point, as it getting assigned
// a non-nil value is the only way the loop above can exit.
if err != io.EOF {
return err
}

Expand Down

0 comments on commit da69c32

Please sign in to comment.