Skip to content

Commit

Permalink
Merge pull request #892 from mjtrangoni/fix-golanci-lint
Browse files Browse the repository at this point in the history
Fix and update golanci-lint reported issues
  • Loading branch information
breed808 authored Dec 25, 2021
2 parents c7d07a3 + 919f90a commit 4d771d2
Show file tree
Hide file tree
Showing 55 changed files with 79 additions and 37 deletions.
8 changes: 5 additions & 3 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ linters:
enable:
- deadcode
- errcheck
- golint
- revive
- govet
- gofmt
- ineffassign
- interfacer
- structcheck
- unconvert
- varcheck
Expand All @@ -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
6 changes: 3 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
- go install github.com/josephspurrier/goversioninfo/cmd/[email protected]

Expand Down
1 change: 1 addition & 0 deletions collector/ad.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

package collector
Expand Down
1 change: 1 addition & 0 deletions collector/adfs.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

package collector
Expand Down
1 change: 1 addition & 0 deletions collector/cache.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

package collector
Expand Down
2 changes: 1 addition & 1 deletion collector/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
1 change: 1 addition & 0 deletions collector/container.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

package collector
Expand Down
1 change: 1 addition & 0 deletions collector/cpu.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

package collector
Expand Down
1 change: 1 addition & 0 deletions collector/cpu_info.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

package collector
Expand Down
1 change: 1 addition & 0 deletions collector/cs.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

package collector
Expand Down
3 changes: 2 additions & 1 deletion collector/dfsr.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

package collector
Expand Down Expand Up @@ -128,7 +129,7 @@ func NewDFSRCollector() (Collector, error) {

ConnectionFilesReceivedTotal: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "connection_received_files_total"),
"Total number of files receieved for connection",
"Total number of files received for connection",
[]string{"name"},
nil,
),
Expand Down
1 change: 1 addition & 0 deletions collector/dhcp.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

package collector
Expand Down
3 changes: 2 additions & 1 deletion collector/dns.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

package collector
Expand Down Expand Up @@ -136,7 +137,7 @@ func NewDNSCollector() (Collector, error) {
),
Responses: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "responses_total"),
"Number of reponses sent by DNS server",
"Number of responses sent by DNS server",
[]string{"protocol"},
nil,
),
Expand Down
3 changes: 2 additions & 1 deletion collector/exchange.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

package collector
Expand Down Expand Up @@ -234,7 +235,7 @@ func (c *exchangeCollector) collectADAccessProcesses(ctx *ScrapeContext, ch chan
}

