Merge pull request #3572 from nspcc-dev/feat/add-for-range-linter

.golangci.yml: add `intrange` linter
This commit is contained in:
Anna Shaleva 2024-09-05 18:02:10 +05:00 committed by GitHub
commit d9a6a7cd3f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 9 additions and 9 deletions

View file

@ -51,6 +51,7 @@ linters:
- decorder - decorder
- durationcheck - durationcheck
- errorlint - errorlint
- intrange
- copyloopvar - copyloopvar
- gofmt - gofmt
- misspell - misspell

View file

@ -142,7 +142,7 @@ func Sign(h hash.Hashable) []byte {
// SignCommittee signs data by a majority of committee members. // SignCommittee signs data by a majority of committee members.
func SignCommittee(h hash.Hashable) []byte { func SignCommittee(h hash.Hashable) []byte {
buf := io.NewBufBinWriter() buf := io.NewBufBinWriter()
for i := 0; i < CommitteeSize()/2+1; i++ { for i := range CommitteeSize()/2 + 1 {
pKey := PrivateKey(i) pKey := PrivateKey(i)
sig := pKey.SignHashable(uint32(Network()), h) sig := pKey.SignHashable(uint32(Network()), h)
if len(sig) != 64 { if len(sig) != 64 {

View file

@ -116,7 +116,7 @@ func TestRemoveOldTransfers(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
require.NotEqual(t, 0, len(log.Raw)) 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) log, err = bc.dao.GetTokenTransferLog(acc2, newer, i, false)
require.NoError(t, err) require.NoError(t, err)
require.NotEqual(t, 0, len(log.Raw)) require.NotEqual(t, 0, len(log.Raw))
@ -130,7 +130,7 @@ func TestRemoveOldTransfers(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
require.NotEqual(t, 0, len(log.Raw)) 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) log, err = bc.dao.GetTokenTransferLog(acc3, newer, i, true)
require.NoError(t, err) require.NoError(t, err)
require.NotEqual(t, 0, len(log.Raw)) require.NotEqual(t, 0, len(log.Raw))

View file

@ -13,14 +13,13 @@ func lcp(a, b []byte) []byte {
return lcp(b, a) return lcp(b, a)
} }
var i int for i := range b {
for i = 0; i < len(b); i++ {
if a[i] != b[i] { if a[i] != b[i] {
break return b[:i]
} }
} }
return a[:i] return b
} }
func lcpMany(kv []keyValue) []byte { func lcpMany(kv []keyValue) []byte {

View file

@ -821,7 +821,7 @@ func TestNEO_GetCandidates(t *testing.T) {
for i := range len(expected) + 1 { for i := range len(expected) + 1 {
w := io.NewBufBinWriter() w := io.NewBufBinWriter()
emit.AppCall(w.BinWriter, neoCommitteeInvoker.Hash, "getAllCandidates", callflag.All) 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.Opcodes(w.BinWriter, opcode.DUP)
emit.Syscall(w.BinWriter, interopnames.SystemIteratorNext) emit.Syscall(w.BinWriter, interopnames.SystemIteratorNext)
emit.Opcodes(w.BinWriter, opcode.DROP) // drop the value returned from Next. emit.Opcodes(w.BinWriter, opcode.DROP) // drop the value returned from Next.

View file

@ -1860,7 +1860,7 @@ func (v *VM) ContractHasTryBlock() bool {
if ictx.sc != topctx.sc { if ictx.sc != topctx.sc {
return false // Different contract -> no one cares. 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) eCtx := ictx.tryStack.Peek(j).Value().(*exceptionHandlingContext)
if eCtx.State == eTry { if eCtx.State == eTry {
return true return true