Skip to content

Commit 4228af2

Browse files
committed
fix: enable nilerr linter and fix iferr checks
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.
1 parent 7f53062 commit 4228af2

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

.golangci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ linters:
5757
# - ineffassign
5858
# - misspell
5959
# - nakedret
60+
- nilerr
6061
# - scopelint
6162
- staticcheck
6263
- structcheck

alter_configs_response.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ func (a *AlterConfigsResourceResponse) encode(pe packetEncoder) error {
6161
pe.putInt16(a.ErrorCode)
6262
err := pe.putString(a.ErrorMsg)
6363
if err != nil {
64-
return nil
64+
return err
6565
}
6666
pe.putInt8(int8(a.Type))
6767
err = pe.putString(a.Name)
6868
if err != nil {
69-
return nil
69+
return err
7070
}
7171
return nil
7272
}

describe_configs_response.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -308,19 +308,19 @@ func (c *ConfigSynonym) encode(pe packetEncoder, version int16) (err error) {
308308
func (c *ConfigSynonym) decode(pd packetDecoder, version int16) error {
309309
name, err := pd.getString()
310310
if err != nil {
311-
return nil
311+
return err
312312
}
313313
c.ConfigName = name
314314

315315
value, err := pd.getString()
316316
if err != nil {
317-
return nil
317+
return err
318318
}
319319
c.ConfigValue = value
320320

321321
source, err := pd.getInt8()
322322
if err != nil {
323-
return nil
323+
return err
324324
}
325325
c.Source = ConfigSource(source)
326326
return nil

logger_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import "testing"
66
// logs of the given T passed from Test functions.
77
// and records the text in the error log.
88
//
9-
// nolint
9+
1010
type testLogger struct {
1111
t *testing.T
1212
}

0 commit comments

Comments
 (0)