Skip to content

Commit 2c85076

Browse files
authored
Merge pull request #1085 from oasisprotocol/ptrus/feature/update-golangcilint
Update golangci-lint to v2.2.1
2 parents 506c16d + b84afba commit 2c85076

File tree

53 files changed

+171
-89
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+171
-89
lines changed

.changelog/1085.trivial.md

Whitespace-only changes.

.github/workflows/ci-lint.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ jobs:
9191
# Always run this step so that all linting errors can be seen at once.
9292
if: always()
9393
- name: Lint Go
94-
uses: golangci/golangci-lint-action@v3
94+
uses: golangci/golangci-lint-action@v8
9595
with:
9696
# Update README.md instructions when bumping this.
97-
version: v1.64.8
97+
version: v2.2.1
9898
# Always run this step so that all linting errors can be seen at once.
9999
if: always()

.golangci.yaml

Lines changed: 110 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,126 @@
1-
# golangci-lint configuration.
2-
3-
# For more information, see:
4-
# https://golangci-lint.run/usage/configuration/.
5-
6-
run:
7-
timeout: 5m
8-
9-
issues:
10-
exclude-dirs:
11-
# Contains a cloned subset of oasis-core. Some types are unused, some
12-
# formatting is haphazard. We don't care much; this code is meant to be
13-
# frozen in time.
14-
- coreapi
15-
16-
exclude-rules:
17-
- path: '(.+)_test\.go'
18-
linters:
19-
- govet
20-
- linters: [revive]
21-
text: var-naming # do not demand that `Id` always be spelled `ID`; messes with autogenerated code
22-
- linters: [structcheck]
23-
text: is unused # linter has false positives; claims that fields are unused even though they're not
24-
- linters: [revive]
25-
text: stutters
26-
- linters: [revive]
27-
text: unused-parameter # it's fine to have unused func parameters that are not named `_`; they're usually there because the function is part of an interface
28-
- linters: [stylecheck]
29-
text: ST1003 # do not demand that `Id` always be spelled `ID`; messes with autogenerated code
30-
1+
version: "2"
312
linters:
32-
# Disable all linters except the ones explicitly listed below.
33-
disable-all: true
3+
default: none
344
enable:
35-
- asciicheck
365
- bodyclose
37-
- dogsled
38-
- errcheck
39-
- exhaustive
6+
- copyloopvar
7+
- depguard
408
- goconst
41-
- gocritic
429
- gocyclo
43-
- godot
44-
- gofumpt
45-
- goheader
46-
- goimports
47-
- gomodguard
4810
- goprintffuncname
4911
- gosec
50-
- gosimple
5112
- govet
5213
- ineffassign
5314
- misspell
54-
- nakedret
55-
- nestif
56-
- noctx
57-
- nolintlint
58-
- prealloc
5915
- revive
6016
- rowserrcheck
6117
- staticcheck
62-
- stylecheck
63-
- sqlclosecheck
64-
- typecheck
6518
- unconvert
66-
- unparam
6719
- unused
68-
- whitespace
6920

