Skip to content

Commit b79d7df

Browse files
authored
feat: update linter (#1826)
* update lint * to be reverted: enable linter in this PR * revert * fix lint * fix more lint * add changelog * fix lint * fix lint * remove comment * fix comments
1 parent 787dd00 commit b79d7df

130 files changed

Lines changed: 794 additions & 631 deletions

File tree

Some content is hidden

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

.github/workflows/lint.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ jobs:
4646
4747
BUILD_TAGS=rocksdb,grocksdb_clean_link,objstore
4848
go build -tags $BUILD_TAGS ./cmd/cronosd
49-
golangci-lint run --out-format=github-actions --path-prefix=./ --timeout 30m --build-tags $BUILD_TAGS
49+
golangci-lint run --output.text.path stdout --path-prefix=./ --timeout 30m --build-tags $BUILD_TAGS
5050
cd versiondb
51-
golangci-lint run --out-format=github-actions --path-prefix=./versiondb --timeout 30m --build-tags $BUILD_TAGS
51+
golangci-lint run --output.text.path stdout --path-prefix=./versiondb --timeout 30m --build-tags $BUILD_TAGS
5252
cd ../memiavl
53-
golangci-lint run --out-format=github-actions --path-prefix=./memiavl --timeout 30m --build-tags objstore
53+
golangci-lint run --output.text.path stdout --path-prefix=./memiavl --timeout 30m --build-tags objstore
5454
cd ../store
55-
golangci-lint run --out-format=github-actions --path-prefix=./store --timeout 30m --build-tags objstore
55+
golangci-lint run --output.text.path stdout --path-prefix=./store --timeout 30m --build-tags objstore
5656
# Check only if there are differences in the source code
5757
if: steps.changed-files.outputs.any_changed == 'true'
5858

.golangci.yml

Lines changed: 120 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,143 @@
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
1716
- gosec
18-
- gosimple
1917
- govet
2018
- ineffassign
2119
- misspell
2220
- nakedret
2321
- nolintlint
22+
- revive
2423
- staticcheck
25-
- stylecheck
26-
- typecheck
24+
- thelper
2725
- unconvert
2826
- unused
27+
- tagalign
2928

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
30114
issues:
31-
exclude-rules:
32-
- text: "Use of weak random number generator"
33-
linters:
34-
- gosec
35-
- text: "ST1003:"
36-
linters:
37-
- stylecheck
38-
# FIXME: Disabled until golangci-lint updates stylecheck with this fix:
39-
# https://github.com/dominikh/go-tools/issues/389
40-
- text: "ST1016:"
41-
linters:
42-
- stylecheck
43-
- path: "migrations"
44-
text: "SA1019:"
45-
linters:
46-
- staticcheck
47-
- text: "leading space"
48-
linters:
49-
- nolintlint
50-
51115
max-issues-per-linter: 10000
52116
max-same-issues: 10000
53-
54-
linters-settings:
55-
dogsled:
56-
max-blank-identifiers: 3
57-
maligned:
58-
# print struct with more effective memory layout or not, false by default
59-
suggest-new: true
60-
nolintlint:
61-
allow-unused: false
62-
allow-leading-space: true
63-
require-explanation: false
64-
require-specific: false
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+
- proto/*
140+
- third_party$
141+
- builtin$
142+
- examples$
143+
- ./pystarport/*

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
* [#1779](https://github.com/crypto-org-chain/cronos/pull/1779) Upgrade rocksdb to `v9.11.2`.
88
* [#1824](https://github.com/crypto-org-chain/cronos/pull/1824) Rework on github actions.
9+
* [#1826](https://github.com/crypto-org-chain/cronos/pull/1826) Update linter and tidy up code.
910

1011
*Jun 20, 2025*
1112

Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ DOCKER := $(shell which docker)
1616

1717
UNAME_S := $(shell uname -s)
1818

19+
GOLANGCI_VERSION := "2.1.6"
20+
1921
# process build tags
2022
build_tags = netgo objstore pebbledb
2123
ifeq ($(NETWORK),mainnet)
@@ -128,12 +130,16 @@ clean:
128130
### Linting ###
129131
###############################################################################
130132

133+
lint-install:
134+
@echo "--> Installing golangci-lint $(GOLANGCI_VERSION)"
135+
@nix profile install -f ./nix golangci-lint
136+
131137
lint:
132138
go mod verify
133-
golangci-lint run --out-format=tab
139+
golangci-lint run --output.text.path stdout --path-prefix=./
134140

135141
lint-fix:
136-
golangci-lint run --fix --out-format=tab --issues-exit-code=0
142+
golangci-lint run --fix --output.text.path stdout --issues-exit-code=0
137143

138144
lint-py:
139145
flake8 --show-source --count --statistics \

0 commit comments

Comments
 (0)