Skip to content

Commit cb76763

Browse files
authored
PMM-7 Bump up Go, lint, modules (expect prometheus). (#353)
* PMM-7 Update go version. * PMM-7 Update lint. * PMM-7 Updates lint. * PMM-7 Lint. * PMM-7 Lint. * PMM-7 Migrate yaml. * PMM-7 Fix lint issues. * PMM-7 Fix. * PMM-7 Format, lint. * PMM-7 Lint. * PMM-7 Modules update * PMM-7 Prom downgrade. * PMM-7 Another updates. * PMM-7 Lint. * PMM-7 Lint. * PMM-7 Lint v2 in yaml.
1 parent b1fc4c8 commit cb76763

File tree

17 files changed

+491
-444
lines changed

17 files changed

+491
-444
lines changed

.github/workflows/go.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131

3232
- name: Run checks
3333
run: |
34-
go build -modfile=tools/go.mod -o bin/golangci-lint github.com/golangci/golangci-lint/cmd/golangci-lint
34+
go build -modfile=tools/go.mod -o bin/golangci-lint github.com/golangci/golangci-lint/v2/cmd/golangci-lint
3535
go build -modfile=tools/go.mod -o bin/reviewdog github.com/reviewdog/reviewdog/cmd/reviewdog
3636
bin/golangci-lint run -c=.golangci.yml --out-format=line-number | env REVIEWDOG_GITHUB_API_TOKEN=${{ secrets.GITHUB_TOKEN }} bin/reviewdog -f=golangci-lint -level=error -reporter=github-pr-review
3737

.github/workflows/golangci-lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ jobs:
2929
if: github.repository == 'prometheus/snmp_exporter'
3030

3131
- name: Lint
32-
uses: golangci/golangci-lint-action@2226d7cb06a077cd73e56eedd38eecad18e5d837 # v6.5.0
32+
uses: golangci/golangci-lint-action@v9.1.0 # v9.1.0
3333
with:
34-
version: v1.64.8
34+
version: v2.6.2

.golangci.yml

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,36 @@
1-
---
1+
version: "2"
22
linters:
33
enable:
4-
- misspell
5-
- revive
6-
7-
issues:
8-
exclude-rules:
9-
- path: _test.go
10-
linters:
11-
- errcheck
12-
13-
linters-settings:
14-
errcheck:
15-
exclude-functions:
16-
# Never check for logger errors.
17-
- (github.com/go-kit/log.Logger).Log
18-
revive:
4+
- misspell
5+
- revive
6+
settings:
7+
errcheck:
8+
exclude-functions:
9+
- (github.com/go-kit/log.Logger).Log
10+
revive:
11+
rules:
12+
- name: unused-parameter
13+
severity: warning
14+
disabled: true
15+
exclusions:
16+
generated: lax
17+
presets:
18+
- comments
19+
- common-false-positives
20+
- legacy
21+
- std-error-handling
1922
rules:
20-
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-parameter
21-
- name: unused-parameter
22-
severity: warning
23-
disabled: true
23+
- linters:
24+
- errcheck
25+
path: _test.go
26+
paths:
27+
- third_party$
28+
- builtin$
29+
- examples$
30+
formatters:
31+
exclusions:
32+
generated: lax
33+
paths:
34+
- third_party$
35+
- builtin$
36+
- examples$

Makefile.common

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_
6161
SKIP_GOLANGCI_LINT ?= $(CI)
6262
GOLANGCI_LINT :=
6363
GOLANGCI_LINT_OPTS ?=
64-
GOLANGCI_LINT_VERSION ?= v1.54.2
64+
GOLANGCI_LINT_VERSION ?= v2.6.2
6565
# golangci-lint only supports linux, darwin and windows platforms on i386/amd64.
6666
# windows isn't included here because of the path separator being different.
6767
ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux darwin))

cmd/postgres_exporter/percona_compatibility_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build manual
2-
// +build manual
32

43
package main
54

