Skip to content

Commit

Permalink
Merge pull request #3572 from nspcc-dev/feat/add-for-range-linter
Browse files Browse the repository at this point in the history
.golangci.yml: add `intrange` linter
  • Loading branch information
AnnaShaleva authored Sep 5, 2024
2 parents 585af7e + f8549a4 commit d9a6a7c
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
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() {
eCtx := ictx.tryStack.Peek(j).Value().(*exceptionHandlingContext)
if eCtx.State == eTry {
return true
Expand Down

0 comments on commit d9a6a7c

Please sign in to comment.