From aaaa9b49515eb372a0aad871cc5a7fe184b97423 Mon Sep 17 00:00:00 2001 From: Pawel Zak Date: Thu, 5 Sep 2024 23:45:47 +0200 Subject: [PATCH] chore: Fix linter findings for `revive:enforce-repeated-arg-type-style` in `plugins/inputs/[h-n]*` --- .../inputs/http_listener_v2/http_listener_v2_test.go | 2 +- plugins/inputs/http_response/http_response_test.go | 9 +-------- plugins/inputs/hugepages/hugepages.go | 7 +------ plugins/inputs/infiniband/infiniband_linux.go | 2 +- .../influxdb_listener/influxdb_listener_test.go | 2 +- .../influxdb_v2_listener/influxdb_v2_listener_test.go | 2 +- plugins/inputs/intel_pmt/intel_pmt.go | 2 +- plugins/inputs/intel_pmt/intel_pmt_test.go | 2 +- plugins/inputs/intel_pmt/xml_parser.go | 4 ++-- plugins/inputs/intel_pmu/config.go | 4 ++-- plugins/inputs/intel_pmu/intel_pmu.go | 2 +- plugins/inputs/intel_pmu/intel_pmu_test.go | 2 +- plugins/inputs/intel_pmu/resolver.go | 2 +- plugins/inputs/intel_powerstat/intel_powerstat.go | 4 ++-- plugins/inputs/intel_rdt/intel_rdt.go | 2 +- plugins/inputs/ipmi_sensor/ipmi_sensor.go | 2 +- plugins/inputs/jenkins/client.go | 2 +- plugins/inputs/knx_listener/knx_listener_test.go | 2 +- plugins/inputs/kube_inventory/client.go | 2 +- plugins/inputs/leofs/leofs_test.go | 2 +- plugins/inputs/mcrouter/mcrouter.go | 2 +- plugins/inputs/mongodb/mongodb_server.go | 11 ++--------- plugins/inputs/mongodb/mongostat.go | 2 +- plugins/inputs/mqtt_consumer/topic_parser.go | 2 +- plugins/inputs/mysql/mysql.go | 2 +- plugins/inputs/nfsclient/nfsclient.go | 2 +- .../nginx_plus_api/nginx_plus_api_metrics_test.go | 2 +- plugins/inputs/nsd/nsd.go | 2 +- 28 files changed, 32 insertions(+), 51 deletions(-) diff --git a/plugins/inputs/http_listener_v2/http_listener_v2_test.go b/plugins/inputs/http_listener_v2/http_listener_v2_test.go index 6d9113f17770b..2dbe902efee6b 100644 --- a/plugins/inputs/http_listener_v2/http_listener_v2_test.go +++ b/plugins/inputs/http_listener_v2/http_listener_v2_test.go @@ -111,7 +111,7 @@ func getHTTPSClient() *http.Client { } } -func createURL(listener *HTTPListenerV2, scheme string, path string, rawquery string) string { +func createURL(listener *HTTPListenerV2, scheme, path, rawquery string) string { var port int if strings.HasPrefix(listener.ServiceAddress, "tcp://") { port = listener.listener.Addr().(*net.TCPAddr).Port diff --git a/plugins/inputs/http_response/http_response_test.go b/plugins/inputs/http_response/http_response_test.go index 1adfcee01420e..20c60a00df9e3 100644 --- a/plugins/inputs/http_response/http_response_test.go +++ b/plugins/inputs/http_response/http_response_test.go @@ -149,14 +149,7 @@ func setUpTestMux() http.Handler { return mux } -func checkOutput( - t *testing.T, - acc *testutil.Accumulator, - presentFields map[string]interface{}, - presentTags map[string]interface{}, - absentFields []string, - absentTags []string, -) { +func checkOutput(t *testing.T, acc *testutil.Accumulator, presentFields, presentTags map[string]interface{}, absentFields, absentTags []string) { t.Helper() if presentFields != nil { checkFields(t, presentFields, acc) diff --git a/plugins/inputs/hugepages/hugepages.go b/plugins/inputs/hugepages/hugepages.go index ea615d0f59f4a..926f10540e9c1 100644 --- a/plugins/inputs/hugepages/hugepages.go +++ b/plugins/inputs/hugepages/hugepages.go @@ -152,12 +152,7 @@ func (h *Hugepages) gatherStatsPerNode(acc telegraf.Accumulator) error { return nil } -func (h *Hugepages) gatherFromHugepagePath( - acc telegraf.Accumulator, - measurement, path string, - fileFilter map[string]string, - defaultTags map[string]string, -) error { +func (h *Hugepages) gatherFromHugepagePath(acc telegraf.Accumulator, measurement, path string, fileFilter, defaultTags map[string]string) error { // read metrics from: hugepages/hugepages-*/* hugepagesDirs, err := os.ReadDir(path) if err != nil { diff --git a/plugins/inputs/infiniband/infiniband_linux.go b/plugins/inputs/infiniband/infiniband_linux.go index 7f95e8be7ccf0..72bbc4714d763 100644 --- a/plugins/inputs/infiniband/infiniband_linux.go +++ b/plugins/inputs/infiniband/infiniband_linux.go @@ -40,7 +40,7 @@ func (i *Infiniband) Gather(acc telegraf.Accumulator) error { } // Add the statistics to the accumulator -func addStats(dev string, port string, stats []rdmamap.RdmaStatEntry, acc telegraf.Accumulator) { +func addStats(dev, port string, stats []rdmamap.RdmaStatEntry, acc telegraf.Accumulator) { // Allow users to filter by card and port tags := map[string]string{"device": dev, "port": port} fields := make(map[string]interface{}) diff --git a/plugins/inputs/influxdb_listener/influxdb_listener_test.go b/plugins/inputs/influxdb_listener/influxdb_listener_test.go index 22defcb594afa..0ecb6a9c65df6 100644 --- a/plugins/inputs/influxdb_listener/influxdb_listener_test.go +++ b/plugins/inputs/influxdb_listener/influxdb_listener_test.go @@ -95,7 +95,7 @@ func getSecureClient() *http.Client { } } -func createURL(listener *InfluxDBListener, scheme string, path string, rawquery string) string { +func createURL(listener *InfluxDBListener, scheme, path, rawquery string) string { u := url.URL{ Scheme: scheme, Host: "localhost:" + strconv.Itoa(listener.port), diff --git a/plugins/inputs/influxdb_v2_listener/influxdb_v2_listener_test.go b/plugins/inputs/influxdb_v2_listener/influxdb_v2_listener_test.go index 21e10882b3bd1..6a819881be07f 100644 --- a/plugins/inputs/influxdb_v2_listener/influxdb_v2_listener_test.go +++ b/plugins/inputs/influxdb_v2_listener/influxdb_v2_listener_test.go @@ -96,7 +96,7 @@ func getSecureClient() *http.Client { } } -func createURL(listener *InfluxDBV2Listener, scheme string, path string, rawquery string) string { +func createURL(listener *InfluxDBV2Listener, scheme, path, rawquery string) string { u := url.URL{ Scheme: scheme, Host: "localhost:" + strconv.Itoa(listener.port), diff --git a/plugins/inputs/intel_pmt/intel_pmt.go b/plugins/inputs/intel_pmt/intel_pmt.go index 2b05823b40af5..1df882f33ae21 100644 --- a/plugins/inputs/intel_pmt/intel_pmt.go +++ b/plugins/inputs/intel_pmt/intel_pmt.go @@ -299,7 +299,7 @@ func getTelemSample(s sample, buf []byte, offset uint64) (uint64, error) { // Returns: // // error - error if getting values has failed, if sample IDref is missing or if equation evaluation has failed. -func (p *IntelPMT) aggregateSamples(acc telegraf.Accumulator, guid string, data []byte, numaNode string, pciBdf string) error { +func (p *IntelPMT) aggregateSamples(acc telegraf.Accumulator, guid string, data []byte, numaNode, pciBdf string) error { results, err := p.getSampleValues(guid, data) if err != nil { return err diff --git a/plugins/inputs/intel_pmt/intel_pmt_test.go b/plugins/inputs/intel_pmt/intel_pmt_test.go index 01e485f67f9f1..4a35bc3bdb7a2 100644 --- a/plugins/inputs/intel_pmt/intel_pmt_test.go +++ b/plugins/inputs/intel_pmt/intel_pmt_test.go @@ -13,7 +13,7 @@ import ( "github.com/stretchr/testify/require" ) -func createTempFile(t *testing.T, dir string, pattern string, data []byte) (*os.File, os.FileInfo) { +func createTempFile(t *testing.T, dir, pattern string, data []byte) (*os.File, os.FileInfo) { tempFile, err := os.CreateTemp(dir, pattern) if err != nil { t.Fatalf("error creating a temporary file %v: %v", tempFile.Name(), err) diff --git a/plugins/inputs/intel_pmt/xml_parser.go b/plugins/inputs/intel_pmt/xml_parser.go index 79329dfbb6289..159e84e448a03 100644 --- a/plugins/inputs/intel_pmt/xml_parser.go +++ b/plugins/inputs/intel_pmt/xml_parser.go @@ -199,7 +199,7 @@ func (p *IntelPMT) readXMLs() error { // Returns: // // error - if reading XML has failed. -func (p *IntelPMT) getAllXMLData(guid string, dtMetricsFound map[string]bool, smFound map[string]bool) error { +func (p *IntelPMT) getAllXMLData(guid string, dtMetricsFound, smFound map[string]bool) error { for _, mapping := range p.pmtMetadata.Mappings.Mapping { if mapping.GUID == guid { basedir := mapping.XMLSet.Basedir @@ -246,7 +246,7 @@ func (a *aggregator) calculateMasks() { } } -func computeMask(msb uint64, lsb uint64) uint64 { +func computeMask(msb, lsb uint64) uint64 { msbMask := uint64(0xffffffffffffffff) & ((1 << (msb + 1)) - 1) lsbMask := uint64(0xffffffffffffffff) & (1<