Skip to content

Commit 25e7f9b

Browse files
authored
fix: make 46's linter work (cosmos#13186)
1 parent 8121f34 commit 25e7f9b

File tree

199 files changed

+977
-2990
lines changed

Some content is hidden

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

199 files changed

+977
-2990
lines changed

.github/workflows/lint.yml

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,26 @@
11
name: Lint
2-
# Lint runs golangci-lint over the entire cosmos-sdk repository
3-
# This workflow is run on every pull request and push to main
4-
# The `golangci` will pass without running if no *.{go, mod, sum} files have been changed.
52
on:
6-
pull_request:
73
push:
4+
tags:
5+
- v*
86
branches:
97
- main
8+
pull_request:
9+
permissions:
10+
contents: read
11+
# Optional: allow read access to pull request. Use with `only-new-issues` option.
12+
# pull-requests: read
1013
jobs:
1114
golangci:
1215
name: golangci-lint
1316
runs-on: ubuntu-latest
1417
steps:
1518
- uses: actions/setup-go@v3
1619
with:
17-
go-version: 1.18
18-
- uses: technote-space/get-diff-action@v6.0.1
19-
id: git_diff
20-
with:
21-
PATTERNS: |
22-
**/**.go
23-
go.mod
24-
go.sum
20+
go-version: 1.19
21+
- uses: actions/checkout@v3
2522
- name: golangci-lint
2623
uses: golangci/golangci-lint-action@v3
2724
with:
25+
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
2826
version: latest
29-
args: --out-format=tab
30-
skip-go-installation: true
31-
if: env.GIT_DIFF

.golangci.yml

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,30 @@ run:
66
linters:
77
disable-all: true
88
enable:
9-
- bodyclose
10-
- deadcode
119
- depguard
1210
- dogsled
13-
# - errcheck
1411
- exportloopref
1512
- goconst
1613
- gocritic
17-
- gofmt
18-
- goimports
14+
- gofumpt
1915
- gosec
2016
- gosimple
2117
- govet
2218
- ineffassign
2319
- misspell
2420
- nakedret
2521
- nolintlint
26-
- prealloc
27-
- revive
2822
- staticcheck
29-
- structcheck
3023
- stylecheck
3124
- typecheck
3225
- unconvert
33-
- unparam
3426
- unused
35-
# - wsl
3627

3728
issues:
3829
exclude-rules:
3930
- text: "Use of weak random number generator"
4031
linters:
4132
- gosec
42-
- text: "comment on exported var"
43-
linters:
44-
- golint
45-
- text: "don't use an underscore in package name"
46-
linters:
47-
- golint
4833
- text: "ST1003:"
4934
linters:
5035
- stylecheck
@@ -53,6 +38,9 @@ issues:
5338
- text: "ST1016:"
5439
linters:
5540
- stylecheck
41+
- text: "should be written without leading space as"
42+
linters:
43+
- nolintlint
5644
- path: "migrations"
5745
text: "SA1019:"
5846
linters:
@@ -69,6 +57,5 @@ linters-settings:
6957
suggest-new: true
7058
nolintlint:
7159
allow-unused: false
72-
allow-leading-space: true
7360
require-explanation: false
74-
require-specific: false
61+
require-specific: false

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3421,7 +3421,7 @@ BREAKING CHANGES
34213421
* SDK
34223422
* [baseapp] Msgs are no longer run on CheckTx, removed `ctx.IsCheckTx()`
34233423
* [baseapp] NewBaseApp constructor takes sdk.TxDecoder as argument instead of wire.Codec
3424-
* [types] sdk.NewCoin takes sdk.Int, sdk.NewInt64Coin takes int64
3424+
* [types] sdk.NewCoin takes math.Int, sdk.NewInt64Coin takes int64
34253425
* [x/auth] Default TxDecoder can be found in `x/auth` rather than baseapp
34263426
* [client] [\#1551](https://github.com/cosmos/cosmos-sdk/issues/1551): Refactored `CoreContext` to `TxContext` and `QueryContext`
34273427
* Removed all tx related fields and logic (building & signing) to separate
@@ -3747,7 +3747,7 @@ BREAKING CHANGES
37473747

37483748
* msg.GetSignBytes() now returns bech32-encoded addresses in all cases
37493749
* [lcd] REST end-points now include gas
3750-
* sdk.Coin now uses sdk.Int, a big.Int wrapper with 256bit range cap
3750+
* sdk.Coin now uses math.Int, a big.Int wrapper with 256bit range cap
37513751

37523752
FEATURES
37533753

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,8 @@ lint-go:
361361
.PHONY: lint lint-fix
362362

363363
format:
364+
@go install mvdan.cc/gofumpt@latest
365+
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
364366
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -path "./tests/mocks/*" -not -name "*.pb.go" -not -name "*.pb.gw.go" -not -name "*.pulsar.go" -not -path "./crypto/keys/secp256k1/*" | xargs gofumpt -w -l
365367
golangci-lint run --fix
366368
.PHONY: format

baseapp/baseapp.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
1212
dbm "github.com/tendermint/tm-db"
1313

14-
"github.com/cosmos/cosmos-sdk/codec/types"
1514
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
1615
"github.com/cosmos/cosmos-sdk/snapshots"
1716
"github.com/cosmos/cosmos-sdk/store"
@@ -54,7 +53,7 @@ type BaseApp struct { // nolint: maligned
5453
queryRouter sdk.QueryRouter // router for redirecting query calls
5554
grpcQueryRouter *GRPCQueryRouter // router for redirecting gRPC query calls
5655
msgServiceRouter *MsgServiceRouter // router for redirecting Msg service messages
57-
interfaceRegistry types.InterfaceRegistry
56+
interfaceRegistry codectypes.InterfaceRegistry
5857
txDecoder sdk.TxDecoder // unmarshal []byte into sdk.Tx
5958

6059
anteHandler sdk.AnteHandler // ante handler for fee and auth

baseapp/baseapp_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1295,7 +1295,6 @@ func TestTxGasLimits(t *testing.T) {
12951295

12961296
return newCtx, nil
12971297
})
1298-
12991298
}
13001299

13011300
routerOpt := func(bapp *BaseApp) {

baseapp/msg_service_router.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ func (msr *MsgServiceRouter) HandlerByTypeURL(typeURL string) MsgServiceHandler
4646
// service description, handler is an object which implements that gRPC service.
4747
//
4848
// This function PANICs:
49-
// - if it is called before the service `Msg`s have been registered using
50-
// RegisterInterfaces,
51-
// - or if a service is being registered twice.
49+
// - if it is called before the service `Msg`s have been registered using
50+
// RegisterInterfaces,
51+
// - or if a service is being registered twice.
5252
func (msr *MsgServiceRouter) RegisterService(sd *grpc.ServiceDesc, handler interface{}) {
5353
// Adds a top-level query handler based on the gRPC service name.
5454
for _, method := range sd.Methods {

client/cmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ func readTxCommandFlags(clientCtx Context, flagSet *pflag.FlagSet) (Context, err
268268
isAux, _ := flagSet.GetBool(flags.FlagAux)
269269
clientCtx = clientCtx.WithAux(isAux)
270270
if isAux {
271-
// If the user didn't explicity set an --output flag, use JSON by
271+
// If the user didn't explicitly set an --output flag, use JSON by
272272
// default.
273273
if clientCtx.OutputFormat == "" || !flagSet.Changed(cli.OutputFlag) {
274274
clientCtx = clientCtx.WithOutputFormat("json")

client/debug/main.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
"github.com/cosmos/cosmos-sdk/types/errors"
1818
"github.com/cosmos/cosmos-sdk/version"
1919

20-
legacybech32 "github.com/cosmos/cosmos-sdk/types/bech32/legacybech32"
20+
legacybech32 "github.com/cosmos/cosmos-sdk/types/bech32/legacybech32" //nolint:staticcheck
2121
)
2222

2323
var flagPubkeyType = "type"
@@ -69,7 +69,7 @@ $ %s debug pubkey '{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"AurroA7jvfP
6969
}
7070

7171
func bytesToPubkey(bz []byte, keytype string) (cryptotypes.PubKey, bool) {
72-
if keytype == "ed25519" {
72+
if keytype == "ed25519" { //nolint:goconst
7373
if len(bz) == ed25519.PubKeySize {
7474
return &ed25519.PubKey{Key: bz}, true
7575
}
@@ -102,17 +102,17 @@ func getPubKeyFromRawString(pkstr string, keytype string) (cryptotypes.PubKey, e
102102
}
103103
}
104104

105-
pk, err := legacybech32.UnmarshalPubKey(legacybech32.AccPK, pkstr)
105+
pk, err := legacybech32.UnmarshalPubKey(legacybech32.AccPK, pkstr) //nolint:staticcheck
106106
if err == nil {
107107
return pk, nil
108108
}
109109

110-
pk, err = legacybech32.UnmarshalPubKey(legacybech32.ValPK, pkstr)
110+
pk, err = legacybech32.UnmarshalPubKey(legacybech32.ValPK, pkstr) //nolint:staticcheck
111111
if err == nil {
112112
return pk, nil
113113
}
114114

115-
pk, err = legacybech32.UnmarshalPubKey(legacybech32.ConsPK, pkstr)
115+
pk, err = legacybech32.UnmarshalPubKey(legacybech32.ConsPK, pkstr) //nolint:staticcheck
116116
if err == nil {
117117
return pk, nil
118118
}
@@ -150,7 +150,7 @@ $ %s debug pubkey-raw cosmos1e0jnq2sun3dzjh8p2xq95kk0expwmd7shwjpfg
150150
var consensusPub string
151151
edPK, ok := pk.(*ed25519.PubKey)
152152
if ok && pubkeyType == "ed25519" {
153-
consensusPub, err = legacybech32.MarshalPubKey(legacybech32.ConsPK, edPK)
153+
consensusPub, err = legacybech32.MarshalPubKey(legacybech32.ConsPK, edPK) //nolint:staticcheck
154154
if err != nil {
155155
return err
156156
}
@@ -163,11 +163,11 @@ $ %s debug pubkey-raw cosmos1e0jnq2sun3dzjh8p2xq95kk0expwmd7shwjpfg
163163
if err != nil {
164164
return err
165165
}
166-
accPub, err := legacybech32.MarshalPubKey(legacybech32.AccPK, pk)
166+
accPub, err := legacybech32.MarshalPubKey(legacybech32.AccPK, pk) //nolint:staticcheck
167167
if err != nil {
168168
return err
169169
}
170-
valPub, err := legacybech32.MarshalPubKey(legacybech32.ValPK, pk)
170+
valPub, err := legacybech32.MarshalPubKey(legacybech32.ValPK, pk) //nolint:staticcheck
171171
if err != nil {
172172
return err
173173
}

client/keys/add.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,13 @@ func runAddCmdPrepare(cmd *cobra.Command, args []string) error {
9393

9494
/*
9595
input
96-
- bip39 mnemonic
97-
- bip39 passphrase
98-
- bip44 path
99-
- local encryption password
96+
- bip39 mnemonic
97+
- bip39 passphrase
98+
- bip44 path
99+
- local encryption password
100+
100101
output
101-
- armor encrypted private key (saved to file)
102+
- armor encrypted private key (saved to file)
102103
*/
103104
func runAddCmd(ctx client.Context, cmd *cobra.Command, args []string, inBuf *bufio.Reader) error {
104105
var err error
@@ -298,7 +299,7 @@ func printCreate(cmd *cobra.Command, k *keyring.Record, showMnemonic bool, mnemo
298299

299300
// print mnemonic unless requested not to.
300301
if showMnemonic {
301-
if _, err := fmt.Fprintln(cmd.ErrOrStderr(), fmt.Sprintf("\n**Important** write this mnemonic phrase in a safe place.\nIt is the only way to recover your account if you ever forget your password.\n\n%s\n", mnemonic)); err != nil {
302+
if _, err := fmt.Fprintln(cmd.ErrOrStderr(), fmt.Sprintf("\n**Important** write this mnemonic phrase in a safe place.\nIt is the only way to recover your account if you ever forget your password.\n\n%s\n", mnemonic)); err != nil { //nolint:gosimple
302303
return fmt.Errorf("failed to print mnemonic: %v", err)
303304
}
304305
}

0 commit comments

Comments
 (0)