Skip to content

Commit 618082e

Browse files
committed
Update linter and fix linting issues
1 parent 81cb7ef commit 618082e

File tree

5 files changed

+75
-62
lines changed

5 files changed

+75
-62
lines changed

.github/workflows/lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ jobs:
3333
go-version: stable
3434

3535
- name: Lint Go
36-
uses: golangci/golangci-lint-action@2226d7cb06a077cd73e56eedd38eecad18e5d837 # v6.5.0
36+
uses: golangci/golangci-lint-action@1481404843c368bc19ca9406f87d6e0fc97bdcfd # v7.0.0
3737
with:
38-
version: v1.64.8 # renovate: datasource=github-tags depName=golangci/golangci-lint
38+
version: v2.1.5 # renovate: datasource=github-tags depName=golangci/golangci-lint
3939

4040
actionlint:
4141
name: Actionlint

.golangci.yml

Lines changed: 64 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +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
1+
version: "2"
412
linters:
3+
default: none
424
enable:
435
- asasalint
446
- asciicheck
@@ -59,11 +21,7 @@ linters:
5921
- gochecksumtype
6022
- gocritic
6123
- godot
62-
- gofmt
63-
- gofumpt
64-
- goimports
6524
- gosec
66-
- gosimple
6725
- gosmopolitan
6826
- govet
6927
- ineffassign
@@ -75,29 +33,84 @@ linters:
7533
- nilerr
7634
- noctx
7735
- nolintlint
36+
- paralleltest
7837
- perfsprint
7938
- prealloc
8039
- predeclared
81-
- paralleltest
8240
- reassign
8341
- revive
8442
- staticcheck
85-
- stylecheck
8643
- tagalign
87-
- tenv
8844
- thelper
8945
- tparallel
90-
- typecheck
9146
- unconvert
9247
- unparam
9348
- unused
9449
- usestdlibvars
9550
- wastedassign
9651
- whitespace
9752
- wrapcheck
98-
disable-all: true
53+
settings:
54+
govet:
55+
enable-all: true
56+
misspell:
57+
locale: US
58+
revive:
59+
rules:
60+
- name: blank-imports
61+
- name: constant-logical-expr
62+
- name: context-as-argument
63+
- name: context-keys-type
64+
- name: defer
65+
- name: dot-imports
66+
- name: duplicated-imports
67+
- name: empty-block
68+
- name: error-naming
69+
- name: error-return
70+
- name: error-strings
71+
- name: errorf
72+
- name: exported
73+
- name: import-shadowing
74+
- name: increment-decrement
75+
- name: indent-error-flow
76+
- name: package-comments
77+
- name: range
78+
- name: range-val-address
79+
- name: range-val-in-closure
80+
- name: receiver-naming
81+
- name: redefines-builtin-id
82+
- name: string-of-int
83+
- name: superfluous-else
84+
- name: time-naming
85+
- name: unchecked-type-assertion
86+
- name: unexported-return
87+
- name: unnecessary-stmt
88+
- name: unreachable-code
89+
- name: unused-parameter
90+
- name: var-declaration
91+
- name: var-naming
92+
exclusions:
93+
generated: lax
94+
presets:
95+
- comments
96+
- common-false-positives
97+
- legacy
98+
- std-error-handling
99+
paths:
100+
- third_party$
101+
- builtin$
102+
- examples$
99103
issues:
100104
max-issues-per-linter: 0
101105
max-same-issues: 0
102-
run:
103-
timeout: 5m
106+
formatters:
107+
enable:
108+
- gofmt
109+
- gofumpt
110+
- goimports
111+
exclusions:
112+
generated: lax
113+
paths:
114+
- third_party$
115+
- builtin$
116+
- examples$

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ repos:
2424
- id: detect-private-key
2525

2626
- repo: https://github.com/golangci/golangci-lint
27-
rev: v1.64.8
27+
rev: v2.0.2
2828
hooks:
2929
- id: golangci-lint-full
3030

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# renovate: datasource=github-tags depName=golangci/golangci-lint
2-
GOLANGCI_LINT_VERSION = v1.64.8
2+
GOLANGCI_LINT_VERSION = v2.1.5
33

44
test: unit-test test-integration test-integration-no-stream-block clean
55

66
lint:
7-
go run github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) run --fix
7+
go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) run --fix
88

99
unit-test:
1010
go test -v -shuffle=on -race client/*.go

client/nginx_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -677,8 +677,8 @@ func TestClientWithMaxAPI(t *testing.T) {
677677
t.Parallel()
678678
// Test creating a new client with max API version
679679
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
680-
switch {
681-
case r.RequestURI == "/":
680+
switch r.RequestURI {
681+
case "/":
682682
_, err := w.Write([]byte(tt.apiVersions))
683683
if err != nil {
684684
t.Fatalf("unexpected error: %v", err)
@@ -852,8 +852,8 @@ func TestGetStats_SSL(t *testing.T) {
852852
func TestGetMaxAPIVersionServer(t *testing.T) {
853853
t.Parallel()
854854
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
855-
switch {
856-
case r.RequestURI == "/":
855+
switch r.RequestURI {
856+
case "/":
857857
_, err := w.Write([]byte(`[4, 5, 6, 7]`))
858858
if err != nil {
859859
t.Fatalf("unexpected error: %v", err)
@@ -884,8 +884,8 @@ func TestGetMaxAPIVersionServer(t *testing.T) {
884884
func TestGetMaxAPIVersionClient(t *testing.T) {
885885
t.Parallel()
886886
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
887-
switch {
888-
case r.RequestURI == "/":
887+
switch r.RequestURI {
888+
case "/":
889889
_, err := w.Write([]byte(`[4, 5, 6, 7, 8, 9, 25]`))
890890
if err != nil {
891891
t.Fatalf("unexpected error: %v", err)

0 commit comments

Comments
 (0)