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

Linter: adapt org-wide linter #3592

Merged
merged 3 commits into from
Sep 26, 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
14 changes: 1 addition & 13 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,7 @@ on:
jobs:
lint:
name: Lint
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
with:
version: latest
skip-pkg-cache: true # golangci-lint can't work with this cache enabled, ref. https://github.com/golangci/golangci-lint-action/issues/135.

uses: nspcc-dev/.github/.github/workflows/go-linter.yml@master
gomodcheck:
name: Check internal dependencies
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,6 @@ testdata/
pkg/vm/testdata/fuzz
!pkg/vm/testdata
!pkg/wallet/testdata

# Linter
.golangci.yml
74 changes: 0 additions & 74 deletions .golangci.yml

This file was deleted.

5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ test:
vet:
@go vet ./...

lint:
.golangci.yml:
curl -L -o $@ https://github.com/nspcc-dev/.github/raw/master/.golangci.yml

lint: .golangci.yml
@golangci-lint run

fmt:
Expand Down
1 change: 1 addition & 0 deletions cli/cmdargs/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ func parseCosigner(c string) (transaction.Signer, error) {

res.AllowedGroups = append(res.AllowedGroups, pub)
}
default:
}
}
return res, nil
Expand Down
8 changes: 6 additions & 2 deletions pkg/compiler/codegen.go
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,7 @@
expectedLen = 20
case smartcontract.Hash256Type:
expectedLen = 32
default:
}
if expectedLen != -1 && expectedLen != len(n.Elts) {
c.prog.Err = fmt.Errorf("%s type must have size %d", tn.Obj().Name(), expectedLen)
Expand Down Expand Up @@ -1225,10 +1226,10 @@
case token.CONTINUE:
post := c.getLabelOffset(labelPost, label)
emit.Jmp(c.prog.BinWriter, opcode.JMPL, post)
default:
return nil

Check warning on line 1230 in pkg/compiler/codegen.go

View check run for this annotation

Codecov / codecov/patch

pkg/compiler/codegen.go#L1229-L1230

Added lines #L1229 - L1230 were not covered by tests
}

return nil

case *ast.LabeledStmt:
c.nextLabel = n.Label.Name

Expand Down Expand Up @@ -1722,6 +1723,7 @@
}
return opcode.JMPNEL, true
}
default:

Check warning on line 1726 in pkg/compiler/codegen.go

View check run for this annotation

Codecov / codecov/patch

pkg/compiler/codegen.go#L1726

Added line #L1726 was not covered by tests
}
return 0, false
}
Expand Down Expand Up @@ -2393,6 +2395,7 @@
return nil, fmt.Errorf("func '%s' has %d local variables (maximum is 255)", info.name, info.count)
}
b[nextIP-2] = byte(info.count)
default:
}
}

Expand Down Expand Up @@ -2502,6 +2505,7 @@
finallyOffset := int(int32(binary.LittleEndian.Uint32(arg)))
finallyOffset += calcOffsetCorrection(ip, ip+finallyOffset, nopOffsets)
binary.LittleEndian.PutUint32(arg, uint32(finallyOffset))
default:
}
}

Expand Down
1 change: 1 addition & 0 deletions pkg/compiler/inline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func checkInstrCount(t *testing.T, src string, expectedSSlotCount, expectedCall,
if ctx.IP() == mainStart && expectedLocalsMain >= 0 {
require.Equal(t, expectedLocalsMain, int(param[0]))
}
default:
}
if ctx.IP() == ctx.LenInstr() {
break
Expand Down
1 change: 1 addition & 0 deletions pkg/consensus/recovery_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@
Signature: p.GetCommit().(*commit).signature,
InvocationScript: p.(*Payload).Witness.InvocationScript,
})
default:

Check warning on line 183 in pkg/consensus/recovery_message.go

View check run for this annotation

Codecov / codecov/patch

pkg/consensus/recovery_message.go#L183

Added line #L183 was not covered by tests
}
}

Expand Down
1 change: 1 addition & 0 deletions pkg/core/native/designate.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ func (s *Designate) notifyRoleChanged(v *roleData, r noderoles.Role) {
if s.StateRootService != nil {
s.StateRootService.UpdateStateValidators(v.height, v.nodes.Copy())
}
default:
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/core/native/native_test/cryptolib_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,5 +468,5 @@ func TestVerifyGroth16Proof(t *testing.T) {
publicWitness := make([]byte, fr.Bytes)

// Verify.
validatorInvoker.Invoke(t, true, "verifyProof", argA, argB, argC, []interface{}{publicWitness})
validatorInvoker.Invoke(t, true, "verifyProof", argA, argB, argC, []any{publicWitness})
}
3 changes: 2 additions & 1 deletion pkg/neorpc/rpcevent/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
}
}
return senderOk && signerOK && typeOk
default:
return false

Check warning on line 93 in pkg/neorpc/rpcevent/filter.go

View check run for this annotation

Codecov / codecov/patch

pkg/neorpc/rpcevent/filter.go#L92-L93

Added lines #L92 - L93 were not covered by tests
}
return false
}
1 change: 1 addition & 0 deletions pkg/network/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1446,6 +1446,7 @@
return s.handlePong(peer, pong)
case CMDVersion, CMDVerack:
return fmt.Errorf("received '%s' after the handshake", msg.Command.String())
default:

Check warning on line 1449 in pkg/network/server.go

View check run for this annotation

Codecov / codecov/patch

pkg/network/server.go#L1449

