Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add workflow to lint and fix lint errors #1

Merged
merged 4 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading