Skip to content

Commit

Permalink
fix: enable nilerr linter and fix iferr checks
Browse files Browse the repository at this point in the history
nilerr finds code which returns nil even though it checks that error is
not nil. This flagged up a few incorrect checks in some of our packet
encoder/decoders, so fix those.
  • Loading branch information
dnwe committed Sep 8, 2021
1 parent 7f53062 commit 4228af2
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ linters:
# - ineffassign
# - misspell
# - nakedret
- nilerr
# - scopelint
- staticcheck
- structcheck
Expand Down
4 changes: 2 additions & 2 deletions alter_configs_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ func (a *AlterConfigsResourceResponse) encode(pe packetEncoder) error {
pe.putInt16(a.ErrorCode)
err := pe.putString(a.ErrorMsg)
if err != nil {
return nil
return err
}
pe.putInt8(int8(a.Type))
err = pe.putString(a.Name)
if err != nil {
return nil
return err
}
return nil
}
Expand Down
6 changes: 3 additions & 3 deletions describe_configs_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,19 +308,19 @@ func (c *ConfigSynonym) encode(pe packetEncoder, version int16) (err error) {
func (c *ConfigSynonym) decode(pd packetDecoder, version int16) error {
name, err := pd.getString()
if err != nil {
return nil
return err
}
c.ConfigName = name

value, err := pd.getString()
if err != nil {
return nil
return err
}
c.ConfigValue = value

source, err := pd.getInt8()
if err != nil {
return nil
return err
}
c.Source = ConfigSource(source)
return nil
Expand Down
2 changes: 1 addition & 1 deletion logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "testing"
// logs of the given T passed from Test functions.
// and records the text in the error log.
//
// nolint

type testLogger struct {
t *testing.T
}
Expand Down

0 comments on commit 4228af2

Please sign in to comment.