cmd/postgres_exporter/pg_setting.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ type pgSetting struct {
6868
func (s *pgSetting) metric(labels prometheus.Labels) prometheus.Metric {
6969
var (
7070
err error
71-
name = strings.Replace(s.name, ".", "_", -1)
71+
name = strings.ReplaceAll(s.name, ".", "_")
7272
unit = s.unit // nolint: ineffassign
7373
shortDesc = fmt.Sprintf("Server Parameter: %s", s.name)
7474
subsystem = "settings"
@@ -132,7 +132,7 @@ func (s *pgSetting) normaliseUnit() (val float64, unit string, err error) {
132132
case "B", "kB", "MB", "GB", "TB", "1kB", "2kB", "4kB", "8kB", "16kB", "32kB", "64kB", "16MB", "32MB", "64MB":
133133
unit = "bytes"
134134
default:
135-
err = fmt.Errorf("Unknown unit for runtime variable: %q", s.unit)
135+
err = fmt.Errorf("unknown unit for runtime variable: %q", s.unit)
136136
return
137137
}
138138

cmd/postgres_exporter/pg_setting_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// limitations under the License.
1313

1414
//go:build !integration
15-
// +build !integration
1615

1716
package main
1817

@@ -214,7 +213,7 @@ var fixtures = []fixture{
214213
n: normalised{
215214
val: 10,
216215
unit: "",
217-
err: `Unknown unit for runtime variable: "nonexistent"`,
216+
err: `unknown unit for runtime variable: "nonexistent"`,
218217
},
219218
},
220219
}
@@ -240,7 +239,7 @@ func (s *PgSettingSuite) TestNormaliseUnit(c *C) {
240239
func (s *PgSettingSuite) TestMetric(c *C) {
241240
defer func() {
242241
if r := recover(); r != nil {
243-
if r.(error).Error() != `Unknown unit for runtime variable: "nonexistent"` {
242+
if r.(error).Error() != `unknown unit for runtime variable: "nonexistent"` {
244243
panic(r)
245244
}
246245
}

cmd/postgres_exporter/postgres_exporter_integration_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
// a lot of additional work to keep the external docker environment they require
1616
// working.
1717
//go:build integration
18-
// +build integration
1918

2019
package main
2120

cmd/postgres_exporter/postgres_exporter_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// limitations under the License.
1313

1414
//go:build !integration
15-
// +build !integration
1615

1716
package main
1817

collector/collector_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ func readMetric(m prometheus.Metric) MetricResult {
4848

4949
func sanitizeQuery(q string) string {
5050
q = strings.Join(strings.Fields(q), " ")
51-
q = strings.Replace(q, "(", "\\(", -1)
52-
q = strings.Replace(q, "?", "\\?", -1)
53-
q = strings.Replace(q, ")", "\\)", -1)
54-
q = strings.Replace(q, "[", "\\[", -1)
55-
q = strings.Replace(q, "]", "\\]", -1)
56-
q = strings.Replace(q, "{", "\\{", -1)
57-
q = strings.Replace(q, "}", "\\}", -1)
58-
q = strings.Replace(q, "*", "\\*", -1)
59-
q = strings.Replace(q, "^", "\\^", -1)
60-
q = strings.Replace(q, "$", "\\$", -1)
51+
q = strings.ReplaceAll(q, "(", "\\(")
52+
q = strings.ReplaceAll(q, "?", "\\?")
53+
q = strings.ReplaceAll(q, ")", "\\)")
54+
q = strings.ReplaceAll(q, "[", "\\[")
55+
q = strings.ReplaceAll(q, "]", "\\]")
56+
q = strings.ReplaceAll(q, "{", "\\{")
57+
q = strings.ReplaceAll(q, "}", "\\}")
58+
q = strings.ReplaceAll(q, "*", "\\*")
59+
q = strings.ReplaceAll(q, "^", "\\^")
60+
q = strings.ReplaceAll(q, "$", "\\$")
6161
return q
6262
}

0 commit comments

Comments
 (0)