Skip to content

Commit 3da1bf8

Browse files
zramsayfjl
authored andcommitted
all: use gometalinter.v2, fix new gosimple issues (ethereum#15650)
1 parent bbea4b2 commit 3da1bf8

File tree

24 files changed

+57
-67
lines changed

24 files changed

+57
-67
lines changed

accounts/abi/bind/bind.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func Bind(types []string, abis []string, bytecodes []string, pkg string, lang La
129129
return string(code), nil
130130
}
131131
// For all others just return as is for now
132-
return string(buffer.Bytes()), nil
132+
return buffer.String(), nil
133133
}
134134

135135
// bindType is a set of type binders that convert Solidity types to some supported

accounts/abi/unpack_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,11 +368,11 @@ func TestUnmarshal(t *testing.T) {
368368
if err != nil {
369369
t.Error(err)
370370
} else {
371-
if bytes.Compare(p0, p0Exp) != 0 {
371+
if !bytes.Equal(p0, p0Exp) {
372372
t.Errorf("unexpected value unpacked: want %x, got %x", p0Exp, p0)
373373
}
374374

375-
if bytes.Compare(p1[:], p1Exp) != 0 {
375+
if !bytes.Equal(p1[:], p1Exp) {
376376
t.Errorf("unexpected value unpacked: want %x, got %x", p1Exp, p1)
377377
}
378378
}

bmt/bmt.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,7 @@ func NewTree(hasher BaseHasher, segmentSize, segmentCount int) *Tree {
260260
for d := 1; d <= depth(segmentCount); d++ {
261261
nodes := make([]*Node, count)
262262
for i := 0; i < len(nodes); i++ {
263-
var parent *Node
264-
parent = prevlevel[i/2]
263+
parent := prevlevel[i/2]
265264
t := NewNode(level, i, parent)
266265
nodes[i] = t
267266
}

build/ci.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,8 @@ func doLint(cmdline []string) {
319319
packages = flag.CommandLine.Args()
320320
}
321321
// Get metalinter and install all supported linters
322-
build.MustRun(goTool("get", "gopkg.in/alecthomas/gometalinter.v1"))
323-
build.MustRunCommand(filepath.Join(GOBIN, "gometalinter.v1"), "--install")
322+
build.MustRun(goTool("get", "gopkg.in/alecthomas/gometalinter.v2"))
323+
build.MustRunCommand(filepath.Join(GOBIN, "gometalinter.v2"), "--install")
324324

325325
// Run fast linters batched together
326326
configs := []string{
@@ -332,12 +332,12 @@ func doLint(cmdline []string) {
332332
"--enable=goconst",
333333
"--min-occurrences=6", // for goconst
334334
}
335-
build.MustRunCommand(filepath.Join(GOBIN, "gometalinter.v1"), append(configs, packages...)...)
335+
build.MustRunCommand(filepath.Join(GOBIN, "gometalinter.v2"), append(configs, packages...)...)
336336

337337
// Run slow linters one by one
338338
for _, linter := range []string{"unconvert", "gosimple"} {
339339
configs = []string{"--vendor", "--deadline=10m", "--disable-all", "--enable=" + linter}
340-
build.MustRunCommand(filepath.Join(GOBIN, "gometalinter.v1"), append(configs, packages...)...)
340+
build.MustRunCommand(filepath.Join(GOBIN, "gometalinter.v2"), append(configs, packages...)...)
341341
}
342342
}
343343

cmd/faucet/faucet.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ func (f *faucet) apiHandler(conn *websocket.Conn) {
506506

507507
// Send an error if too frequent funding, othewise a success
508508
if !fund {
509-
if err = sendError(conn, fmt.Errorf("%s left until next allowance", common.PrettyDuration(timeout.Sub(time.Now())))); err != nil {
509+
if err = sendError(conn, fmt.Errorf("%s left until next allowance", common.PrettyDuration(timeout.Sub(time.Now())))); err != nil { // nolint: gosimple
510510
log.Warn("Failed to send funding error to client", "err", err)
511511
return
512512
}

cmd/puppeth/module_dashboard.go

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

cmd/swarm/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ func envVarsOverride(currentConfig *bzzapi.Config) (config *bzzapi.Config) {
267267
}
268268

269269
//EnsApi can be set to "", so can't check for empty string, as it is allowed
270-
if ensapi, exists := os.LookupEnv(SWARM_ENV_ENS_API); exists == true {
270+
if ensapi, exists := os.LookupEnv(SWARM_ENV_ENS_API); exists {
271271
currentConfig.EnsApi = ensapi
272272
}
273273

cmd/swarm/config_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func TestCmdLineOverrides(t *testing.T) {
124124
t.Fatalf("Expected network ID to be %d, got %d", 42, info.NetworkId)
125125
}
126126

127-
if info.SyncEnabled != true {
127+
if !info.SyncEnabled {
128128
t.Fatal("Expected Sync to be enabled, but is false")
129129
}
130130

@@ -219,7 +219,7 @@ func TestFileOverrides(t *testing.T) {
219219
t.Fatalf("Expected network ID to be %d, got %d", 54, info.NetworkId)
220220
}
221221

222-
if info.SyncEnabled != true {
222+
if !info.SyncEnabled {
223223
t.Fatal("Expected Sync to be enabled, but is false")
224224
}
225225

@@ -334,7 +334,7 @@ func TestEnvVars(t *testing.T) {
334334
t.Fatalf("Expected Cors flag to be set to %s, got %s", "*", info.Cors)
335335
}
336336

337-
if info.SyncEnabled != true {
337+
if !info.SyncEnabled {
338338
t.Fatal("Expected Sync to be enabled, but is false")
339339
}
340340

@@ -431,7 +431,7 @@ func TestCmdLineOverridesFile(t *testing.T) {
431431
t.Fatalf("Expected network ID to be %d, got %d", expectNetworkId, info.NetworkId)
432432
}
433433

434-
if info.SyncEnabled != true {
434+
if !info.SyncEnabled {
435435
t.Fatal("Expected Sync to be enabled, but is false")
436436
}
437437

consensus/clique/clique.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ func (c *Clique) Seal(chain consensus.ChainReader, block *types.Block, stop <-ch
630630
}
631631
}
632632
// Sweet, the protocol permits us to sign the block, wait for our time
633-
delay := time.Unix(header.Time.Int64(), 0).Sub(time.Now())
633+
delay := time.Unix(header.Time.Int64(), 0).Sub(time.Now()) // nolint: gosimple
634634
if header.Difficulty.Cmp(diffNoTurn) == 0 {
635635
// It's not our turn explicitly to sign, delay it a bit
636636
wiggle := time.Duration(len(snap.Signers)/2+1) * wiggleTime

console/console_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ func TestWelcome(t *testing.T) {
164164

165165
tester.console.Welcome()
166166

167-
output := string(tester.output.Bytes())
167+
output := tester.output.String()
168168
if want := "Welcome"; !strings.Contains(output, want) {
169169
t.Fatalf("console output missing welcome message: have\n%s\nwant also %s", output, want)
170170
}
@@ -188,7 +188,7 @@ func TestEvaluate(t *testing.T) {
188188
defer tester.Close(t)
189189

190190
tester.console.Evaluate("2 + 2")
191-
if output := string(tester.output.Bytes()); !strings.Contains(output, "4") {
191+
if output := tester.output.String(); !strings.Contains(output, "4") {
192192
t.Fatalf("statement evaluation failed: have %s, want %s", output, "4")
193193
}
194194
}
@@ -218,7 +218,7 @@ func TestInteractive(t *testing.T) {
218218
case <-time.After(time.Second):
219219
t.Fatalf("secondary prompt timeout")
220220
}
221-
if output := string(tester.output.Bytes()); !strings.Contains(output, "4") {
221+
if output := tester.output.String(); !strings.Contains(output, "4") {
222222
t.Fatalf("statement evaluation failed: have %s, want %s", output, "4")
223223
}
224224
}
@@ -230,7 +230,7 @@ func TestPreload(t *testing.T) {
230230
defer tester.Close(t)
231231

232232
tester.console.Evaluate("preloaded")
233-
if output := string(tester.output.Bytes()); !strings.Contains(output, "some-preloaded-string") {
233+
if output := tester.output.String(); !strings.Contains(output, "some-preloaded-string") {
234234
t.Fatalf("preloaded variable missing: have %s, want %s", output, "some-preloaded-string")
235235
}
236236
}
@@ -243,7 +243,7 @@ func TestExecute(t *testing.T) {
243243
tester.console.Execute("exec.js")
244244

245245
tester.console.Evaluate("execed")
246-
if output := string(tester.output.Bytes()); !strings.Contains(output, "some-executed-string") {
246+
if output := tester.output.String(); !strings.Contains(output, "some-executed-string") {
247247
t.Fatalf("execed variable missing: have %s, want %s", output, "some-executed-string")
248248
}
249249
}
@@ -275,7 +275,7 @@ func TestPrettyPrint(t *testing.T) {
275275
string: ` + two + `
276276
}
277277
`
278-
if output := string(tester.output.Bytes()); output != want {
278+
if output := tester.output.String(); output != want {
279279
t.Fatalf("pretty print mismatch: have %s, want %s", output, want)
280280
}
281281
}
@@ -287,7 +287,7 @@ func TestPrettyError(t *testing.T) {
287287
tester.console.Evaluate("throw 'hello'")
288288

289289
want := jsre.ErrorColor("hello") + "\n"
290-
if output := string(tester.output.Bytes()); output != want {
290+
if output := tester.output.String(); output != want {
291291
t.Fatalf("pretty error mismatch: have %s, want %s", output, want)
292292
}
293293
}

0 commit comments

Comments
 (0)