Skip to content

Commit 3544e0e

Browse files
linter v2 (#114)
* sav * sav
1 parent e233c93 commit 3544e0e

7 files changed

Lines changed: 138 additions & 143 deletions

File tree

.github/workflows/go-checks.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ jobs:
1313
- uses: actions/checkout@v4
1414
- uses: actions/setup-go@v5
1515
with:
16-
go-version: '1.22'
16+
go-version: '1.23'
1717
- run: go mod tidy
18-
- uses: golangci/golangci-lint-action@v6
18+
- uses: golangci/golangci-lint-action@v7
1919
with:
20-
version: 'v1.61'
20+
version: 'v2.1.5'
2121
- run: go build -v ./...
2222
- run: go test -v ./...

.golangci.yml

Lines changed: 130 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,122 +1,138 @@
1-
run:
2-
timeout: 10m
3-
1+
version: "2"
42
linters:
5-
presets:
6-
- bugs
7-
- error
3+
enable:
4+
- asasalint
5+
- asciicheck
6+
- bidichk
7+
- bodyclose
8+
- durationcheck
9+
- fatcontext
10+
- gochecksumtype
11+
- gocritic
12+
- gosec
13+
- gosmopolitan
14+
- loggercheck
15+
- nilnesserr
16+
- prealloc
17+
- protogetter
18+
- reassign
19+
- recvcheck
20+
- rowserrcheck
21+
- spancheck
22+
- sqlclosecheck
23+
- testifylint
24+
- unconvert
25+
- zerologlint
26+
- makezero
27+
- noctx
28+
- nilerr
29+
- errorlint
830
- unused
9-
- performance
1031
disable:
11-
- exhaustive
12-
- musttag
13-
- contextcheck
14-
- wrapcheck
15-
- goerr113
16-
- unparam
17-
- makezero #TODO: enable me
18-
- noctx #TODO: enable me
19-
- nilerr #TODO: enable me
20-
- errorlint #TODO: enable me
2132
- errchkjson #TODO: enable me
22-
- unused #TODO: enable me
2333
- perfsprint #TODO: enable me
34+
- contextcheck
35+
- err113
36+
- exhaustive
2437
- gocheckcompilerdirectives
38+
- musttag
39+
- unparam
40+
- wrapcheck
41+
settings:
42+
goconst:
43+
min-len: 2
44+
min-occurrences: 2
45+
gocritic:
46+
disabled-checks:
47+
- rangeValCopy
48+
- exitAfterDefer
49+
- elseif
50+
- dupBranchBody
51+
- assignOp
52+
- singleCaseSwitch
53+
- captLocal
54+
- commentFormatting
55+
- ifElseChain
56+
- sprintfQuotedString
57+
- commentedOutCode
58+
- preferFprint
59+
- importShadow
60+
- emptyStringTest
61+
- paramTypeCombine
62+
- unnamedResult
63+
enabled-tags:
64+
- performance
65+
- diagnostic
66+
- style
67+
settings:
68+
rangeExprCopy:
69+
sizeThreshold: 512
70+
skipTestFuncs: true
71+
underef:
72+
skipRecvDeref: true
73+
govet:
74+
disable:
75+
- deepequalerrors
76+
- fieldalignment
77+
- shadow
78+
- unsafeptr
79+
exclusions:
80+
generated: lax
81+
presets:
82+
- comments
83+
- common-false-positives
84+
- legacy
85+
- std-error-handling
86+
rules:
87+
- linters:
88+
- golint
89+
text: should be
90+
- linters:
91+
- errcheck
92+
text: not checked
93+
- linters:
94+
- staticcheck
95+
text: SA(1019|1029|5011)
96+
- linters:
97+
- gocritic
98+
- gosec
99+
- unused
100+
path: test\.go
101+
- linters:
102+
- gocritic
103+
- gosec
104+
- unused
105+
path: hack\.go
106+
- linters:
107+
- gocritic
108+
- gosec
109+
- unused
110+
path: cmd/devp2p
111+
- linters:
112+
- gocritic
113+
- gosec
114+
path: metrics/sample\.go
115+
- linters:
116+
- gocritic
117+
- gosec
118+
path: p2p/simulations
119+
- linters:
120+
- gocritic
121+
- gosec
122+
path: p2p/dnsdisc
123+
paths:
124+
- third_party$
125+
- builtin$
126+
- examples$
127+
formatters:
25128
enable:
26-
- unconvert
27-
# - predeclared #TODO: enable me
28-
# - thelper #TODO: enable me
29-
# - wastedassign
30129
- gofmt
31-
- gocritic
32-
# - revive
33-
# - forcetypeassert
34-
# - stylecheck
35-
36-
linters-settings:
37-
gocritic: # see https://golangci-lint.run/usage/linters/#gocritic and https://go-critic.github.io/overview#checks-overview
38-
enabled-tags:
39-
- performance
40-
- diagnostic
41-
- style
42-
disabled-checks:
43-
- rangeValCopy
44-
- exitAfterDefer
45-
- elseif
46-
- dupBranchBody
47-
- assignOp
48-
- singleCaseSwitch
49-
- captLocal
50-
- commentFormatting
51-
- ifElseChain
52-
- sprintfQuotedString
53-
- commentedOutCode
54-
- preferFprint
55-
56-
# style tag
57-
- importShadow
58-
- emptyStringTest
59-
- paramTypeCombine
60-
- unnamedResult
61-
62-
settings:
63-
rangeExprCopy:
64-
# size in bytes that makes the warning trigger (default 512)
65-
sizeThreshold: 512
66-
# whether to check test functions (default true)
67-
skipTestFuncs: true
68-
underef:
69-
# whether to skip (*x).method() calls where x is a pointer receiver (default true)
70-
skipRecvDeref: true
71-
72-
govet:
73-
disable:
74-
- deepequalerrors
75-
- fieldalignment
76-
- shadow
77-
- unsafeptr
78-
goconst:
79-
min-len: 2
80-
min-occurrences: 2
81-
gofmt:
82-
simplify: false
83-
84-
issues:
85-
exclude-rules:
86-
- linters:
87-
- golint
88-
text: "should be"
89-
- linters:
90-
- errcheck
91-
text: "not checked"
92-
- linters:
93-
- staticcheck
94-
text: "SA(1019|1029|5011)"
95-
# Exclude some linters from running on tests files.
96-
- path: test\.go
97-
linters:
98-
- gosec
99-
- unused
100-
- gocritic
101-
- path: hack\.go
102-
linters:
103-
- gosec
104-
- unused
105-
- gocritic
106-
- path: cmd/devp2p
107-
linters:
108-
- gosec
109-
- unused
110-
- gocritic
111-
- path: metrics/sample\.go
112-
linters:
113-
- gosec
114-
- gocritic
115-
- path: p2p/simulations
116-
linters:
117-
- gosec
118-
- gocritic
119-
- path: p2p/dnsdisc
120-
linters:
121-
- gosec
122-
- gocritic
130+
settings:
131+
gofmt:
132+
simplify: false
133+
exclusions:
134+
generated: lax
135+
paths:
136+
- third_party$
137+
- builtin$
138+
- examples$

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ lintci:
3838
## lintci-deps: (re)installs golangci-lint to build/bin/golangci-lint
3939
lintci-deps:
4040
rm -f ./build/bin/golangci-lint
41-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./build/bin v1.57.2
41+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./build/bin v2.1.5
4242

4343
.PHONY: build test run clean

cmd/diagnostics/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"bufio"
55
"context"
6+
"errors"
67
"fmt"
78
"log"
89
"net/http"
@@ -68,7 +69,7 @@ func main() {
6869
switch s := <-signalCh; s {
6970
case syscall.SIGTERM:
7071
log.Println("Terminating gracefully.")
71-
if err := srv.Shutdown(context.Background()); err != http.ErrServerClosed {
72+
if err := srv.Shutdown(context.Background()); !errors.Is(err, http.ErrServerClosed) {
7273
log.Println("Failed to shutdown server:", err)
7374
}
7475
case syscall.SIGINT:

internal/erigon_node/remote_db.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,13 @@ func (rc *RemoteCursor) findFullDbPath(ctx context.Context, db string) (string,
145145
request, err := rc.nodeClient.fetch(ctx, "dbs", nil)
146146

147147
if err != nil {
148-
return "", fmt.Errorf("unable to fetch database list: %s", err)
148+
return "", fmt.Errorf("unable to fetch database list: %w", err)
149149
}
150150

151151
_, result, err := request.nextResult(ctx)
152152

153153
if err != nil {
154-
return "", fmt.Errorf("unable to fetch database list: %s", err)
154+
return "", fmt.Errorf("unable to fetch database list: %w", err)
155155
}
156156

157157
var lines []string

internal/sessions/helpers.go

Lines changed: 0 additions & 18 deletions
This file was deleted.

internal/sessions/middleware.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ import (
44
"net/http"
55
)
66

7-
const sessionIdCookieName = "sessionId"
8-
9-
const sessionIdCookieDuration = 30 * 24 * 3600 // 30 days
10-
117
type Middleware struct {
128
CacheService
139
}

0 commit comments

Comments
 (0)