Skip to content

Commit d3a5641

Browse files
authored
Merge pull request #1 from initia-labs/chore/add-lint-action
add workflow to lint and fix lint errors
2 parents 7046b55 + 142375b commit d3a5641

File tree

8 files changed

+61
-7
lines changed

8 files changed

+61
-7
lines changed

.github/workflows/lint.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ concurrency:
2323
jobs:
2424
golangci:
2525
env:
26+
GOPRIVATE: github.com/initia-labs
27+
GITHUB_ACCESS_TOKEN: ${{ secrets.GH_READ_TOKEN }}
2628
GOLANGCI_LINT_VERSION: v1.59.1
2729
name: golangci-lint
2830
runs-on: ubuntu-latest
@@ -39,6 +41,7 @@ jobs:
3941
**/**.go
4042
go.mod
4143
go.sum
44+
- run: git config --global url.https://${GITHUB_ACCESS_TOKEN}:[email protected]/.insteadOf https://github.com/
4245
# install golangci-lint
4346
- run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}
4447
- name: run go linters (long)
@@ -65,6 +68,10 @@ jobs:
6568
# Use --check or --exit-code when available (Go 1.19?)
6669
# https://github.com/golang/go/issues/27005
6770
tidy:
71+
env:
72+
# for private repo access
73+
GOPRIVATE: github.com/initia-labs,github.com/skip-mev/slinky
74+
GITHUB_ACCESS_TOKEN: ${{ secrets.GH_READ_TOKEN }}
6875
runs-on: ubuntu-latest
6976
name: tidy
7077
steps:
@@ -74,6 +81,7 @@ jobs:
7481
with:
7582
go-version: 1.22
7683
check-latest: true
84+
- run: git config --global url.https://${GITHUB_ACCESS_TOKEN}:[email protected]/.insteadOf https://github.com/
7785
- run: |
7886
go mod tidy
7987
CHANGES_IN_REPO=$(git status --porcelain)

.golangci.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
linters:
2+
enable:
3+
- asciicheck
4+
- bodyclose
5+
- dogsled
6+
- dupl
7+
- errcheck
8+
- exportloopref
9+
- goconst
10+
- gofmt
11+
- goimports
12+
- gosec
13+
- gosimple
14+
- govet
15+
- ineffassign
16+
- misspell
17+
# - nakedret
18+
- nolintlint
19+
# - prealloc
20+
- staticcheck
21+
# - structcheck // to be fixed by golangci-lint
22+
- stylecheck
23+
- typecheck
24+
- unconvert
25+
- unused
26+
27+
issues:
28+
exclude-rules:
29+
- path: _test\.go
30+
linters:
31+
- gosec
32+
- linters:
33+
- stylecheck
34+
text: "ST1003:"
35+
max-same-issues: 50
36+
37+
linters-settings:
38+
dogsled:
39+
max-blank-identifiers: 3
40+
#golint:
41+
# min-confidence: 0
42+
goconst:
43+
ignore-tests: true
44+
#maligned:
45+
# suggest-new: true
46+
misspell:
47+
locale: US

executor/batch/handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ func (bs *BatchSubmitter) finalizeBatch(blockHeight uint64) error {
177177
Save: true,
178178
})
179179

180-
for offset := int64(0); ; offset += int64(bs.batchCfg.MaxChunkSize) {
180+
for offset := int64(0); ; offset += bs.batchCfg.MaxChunkSize {
181181
readLength, err := bs.batchFile.ReadAt(batchBuffer, offset)
182182
if err != nil && err != io.EOF {
183183
return err

executor/child/handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (ch *Child) beginBlockHandler(args nodetypes.BeginBlockArgs) (err error) {
3030
func (ch *Child) endBlockHandler(args nodetypes.EndBlockArgs) error {
3131
blockHeight := uint64(args.Block.Header.Height)
3232
batchKVs := make([]types.RawKV, 0)
33-
treeKVs, storageRoot, err := ch.handleTree(blockHeight, uint64(args.LatestHeight), args.BlockID, args.Block.Header)
33+
treeKVs, storageRoot, err := ch.handleTree(blockHeight, args.LatestHeight, args.BlockID, args.Block.Header)
3434
if err != nil {
3535
return err
3636
}

executor/child/withdraw.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func (ch *Child) prepareTree(blockHeight uint64) error {
9393
err := ch.mk.LoadWorkingTree(blockHeight - 1)
9494
if err == dbtypes.ErrNotFound {
9595
// must not happened
96-
// TOOD: if user want to start from a specific height, we need to provide a way to do so
96+
// TODO: if user want to start from a specific height, we need to provide a way to do so
9797
panic(fmt.Errorf("working tree not found at height: %d, current: %d", blockHeight-1, blockHeight))
9898
} else if err != nil {
9999
return err

merkle/merkle.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ func (m *Merkle) fillLeaves() error {
186186
}
187187

188188
lastLeaf := m.workingTree.LastSiblings[0]
189-
//nolint:typecheck
190189
for range numRestLeaves {
191190
if err := m.InsertLeaf(lastLeaf); err != nil {
192191
return err

node/broadcaster/broadcaster.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ func (b Broadcaster) getClientCtx() client.Context {
125125
WithFromAddress(b.keyAddress)
126126
}
127127

128-
func (n Broadcaster) GetTxf() tx.Factory {
129-
return n.txf
128+
func (b Broadcaster) GetTxf() tx.Factory {
129+
return b.txf
130130
}
131131

132132
func (b *Broadcaster) prepareBroadcaster(_ /*lastBlockHeight*/ uint64, lastBlockTime time.Time) error {

node/process.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ func (n *Node) txChecker(ctx context.Context) error {
232232
}
233233
}
234234

235-
err = n.broadcaster.RemovePendingTx(int64(res.Height), pendingTx.TxHash, pendingTx.Sequence)
235+
err = n.broadcaster.RemovePendingTx(res.Height, pendingTx.TxHash, pendingTx.Sequence)
236236
if err != nil {
237237
return err
238238
}

0 commit comments

Comments
 (0)