// since we're not including the PID suffix from the instance names in the label names,
// we get an occational duplicate. This seems to affect about 4 instances only on this object.
// we get an occasional duplicate. This seems to affect about 4 instances only on this object.
labelUseCount[labelName]++
if labelUseCount[labelName] > 1 {
labelName = fmt.Sprintf("%s_%d", labelName, labelUseCount[labelName])
Expand Down
1 change: 1 addition & 0 deletions collector/hyperv.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

package collector
Expand Down
9 changes: 5 additions & 4 deletions collector/iis.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

package collector
Expand Down Expand Up @@ -1274,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"`
Expand Down
1 change: 1 addition & 0 deletions collector/logical_disk.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

package collector
Expand Down
1 change: 1 addition & 0 deletions collector/logon.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

package collector
Expand Down
1 change: 1 addition & 0 deletions collector/memory.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// returns data points from Win32_PerfRawData_PerfOS_Memory
// <add link to documentation here> - Win32_PerfRawData_PerfOS_Memory class

//go:build windows
// +build windows

package collector
Expand Down
1 change: 1 addition & 0 deletions collector/msmq.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

package collector
Expand Down
3 changes: 2 additions & 1 deletion collector/mssql.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

package collector
Expand Down Expand Up @@ -1957,7 +1958,7 @@ func (c *MSSQLCollector) Collect(ctx *ScrapeContext, ch chan<- prometheus.Metric
}
wg.Wait()

// this shoud return an error if any? some? children errord.
// this should return an error if any? some? children errord.
if c.mssqlChildCollectorFailure > 0 {
return errors.New("at least one child collector failed")
}
Expand Down
1 change: 1 addition & 0 deletions collector/net.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

package collector
Expand Down
1 change: 1 addition & 0 deletions collector/net_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

package collector
Expand Down
1 change: 1 addition & 0 deletions collector/netframework_clrexceptions.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

package collector
Expand Down
1 change: 1 addition & 0 deletions collector/netframework_clrinterop.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

package collector
Expand Down
1 change: 1 addition & 0 deletions collector/netframework_clrjit.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

package collector
Expand Down
1 change: 1 addition & 0 deletions collector/netframework_clrloading.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

package collector
Expand Down
1 change: 1 addition & 0 deletions collector/netframework_clrlocksandthreads.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

package collector
Expand Down
1 change: 1 addition & 0 deletions collector/netframework_clrmemory.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

package collector
Expand Down
1 change: 1 addition & 0 deletions collector/netframework_clrremoting.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

package collector
Expand Down
1 change: 1 addition & 0 deletions collector/netframework_clrsecurity.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

package collector
Expand Down
7 changes: 4 additions & 3 deletions collector/os.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

package collector
Expand Down Expand Up @@ -201,7 +202,7 @@ func (c *OSCollector) collect(ctx *ScrapeContext, ch chan<- prometheus.Metric) (
return nil, err
}

var fsipf float64 = 0
var fsipf float64
for _, pagingFile := range pagingFiles {
fileString := strings.ReplaceAll(pagingFile, `\??\`, "")
file, err := os.Stat(fileString)
Expand All @@ -222,7 +223,7 @@ func (c *OSCollector) collect(ctx *ScrapeContext, ch chan<- prometheus.Metric) (
}

// Get current page file usage.
var pfbRaw float64 = 0
var pfbRaw float64
for _, pageFile := range pfc {
if strings.Contains(strings.ToLower(pageFile.Name), "_total") {
continue
Expand Down Expand Up @@ -302,7 +303,7 @@ func (c *OSCollector) collect(ctx *ScrapeContext, ch chan<- prometheus.Metric) (
ch <- prometheus.MustNewConstMetric(
c.PagingLimitBytes,
prometheus.GaugeValue,
float64(fsipf),
fsipf,
)

ch <- prometheus.MustNewConstMetric(
Expand Down
3 changes: 2 additions & 1 deletion collector/process.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

package collector
Expand Down Expand Up @@ -133,7 +134,7 @@ func newProcessCollector() (Collector, error) {
),
WorkingSetPrivate: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "working_set_private_bytes"),
"Size of the working set, in bytes, that is use for this process only and not shared nor sharable by other processes.",
"Size of the working set, in bytes, that is use for this process only and not shared nor shareable by other processes.",
[]string{"process", "process_id", "creating_process_id"},
nil,
),
Expand Down
3 changes: 2 additions & 1 deletion collector/remote_fx.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

package collector
Expand Down Expand Up @@ -60,7 +61,7 @@ func NewRemoteFx() (Collector, error) {
),
CurrentTCPBandwidth: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "net_current_tcp_bandwidth"),
"TCP Bandwidth detected in bytes per seccond.",
"TCP Bandwidth detected in bytes per second.",
[]string{"session_name"},
nil,
),
Expand Down
3 changes: 2 additions & 1 deletion collector/service.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

package collector
Expand Down Expand Up @@ -231,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()
Expand Down
1 change: 1 addition & 0 deletions collector/smtp.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

package collector
Expand Down
1 change: 1 addition & 0 deletions collector/system.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

package collector
Expand Down
1 change: 1 addition & 0 deletions collector/tcp.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

package collector
Expand Down
1 change: 1 addition & 0 deletions collector/terminal_services.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

package collector
Expand Down
1 change: 1 addition & 0 deletions collector/textfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build !notextfile
// +build !notextfile

package collector
Expand Down
1 change: 1 addition & 0 deletions collector/time.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

package collector
Expand Down
1 change: 1 addition & 0 deletions collector/vmware.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

package collector
Expand Down
2 changes: 1 addition & 1 deletion docs/collector.dfsr.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Name | Description | Type | Labels
`windows_dfsr_folder_deleted_bytes_cleaned_up_total` | Total size (in bytes) of replicating deleted files and folders that were cleaned up from the Conflict and Deleted folder. | gauge | name
`windows_dfsr_folder_deleted_bytes_generated_total` | Total size (in bytes) of replicated deleted files and folders that were moved to the Conflict and Deleted folder after they were deleted from a replicated folder on a sending member. | counter | name
`windows_dfsr_folder_deleted_files_cleaned_up_total` | Number of files and folders that were cleaned up from the Conflict and Deleted folder. | counter | name
`windows_dfsr_folder_deleted_files_generated_total` | Number of deleted fils and folders that were moved to the Conflict and Deleted folder. | counter | name
`windows_dfsr_folder_deleted_files_generated_total` | Number of deleted files and folders that were moved to the Conflict and Deleted folder. | counter | name
`windows_dfsr_folder_file_installs_retried_total` | Total number of file installs that are being retried due to sharing violations or other errors encountered when installing the files. The DFS Replication service replicates staged files into a staging folder, uncompresses them in the Installing folder, and renames them to the target location. The second and third steps of this process are known as installing the file. | counter | name
`windows_dfsr_folder_file_installs_succeeded_total` | Total number of files that were successfully received from sending members and installed locally on this server. The DFS Replication service replicates staged files into a staging folder, uncompresses them in the Installing folder, and renames them to the target location. The second and third steps of this process are known as installing the file. | counter | name
`windows_dfsr_folder_files_received_total` | Total number of files received. | counter | name
Expand Down
2 changes: 1 addition & 1 deletion docs/collector.exchange.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Name | Description
`windows_exchange_transport_queues_internal_active_remote_delivery` | Internal Active Remote Delivery Queue length
`windows_exchange_transport_queues_active_mailbox_delivery` | Active Mailbox Delivery Queue length
`windows_exchange_transport_queues_retry_mailbox_delivery` | Retry Mailbox Delivery Queue length
`windows_exchange_transport_queues_unreachable` | Unreachable Queue lengt
`windows_exchange_transport_queues_unreachable` | Unreachable Queue length
`windows_exchange_transport_queues_external_largest_delivery` | External Largest Delivery Queue length
`windows_exchange_transport_queues_internal_largest_delivery` | Internal Largest Delivery Queue length
`windows_exchange_transport_queues_poison` | Poison Queue length
Expand Down
4 changes: 2 additions & 2 deletions docs/collector.fsrmquota.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Microsoft File Server Resource Manager (FSRM) Quotas collector

The fsrmquota collector exposes metrics about File Server Ressource Manager Quotas. Note that this collector has only been tested against Windows server 2012R2.
The fsrmquota collector exposes metrics about File Server Resource Manager Quotas. Note that this collector has only been tested against Windows server 2012R2.
Other FSRM versions may work but are not tested.

|||
Expand Down Expand Up @@ -48,5 +48,5 @@ rate(windows_fsrmquota_usage_bytes)[1d]
severity: "high"
annotations:
summary: "High Quotas Usage"
description: "High use of File Ressource.\n Quotas: {{ $labels.path }}\n Current use : {{ $value }}"
description: "High use of File Resource.\n Quotas: {{ $labels.path }}\n Current use : {{ $value }}"
```
2 changes: 1 addition & 1 deletion docs/collector.os.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ None
Name | Description | Type | Labels
-----|-------------|------|-------
`windows_os_info` | Contains full product name & version in labels | gauge | `product`, `version`
`windows_os_paging_limit_bytes` | Total number of bytes that can be sotred in the operating system paging files. 0 (zero) indicates that there are no paging files | gauge | None
`windows_os_paging_limit_bytes` | Total number of bytes that can be stored in the operating system paging files. 0 (zero) indicates that there are no paging files | gauge | None
`windows_os_paging_free_bytes` | Number of bytes that can be mapped into the operating system paging files without causing any other pages to be swapped out | gauge | None
`windows_os_physical_memory_free_bytes` | Bytes of physical memory currently unused and available | gauge | None
`windows_os_time` | Current time as reported by the operating system, in [Unix time](https://en.wikipedia.org/wiki/Unix_time). See [time.Unix()](https://golang.org/pkg/time/#Unix) for details | gauge | None
Expand Down
Loading

0 comments on commit 4d771d2

Please sign in to comment.