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

.golangci.yml: add intrange linter #3572

Merged
merged 2 commits into from
Sep 5, 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
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ linters:
- decorder
- durationcheck
- errorlint
- intrange
- copyloopvar
- gofmt
- misspell
Expand Down
2 changes: 1 addition & 1 deletion internal/testchain/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func Sign(h hash.Hashable) []byte {
// SignCommittee signs data by a majority of committee members.
func SignCommittee(h hash.Hashable) []byte {
buf := io.NewBufBinWriter()
for i := 0; i < CommitteeSize()/2+1; i++ {
for i := range CommitteeSize()/2 + 1 {
pKey := PrivateKey(i)
sig := pKey.SignHashable(uint32(Network()), h)
if len(sig) != 64 {
Expand Down
4 changes: 2 additions & 2 deletions pkg/core/blockchain_core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func TestRemoveOldTransfers(t *testing.T) {
require.NoError(t, err)
require.NotEqual(t, 0, len(log.Raw))

for i := uint32(0); i < 3; i++ {
for i := range uint32(3) {
log, err = bc.dao.GetTokenTransferLog(acc2, newer, i, false)
require.NoError(t, err)
require.NotEqual(t, 0, len(log.Raw))
Expand All @@ -130,7 +130,7 @@ func TestRemoveOldTransfers(t *testing.T) {
require.NoError(t, err)
require.NotEqual(t, 0, len(log.Raw))

for i := uint32(0); i < 2; i++ {
for i := range uint32(2) {
log, err = bc.dao.GetTokenTransferLog(acc3, newer, i, true)
require.NoError(t, err)
require.NotEqual(t, 0, len(log.Raw))
Expand Down
7 changes: 3 additions & 4 deletions pkg/core/mpt/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ func lcp(a, b []byte) []byte {
return lcp(b, a)
}

var i int
for i = 0; i < len(b); i++ {
for i := range b {
if a[i] != b[i] {
break
return b[:i]
}
}

return a[:i]
return b
}

func lcpMany(kv []keyValue) []byte {
Expand Down
2 changes: 1 addition & 1 deletion pkg/core/native/native_test/neo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ func TestNEO_GetCandidates(t *testing.T) {
for i := range len(expected) + 1 {
w := io.NewBufBinWriter()
emit.AppCall(w.BinWriter, neoCommitteeInvoker.Hash, "getAllCandidates", callflag.All)
for j := 0; j < i+1; j++ {
for range i + 1 {
emit.Opcodes(w.BinWriter, opcode.DUP)
emit.Syscall(w.BinWriter, interopnames.SystemIteratorNext)
emit.Opcodes(w.BinWriter, opcode.DROP) // drop the value returned from Next.
Expand Down
2 changes: 1 addition & 1 deletion pkg/vm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -1860,7 +1860,7 @@ func (v *VM) ContractHasTryBlock() bool {
if ictx.sc != topctx.sc {
return false // Different contract -> no one cares.
}
for j := 0; j < ictx.tryStack.Len(); j++ {
for j := range ictx.tryStack.Len() {
roman-khimov marked this conversation as resolved.
Show resolved Hide resolved
eCtx := ictx.tryStack.Peek(j).Value().(*exceptionHandlingContext)
if eCtx.State == eTry {
return true
Expand Down
Loading