Skip to content

Commit

Permalink
Merge pull request #14 from keybase/joshblum/revive
Browse files Browse the repository at this point in the history
Add revive linter to golangci-lint
  • Loading branch information
joshblum authored Jan 6, 2025
2 parents 6f00804 + d343e98 commit 93bf3a4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ linters:
- gofmt
- gocritic
- unconvert
- revive
- govet
14 changes: 7 additions & 7 deletions compress.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (c *compressor) collectFrequencies() (ret map[interface{}]int, err error) {
hooks := msgpackDecoderHooks{
mapKeyHook: func(d decodeStack) (decodeStack, error) {
d.hooks = msgpackDecoderHooks{
stringHook: func(l msgpackInt, s string) error {
stringHook: func(_ msgpackInt, s string) error {
if c.collectMapKeys {
ret[s]++
}
Expand All @@ -144,19 +144,19 @@ func (c *compressor) collectFrequencies() (ret map[interface{}]int, err error) {
}
return nil
},
fallthroughHook: func(i interface{}, s string) error {
fallthroughHook: func(i interface{}, _ string) error {
return fmt.Errorf("bad map key (type %T)", i)
},
}
return d, nil
},
stringHook: func(l msgpackInt, s string) error {
stringHook: func(_ msgpackInt, s string) error {
if c.valueWhitelist.hasString(s) {
ret[s]++
}
return nil
},
binaryHook: func(l msgpackInt, b []byte) error {
binaryHook: func(_ msgpackInt, b []byte) error {
s := string(b)
if c.valueWhitelist.hasBinary(b) {
ret[BinaryMapKey(s)]++
Expand Down Expand Up @@ -244,14 +244,14 @@ func (c *compressor) outputData(keys map[interface{}]uint) (output []byte, err e
}
return data.outputRawUint(val)
},
stringHook: func(l msgpackInt, s string) error {
stringHook: func(_ msgpackInt, s string) error {
val, ok := keys[s]
if !ok {
return fmt.Errorf("unexpected map key: %q", s)
}
return data.outputRawUint(val)
},
fallthroughHook: func(i interface{}, s string) error {
fallthroughHook: func(i interface{}, _ string) error {
return fmt.Errorf("bad map key (type %T)", i)
},
}
Expand All @@ -277,7 +277,7 @@ func (c *compressor) outputData(keys map[interface{}]uint) (output []byte, err e
}

// external data types are output and aren't allowed in inputs
hooks.extHook = func(b []byte) error {
hooks.extHook = func(_ []byte) error {
return fmt.Errorf("cannot handle external data types")
}

Expand Down
12 changes: 6 additions & 6 deletions inflate.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (c *inflator) openOuter() (version int, compressedData []byte, compressedKe
idx++
return nil
},
binaryHook: func(i msgpackInt, b []byte) error {
binaryHook: func(_ msgpackInt, b []byte) error {
switch idx {
case 1:
compressedData = b
Expand All @@ -85,7 +85,7 @@ func (c *inflator) openOuter() (version int, compressedData []byte, compressedKe
idx++
return nil
},
fallthroughHook: func(i interface{}, typ string) error {
fallthroughHook: func(_ interface{}, typ string) error {
return fmt.Errorf("unexpected value of type %q at top level", typ)
},
}
Expand Down Expand Up @@ -127,7 +127,7 @@ func (c *inflator) inflateKeymap(compressedKeymap []byte) (keymap map[uint]inter
return nil
}

fallthroughHook := func(i interface{}, typ string) error {
fallthroughHook := func(_ interface{}, typ string) error {
return fmt.Errorf("unexpected value of type %q in keymap", typ)
}

Expand Down Expand Up @@ -165,10 +165,10 @@ func (c *inflator) inflateKeymap(compressedKeymap []byte) (keymap map[uint]inter
}
return putValue(i)
},
stringHook: func(mpi msgpackInt, s string) error {
stringHook: func(_ msgpackInt, s string) error {
return putValue(s)
},
binaryHook: func(mpi msgpackInt, b []byte) error {
binaryHook: func(_ msgpackInt, b []byte) error {
return putValue(BinaryMapKey(string(b)))
},
fallthroughHook: fallthroughHook,
Expand Down Expand Up @@ -234,7 +234,7 @@ func (c *inflator) inflateData(keymap map[uint]interface{}, compressedData []byt
}
return data.outputStringOrUintOrBinary(key)
},
fallthroughHook: func(i interface{}, typ string) error {
fallthroughHook: func(_ interface{}, typ string) error {
return fmt.Errorf("Expected only int map keys; got a %q", typ)
},
}
Expand Down
4 changes: 2 additions & 2 deletions output.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ func (o *outputter) outputStringOrUintOrBinary(i interface{}) error {
}
}

// we we substitue in a binary or string for something in our dictionary,
// we output it as a bigendian integer, prefixed by the "external" byte.
// we we substitute in a binary or string for something in our dictionary,
// we output it as a big endian integer, prefixed by the "external" byte.
func (o *outputter) outputExtUint(u uint) error {
var i interface{}
var b byte
Expand Down

0 comments on commit 93bf3a4

Please sign in to comment.