build: use golangci-lint (#20295)

* build: use golangci-lint

This changes build/ci.go to download and run golangci-lint instead
of gometalinter.

* core/state: fix unnecessary conversion

* p2p/simulations: fix lock copying (found by go vet)

* signer/core: fix unnecessary conversions

* crypto/ecies: remove unused function cmpPublic

* core/rawdb: remove unused function print

* core/state: remove unused function xTestFuzzCutter

* core/vm: disable TestWriteExpectedValues in a different way

* core/forkid: remove unused function checksum

* les: remove unused type proofsData

* cmd/utils: remove unused functions prefixedNames, prefixFor

* crypto/bn256: run goimports

* p2p/nat: fix goimports lint issue

* cmd/clef: avoid using unkeyed struct fields

* les: cancel context in testRequest

* rlp: delete unreachable code

* core: gofmt

* internal/build: simplify DownloadFile for Go 1.11 compatibility

* build: remove go test --short flag

* .travis.yml: disable build cache

* whisper/whisperv6: fix ineffectual assignment in TestWhisperIdentityManagement

* .golangci.yml: enable goconst and ineffassign linters

* build: print message when there are no lint issues

* internal/build: refactor download a bit
This commit is contained in:
Felix Lange
2019-11-18 09:49:18 +01:00
committed by Péter Szilágyi
parent 7c4a4eb58a
commit 689486449d
29 changed files with 352 additions and 314 deletions

View File

@ -758,27 +758,22 @@ func benchmarkMinimalServiceTmp(b *testing.B) {
}
func TestNode_UnmarshalJSON(t *testing.T) {
t.Run(
"test unmarshal of Node up field",
func(t *testing.T) {
runNodeUnmarshalJSON(t, casesNodeUnmarshalJSONUpField())
},
)
t.Run(
"test unmarshal of Node Config field",
func(t *testing.T) {
runNodeUnmarshalJSON(t, casesNodeUnmarshalJSONConfigField())
},
)
t.Run("up_field", func(t *testing.T) {
runNodeUnmarshalJSON(t, casesNodeUnmarshalJSONUpField())
})
t.Run("config_field", func(t *testing.T) {
runNodeUnmarshalJSON(t, casesNodeUnmarshalJSONConfigField())
})
}
func runNodeUnmarshalJSON(t *testing.T, tests []nodeUnmarshalTestCase) {
t.Helper()
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
var got Node
if err := got.UnmarshalJSON([]byte(tt.marshaled)); err != nil {
var got *Node
if err := json.Unmarshal([]byte(tt.marshaled), &got); err != nil {
expectErrorMessageToContain(t, err, tt.wantErr)
got = nil
}
expectNodeEquality(t, got, tt.want)
})
@ -788,7 +783,7 @@ func runNodeUnmarshalJSON(t *testing.T, tests []nodeUnmarshalTestCase) {
type nodeUnmarshalTestCase struct {
name string
marshaled string
want Node
want *Node
wantErr string
}
@ -812,7 +807,7 @@ func expectErrorMessageToContain(t *testing.T, got error, want string) {
}
}
func expectNodeEquality(t *testing.T, got Node, want Node) {
func expectNodeEquality(t *testing.T, got, want *Node) {
t.Helper()
if !reflect.DeepEqual(got, want) {
t.Errorf("Node.UnmarshalJSON() = %v, want %v", got, want)
@ -824,23 +819,17 @@ func casesNodeUnmarshalJSONUpField() []nodeUnmarshalTestCase {
{
name: "empty json",
marshaled: "{}",
want: Node{
up: false,
},
want: newNode(nil, nil, false),
},
{
name: "a stopped node",
marshaled: "{\"up\": false}",
want: Node{
up: false,
},
want: newNode(nil, nil, false),
},
{
name: "a running node",
marshaled: "{\"up\": true}",
want: Node{
up: true,
},
want: newNode(nil, nil, true),
},
{
name: "invalid JSON value on valid key",
@ -867,26 +856,17 @@ func casesNodeUnmarshalJSONConfigField() []nodeUnmarshalTestCase {
{
name: "Config field is omitted",
marshaled: "{}",
want: Node{
Config: nil,
},
want: newNode(nil, nil, false),
},
{
name: "Config field is nil",
marshaled: "{\"config\": nil}",
want: Node{
Config: nil,
},
marshaled: "{\"config\": null}",
want: newNode(nil, nil, false),
},
{
name: "a non default Config field",
marshaled: "{\"config\":{\"name\":\"node_ecdd0\",\"port\":44665}}",
want: Node{
Config: &adapters.NodeConfig{
Name: "node_ecdd0",
Port: 44665,
},
},
want: newNode(nil, &adapters.NodeConfig{Name: "node_ecdd0", Port: 44665}, false),
},
}
}