From 14c4d5b635fc3fccd626890000cc43b0ef22131c Mon Sep 17 00:00:00 2001 From: Luca Comellini Date: Tue, 16 Jul 2024 18:07:26 -0700 Subject: [PATCH 1/2] Add linters that check for bugs --- .golangci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.golangci.yml b/.golangci.yml index 25b28f215..68cbf5196 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -37,14 +37,19 @@ linters: - asasalint - asciicheck - bidichk + - contextcheck - dupword + - durationcheck - errcheck + - errchkjson - errname - errorlint - exportloopref - fatcontext - forcetypeassert - gocheckcompilerdirectives + - gochecksumtype + - gocritic - godot - gofmt - gofumpt @@ -58,6 +63,7 @@ linters: - loggercheck - makezero - misspell + - musttag - nilerr - noctx - nolintlint From 2234d30edb3136d443711cbc112d52993fd77c33 Mon Sep 17 00:00:00 2001 From: Luca Comellini Date: Tue, 16 Jul 2024 18:14:28 -0700 Subject: [PATCH 2/2] Fix linter errors --- collector/nginx_plus.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/collector/nginx_plus.go b/collector/nginx_plus.go index 70d9e32c6..57badf47e 100644 --- a/collector/nginx_plus.go +++ b/collector/nginx_plus.go @@ -280,8 +280,11 @@ func NewVariableLabelNames(upstreamServerVariableLabelNames []string, serverZone // NewNginxPlusCollector creates an NginxPlusCollector. func NewNginxPlusCollector(nginxClient *plusclient.NginxClient, namespace string, variableLabelNames VariableLabelNames, constLabels map[string]string, logger log.Logger) *NginxPlusCollector { - upstreamServerVariableLabelNames := append(variableLabelNames.UpstreamServerVariableLabelNames, variableLabelNames.UpstreamServerPeerVariableLabelNames...) - streamUpstreamServerVariableLabelNames := append(variableLabelNames.StreamUpstreamServerVariableLabelNames, variableLabelNames.StreamUpstreamServerPeerVariableLabelNames...) + upstreamServerVariableLabelNames := variableLabelNames.UpstreamServerVariableLabelNames + streamUpstreamServerVariableLabelNames := variableLabelNames.StreamUpstreamServerVariableLabelNames + + upstreamServerVariableLabelNames = append(upstreamServerVariableLabelNames, variableLabelNames.UpstreamServerPeerVariableLabelNames...) + streamUpstreamServerVariableLabelNames = append(streamUpstreamServerVariableLabelNames, variableLabelNames.StreamUpstreamServerPeerVariableLabelNames...) return &NginxPlusCollector{ variableLabelNames: variableLabelNames, upstreamServerLabels: make(map[string][]string),