Skip to content

Commit 2e74b96

Browse files
authored
chore: update linter (#1169)
* update lint * fix all lint errors * update nix golang-lint * update nix * update nix * update github * add more commands to makefile * revert flag * fix github actions * fix gci * remove unecessary file * add change log
1 parent 07eeb02 commit 2e74b96

Some content is hidden

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

85 files changed

+547
-393
lines changed

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ jobs:
4343
4444
BUILD_TAGS=rocksdb,grocksdb_clean_link
4545
go build -tags $BUILD_TAGS ./cmd/chain-maind
46-
golangci-lint run --out-format=github-actions --path-prefix=./ --timeout 30m --build-tags $BUILD_TAGS
46+
golangci-lint run --output.text.path stdout --path-prefix=./ --timeout 30m --build-tags $BUILD_TAGS
4747
# Check only if there are differences in the source code
4848
if: steps.changed-files.outputs.any_changed == 'true'

.golangci.yml

Lines changed: 123 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,144 @@
1+
version: "2"
12
run:
23
tests: true
34
timeout: 10m
4-
sort-results: true
55
allow-parallel-runners: true
6-
exclude-dir: testutil/testdata_pulsar
76
concurrency: 4
8-
97
linters:
10-
disable-all: true
8+
default: none
119
enable:
10+
- copyloopvar
1211
- dogsled
13-
- exportloopref
12+
- errcheck
13+
- errorlint
1414
- goconst
1515
- gocritic
16-
- gofumpt
17-
- goimports
1816
- gosec
19-
- gosimple
2017
- govet
2118
- ineffassign
2219
- misspell
2320
- nakedret
2421
- nolintlint
22+
- revive
2523
- staticcheck
26-
- stylecheck
27-
- typecheck
24+
- thelper
2825
- unconvert
2926
- unused
27+
- tagalign
3028

29+
settings:
30+
dogsled:
31+
max-blank-identifiers: 3
32+
gocritic:
33+
disabled-checks:
34+
- regexpMust
35+
- appendAssign
36+
- ifElseChain
37+
gosec:
38+
excludes:
39+
- G101
40+
- G107
41+
- G404
42+
confidence: medium
43+
misspell:
44+
locale: US
45+
nolintlint:
46+
allow-unused: false
47+
require-explanation: false
48+
require-specific: false
49+
revive:
50+
rules:
51+
- name: redefines-builtin-id
52+
disabled: true
53+
- name: exported
54+
severity: error
55+
disabled: false
56+
staticcheck:
57+
checks:
58+
- all
59+
unused:
60+
local-variables-are-used: false
61+
exclusions:
62+
generated: lax
63+
presets:
64+
- common-false-positives
65+
- legacy
66+
- std-error-handling
67+
rules:
68+
- linters:
69+
- staticcheck
70+
text: 'ST1000:'
71+
- linters:
72+
- revive
73+
text: 'or be unexported' # don't report types that have no comments at all. there are way too many of these.
74+
- linters:
75+
- staticcheck
76+
text: 'ST1003:'
77+
- linters:
78+
- staticcheck
79+
text: 'ST1016:'
80+
- linters:
81+
- staticcheck
82+
path: migrations
83+
text: 'SA1019:'
84+
- linters:
85+
- staticcheck
86+
text: 'SA1019: codec.NewAminoCodec is deprecated'
87+
- linters:
88+
- staticcheck
89+
text: 'SA1019: legacybech32.MustMarshalPubKey'
90+
- linters:
91+
- staticcheck
92+
text: 'SA1019: legacybech32.MarshalPubKey'
93+
- linters:
94+
- staticcheck
95+
text: 'SA1019: legacybech32.UnmarshalPubKey'
96+
- linters:
97+
- staticcheck
98+
text: 'SA1019: params.SendEnabled is deprecated'
99+
- linters:
100+
- gosec
101+
text: 'G115: integer overflow conversion'
102+
- linters:
103+
- nolintlint
104+
text: leading space
105+
paths:
106+
- .*\.pb\.go$
107+
- .*\.pb\.gw\.go$
108+
- .*\.pulsar\.go$
109+
- third_party$
110+
- builtin$
111+
- examples$
112+
- ./pystarport/*
113+
- testutil/testdata_pulsar
31114
issues:
32-
exclude-rules:
33-
# fixed in go 1.22
34-
- text: "G601:"
35-
linters:
36-
- gosec
37-
38-
linters-settings:
39-
exclude: ./pystarport/*
40-
errcheck:
41-
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
42-
# default is false: such cases aren't reported by default.
43-
check-blank: true
44-
dogsled:
45-
max-blank-identifiers: 3
46-
maligned:
47-
# print struct with more effective memory layout or not, false by default
48-
suggest-new: true
49-
nolintlint:
50-
allow-unused: false
51-
allow-leading-space: true
52-
require-explanation: false
53-
require-specific: false
115+
max-issues-per-linter: 10000
116+
max-same-issues: 10000
117+
formatters:
118+
enable:
119+
- gci
120+
- gofumpt
121+
settings:
122+
gci:
123+
sections:
124+
- standard
125+
- default
126+
- prefix(cosmossdk.io)
127+
- prefix(github.com/cosmos/cosmos-sdk)
128+
custom-order: true
129+
gofumpt:
130+
extra-rules: true
131+
exclusions:
132+
generated: lax
133+
paths:
134+
- server/grpc/gogoreflection/fix_registration.go
135+
- fix_registration.go
136+
- .*\.pb\.go$
137+
- .*\.pb\.gw\.go$
138+
- .*\.pulsar\.go$
139+
- types/coin_regex.go
140+
- proto/*
141+
- third_party$
142+
- builtin$
143+
- examples$
144+
- ./pystarport/*

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## UNRELEASED
4+
5+
### Improvements
6+
- [#1169](https://github.com/crypto-org-chain/chain-main/pull/1169) Update linter and tidy up code
7+
38
*May 26, 2025*
49

510
## v6.0.0

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@ test: check-network
144144
@go test $(TEST_FLAGS) -v -mod=readonly $(PACKAGES) -coverprofile=$(COVERAGE) -covermode=atomic
145145
.PHONY: test
146146

147+
lint-install:
148+
@echo "--> Installing golangci-lint $(golangci_version)"
149+
@nix profile install -f ./nix golangci-lint
150+
147151
# look into .golangci.yml for enabling / disabling linters
148152
lint:
149153
@echo "--> Running linter"
@@ -152,6 +156,14 @@ lint:
152156
@flake8 --show-source --count --statistics
153157
@find . -name "*.nix" -type f | xargs nixfmt -c
154158

159+
160+
lint-fix:
161+
@echo "--> Running linter"
162+
@golangci-lint run --fix
163+
@go mod verify
164+
@flake8 --show-source --count --statistics
165+
@find . -name "*.nix" -type f | xargs nixfmt -c
166+
155167
# a trick to make all the lint commands execute, return error when at least one fails.
156168
# golangci-lint is run in standalone job in ci
157169
lint-ci:

app/ante.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
package app
22

33
import (
4+
ibcante "github.com/cosmos/ibc-go/v8/modules/core/ante"
5+
"github.com/cosmos/ibc-go/v8/modules/core/keeper"
6+
nfttypes "github.com/crypto-org-chain/chain-main/v4/x/nft-transfer/types"
7+
48
newsdkerrors "cosmossdk.io/errors"
59
circuitante "cosmossdk.io/x/circuit/ante"
10+
611
sdk "github.com/cosmos/cosmos-sdk/types"
712
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
813
"github.com/cosmos/cosmos-sdk/x/auth/ante"
9-
ibcante "github.com/cosmos/ibc-go/v8/modules/core/ante"
10-
"github.com/cosmos/ibc-go/v8/modules/core/keeper"
11-
nfttypes "github.com/crypto-org-chain/chain-main/v4/x/nft-transfer/types"
1214
)
1315

1416
// HandlerOptions extend the SDK's AnteHandler options by requiring the IBC
@@ -59,7 +61,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
5961
}
6062

6163
const (
62-
// values chosen arbitrarily
64+
// MaxClassIDLength values chosen arbitrarily
6365
MaxClassIDLength = 2048
6466
MaxTokenIds = 256
6567
MaxTokenIDLength = 2048

0 commit comments

Comments
 (0)