Skip to content

Commit 3be6388

Browse files
committed
feat(ci): golangci-lint update
1 parent 1e3b54e commit 3be6388

File tree

26 files changed

+115
-71
lines changed

26 files changed

+115
-71
lines changed

.github/workflows/ci-lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ jobs:
4848
# Skip this step for dependabot pull requests.
4949
if: always() && github.actor != 'dependabot[bot]'
5050
- name: Lint Go
51-
uses: golangci/golangci-lint-action@v6
51+
uses: golangci/golangci-lint-action@v8
5252
with:
53-
version: v1.64.5
53+
version: v2.3.0
5454
# Always run this step so that all linting errors can be seen at once.
5555
if: always()

.golangci.yml

Lines changed: 87 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,105 @@
1-
# golangci-lint configuration.
2-
3-
# For more information, see:
4-
# https://golangci-lint.run/usage/configuration/.
5-
6-
run:
7-
timeout: 5m
8-
1+
version: "2"
92
linters:
10-
# Disable all linters except the ones explicitly listed below.
11-
disable-all: true
3+
default: none
124
enable:
13-
- asciicheck
145
- bodyclose
6+
- copyloopvar
157
- depguard
16-
- dogsled
17-
- dupl
188
- errcheck
19-
- exhaustive
209
- goconst
21-
- gocritic
2210
- gocyclo
23-
- godot
24-
- gofumpt
25-
- goheader
26-
- goimports
27-
- revive
28-
- gomodguard
2911
- goprintffuncname
3012
- gosec
31-
- gosimple
3213
- govet
3314
- ineffassign
3415
- misspell
35-
- nakedret
36-
- nestif
37-
- noctx
38-
- prealloc
16+
- revive
3917
- rowserrcheck
4018
- staticcheck
41-
- stylecheck
42-
- sqlclosecheck
43-
- typecheck
4419
- unconvert
45-
- unparam
4620
- unused
47-
- whitespace
4821

49-
linters-settings:
50-
exhaustive:
51-
# Switch statements are to be considered exhaustive if a 'default' case is
52-
# present, even if all enum members aren't listed in the switch.
53-
default-signifies-exhaustive: true
54-
goimports:
55-
# Put local imports after 3rd-party packages.
56-
local-prefixes: github.com/oasisprotocol/
57-
gosec:
58-
excludes:
59-
# https://github.com/securego/gosec#available-rules
60-
- G402
61-
- G404
62-
- G115
63-
depguard:
22+
settings:
23+
depguard:
24+
rules:
25+
main:
26+
files:
27+
- $all
28+
allow:
29+
- $gostd
30+
- github.com/oasisprotocol/oasis-web3-gateway
31+
- github.com/oasisprotocol/oasis-core
32+
- github.com/oasisprotocol/oasis-sdk
33+
- github.com/ethereum/go-ethereum
34+
- github.com/gorilla/mux
35+
- github.com/gorilla/websocket
36+
- github.com/knadh/koanf
37+
- github.com/prometheus/client_golang/prometheus
38+
- github.com/rs/cors
39+
- github.com/spf13/cobra
40+
- github.com/stretchr/testify
41+
- github.com/uptrace/bun
42+
- golang.org/x/crypto
43+
- google.golang.org/grpc
44+
deny:
45+
- pkg: "github.com/pkg/errors"
46+
desc: Should be replaced by standard lib errors package
47+
- pkg: github.com/fxamacker/cbor/v2
48+
desc: Use oasis-core/go/common/cbor instead
49+
50+
exclusions:
51+
generated: lax
6452
rules:
65-
main:
66-
files:
67-
- $all
68-
allow:
69-
- $gostd
70-
- github.com/oasisprotocol
71-
- google.golang.org/grpc
72-
- github.com/ethereum/go-ethereum
73-
- github.com/stretchr/testify
74-
- github.com/uptrace/bun
75-
- github.com/gorilla
76-
- github.com/prometheus
77-
- github.com/knadh/koanf
78-
- github.com/rs/cors
79-
- github.com/spf13/cobra
53+
# Exclude some linters on test files.
54+
- linters:
55+
- govet
56+
- revive
57+
- gosec
58+
- errcheck
59+
path: (.+)_test\.go
60+
- linters:
61+
- govet
62+
- revive
63+
- gosec
64+
path: tests/*
65+
# Exclude var-naming.
66+
- linters:
67+
- revive
68+
text: var-naming
69+
# Exclude sttutering.
70+
- linters:
71+
- revive
72+
text: and that stutters
73+
# Exclude unused parameters.
74+
- linters:
75+
- revive
76+
text: unused-parameter
77+
# Exclude required comments on exported structs/fields.
78+
- linters:
79+
- revive
80+
text: "exported:"
81+
# Exclude could apply De Morgan's law.
82+
- linters:
83+
- staticcheck
84+
text: QF1001
85+
# Exclude could remove embedded fields.
86+
- linters:
87+
- staticcheck
88+
text: QF1008
89+
# Exclude intiger overflow conversion.
90+
- linters:
91+
- gosec
92+
text: G115
93+
# Exclude audited unsafe calls.
94+
- linters:
95+
- gosec
96+
text: G103
97+
98+
formatters:
99+
enable:
100+
- gofumpt
101+
- goimports
102+
settings:
103+
goimports:
104+
local-prefixes:
105+
- github.com/oasisprotocol/

conf/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package conf provides the configuration for the Oasis Web3 Gateway.
12
package conf
23

34
import (

db/migrations/migrations.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package migrations provides database migrations for the Oasis Web3 Gateway.
12
package migrations
23

34
import (

db/migrator/migrator.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,7 @@ func (m *Migrator) Migrate(ctx context.Context) error {
6161
return fmt.Errorf("no migrations")
6262
}
6363
var stop bool
64-
for {
65-
if stop {
66-
break
67-
}
64+
for !stop {
6865
// Apply next migration in a transaction.
6966
if err := m.db.RunInTx(ctx, nil, func(ctx context.Context, tx bun.Tx) error {
7067
// Lock migrations table for the transaction duration.

db/model/model.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package model defines the database models used in the application.
12
package model
23

34
// AccessTuple is the element of an AccessList.

filters/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package filters defines the filtering event system.
12
package filters
23

34
import (

indexer/backend.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package indexer provides the indexer backend implementation.
12
package indexer
23

34
import (

log/log.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package log provides logging functionality for the Oasis Web3 Gateway.
12
package log
23

34
import (

main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package main implements the main entry point for the Oasis Web3 Gateway.
12
package main
23

34
import (
@@ -210,7 +211,7 @@ func runRoot() error {
210211
logger.Error("failed to establish connection", "err", err)
211212
return err
212213
}
213-
defer conn.Close()
214+
defer conn.Close() // nolint:errcheck
214215

215216
// Create the runtime client with account module query helpers.
216217
rc := client.New(conn, runtimeID)
@@ -305,7 +306,7 @@ func runRoot() error {
305306

306307
<-sigc
307308
logger.Info("Got interrupt, shutting down...")
308-
go svr.Close()
309+
go svr.Close() //nolint:errcheck
309310
go indx.Stop()
310311
go gasPriceOracle.Stop()
311312
}()

0 commit comments

Comments
 (0)