From 7a92925f004e01fd9dff60f8c9514440fdcea75a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20=C5=BBak?= Date: Fri, 17 Jan 2025 11:12:49 +0100 Subject: [PATCH] chore(linters): Enable `unused-receiver` rule for revive (#16406) --- .golangci.yml | 1 + plugins/inputs/processes/processes_windows.go | 2 +- plugins/inputs/temp/temp_notlinux.go | 2 +- plugins/inputs/win_eventlog/win_eventlog.go | 4 ++-- plugins/inputs/win_perf_counters/performance_query.go | 6 +++--- plugins/inputs/win_perf_counters/win_perf_counters.go | 2 +- plugins/inputs/win_services/win_services.go | 2 +- plugins/inputs/win_services/win_services_test.go | 4 ++-- 8 files changed, 12 insertions(+), 11 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 4fd1123fef3d7..4715c5109f0bc 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -318,6 +318,7 @@ linters-settings: - name: unnecessary-stmt - name: unreachable-code - name: unused-parameter + - name: unused-receiver - name: var-declaration - name: var-naming - name: waitgroup-by-value diff --git a/plugins/inputs/processes/processes_windows.go b/plugins/inputs/processes/processes_windows.go index 4287f2c4138d9..157e79adeca21 100644 --- a/plugins/inputs/processes/processes_windows.go +++ b/plugins/inputs/processes/processes_windows.go @@ -16,7 +16,7 @@ func (e *Processes) Init() error { return nil } -func (e *Processes) Gather(_ telegraf.Accumulator) error { +func (*Processes) Gather(telegraf.Accumulator) error { return nil } diff --git a/plugins/inputs/temp/temp_notlinux.go b/plugins/inputs/temp/temp_notlinux.go index 437efde87c7ba..869740bc0d5fc 100644 --- a/plugins/inputs/temp/temp_notlinux.go +++ b/plugins/inputs/temp/temp_notlinux.go @@ -25,7 +25,7 @@ func (t *Temperature) Init() error { return nil } -func (t *Temperature) Gather(acc telegraf.Accumulator) error { +func (*Temperature) Gather(acc telegraf.Accumulator) error { temps, err := sensors.SensorsTemperatures() if err != nil { var sensorsWarnings *sensors.Warnings diff --git a/plugins/inputs/win_eventlog/win_eventlog.go b/plugins/inputs/win_eventlog/win_eventlog.go index 79ce9de7b102c..f0c60cf9bf0a2 100644 --- a/plugins/inputs/win_eventlog/win_eventlog.go +++ b/plugins/inputs/win_eventlog/win_eventlog.go @@ -113,7 +113,7 @@ func (w *WinEventLog) Stop() { } func (w *WinEventLog) GetState() interface{} { - bookmarkXML, err := w.renderBookmark(w.bookmark) + bookmarkXML, err := renderBookmark(w.bookmark) if err != nil { w.Log.Errorf("State-persistence failed, cannot render bookmark: %v", err) return "" @@ -381,7 +381,7 @@ func (w *WinEventLog) fetchEvents(subsHandle EvtHandle) ([]Event, error) { return events, evterr } -func (w *WinEventLog) renderBookmark(bookmark EvtHandle) (string, error) { +func renderBookmark(bookmark EvtHandle) (string, error) { var bufferUsed, propertyCount uint32 buf := make([]byte, bufferSize) diff --git a/plugins/inputs/win_perf_counters/performance_query.go b/plugins/inputs/win_perf_counters/performance_query.go index a4286a4344837..482d3660eaeec 100644 --- a/plugins/inputs/win_perf_counters/performance_query.go +++ b/plugins/inputs/win_perf_counters/performance_query.go @@ -69,7 +69,7 @@ type performanceQueryImpl struct { type performanceQueryCreatorImpl struct{} -func (m performanceQueryCreatorImpl) NewPerformanceQuery(_ string, maxBufferSize uint32) PerformanceQuery { +func (performanceQueryCreatorImpl) NewPerformanceQuery(_ string, maxBufferSize uint32) PerformanceQuery { return &performanceQueryImpl{maxBufferSize: maxBufferSize} } @@ -181,7 +181,7 @@ func (m *performanceQueryImpl) ExpandWildCardPath(counterPath string) ([]string, } // GetFormattedCounterValueDouble computes a displayable value for the specified counter -func (m *performanceQueryImpl) GetFormattedCounterValueDouble(hCounter pdhCounterHandle) (float64, error) { +func (*performanceQueryImpl) GetFormattedCounterValueDouble(hCounter pdhCounterHandle) (float64, error) { var counterType uint32 var value pdhFmtCountervalueDouble @@ -287,7 +287,7 @@ func (m *performanceQueryImpl) CollectDataWithTime() (time.Time, error) { return mtime, nil } -func (m *performanceQueryImpl) IsVistaOrNewer() bool { +func (*performanceQueryImpl) IsVistaOrNewer() bool { return PdhAddEnglishCounterSupported() } diff --git a/plugins/inputs/win_perf_counters/win_perf_counters.go b/plugins/inputs/win_perf_counters/win_perf_counters.go index 1f0c6269f785b..4802eb17e2fa5 100644 --- a/plugins/inputs/win_perf_counters/win_perf_counters.go +++ b/plugins/inputs/win_perf_counters/win_perf_counters.go @@ -153,7 +153,7 @@ func extractCounterInfoFromCounterPath(counterPath string) (computer string, obj return computer, object, instance, counter, nil } -func (m *WinPerfCounters) SampleConfig() string { +func (*WinPerfCounters) SampleConfig() string { return sampleConfig } diff --git a/plugins/inputs/win_services/win_services.go b/plugins/inputs/win_services/win_services.go index c6f407b5acadb..785862d2af27a 100644 --- a/plugins/inputs/win_services/win_services.go +++ b/plugins/inputs/win_services/win_services.go @@ -89,7 +89,7 @@ func (m *winSvcMgr) ListServices() ([]string, error) { type mgProvider struct { } -func (rmr *mgProvider) Connect() (WinServiceManager, error) { +func (*mgProvider) Connect() (WinServiceManager, error) { h, err := windows.OpenSCManager(nil, nil, windows.GENERIC_READ) if err != nil { return nil, err diff --git a/plugins/inputs/win_services/win_services_test.go b/plugins/inputs/win_services/win_services_test.go index f5767593774ad..756b8bb3dad3c 100644 --- a/plugins/inputs/win_services/win_services_test.go +++ b/plugins/inputs/win_services/win_services_test.go @@ -39,7 +39,7 @@ type FakeSvcMgr struct { testData testData } -func (m *FakeSvcMgr) Disconnect() error { +func (*FakeSvcMgr) Disconnect() error { return nil } @@ -77,7 +77,7 @@ type FakeWinSvc struct { testData serviceTestInfo } -func (m *FakeWinSvc) Close() error { +func (*FakeWinSvc) Close() error { return nil } func (m *FakeWinSvc) Config() (mgr.Config, error) {