Skip to content

Commit 7a94243

Browse files
authored
Update golangci-lint (#2269)
* Remove deprecated golangci-lint configs * Update golangci-lint * Apply linter fixes
1 parent 1eaa762 commit 7a94243

File tree

5 files changed

+149
-140
lines changed

5 files changed

+149
-140
lines changed

.circleci/config.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ jobs:
8080
8181
lint:
8282
docker:
83-
- image: golangci/golangci-lint:v1.64.8
84-
resource_class: large
83+
- image: golangci/golangci-lint:v2.1.6
8584
steps:
8685
- checkout
8786
- run:

.golangci.yml

Lines changed: 141 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -1,148 +1,162 @@
1+
version: "2"
12
run:
23
tests: true
3-
timeout: 15m
4-
sort-results: true
54
allow-parallel-runners: true
6-
exclude-dir: testutil/testdata
7-
85
linters:
9-
disable-all: true
6+
default: none
107
enable:
11-
- errcheck
12-
- dogsled
138
- copyloopvar
9+
- dogsled
10+
- errcheck
1411
- goconst
1512
- gocritic
16-
- gci
17-
- gofumpt
1813
- gosec
19-
- gosimple
2014
- govet
2115
- ineffassign
2216
- misspell
2317
- nakedret
2418
- nolintlint
25-
- staticcheck
2619
- revive
27-
- stylecheck
28-
- typecheck
20+
- staticcheck
2921
# - thelper # too many positives with table tests that have custom setup(*testing.T)
3022
- unconvert
3123
- unused
32-
24+
settings:
25+
dogsled:
26+
max-blank-identifiers: 6
27+
gocritic:
28+
disabled-checks:
29+
- regexpMust
30+
- appendAssign
31+
- ifElseChain
32+
gosec:
33+
# To select a subset of rules to run.
34+
# Available rules: https://github.com/securego/gosec#available-rules
35+
# Default: [] - means include all rules
36+
includes:
37+
# - G101 # Look for hard coded credentials
38+
- G102 # Bind to all interfaces
39+
- G103 # Audit the use of unsafe block
40+
- G104 # Audit errors not checked
41+
- G106 # Audit the use of ssh.InsecureIgnoreHostKey
42+
- G107 # Url provided to HTTP request as taint input
43+
- G108 # Profiling endpoint automatically exposed on /debug/pprof
44+
- G109 # Potential Integer overflow made by strconv.Atoi result conversion to int16/32
45+
- G110 # Potential DoS vulnerability via decompression bomb
46+
- G111 # Potential directory traversal
47+
- G112 # Potential slowloris attack
48+
- G113 # Usage of Rat.SetString in math/big with an overflow (CVE-2022-23772)
49+
- G114 # Use of net/http serve function that has no support for setting timeouts
50+
- G201 # SQL query construction using format string
51+
- G202 # SQL query construction using string concatenation
52+
- G203 # Use of unescaped data in HTML templates
53+
- G204 # Audit use of command execution
54+
- G301 # Poor file permissions used when creating a directory
55+
- G302 # Poor file permissions used with chmod
56+
- G303 # Creating tempfile using a predictable path
57+
- G304 # File path provided as taint input
58+
- G305 # File traversal when extracting zip/tar archive
59+
- G306 # Poor file permissions used when writing to a new file
60+
- G307 # Deferring a method which returns an error
61+
- G401 # Detect the usage of DES, RC4, MD5 or SHA1
62+
- G402 # Look for bad TLS connection settings
63+
- G403 # Ensure minimum RSA key length of 2048 bits
64+
- G404 # Insecure random number source (rand)
65+
- G501 # Import blocklist: crypto/md5
66+
- G502 # Import blocklist: crypto/des
67+
- G503 # Import blocklist: crypto/rc4
68+
- G504 # Import blocklist: net/http/cgi
69+
- G505 # Import blocklist: crypto/sha1
70+
- G601 # Implicit memory aliasing of items from a range statement
71+
misspell:
72+
locale: US
73+
nolintlint:
74+
require-explanation: false
75+
require-specific: false
76+
allow-unused: false
77+
revive:
78+
rules:
79+
- name: redefines-builtin-id
80+
disabled: true
81+
staticcheck:
82+
checks:
83+
- all
84+
exclusions:
85+
generated: lax
86+
presets:
87+
- comments
88+
- common-false-positives
89+
- legacy
90+
- std-error-handling
91+
rules:
92+
- linters:
93+
- gosec
94+
text: Use of weak random number generator
95+
- linters:
96+
- staticcheck
97+
text: "ST1003:"
98+
# FIXME: Disabled until golangci-lint updates stylecheck with this fix:
99+
# https://github.com/dominikh/go-tools/issues/389
100+
- linters:
101+
- staticcheck
102+
text: "ST1016:"
103+
- linters:
104+
- staticcheck
105+
path: migrations
106+
text: "SA1019:"
107+
- linters:
108+
- staticcheck
109+
text: "SA1019: codec.NewAminoCodec is deprecated" # TODO remove once migration path is set out
110+
- linters:
111+
- staticcheck
112+
text: "SA1019: legacybech32.MustMarshalPubKey" # TODO remove once ready to remove from the sdk
113+
- linters:
114+
- staticcheck
115+
text: "SA1019: legacybech32.MarshalPubKey" # TODO remove once ready to remove from the sdk
116+
- linters:
117+
- staticcheck
118+
text: "SA1019: legacybech32.UnmarshalPubKey" # TODO remove once ready to remove from the sdk
119+
- linters:
120+
- staticcheck
121+
text: "SA1019: params.SendEnabled is deprecated" # TODO remove once ready to remove from the sdk
122+
- linters:
123+
- nolintlint
124+
text: leading space
125+
paths:
126+
- server/grpc/gogoreflection/fix_registration.go
127+
- .*\.pb\.go$
128+
- .*\.pb\.gw\.\.go$
129+
- .*\.pulsar\.go$
130+
- testutil/testdata
131+
- third_party$
132+
- builtin$
133+
- examples$
33134
issues:
34-
exclude-files:
35-
- server/grpc/gogoreflection/fix_registration.go
36-
- ".*\\.pb\\.go$"
37-
- ".*\\.pb\\.gw\\.\\.go$"
38-
- ".*\\.pulsar\\.go$"
39-
exclude-rules:
40-
- text: "Use of weak random number generator"
41-
linters:
42-
- gosec
43-
- text: "ST1003:"
44-
linters:
45-
- stylecheck
46-
# FIXME: Disabled until golangci-lint updates stylecheck with this fix:
47-
# https://github.com/dominikh/go-tools/issues/389
48-
- text: "ST1016:"
49-
linters:
50-
- stylecheck
51-
- path: "migrations"
52-
text: "SA1019:"
53-
linters:
54-
- staticcheck
55-
- text: "SA1019: codec.NewAminoCodec is deprecated" # TODO remove once migration path is set out
56-
linters:
57-
- staticcheck
58-
- text: "SA1019: legacybech32.MustMarshalPubKey" # TODO remove once ready to remove from the sdk
59-
linters:
60-
- staticcheck
61-
- text: "SA1019: legacybech32.MarshalPubKey" # TODO remove once ready to remove from the sdk
62-
linters:
63-
- staticcheck
64-
- text: "SA1019: legacybech32.UnmarshalPubKey" # TODO remove once ready to remove from the sdk
65-
linters:
66-
- staticcheck
67-
- text: "SA1019: params.SendEnabled is deprecated" # TODO remove once ready to remove from the sdk
68-
linters:
69-
- staticcheck
70-
- text: "leading space"
71-
linters:
72-
- nolintlint
73135
max-issues-per-linter: 10000
74136
max-same-issues: 10000
75-
76-
linters-settings:
77-
gci:
78-
custom-order: true
79-
sections:
80-
- standard # Standard section: captures all standard packages.
81-
- default # Default section: contains all imports that could not be matched to another section type.
82-
- prefix(cosmossdk.io)
83-
- prefix(github.com/cosmos/cosmos-sdk)
84-
- prefix(github.com/CosmWasm/wasmd)
85-
revive:
86-
rules:
87-
- name: redefines-builtin-id
88-
disabled: true
89-
90-
gosec:
91-
# To select a subset of rules to run.
92-
# Available rules: https://github.com/securego/gosec#available-rules
93-
# Default: [] - means include all rules
94-
includes:
95-
# - G101 # Look for hard coded credentials
96-
- G102 # Bind to all interfaces
97-
- G103 # Audit the use of unsafe block
98-
- G104 # Audit errors not checked
99-
- G106 # Audit the use of ssh.InsecureIgnoreHostKey
100-
- G107 # Url provided to HTTP request as taint input
101-
- G108 # Profiling endpoint automatically exposed on /debug/pprof
102-
- G109 # Potential Integer overflow made by strconv.Atoi result conversion to int16/32
103-
- G110 # Potential DoS vulnerability via decompression bomb
104-
- G111 # Potential directory traversal
105-
- G112 # Potential slowloris attack
106-
- G113 # Usage of Rat.SetString in math/big with an overflow (CVE-2022-23772)
107-
- G114 # Use of net/http serve function that has no support for setting timeouts
108-
- G201 # SQL query construction using format string
109-
- G202 # SQL query construction using string concatenation
110-
- G203 # Use of unescaped data in HTML templates
111-
- G204 # Audit use of command execution
112-
- G301 # Poor file permissions used when creating a directory
113-
- G302 # Poor file permissions used with chmod
114-
- G303 # Creating tempfile using a predictable path
115-
- G304 # File path provided as taint input
116-
- G305 # File traversal when extracting zip/tar archive
117-
- G306 # Poor file permissions used when writing to a new file
118-
- G307 # Deferring a method which returns an error
119-
- G401 # Detect the usage of DES, RC4, MD5 or SHA1
120-
- G402 # Look for bad TLS connection settings
121-
- G403 # Ensure minimum RSA key length of 2048 bits
122-
- G404 # Insecure random number source (rand)
123-
- G501 # Import blocklist: crypto/md5
124-
- G502 # Import blocklist: crypto/des
125-
- G503 # Import blocklist: crypto/rc4
126-
- G504 # Import blocklist: net/http/cgi
127-
- G505 # Import blocklist: crypto/sha1
128-
- G601 # Implicit memory aliasing of items from a range statement
129-
misspell:
130-
locale: US
131-
gofumpt:
132-
extra-rules: true
133-
dogsled:
134-
max-blank-identifiers: 6
135-
maligned:
136-
suggest-new: true
137-
nolintlint:
138-
allow-unused: false
139-
allow-leading-space: true
140-
require-explanation: false
141-
require-specific: false
142-
gosimple:
143-
checks: ["all"]
144-
gocritic:
145-
disabled-checks:
146-
- regexpMust
147-
- appendAssign
148-
- ifElseChain
137+
formatters:
138+
enable:
139+
- gci
140+
- gofumpt
141+
settings:
142+
gci:
143+
sections:
144+
- standard # Standard section: captures all standard packages.
145+
- default # Default section: contains all imports that could not be matched to another section type.
146+
- prefix(cosmossdk.io)
147+
- prefix(github.com/cosmos/cosmos-sdk)
148+
- prefix(github.com/CosmWasm/wasmd)
149+
custom-order: true
150+
gofumpt:
151+
extra-rules: true
152+
exclusions:
153+
generated: lax
154+
paths:
155+
- server/grpc/gogoreflection/fix_registration.go
156+
- .*\.pb\.go$
157+
- .*\.pb\.gw\.\.go$
158+
- .*\.pulsar\.go$
159+
- testutil/testdata
160+
- third_party$
161+
- builtin$
162+
- examples$

app/app.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ func NewWasmApp(
447447
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
448448
app.AccountKeeper.AddressCodec(),
449449
)
450-
app.BaseApp.SetCircuitBreaker(&app.CircuitKeeper)
450+
app.SetCircuitBreaker(&app.CircuitKeeper)
451451

452452
app.AuthzKeeper = authzkeeper.NewKeeper(
453453
runtime.NewKVStoreService(keys[authzkeeper.StoreKey]),
@@ -904,7 +904,7 @@ func NewWasmApp(
904904
if err := app.LoadLatestVersion(); err != nil {
905905
panic(fmt.Errorf("error loading last version: %w", err))
906906
}
907-
ctx := app.BaseApp.NewUncachedContext(true, tmproto.Header{})
907+
ctx := app.NewUncachedContext(true, tmproto.Header{})
908908

909909
// Initialize pinned codes in wasmvm as they are not persisted there
910910
if err := app.WasmKeeper.InitializePinnedCodes(ctx); err != nil {
@@ -1099,15 +1099,15 @@ func (app *WasmApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APICo
10991099

11001100
// RegisterTxService implements the Application.RegisterTxService method.
11011101
func (app *WasmApp) RegisterTxService(clientCtx client.Context) {
1102-
authtx.RegisterTxService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.BaseApp.Simulate, app.interfaceRegistry)
1102+
authtx.RegisterTxService(app.GRPCQueryRouter(), clientCtx, app.Simulate, app.interfaceRegistry)
11031103
}
11041104

11051105
// RegisterTendermintService implements the Application.RegisterTendermintService method.
11061106
func (app *WasmApp) RegisterTendermintService(clientCtx client.Context) {
11071107
cmtApp := server.NewCometABCIWrapper(app)
11081108
cmtservice.RegisterTendermintService(
11091109
clientCtx,
1110-
app.BaseApp.GRPCQueryRouter(),
1110+
app.GRPCQueryRouter(),
11111111
app.interfaceRegistry,
11121112
cmtApp.Query,
11131113
)

app/export.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func (app *WasmApp) ExportAppStateAndValidators(forZeroHeight bool, jailAllowedA
4545
AppState: appState,
4646
Validators: validators,
4747
Height: height,
48-
ConsensusParams: app.BaseApp.GetConsensusParams(ctx),
48+
ConsensusParams: app.GetConsensusParams(ctx),
4949
}, err
5050
}
5151

@@ -54,12 +54,8 @@ func (app *WasmApp) ExportAppStateAndValidators(forZeroHeight bool, jailAllowedA
5454
//
5555
// in favor of export at a block height
5656
func (app *WasmApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) {
57-
applyAllowedAddrs := false
58-
5957
// check if there is a allowed address list
60-
if len(jailAllowedAddrs) > 0 {
61-
applyAllowedAddrs = true
62-
}
58+
applyAllowedAddrs := len(jailAllowedAddrs) > 0
6359

6460
allowedAddrsMap := make(map[string]bool)
6561

tests/wasmibctesting/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func (chain *WasmTestChain) CaptureIBCEvents(result *abci.ExecTxResult) {
7575

7676
func (chain *WasmTestChain) OverrideSendMsgs(msgs ...sdk.Msg) (*abci.ExecTxResult, error) {
7777
chain.SendMsgsOverride = nil
78-
result, err := chain.TestChain.SendMsgs(msgs...)
78+
result, err := chain.SendMsgs(msgs...)
7979
chain.SendMsgsOverride = chain.OverrideSendMsgs
8080
chain.CaptureIBCEvents(result)
8181
return result, err

0 commit comments

Comments
 (0)