From 919f90a571565b1d3e8bdd592f49930b5fb012fe Mon Sep 17 00:00:00 2001 From: Mario Trangoni Date: Fri, 24 Dec 2021 11:19:05 +0100 Subject: [PATCH] golangci-lint: Acknowledge all remaining checks and update golanci-lint to v1.43.0 Signed-off-by: Mario Trangoni --- .golangci.yaml | 8 +++++--- appveyor.yml | 6 +++--- collector/collector_test.go | 2 +- collector/iis.go | 8 ++++---- collector/service.go | 2 +- exporter.go | 2 +- headers/netapi32/netapi32.go | 2 +- headers/sysinfoapi/sysinfoapi.go | 2 +- 8 files changed, 17 insertions(+), 15 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index c9f9b66b..4e21c24c 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -3,11 +3,10 @@ linters: enable: - deadcode - errcheck - - golint + - revive - govet - gofmt - ineffassign - - interfacer - structcheck - unconvert - varcheck @@ -20,4 +19,7 @@ issues: - # Golint has many capitalisation complaints on WMI class names text: "`?\\w+`? should be `?\\w+`?" linters: - - golint + - revive + - text: "don't use ALL_CAPS in Go names; use CamelCase" + linters: + - revive diff --git a/appveyor.yml b/appveyor.yml index 6afbe874..159f7afe 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -15,9 +15,9 @@ install: - set PATH=%PATH%;C:\msys64\mingw64\bin - choco install gitversion.portable make -y - ps: | - appveyor DownloadFile https://github.com/golangci/golangci-lint/releases/download/v1.21.0/golangci-lint-1.21.0-windows-amd64.zip - Expand-Archive golangci-lint-1.21.0-windows-amd64.zip - Move-Item golangci-lint-1.21.0-windows-amd64\golangci-lint-1.21.0-windows-amd64\golangci-lint.exe $env:GOPATH\bin\golangci-lint.exe + appveyor DownloadFile https://github.com/golangci/golangci-lint/releases/download/v1.43.0/golangci-lint-1.43.0-windows-amd64.zip + Expand-Archive golangci-lint-1.43.0-windows-amd64.zip + Move-Item golangci-lint-1.43.0-windows-amd64\golangci-lint-1.43.0-windows-amd64\golangci-lint.exe $env:GOPATH\bin\golangci-lint.exe - go install github.com/prometheus/promu@v0.11.1 - go install github.com/josephspurrier/goversioninfo/cmd/goversioninfo@v1.2.0 diff --git a/collector/collector_test.go b/collector/collector_test.go index cfbc284d..c356d873 100644 --- a/collector/collector_test.go +++ b/collector/collector_test.go @@ -55,6 +55,6 @@ func benchmarkCollector(b *testing.B, name string, collectFunc func() (Collector }() for i := 0; i < b.N; i++ { - c.Collect(scrapeContext, metrics) + c.Collect(scrapeContext, metrics) //nolint:errcheck } } diff --git a/collector/iis.go b/collector/iis.go index 9dd5b2dd..1438ffb0 100644 --- a/collector/iis.go +++ b/collector/iis.go @@ -1275,13 +1275,13 @@ type perflibW3SVC_W3WP struct { URICacheFlushesTotal float64 `perflib:"Total Flushed URIs"` URICacheFlushesTotalKernel float64 `perflib:"Total Flushed URIs"` - URIsFlushedTotalKernel float64 `perflib:"Kernel\: Total Flushed URIs"` + URIsFlushedTotalKernel float64 `perflib:"Kernel\: Total Flushed URIs"` //nolint:govet URICacheHitsTotal float64 `perflib:"URI Cache Hits"` - URICacheHitsTotalKernel float64 `perflib:"Kernel\: URI Cache Hits"` + URICacheHitsTotalKernel float64 `perflib:"Kernel\: URI Cache Hits"` //nolint:govet URICacheMissesTotal float64 `perflib:"URI Cache Misses"` - URICacheMissesTotalKernel float64 `perflib:"Kernel\: URI Cache Misses"` + URICacheMissesTotalKernel float64 `perflib:"Kernel\: URI Cache Misses"` //nolint:govet URIsCached float64 `perflib:"Current URIs Cached"` - URIsCachedKernel float64 `perflib:"Kernel\: Current URIs Cached"` + URIsCachedKernel float64 `perflib:"Kernel\: Current URIs Cached"` //nolint:govet URIsCachedTotal float64 `perflib:"Total URIs Cached"` URIsCachedTotalKernel float64 `perflib:"Total URIs Cached"` URIsFlushedTotal float64 `perflib:"Total Flushed URIs"` diff --git a/collector/service.go b/collector/service.go index d4b14caa..ca20f208 100644 --- a/collector/service.go +++ b/collector/service.go @@ -232,7 +232,7 @@ func (c *serviceCollector) collectAPI(ch chan<- prometheus.Metric) error { if err != nil { return err } - defer svcmgrConnection.Disconnect() + defer svcmgrConnection.Disconnect() //nolint:errcheck // List All Services from the Services Manager serviceList, err := svcmgrConnection.ListServices() diff --git a/exporter.go b/exporter.go index adf048b3..fc085118 100644 --- a/exporter.go +++ b/exporter.go @@ -504,7 +504,7 @@ func (mh *metricsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { if err != nil { log.Warnln("Couldn't create filtered metrics handler: ", err) w.WriteHeader(http.StatusBadRequest) - w.Write([]byte(fmt.Sprintf("Couldn't create filtered metrics handler: %s", err))) + w.Write([]byte(fmt.Sprintf("Couldn't create filtered metrics handler: %s", err))) //nolint:errcheck return } reg.MustRegister(wc) diff --git a/headers/netapi32/netapi32.go b/headers/netapi32/netapi32.go index 7b58029d..cc536d30 100644 --- a/headers/netapi32/netapi32.go +++ b/headers/netapi32/netapi32.go @@ -69,7 +69,7 @@ var NetApiStatus = map[uint32]string{ // NetApiBufferFree frees the memory other network management functions use internally to return information. // https://docs.microsoft.com/en-us/windows/win32/api/lmapibuf/nf-lmapibuf-netapibufferfree func netApiBufferFree(buffer *wKSTAInfo102) { - procNetApiBufferFree.Call(uintptr(unsafe.Pointer(buffer))) + procNetApiBufferFree.Call(uintptr(unsafe.Pointer(buffer))) //nolint:errcheck } // NetWkstaGetInfo returns information about the configuration of a workstation. diff --git a/headers/sysinfoapi/sysinfoapi.go b/headers/sysinfoapi/sysinfoapi.go index ebc6087b..502893f7 100644 --- a/headers/sysinfoapi/sysinfoapi.go +++ b/headers/sysinfoapi/sysinfoapi.go @@ -132,7 +132,7 @@ func GlobalMemoryStatusEx() (MemoryStatus, error) { // https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsysteminfo func GetSystemInfo() SystemInfo { var info lpSystemInfo - procGetSystemInfo.Call(uintptr(unsafe.Pointer(&info))) + procGetSystemInfo.Call(uintptr(unsafe.Pointer(&info))) //nolint:errcheck return SystemInfo{ Arch: ProcessorArchitecture(info.Arch.WProcessorArchitecture), PageSize: info.DwPageSize,