Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Fix linter findings for revive:unused-receiver in plugins/: aggregators, common, parsers, processors, secretstores and serializers #16339

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/aggregators/final/final.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (m *Final) Push(acc telegraf.Accumulator) {
}
}

func (m *Final) Reset() {
func (*Final) Reset() {
}

func init() {
Expand Down
4 changes: 2 additions & 2 deletions plugins/aggregators/histogram/histogram.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,12 @@ func (h *HistogramAggregator) groupFieldsByBuckets(
}

sum += count
h.groupField(metricsWithGroupedFields, name, field, sum, copyTags(tags))
groupField(metricsWithGroupedFields, name, field, sum, copyTags(tags))
}
}

// groupField groups field by count value
func (h *HistogramAggregator) groupField(metricsWithGroupedFields *[]groupedByCountFields, name, field string, count int64, tags map[string]string) {
func groupField(metricsWithGroupedFields *[]groupedByCountFields, name, field string, count int64, tags map[string]string) {
for key, metric := range *metricsWithGroupedFields {
if name == metric.name && isTagsIdentical(tags, metric.tags) {
(*metricsWithGroupedFields)[key].fieldsWithCount[field] = count
Expand Down
7 changes: 3 additions & 4 deletions plugins/common/jolokia2/gatherer.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (g *Gatherer) gatherResponses(responses []ReadResponse, tags map[string]str
points = make([]point, 0)
}

responsePoints, responseErrors := g.generatePoints(metric, responses)
responsePoints, responseErrors := generatePoints(metric, responses)
points = append(points, responsePoints...)
for _, err := range responseErrors {
acc.AddError(err)
Expand All @@ -71,9 +71,8 @@ func (g *Gatherer) gatherResponses(responses []ReadResponse, tags map[string]str
}
}

// generatePoints creates points for the supplied metric from the ReadResponse
// objects returned by the Jolokia client.
func (g *Gatherer) generatePoints(metric Metric, responses []ReadResponse) ([]point, []error) {
// generatePoints creates points for the supplied metric from the ReadResponse objects returned by the Jolokia client.
func generatePoints(metric Metric, responses []ReadResponse) ([]point, []error) {
points := make([]point, 0)
errors := make([]error, 0)

Expand Down
4 changes: 2 additions & 2 deletions plugins/common/kafka/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ var (

type debugLogger struct{}

func (l *debugLogger) Print(v ...interface{}) {
func (*debugLogger) Print(v ...interface{}) {
log.Trace(v...)
}

func (l *debugLogger) Printf(format string, v ...interface{}) {
func (*debugLogger) Printf(format string, v ...interface{}) {
log.Tracef(format, v...)
}

Expand Down
4 changes: 2 additions & 2 deletions plugins/common/logrus/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ func InstallHook() {
})
}

func (h *LogHook) Fire(entry *logrus.Entry) error {
func (*LogHook) Fire(entry *logrus.Entry) error {
msg := strings.ReplaceAll(entry.Message, "\n", " ")
log.Print("D! [logrus] ", msg)
return nil
}

func (h *LogHook) Levels() []logrus.Level {
func (*LogHook) Levels() []logrus.Level {
return logrus.AllLevels
}
4 changes: 2 additions & 2 deletions plugins/common/mqtt/mqtt_v5.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,12 @@ func (m *mqttv5Client) Publish(topic string, body []byte) error {
return err
}

func (m *mqttv5Client) SubscribeMultiple(filters map[string]byte, callback paho.MessageHandler) error {
func (*mqttv5Client) SubscribeMultiple(filters map[string]byte, callback paho.MessageHandler) error {
_, _ = filters, callback
panic("not implemented")
}

func (m *mqttv5Client) AddRoute(topic string, callback paho.MessageHandler) {
func (*mqttv5Client) AddRoute(topic string, callback paho.MessageHandler) {
_, _ = topic, callback
panic("not implemented")
}
Expand Down
14 changes: 4 additions & 10 deletions plugins/common/shim/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,28 +66,22 @@ type testDurationInput struct {
Hex int64 `toml:"hex"`
}

func (i *testDurationInput) SampleConfig() string {
func (*testDurationInput) SampleConfig() string {
return ""
}

func (i *testDurationInput) Description() string {
return ""
}
func (i *testDurationInput) Gather(_ telegraf.Accumulator) error {
func (*testDurationInput) Gather(telegraf.Accumulator) error {
return nil
}

type testConfigProcessor struct {
Loaded string `toml:"loaded"`
}

func (p *testConfigProcessor) SampleConfig() string {
func (*testConfigProcessor) SampleConfig() string {
return ""
}

func (p *testConfigProcessor) Description() string {
return ""
}
func (p *testConfigProcessor) Apply(metrics ...telegraf.Metric) []telegraf.Metric {
func (*testConfigProcessor) Apply(metrics ...telegraf.Metric) []telegraf.Metric {
return metrics
}
6 changes: 3 additions & 3 deletions plugins/common/shim/goshim.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func New() *Shim {
}
}

func (s *Shim) watchForShutdown(cancel context.CancelFunc) {
func (*Shim) watchForShutdown(cancel context.CancelFunc) {
quit := make(chan os.Signal, 1)
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
go func() {
Expand Down Expand Up @@ -130,12 +130,12 @@ func (s *Shim) writeProcessedMetrics() error {
}

// LogName satisfies the MetricMaker interface
func (s *Shim) LogName() string {
func (*Shim) LogName() string {
return ""
}

// MakeMetric satisfies the MetricMaker interface
func (s *Shim) MakeMetric(m telegraf.Metric) telegraf.Metric {
func (*Shim) MakeMetric(m telegraf.Metric) telegraf.Metric {
return m // don't need to do anything to it.
}

Expand Down
8 changes: 4 additions & 4 deletions plugins/common/shim/goshim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,18 @@ func runErroringInputPlugin(t *testing.T, interval time.Duration, stdin io.Reade
type erroringInput struct {
}

func (i *erroringInput) SampleConfig() string {
func (*erroringInput) SampleConfig() string {
return ""
}

func (i *erroringInput) Gather(acc telegraf.Accumulator) error {
func (*erroringInput) Gather(acc telegraf.Accumulator) error {
acc.AddError(errors.New("intentional"))
return nil
}

func (i *erroringInput) Start(_ telegraf.Accumulator) error {
func (*erroringInput) Start(telegraf.Accumulator) error {
return nil
}

func (i *erroringInput) Stop() {
func (*erroringInput) Stop() {
}
22 changes: 7 additions & 15 deletions plugins/common/shim/input_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,10 @@ type testInput struct {
metricProcessed chan bool
}

func (i *testInput) SampleConfig() string {
func (*testInput) SampleConfig() string {
return ""
}

func (i *testInput) Description() string {
return "test"
}

func (i *testInput) Gather(acc telegraf.Accumulator) error {
acc.AddFields("measurement",
map[string]interface{}{
Expand All @@ -107,11 +103,11 @@ func (i *testInput) Gather(acc telegraf.Accumulator) error {
return nil
}

func (i *testInput) Start(_ telegraf.Accumulator) error {
func (*testInput) Start(telegraf.Accumulator) error {
return nil
}

func (i *testInput) Stop() {
func (*testInput) Stop() {
}

type serviceInput struct {
Expand All @@ -120,15 +116,11 @@ type serviceInput struct {
SecretValue string `toml:"secret_value"`
}

func (i *serviceInput) SampleConfig() string {
return ""
}

func (i *serviceInput) Description() string {
func (*serviceInput) SampleConfig() string {
return ""
}

func (i *serviceInput) Gather(acc telegraf.Accumulator) error {
func (*serviceInput) Gather(acc telegraf.Accumulator) error {
acc.AddFields("measurement",
map[string]interface{}{
"field": 1,
Expand All @@ -140,9 +132,9 @@ func (i *serviceInput) Gather(acc telegraf.Accumulator) error {
return nil
}

func (i *serviceInput) Start(_ telegraf.Accumulator) error {
func (*serviceInput) Start(telegraf.Accumulator) error {
return nil
}

func (i *serviceInput) Stop() {
func (*serviceInput) Stop() {
}
10 changes: 3 additions & 7 deletions plugins/common/shim/output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,17 @@ type testOutput struct {
MetricsWritten []telegraf.Metric
}

func (o *testOutput) Connect() error {
func (*testOutput) Connect() error {
return nil
}
func (o *testOutput) Close() error {
func (*testOutput) Close() error {
return nil
}
func (o *testOutput) Write(metrics []telegraf.Metric) error {
o.MetricsWritten = append(o.MetricsWritten, metrics...)
return nil
}

func (o *testOutput) SampleConfig() string {
return ""
}

func (o *testOutput) Description() string {
func (*testOutput) SampleConfig() string {
return ""
}
6 changes: 1 addition & 5 deletions plugins/common/shim/processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,6 @@ func (p *testProcessor) Apply(in ...telegraf.Metric) []telegraf.Metric {
return in
}

func (p *testProcessor) SampleConfig() string {
return ""
}

func (p *testProcessor) Description() string {
func (*testProcessor) SampleConfig() string {
return ""
}
6 changes: 3 additions & 3 deletions plugins/common/starlark/field_dict.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (d FieldDict) String() string {
return buf.String()
}

func (d FieldDict) Type() string {
func (FieldDict) Type() string {
return "Fields"
}

Expand All @@ -49,12 +49,12 @@ func (d FieldDict) Truth() starlark.Bool {
return len(d.metric.FieldList()) != 0
}

func (d FieldDict) Hash() (uint32, error) {
func (FieldDict) Hash() (uint32, error) {
return 0, errors.New("not hashable")
}

// AttrNames implements the starlark.HasAttrs interface.
func (d FieldDict) AttrNames() []string {
func (FieldDict) AttrNames() []string {
return builtinAttrNames(FieldDictMethods)
}

Expand Down
8 changes: 4 additions & 4 deletions plugins/common/starlark/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,24 +56,24 @@ func (m *Metric) String() string {
return buf.String()
}

func (m *Metric) Type() string {
func (*Metric) Type() string {
return "Metric"
}

func (m *Metric) Freeze() {
m.frozen = true
}

func (m *Metric) Truth() starlark.Bool {
func (*Metric) Truth() starlark.Bool {
return true
}

func (m *Metric) Hash() (uint32, error) {
func (*Metric) Hash() (uint32, error) {
return 0, errors.New("not hashable")
}

// AttrNames implements the starlark.HasAttrs interface.
func (m *Metric) AttrNames() []string {
func (*Metric) AttrNames() []string {
return []string{"name", "tags", "fields", "time"}
}

Expand Down
6 changes: 3 additions & 3 deletions plugins/common/starlark/tag_dict.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (d TagDict) String() string {
return buf.String()
}

func (d TagDict) Type() string {
func (TagDict) Type() string {
return "Tags"
}

Expand All @@ -47,12 +47,12 @@ func (d TagDict) Truth() starlark.Bool {
return len(d.metric.TagList()) != 0
}

func (d TagDict) Hash() (uint32, error) {
func (TagDict) Hash() (uint32, error) {
return 0, errors.New("not hashable")
}

// AttrNames implements the starlark.HasAttrs interface.
func (d TagDict) AttrNames() []string {
func (TagDict) AttrNames() []string {
return builtinAttrNames(TagDictMethods)
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/parsers/dropwizard/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (p *Parser) Parse(buf []byte) ([]telegraf.Metric, error) {
}

// ParseLine is not supported by the dropwizard format
func (p *Parser) ParseLine(_ string) (telegraf.Metric, error) {
func (*Parser) ParseLine(string) (telegraf.Metric, error) {
return nil, errors.New("parsing line is not supported by the dropwizard format")
}

Expand Down
4 changes: 2 additions & 2 deletions plugins/parsers/form_urlencoded/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (p Parser) Parse(buf []byte) ([]telegraf.Metric, error) {
}

tags := p.extractTags(values)
fields := p.parseFields(values)
fields := parseFields(values)

for key, value := range p.DefaultTags {
tags[key] = value
Expand Down Expand Up @@ -80,7 +80,7 @@ func (p Parser) extractTags(values url.Values) map[string]string {
return tags
}

func (p Parser) parseFields(values url.Values) map[string]interface{} {
func parseFields(values url.Values) map[string]interface{} {
fields := make(map[string]interface{})

for key, value := range values {
Expand Down
Loading
Loading