70-
linters-settings:
71-
exhaustive:
72-
# Switch statements are to be considered exhaustive if a 'default' case is
73-
# present, even if all enum members aren't listed in the switch.
74-
default-signifies-exhaustive: true
75-
govet:
76-
# Enabled checking for shadowed variables.
77-
shadow: true
78-
gosec:
79-
excludes:
80-
# https://github.com/securego/gosec#available-rules
81-
- G115
82-
goimports:
83-
# Put local imports after 3rd-party packages.
84-
local-prefixes: github.com/oasisprotocol/nexus
21+
settings:
22+
depguard:
23+
rules:
24+
main:
25+
files:
26+
- $all
27+
allow:
28+
- $gostd
29+
- github.com/oasisprotocol/nexus
30+
- github.com/oasisprotocol/oasis-core
31+
- github.com/oasisprotocol/oasis-sdk
32+
- github.com/oasisprotocol/metadata-registry-tools
33+
- github.com/akrylysov/pogreb
34+
- github.com/dgraph-io/ristretto
35+
- github.com/ethereum/go-ethereum
36+
- github.com/go-chi/chi/v5
37+
- github.com/go-kit/log
38+
- github.com/golang-migrate/migrate/v4
39+
- github.com/google/uuid
40+
- github.com/jackc/pgx/v5
41+
- github.com/knadh/koanf
42+
- github.com/prometheus/client_golang/prometheus
43+
- github.com/rs/cors
44+
- github.com/spf13/cobra
45+
- github.com/stretchr/testify/assert
46+
- github.com/stretchr/testify/require
47+
- golang.org/x/crypto/sha3
48+
- google.golang.org/grpc
49+
- golang.org/x/sync/errgroup
50+
deny:
51+
- pkg: github.com/pkg/errors
52+
desc: Should be replaced by standard lib errors package
53+
- pkg: github.com/fxamacker/cbor/v2
54+
desc: Use oasis-core/go/common/cbor instead
55+
56+
exclusions:
57+
generated: lax
58+
rules:
59+
# Exclude some linters on test files.
60+
- linters:
61+
- govet
62+
- revive
63+
- gosec
64+
path: (.+)_test\.go
65+
- linters:
66+
- govet
67+
- revive
68+
- gosec
69+
path: tests/*
70+
# Exclude var-naming.
71+
- linters:
72+
- revive
73+
text: var-naming
74+
# Exclude sttutering.
75+
- linters:
76+
- revive
77+
text: and that stutters
78+
# Exclude unused parameters.
79+
- linters:
80+
- revive
81+
text: unused-parameter
82+
# Exclude required comments on exported structs/fields.
83+
- linters:
84+
- revive
85+
text: "exported:"
86+
# Exclude could apply De Morgan's law.
87+
- linters:
88+
- staticcheck
89+
text: QF1001
90+
# Exclude could remove embedded fields.
91+
- linters:
92+
- staticcheck
93+
text: QF1008
94+
# Exclude intiger overflow conversion.
95+
- linters:
96+
- gosec
97+
text: G115
98+
# Exclude audited unsafe calls.
99+
- linters:
100+
- gosec
101+
text: G103
102+
103+
paths:
104+
- coreapi
105+
- third_party$
106+
- builtin$
107+
- examples$
108+
- cmd/bisect
109+
110+
formatters:
111+
enable:
112+
- gofumpt
113+
- goimports
114+
115+
settings:
116+
goimports:
117+
local-prefixes:
118+
- github.com/oasisprotocol/nexus
119+
120+
exclusions:
121+
generated: lax
122+
paths:
123+
- coreapi
124+
- third_party$
125+
- builtin$
126+
- examples$

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ create a PR, but without them, you're at the mercy of CI.
122122

123123
```sh
124124
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh \
125-
| sh -s -- -b $(go env GOPATH)/bin v1.62.2
125+
| sh -s -- -b $(go env GOPATH)/bin v2.2.1
126126
```
127127

128128
- **gofumpt**: `go install mvdan.cc/gofumpt@latest`

analyzer/aggregate_stats/aggregate_stats.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package aggregate_stats implements the aggregate stats analyzer.
12
package aggregate_stats
23

34
import (
@@ -133,7 +134,6 @@ func (a *aggregateStatsAnalyzer) aggregateStatsWorker(ctx context.Context) {
133134
// Compute daily tx volume stats every 5 minutes for all layers.
134135
// Uses the stats.min5_tx_volume results so that it is efficient.
135136
for _, layer := range statsLayers {
136-
layer := layer
137137
sc := &statsComputation{
138138
target: a.target,
139139
name: "daily_tx_volume_" + layer,

analyzer/api.go

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

34
import (

analyzer/consensus/consensus_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ import (
66
"reflect"
77
"testing"
88

9-
"github.com/fxamacker/cbor/v2"
109
"github.com/stretchr/testify/require"
1110

11+
"github.com/oasisprotocol/oasis-core/go/common/cbor"
12+
1213
roothashCobalt "github.com/oasisprotocol/nexus/coreapi/v21.1.1/roothash/api"
1314
"github.com/oasisprotocol/nexus/coreapi/v22.2.11/consensus/api/transaction"
1415
roothashDamask "github.com/oasisprotocol/nexus/coreapi/v22.2.11/roothash/api"

analyzer/consensus/static/accounts.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package static contains static data for the consensus analyzer.
12
package static
23

34
import (

analyzer/consensus_accounts_list/accounts_list.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package consensus_accounts_list implements the consensus accounts list analyzer.
12
package consensus_accounts_list
23

34
import (

analyzer/evmabi/evmabi.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package evmabi implements the common EVM ABI specs.
12
package evmabi
23

34
import (

0 commit comments

Comments
 (0)