Added line #L1449 was not covered by tests
}
} else {
switch msg.Command {
Expand Down
2 changes: 2 additions & 0 deletions pkg/network/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,7 @@ func (s *Server) testHandleGetData(t *testing.T, invType payload.InventoryType,
case CMDNotFound:
require.Equal(t, notFound, msg.Payload.(*payload.Inventory).Hashes)
recvNotFound.Store(true)
default:
}
}

Expand Down Expand Up @@ -818,6 +819,7 @@ func TestHandleGetMPTData(t *testing.T) {
case CMDMPTData:
require.Equal(t, found, msg.Payload)
recvResponse.Store(true)
default:
}
}
hs := []util.Uint256{r1, r2}
Expand Down
44 changes: 22 additions & 22 deletions pkg/rpcclient/nns/contract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -582,18 +582,18 @@ func TestSetAdmin(t *testing.T) {
testCases := []struct {
name string
setup func()
testFunc func() (interface{}, error)
want interface{}
testFunc func() (any, error)
want any
wantErr bool
}{
{
name: "SetAdmin - Error",
setup: func() {
ta.err = errors.New("test error")
},
testFunc: func() (interface{}, error) {
testFunc: func() (any, error) {
txh, vub, err := c.SetAdmin(name, admin)
return []interface{}{txh, vub}, err
return []any{txh, vub}, err
},
wantErr: true,
},
Expand All @@ -604,19 +604,19 @@ func TestSetAdmin(t *testing.T) {
ta.txh = txhMock
ta.vub = 42
},
testFunc: func() (interface{}, error) {
testFunc: func() (any, error) {
txh, vub, err := c.SetAdmin(name, admin)
return []interface{}{txh, vub}, err
return []any{txh, vub}, err
},
want: []interface{}{txhMock, uint32(42)},
want: []any{txhMock, uint32(42)},
},
{
name: "SetAdminTransaction - Success",
setup: func() {
ta.err = nil
ta.tx = txMock
},
testFunc: func() (interface{}, error) {
testFunc: func() (any, error) {
return c.SetAdminTransaction(name, admin)
},
want: txMock,
Expand All @@ -626,7 +626,7 @@ func TestSetAdmin(t *testing.T) {
setup: func() {
ta.err = errors.New("test error")
},
testFunc: func() (interface{}, error) {
testFunc: func() (any, error) {
return c.SetAdminTransaction(name, admin)
},
wantErr: true,
Expand All @@ -637,7 +637,7 @@ func TestSetAdmin(t *testing.T) {
ta.err = nil
ta.tx = txMock
},
testFunc: func() (interface{}, error) {
testFunc: func() (any, error) {
return c.SetAdminUnsigned(name, admin)
},
want: txMock,
Expand All @@ -647,7 +647,7 @@ func TestSetAdmin(t *testing.T) {
setup: func() {
ta.err = errors.New("test error")
},
testFunc: func() (interface{}, error) {
testFunc: func() (any, error) {
return c.SetAdminUnsigned(name, admin)
},
wantErr: true,
Expand Down Expand Up @@ -681,18 +681,18 @@ func TestSetRecord(t *testing.T) {
testCases := []struct {
name string
setup func()
testFunc func() (interface{}, error)
want interface{}
testFunc func() (any, error)
want any
wantErr bool
}{
{
name: "SetRecord - Error",
setup: func() {
ta.err = errors.New("test error")
},
testFunc: func() (interface{}, error) {
testFunc: func() (any, error) {
txh, vub, err := c.SetRecord(name, typev, data)
return []interface{}{txh, vub}, err
return []any{txh, vub}, err
},
wantErr: true,
},
Expand All @@ -703,19 +703,19 @@ func TestSetRecord(t *testing.T) {
ta.txh = txhMock
ta.vub = 42
},
testFunc: func() (interface{}, error) {
testFunc: func() (any, error) {
txh, vub, err := c.SetRecord(name, typev, data)
return []interface{}{txh, vub}, err
return []any{txh, vub}, err
},
want: []interface{}{txhMock, uint32(42)},
want: []any{txhMock, uint32(42)},
},
{
name: "SetRecordTransaction - Success",
setup: func() {
ta.err = nil
ta.tx = txMock
},
testFunc: func() (interface{}, error) {
testFunc: func() (any, error) {
return c.SetRecordTransaction(name, typev, data)
},
want: txMock,
Expand All @@ -725,7 +725,7 @@ func TestSetRecord(t *testing.T) {
setup: func() {
ta.err = errors.New("test error")
},
testFunc: func() (interface{}, error) {
testFunc: func() (any, error) {
return c.SetRecordTransaction(name, typev, data)
},
wantErr: true,
Expand All @@ -736,7 +736,7 @@ func TestSetRecord(t *testing.T) {
ta.err = nil
ta.tx = txMock
},
testFunc: func() (interface{}, error) {
testFunc: func() (any, error) {
return c.SetRecordUnsigned(name, typev, data)
},
want: txMock,
Expand All @@ -746,7 +746,7 @@ func TestSetRecord(t *testing.T) {
setup: func() {
ta.err = errors.New("test error")
},
testFunc: func() (interface{}, error) {
testFunc: func() (any, error) {
return c.SetRecordUnsigned(name, typev, data)
},
wantErr: true,
Expand Down
2 changes: 2 additions & 0 deletions pkg/services/notary/core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ func TestNotary(t *testing.T) {
script, err = smartcontract.CreateMultiSigRedeemScript(requesters[i].m, pubs)
require.NoError(t, err)
nKeys += uint8(len(requesters[i].accounts))
default:
}
signers[i] = transaction.Signer{
Account: hash.Hash160(script),
Expand Down Expand Up @@ -294,6 +295,7 @@ func TestNotary(t *testing.T) {
nSigs++
case notary.MultiSignature:
nSigs += r.m
default:
}
}
nSigners := len(requesters) + 1
Expand Down
Loading
Loading