Skip to content

Commit a60e665

Browse files
cherry-pick: golangci-lint version and action update (#1046)
* Update golangci/golangci-lint-action action to v7 | datasource | package | from | to | | ----------- | ----------------------------- | ------ | ------ | | github-tags | golangci/golangci-lint-action | v6.5.2 | v7.0.0 | Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Update dependency golangci/golangci-lint to v2 | datasource | package | from | to | | ----------- | ---------------------- | ------- | ------ | | github-tags | golangci/golangci-lint | v1.64.8 | v2.1.5 | Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * golangci-lint migrate result * Fix linting error - remove embedded field * Update the make target for lint --------- Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
1 parent 44f438e commit a60e665

File tree

6 files changed

+73
-60
lines changed

6 files changed

+73
-60
lines changed

.github/workflows/lint.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ jobs:
3030
go-version-file: go.mod
3131

3232
- name: Lint Go
33-
uses: golangci/golangci-lint-action@55c2c1448f86e01eaae002a5a3a9624417608d84 # v6.5.2
33+
uses: golangci/golangci-lint-action@1481404843c368bc19ca9406f87d6e0fc97bdcfd # v7.0.0
3434
with:
35-
version: v1.64.8 # renovate: datasource=github-tags depName=golangci/golangci-lint
35+
version: v2.1.5 # renovate: datasource=github-tags depName=golangci/golangci-lint
3636

3737
actionlint:
3838
name: Actionlint

.golangci.yml

+66-53
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,6 @@
1-
linters-settings:
2-
misspell:
3-
locale: US
4-
revive:
5-
ignore-generated-header: true
6-
rules:
7-
- name: blank-imports
8-
- name: constant-logical-expr
9-
- name: context-as-argument
10-
- name: context-keys-type
11-
- name: defer
12-
- name: dot-imports
13-
- name: duplicated-imports
14-
- name: empty-block
15-
- name: error-naming
16-
- name: error-return
17-
- name: error-strings
18-
- name: errorf
19-
- name: exported
20-
- name: import-shadowing
21-
- name: increment-decrement
22-
- name: indent-error-flow
23-
- name: package-comments
24-
- name: range
25-
- name: range-val-address
26-
- name: range-val-in-closure
27-
- name: receiver-naming
28-
- name: redefines-builtin-id
29-
- name: string-of-int
30-
- name: superfluous-else
31-
- name: time-naming
32-
- name: unchecked-type-assertion
33-
- name: unexported-return
34-
- name: unnecessary-stmt
35-
- name: unreachable-code
36-
- name: unused-parameter
37-
- name: var-declaration
38-
- name: var-naming
39-
govet:
40-
enable-all: true
41-
sloglint:
42-
static-msg: true
43-
key-naming-case: snake
1+
version: "2"
442
linters:
3+
default: none
454
enable:
465
- asasalint
476
- asciicheck
@@ -61,11 +20,7 @@ linters:
6120
- gochecksumtype
6221
- gocritic
6322
- godot
64-
- gofmt
65-
- gofumpt
66-
- goimports
6723
- gosec
68-
- gosimple
6924
- gosmopolitan
7025
- govet
7126
- ineffassign
@@ -88,22 +43,80 @@ linters:
8843
- revive
8944
- sloglint
9045
- staticcheck
91-
- stylecheck
9246
- tagalign
93-
- tenv
9447
- thelper
9548
- tparallel
96-
- typecheck
9749
- unconvert
9850
- unparam
9951
- unused
10052
- usestdlibvars
10153
- wastedassign
10254
- whitespace
10355
- wrapcheck
104-
disable-all: true
56+
settings:
57+
govet:
58+
enable-all: true
59+
misspell:
60+
locale: US
61+
revive:
62+
rules:
63+
- name: blank-imports
64+
- name: constant-logical-expr
65+
- name: context-as-argument
66+
- name: context-keys-type
67+
- name: defer
68+
- name: dot-imports
69+
- name: duplicated-imports
70+
- name: empty-block
71+
- name: error-naming
72+
- name: error-return
73+
- name: error-strings
74+
- name: errorf
75+
- name: exported
76+
- name: import-shadowing
77+
- name: increment-decrement
78+
- name: indent-error-flow
79+
- name: package-comments
80+
- name: range
81+
- name: range-val-address
82+
- name: range-val-in-closure
83+
- name: receiver-naming
84+
- name: redefines-builtin-id
85+
- name: string-of-int
86+
- name: superfluous-else
87+
- name: time-naming
88+
- name: unchecked-type-assertion
89+
- name: unexported-return
90+
- name: unnecessary-stmt
91+
- name: unreachable-code
92+
- name: unused-parameter
93+
- name: var-declaration
94+
- name: var-naming
95+
sloglint:
96+
static-msg: true
97+
key-naming-case: snake
98+
exclusions:
99+
generated: lax
100+
presets:
101+
- comments
102+
- common-false-positives
103+
- legacy
104+
- std-error-handling
105+
paths:
106+
- third_party$
107+
- builtin$
108+
- examples$
105109
issues:
106110
max-issues-per-linter: 0
107111
max-same-issues: 0
108-
run:
109-
timeout: 5m
112+
formatters:
113+
enable:
114+
- gofmt
115+
- gofumpt
116+
- goimports
117+
exclusions:
118+
generated: lax
119+
paths:
120+
- third_party$
121+
- builtin$
122+
- examples$

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ repos:
2626
- id: fix-byte-order-marker
2727

2828
- repo: https://github.com/golangci/golangci-lint
29-
rev: v1.64.8
29+
rev: v2.1.5
3030
hooks:
3131
- id: golangci-lint-full
3232

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ VERSION = 1.4.0
22
TAG = $(VERSION)
33
PREFIX = nginx/nginx-prometheus-exporter
44
# renovate: datasource=github-tags depName=golangci/golangci-lint
5-
GOLANGCI_LINT_VERSION = v1.64.8
5+
GOLANGCI_LINT_VERSION = v2.1.5
66

77
.DEFAULT_GOAL:=nginx-prometheus-exporter
88

@@ -21,7 +21,7 @@ build-goreleaser: ## Build all binaries using GoReleaser
2121

2222
.PHONY: lint
2323
lint: ## Run linter
24-
go run github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) run --fix
24+
go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) run --fix
2525

2626
.PHONY: test
2727
test: ## Run tests

exporter.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ func cloneRequest(req *http.Request) *http.Request {
292292
// addMissingEnvironmentFlags sets Envar on any flag which has
293293
// the "web." prefix which doesn't already have an Envar set.
294294
func addMissingEnvironmentFlags(ka *kingpin.Application) {
295-
for _, f := range ka.Model().FlagGroupModel.Flags {
295+
for _, f := range ka.Model().Flags {
296296
if strings.HasPrefix(f.Name, "web.") && f.Envar == "" {
297297
retrievedFlag := ka.GetFlag(f.Name)
298298
if retrievedFlag != nil {

exporter_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func TestAddMissingEnvironmentFlags(t *testing.T) {
130130
// instead of checking the envar of each matching flag name
131131
for k, v := range expectedMatches {
132132
matched := false
133-
for _, f := range kingpin.CommandLine.Model().FlagGroupModel.Flags {
133+
for _, f := range kingpin.CommandLine.Model().Flags {
134134
if f.Name == k && f.Envar == v {
135135
matched = true
136136
}

0 commit comments

Comments
 (0)