Skip to content

Commit

Permalink
Merge pull request #1 from initia-labs/chore/add-lint-action
Browse files Browse the repository at this point in the history
add workflow to lint and fix lint errors
  • Loading branch information
sh-cha authored Aug 7, 2024
2 parents 7046b55 + 142375b commit d3a5641
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 7 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ concurrency:
jobs:
golangci:
env:
GOPRIVATE: github.com/initia-labs
GITHUB_ACCESS_TOKEN: ${{ secrets.GH_READ_TOKEN }}
GOLANGCI_LINT_VERSION: v1.59.1
name: golangci-lint
runs-on: ubuntu-latest
Expand All @@ -39,6 +41,7 @@ jobs:
**/**.go
go.mod
go.sum
- run: git config --global url.https://${GITHUB_ACCESS_TOKEN}:[email protected]/.insteadOf https://github.com/
# install golangci-lint
- run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}
- name: run go linters (long)
Expand All @@ -65,6 +68,10 @@ jobs:
# Use --check or --exit-code when available (Go 1.19?)
# https://github.com/golang/go/issues/27005
tidy:
env:
# for private repo access
GOPRIVATE: github.com/initia-labs,github.com/skip-mev/slinky
GITHUB_ACCESS_TOKEN: ${{ secrets.GH_READ_TOKEN }}
runs-on: ubuntu-latest
name: tidy
steps:
Expand All @@ -74,6 +81,7 @@ jobs:
with:
go-version: 1.22
check-latest: true
- run: git config --global url.https://${GITHUB_ACCESS_TOKEN}:[email protected]/.insteadOf https://github.com/
- run: |
go mod tidy
CHANGES_IN_REPO=$(git status --porcelain)
Expand Down
47 changes: 47 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
linters:
enable:
- asciicheck
- bodyclose
- dogsled
- dupl
- errcheck
- exportloopref
- goconst
- gofmt
- goimports
- gosec
- gosimple
- govet
- ineffassign
- misspell
# - nakedret
- nolintlint
# - prealloc
- staticcheck
# - structcheck // to be fixed by golangci-lint
- stylecheck
- typecheck
- unconvert
- unused

issues:
exclude-rules:
- path: _test\.go
linters:
- gosec
- linters:
- stylecheck
text: "ST1003:"
max-same-issues: 50

linters-settings:
dogsled:
max-blank-identifiers: 3
#golint:
# min-confidence: 0
goconst:
ignore-tests: true
#maligned:
# suggest-new: true
misspell:
locale: US
2 changes: 1 addition & 1 deletion executor/batch/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (bs *BatchSubmitter) finalizeBatch(blockHeight uint64) error {
Save: true,
})

for offset := int64(0); ; offset += int64(bs.batchCfg.MaxChunkSize) {
for offset := int64(0); ; offset += bs.batchCfg.MaxChunkSize {
readLength, err := bs.batchFile.ReadAt(batchBuffer, offset)
if err != nil && err != io.EOF {
return err
Expand Down
2 changes: 1 addition & 1 deletion executor/child/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (ch *Child) beginBlockHandler(args nodetypes.BeginBlockArgs) (err error) {
func (ch *Child) endBlockHandler(args nodetypes.EndBlockArgs) error {
blockHeight := uint64(args.Block.Header.Height)
batchKVs := make([]types.RawKV, 0)
treeKVs, storageRoot, err := ch.handleTree(blockHeight, uint64(args.LatestHeight), args.BlockID, args.Block.Header)
treeKVs, storageRoot, err := ch.handleTree(blockHeight, args.LatestHeight, args.BlockID, args.Block.Header)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion executor/child/withdraw.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (ch *Child) prepareTree(blockHeight uint64) error {
err := ch.mk.LoadWorkingTree(blockHeight - 1)
if err == dbtypes.ErrNotFound {
// must not happened
// TOOD: if user want to start from a specific height, we need to provide a way to do so
// TODO: if user want to start from a specific height, we need to provide a way to do so
panic(fmt.Errorf("working tree not found at height: %d, current: %d", blockHeight-1, blockHeight))
} else if err != nil {
return err
Expand Down
1 change: 0 additions & 1 deletion merkle/merkle.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ func (m *Merkle) fillLeaves() error {
}

lastLeaf := m.workingTree.LastSiblings[0]
//nolint:typecheck
for range numRestLeaves {
if err := m.InsertLeaf(lastLeaf); err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions node/broadcaster/broadcaster.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ func (b Broadcaster) getClientCtx() client.Context {
WithFromAddress(b.keyAddress)
}

func (n Broadcaster) GetTxf() tx.Factory {
return n.txf
func (b Broadcaster) GetTxf() tx.Factory {
return b.txf
}

func (b *Broadcaster) prepareBroadcaster(_ /*lastBlockHeight*/ uint64, lastBlockTime time.Time) error {
Expand Down
2 changes: 1 addition & 1 deletion node/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func (n *Node) txChecker(ctx context.Context) error {
}
}

err = n.broadcaster.RemovePendingTx(int64(res.Height), pendingTx.TxHash, pendingTx.Sequence)
err = n.broadcaster.RemovePendingTx(res.Height, pendingTx.TxHash, pendingTx.Sequence)
if err != nil {
return err
}
Expand Down

0 comments on commit d3a5641

Please sign in to comment.