Skip to content

Commit

Permalink
fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
atoulme committed Apr 28, 2023
1 parent 850de2a commit 12e8aca
Show file tree
Hide file tree
Showing 32 changed files with 93 additions and 74 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/[email protected]
with:
Expand Down
4 changes: 2 additions & 2 deletions clientcfg/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (s *ClientConfigChangerSink) AddEvents(ctx context.Context, events []*event
return s.Destination.AddEvents(ctx, events)
}

func (s *ClientConfigChangerSink) disableCompressionWatch(newValue *distconf.Bool, old bool) {
func (s *ClientConfigChangerSink) disableCompressionWatch(newValue *distconf.Bool, _ bool) {
s.logger.Log("disableCompression watch")
s.mu.Lock()
s.Destination.DisableCompression = newValue.Get()
Expand All @@ -161,7 +161,7 @@ func (s *ClientConfigChangerSink) authTokenWatch(str *distconf.Str, _ string) {

// endpointWatch returns a distconf watch that sets the correct ingest endpoint for a signalfx
// client
func (s *ClientConfigChangerSink) endpointWatch(str *distconf.Str, oldValue string) {
func (s *ClientConfigChangerSink) endpointWatch(str *distconf.Str, _ string) {
s.logger.Log("endpoint watch")
e := str.Get()
if e == "" {
Expand Down
3 changes: 3 additions & 0 deletions datapoint/dpsink/counter.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func (c *Counter) logErrMsg(ctx context.Context, err error, msg string) {
}

// AddDatapoints will send points to the next sink and track points send to the next sink
//
//nolint:dupl
func (c *Counter) AddDatapoints(ctx context.Context, points []*datapoint.Datapoint, next Sink) error {
atomic.AddInt64(&c.TotalDatapoints, int64(len(points)))
Expand All @@ -93,6 +94,7 @@ func (c *Counter) logger() log.Logger {
}

// AddEvents will send events to the next sink and track events sent to the next sink
//
//nolint:dupl
func (c *Counter) AddEvents(ctx context.Context, events []*event.Event, next Sink) error {
atomic.AddInt64(&c.TotalEvents, int64(len(events)))
Expand All @@ -111,6 +113,7 @@ func (c *Counter) AddEvents(ctx context.Context, events []*event.Event, next Sin
}

// AddSpans will send spans to the next sink and track spans sent to the next sink
//
//nolint:dupl
func (c *Counter) AddSpans(ctx context.Context, spans []*trace.Span, next trace.Sink) error {
atomic.AddInt64(&c.TotalSpans, int64(len(spans)))
Expand Down
2 changes: 1 addition & 1 deletion datapoint/dpsink/logfilter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (

type boolFlagCheck bool

func (b *boolFlagCheck) HasFlag(ctx context.Context) bool {
func (b *boolFlagCheck) HasFlag(_ context.Context) bool {
return bool(*b)
}

Expand Down
2 changes: 1 addition & 1 deletion datapoint/dpsink/sink_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (e *expect) next(sendTo Sink) Sink {
}
}

func TestFromChain(t *testing.T) {
func TestFromChain(_ *testing.T) {
e2 := expect{count: 2}
e1 := expect{count: 1}
e0 := expect{count: 0}
Expand Down
1 change: 1 addition & 0 deletions distconf/bool.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type Bool struct {
}

// Update the contents of Bool to the new value
//
//nolint:ifshort
func (s *boolConf) Update(newValue []byte) error {
s.mutex.Lock()
Expand Down
6 changes: 3 additions & 3 deletions distconf/distconf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ type allErrorBacking struct{}

var errNope = errors.New("nope")

func (m *allErrorBacking) Get(key string) ([]byte, error) {
func (m *allErrorBacking) Get(_ string) ([]byte, error) {
return nil, errNope
}

func (m *allErrorBacking) Write(key string, value []byte) error {
func (m *allErrorBacking) Write(_ string, _ []byte) error {
return errNope
}

func (m *allErrorBacking) Watch(key string, callback backingCallbackFunction) error {
func (m *allErrorBacking) Watch(_ string, _ backingCallbackFunction) error {
return errNope
}

Expand Down
1 change: 1 addition & 0 deletions distconf/duration.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func (s *Duration) Get() time.Duration {
}

// Update the contents of Duration to the new value
//
//nolint:ifshort
func (s *durationConf) Update(newValue []byte) error {
s.mutex.Lock()
Expand Down
1 change: 1 addition & 0 deletions distconf/float.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func (c *Float) Get() float64 {
}

// Update the content of this config variable to newValue.
//
//nolint:ifshort
func (c *floatConf) Update(newValue []byte) error {
c.mutex.Lock()
Expand Down
1 change: 1 addition & 0 deletions distconf/int.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func (c *Int) Get() int64 {
}

// Update the content of this config variable to newValue.
//
//nolint:ifshort
func (c *intConf) Update(newValue []byte) error {
c.mutex.Lock()
Expand Down
8 changes: 3 additions & 5 deletions distconf/integration_test.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
//go:build integration
// +build integration

package distconf

import (
"testing"

"time"

"fmt"

"sync/atomic"
"testing"
"time"

"github.com/samuel/go-zookeeper/zk"
"github.com/signalfx/golib/v3/nettest"
Expand Down
14 changes: 7 additions & 7 deletions errors/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ func LogIfErr(err error, l Loggable, msg string, args ...interface{}) {
// DeferLogIfErr will log to l a Printf message if the return value of errCallback is not nil. Intended use
// is during a defer function whos return value you don't really care about.
//
// func Thing() error {
// f, err := os.Open("/tmp/a")
// if err != nil { return Annotate(err, "Cannot open /tmp/a") }
// defer DeferLogIfErr(f.Close, log, "Cannot close file %s", "/tmp/a")
// // Do something with f
// }
// func Thing() error {
// f, err := os.Open("/tmp/a")
// if err != nil { return Annotate(err, "Cannot open /tmp/a") }
// defer DeferLogIfErr(f.Close, log, "Cannot close file %s", "/tmp/a")
// // Do something with f
// }
func DeferLogIfErr(errCallback func() error, l Loggable, msg string, args ...interface{}) {
if err := errCallback(); err != nil {
l.Printf("%s: %s", err.Error(), fmt.Sprintf(msg, args...))
Expand All @@ -37,7 +37,7 @@ func PanicIfErr(err error, msg string, args ...interface{}) {
}

// PanicIfErrWrite is similar to PanicIfErr, but works well with io results that return integer+err
func PanicIfErrWrite(numWritten int, err error) {
func PanicIfErrWrite(_ int, err error) {
if err != nil {
panic(fmt.Sprintf("Write err: %s", err.Error()))
}
Expand Down
8 changes: 4 additions & 4 deletions errors/matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ type Matcher interface {

// Matches is used to wrap the Cause() and is similar to something like:
//
// f, err := do_something()
// if Matches(err, os.IsTimeout) {
// // It was a timeout error somewhere...
// }
// f, err := do_something()
// if Matches(err, os.IsTimeout) {
// // It was a timeout error somewhere...
// }
func Matches(err error, f func(error) bool) bool {
return MatchesI(err, MatcherFunc(f))
}
Expand Down
2 changes: 1 addition & 1 deletion log/counter.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type Counter struct {
var _ Logger = &Counter{}

// Log increments Count
func (c *Counter) Log(keyvals ...interface{}) {
func (c *Counter) Log(_ ...interface{}) {
atomic.AddInt64(&c.Count, 1)
}

Expand Down
2 changes: 1 addition & 1 deletion log/kit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"io/ioutil"
"testing"

"github.com/go-kit/kit/log"
"github.com/go-kit/log"
. "github.com/smartystreets/goconvey/convey"
)

Expand Down
2 changes: 1 addition & 1 deletion log/kitnop_logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/signalfx/golib/v3/log"
)

func TestNopLogger(t *testing.T) {
func TestNopLogger(_ *testing.T) {
logger := log.Discard
logger.Log("abc", 123)
log.NewContext(logger).With("def", "ghi").Log()
Expand Down
2 changes: 1 addition & 1 deletion log/nop.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type nop struct{}
var Discard ErrorHandlingDisableableLogger = nop{}

// Log does nothing
func (n nop) Log(keyvals ...interface{}) {
func (n nop) Log(_ ...interface{}) {
//nolint
return
}
Expand Down
2 changes: 1 addition & 1 deletion logsink/logsink_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type end struct {
count int64
}

func (e *end) AddLogs(ctx context.Context, logs []*Log) error {
func (e *end) AddLogs(_ context.Context, _ []*Log) error {
atomic.AddInt64(&e.count, 1)
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion metadata/aws/ec2metadata/ec2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type requestHandler struct {
response string
}

func (rh *requestHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
func (rh *requestHandler) ServeHTTP(w http.ResponseWriter, _ *http.Request) {
fmt.Fprintf(w, rh.response)
}

Expand Down
4 changes: 2 additions & 2 deletions metadata/hostmetadata/host-not-linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

package hostmetadata

func fillPlatformSpecificOSData(info *OS) error {
func fillPlatformSpecificOSData(_ *OS) error {
return nil
}

func fillPlatformSpecificCPUData(info *CPU) error {
func fillPlatformSpecificCPUData(_ *CPU) error {
return nil
}
2 changes: 1 addition & 1 deletion sfxclient/cumulativebucket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func dpNamed(name string, dps []*datapoint.Datapoint) *datapoint.Datapoint {
return nil
}

func TestCumulativeBucketThreadRaces(t *testing.T) {
func TestCumulativeBucketThreadRaces(_ *testing.T) {
cb := &CumulativeBucket{
MetricName: "mname",
Dimensions: map[string]string{"type": "dev"},
Expand Down
1 change: 1 addition & 0 deletions sfxclient/httpsink.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ func (h *HTTPSink) doBottom(ctx context.Context, f func() (io.Reader, bool, erro
req.Header.Set(k, v)
}
h.setHeadersOnBottom(ctx, req, contentType, compressed)
// nolint:bodyclose
resp, err := h.Client.Do(req)
if err != nil {
// According to docs, resp can be ignored since err is non-nil, so we
Expand Down
3 changes: 3 additions & 0 deletions sfxclient/multitokensink.go
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,7 @@ func (a *AsyncMultiTokenSink) getChannel(input string, size int) (workerID int64
}

// AddDatapointsWithToken emits a list of datapoints using a supplied token
//
//nolint:dupl
func (a *AsyncMultiTokenSink) AddDatapointsWithToken(token string, datapoints []*datapoint.Datapoint) (err error) {
var channelID int64
Expand Down Expand Up @@ -685,6 +686,7 @@ func (a *AsyncMultiTokenSink) AddDatapoints(ctx context.Context, datapoints []*d
}

// AddEventsWithToken emits a list of events using a supplied token
//
//nolint:dupl
func (a *AsyncMultiTokenSink) AddEventsWithToken(token string, events []*event.Event) (err error) {
var channelID int64
Expand Down Expand Up @@ -725,6 +727,7 @@ func (a *AsyncMultiTokenSink) AddEvents(ctx context.Context, events []*event.Eve
}

// AddSpansWithToken emits a list of events using a supplied token
//
//nolint:dupl
func (a *AsyncMultiTokenSink) AddSpansWithToken(token string, spans []*trace.Span) (err error) {
var channelID int64
Expand Down
12 changes: 6 additions & 6 deletions sfxclient/multitokensink_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,39 +71,39 @@ func TestAsyncMultiTokenSinkClose(t *testing.T) {
})
}

func AddDatapointsGetError(ctx context.Context, dps []*datapoint.Datapoint) (err error) {
func AddDatapointsGetError(_ context.Context, _ []*datapoint.Datapoint) (err error) {
err = &SFXAPIError{
StatusCode: http.StatusRequestTimeout,
ResponseBody: "HELLO",
}
return
}

func AddDatapointsGetSuccess(ctx context.Context, dps []*datapoint.Datapoint) (err error) {
func AddDatapointsGetSuccess(_ context.Context, _ []*datapoint.Datapoint) (err error) {
return
}

func AddEventsGetError(ctx context.Context, evs []*event.Event) (err error) {
func AddEventsGetError(_ context.Context, _ []*event.Event) (err error) {
err = &SFXAPIError{
StatusCode: http.StatusRequestTimeout,
ResponseBody: "HELLO",
}
return
}

func AddEventsGetSuccess(ctx context.Context, evs []*event.Event) (err error) {
func AddEventsGetSuccess(_ context.Context, _ []*event.Event) (err error) {
return
}

func AddSpansGetError(ctx context.Context, evs []*trace.Span) (err error) {
func AddSpansGetError(_ context.Context, _ []*trace.Span) (err error) {
err = &SFXAPIError{
StatusCode: http.StatusRequestTimeout,
ResponseBody: "HELLO",
}
return
}

func AddSpansGetSuccess(ctx context.Context, evs []*trace.Span) (err error) {
func AddSpansGetSuccess(_ context.Context, _ []*trace.Span) (err error) {
return
}

Expand Down
2 changes: 1 addition & 1 deletion sfxclient/rollbucket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
. "github.com/smartystreets/goconvey/convey"
)

func TestRollingBucketThreadRaces(t *testing.T) {
func TestRollingBucketThreadRaces(_ *testing.T) {
r := NewRollingBucket("mname", nil)
tk := timekeepertest.NewStubClock(time.Now())
r.Timer = tk
Expand Down
Loading

0 comments on commit 12e8aca

Please sign in to comment.