Skip to content

Commit ef84da8

Browse files
authored
all: remove unneeded parentheses (ethereum#21921)
* remove uneeded convertion type * remove redundant type in composite literal * omit explicit type where implicit * remove unused redundant parenthesis * remove redundant import alias duktape
1 parent 4eae0c6 commit ef84da8

File tree

15 files changed

+23
-23
lines changed

15 files changed

+23
-23
lines changed

accounts/keystore/account_cache.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ func (ac *accountCache) scanAccounts() error {
262262
switch {
263263
case err != nil:
264264
log.Debug("Failed to decode keystore key", "path", path, "err", err)
265-
case (addr == common.Address{}):
265+
case addr == common.Address{}:
266266
log.Debug("Failed to decode keystore key", "path", path, "err", "missing or zero address")
267267
default:
268268
return &accounts.Account{

cmd/puppeth/genesis.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ func newParityChainSpec(network string, genesis *core.Genesis, bootnodes []strin
425425
spec.Params.EIP98Transition = math.MaxInt64
426426

427427
spec.Genesis.Seal.Ethereum.Nonce = types.EncodeNonce(genesis.Nonce)
428-
spec.Genesis.Seal.Ethereum.MixHash = (genesis.Mixhash[:])
428+
spec.Genesis.Seal.Ethereum.MixHash = genesis.Mixhash[:]
429429
spec.Genesis.Difficulty = (*hexutil.Big)(genesis.Difficulty)
430430
spec.Genesis.Author = genesis.Coinbase
431431
spec.Genesis.Timestamp = (hexutil.Uint64)(genesis.Timestamp)

cmd/puppeth/wizard_genesis.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ func (w *wizard) manageGenesis() {
259259

260260
// Export the native genesis spec used by puppeth and Geth
261261
gethJson := filepath.Join(folder, fmt.Sprintf("%s.json", w.network))
262-
if err := ioutil.WriteFile((gethJson), out, 0644); err != nil {
262+
if err := ioutil.WriteFile(gethJson, out, 0644); err != nil {
263263
log.Error("Failed to save genesis file", "err", err)
264264
return
265265
}

core/state/snapshot/conversion.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type trieKV struct {
3838
type (
3939
// trieGeneratorFn is the interface of trie generation which can
4040
// be implemented by different trie algorithm.
41-
trieGeneratorFn func(in chan (trieKV), out chan (common.Hash))
41+
trieGeneratorFn func(in chan trieKV, out chan common.Hash)
4242

4343
// leafCallbackFn is the callback invoked at the leaves of the trie,
4444
// returns the subtrie root with the specified subtrie identifier.
@@ -266,7 +266,7 @@ func generateTrieRoot(it Iterator, account common.Hash, generatorFn trieGenerato
266266

267267
// stdGenerate is a very basic hexary trie builder which uses the same Trie
268268
// as the rest of geth, with no enhancements or optimizations
269-
func stdGenerate(in chan (trieKV), out chan (common.Hash)) {
269+
func stdGenerate(in chan trieKV, out chan common.Hash) {
270270
t, _ := trie.New(common.Hash{}, trie.NewDatabase(memorydb.New()))
271271
for leaf := range in {
272272
t.TryUpdate(leaf.key[:], leaf.value)

core/vm/runtime/runtime_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ func DisabledTestEipExampleCases(t *testing.T) {
500500

501501
{
502502
code := []byte{
503-
byte(vm.PUSH9), 0x00, 0x00, 0x00, 0x00, 0x0, 0x00, 0x00, 0x00, (4 + 8),
503+
byte(vm.PUSH9), 0x00, 0x00, 0x00, 0x00, 0x0, 0x00, 0x00, 0x00, 4 + 8,
504504
byte(vm.JUMPSUB),
505505
byte(vm.STOP),
506506
byte(vm.BEGINSUB),
@@ -516,7 +516,7 @@ func DisabledTestEipExampleCases(t *testing.T) {
516516
// out the trace.
517517
{
518518
code := []byte{
519-
byte(vm.PUSH9), 0x01, 0x00, 0x00, 0x00, 0x0, 0x00, 0x00, 0x00, (4 + 8),
519+
byte(vm.PUSH9), 0x01, 0x00, 0x00, 0x00, 0x0, 0x00, 0x00, 0x00, 4 + 8,
520520
byte(vm.JUMPSUB),
521521
byte(vm.STOP),
522522
byte(vm.BEGINSUB),

crypto/bls12381/bls12_381_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"math/big"
66
)
77

8-
var fuz int = 10
8+
var fuz = 10
99

1010
func randScalar(max *big.Int) *big.Int {
1111
a, _ := rand.Int(rand.Reader, max)

crypto/signify/signify.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func parsePrivateKey(key string) (k ed25519.PrivateKey, header []byte, keyNum []
4646
if string(keydata[:2]) != "Ed" {
4747
return nil, nil, nil, errInvalidKeyHeader
4848
}
49-
return ed25519.PrivateKey(keydata[40:]), keydata[:2], keydata[32:40], nil
49+
return keydata[40:], keydata[:2], keydata[32:40], nil
5050
}
5151

5252
// SignFile creates a signature of the input file.

eth/protocols/snap/sync.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1494,7 +1494,7 @@ func (s *Syncer) revertTrienodeHealRequest(req *trienodeHealRequest) {
14941494
// retrievals as not-pending, ready for resheduling
14951495
req.timeout.Stop()
14961496
for i, hash := range req.hashes {
1497-
req.task.trieTasks[hash] = [][]byte(req.paths[i])
1497+
req.task.trieTasks[hash] = req.paths[i]
14981498
}
14991499
}
15001500

eth/tracers/tracer.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131
"github.com/ethereum/go-ethereum/core/vm"
3232
"github.com/ethereum/go-ethereum/crypto"
3333
"github.com/ethereum/go-ethereum/log"
34-
duktape "gopkg.in/olebedev/go-duktape.v3"
34+
"gopkg.in/olebedev/go-duktape.v3"
3535
)
3636

3737
// bigIntegerJS is the minified version of https://github.com/peterolson/BigInteger.js.

metrics/cpu_syscall.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ func getProcessCPUTime() int64 {
3131
log.Warn("Failed to retrieve CPU time", "err", err)
3232
return 0
3333
}
34-
return int64(usage.Utime.Sec+usage.Stime.Sec)*100 + int64(usage.Utime.Usec+usage.Stime.Usec)/10000 //nolint:unconvert
34+
return (usage.Utime.Sec+usage.Stime.Sec)*100 + int64(usage.Utime.Usec+usage.Stime.Usec)/10000 //nolint:unconvert
3535
}

metrics/exp/exp.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func (exp *exp) publishMeter(name string, metric metrics.Meter) {
128128
exp.getInt(name + ".count").Set(m.Count())
129129
exp.getFloat(name + ".one-minute").Set(m.Rate1())
130130
exp.getFloat(name + ".five-minute").Set(m.Rate5())
131-
exp.getFloat(name + ".fifteen-minute").Set((m.Rate15()))
131+
exp.getFloat(name + ".fifteen-minute").Set(m.Rate15())
132132
exp.getFloat(name + ".mean").Set(m.RateMean())
133133
}
134134

metrics/gauge_float64_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,27 @@ func BenchmarkGuageFloat64(b *testing.B) {
1212

1313
func TestGaugeFloat64(t *testing.T) {
1414
g := NewGaugeFloat64()
15-
g.Update(float64(47.0))
16-
if v := g.Value(); float64(47.0) != v {
15+
g.Update(47.0)
16+
if v := g.Value(); 47.0 != v {
1717
t.Errorf("g.Value(): 47.0 != %v\n", v)
1818
}
1919
}
2020

2121
func TestGaugeFloat64Snapshot(t *testing.T) {
2222
g := NewGaugeFloat64()
23-
g.Update(float64(47.0))
23+
g.Update(47.0)
2424
snapshot := g.Snapshot()
2525
g.Update(float64(0))
26-
if v := snapshot.Value(); float64(47.0) != v {
26+
if v := snapshot.Value(); 47.0 != v {
2727
t.Errorf("g.Value(): 47.0 != %v\n", v)
2828
}
2929
}
3030

3131
func TestGetOrRegisterGaugeFloat64(t *testing.T) {
3232
r := NewRegistry()
33-
NewRegisteredGaugeFloat64("foo", r).Update(float64(47.0))
33+
NewRegisteredGaugeFloat64("foo", r).Update(47.0)
3434
t.Logf("registry: %v", r)
35-
if g := GetOrRegisterGaugeFloat64("foo", r); float64(47.0) != g.Value() {
35+
if g := GetOrRegisterGaugeFloat64("foo", r); 47.0 != g.Value() {
3636
t.Fatal(g)
3737
}
3838
}

node/utils_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ func (f *FullService) Stop() error { return nil }
8282

8383
func (f *FullService) Protocols() []p2p.Protocol {
8484
return []p2p.Protocol{
85-
p2p.Protocol{
85+
{
8686
Name: "test1",
8787
Version: uint(1),
8888
},
89-
p2p.Protocol{
89+
{
9090
Name: "test2",
9191
Version: uint(2),
9292
},

signer/core/api.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ func (api *SignerAPI) newAccount() (common.Address, error) {
439439
continue
440440
}
441441
if pwErr := ValidatePasswordFormat(resp.Text); pwErr != nil {
442-
api.UI.ShowError(fmt.Sprintf("Account creation attempt #%d failed due to password requirements: %v", (i + 1), pwErr))
442+
api.UI.ShowError(fmt.Sprintf("Account creation attempt #%d failed due to password requirements: %v", i+1, pwErr))
443443
} else {
444444
// No error
445445
acc, err := be[0].(*keystore.KeyStore).NewAccount(resp.Text)

trie/trie_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ func TestLargeValue(t *testing.T) {
322322

323323
// TestRandomCases tests som cases that were found via random fuzzing
324324
func TestRandomCases(t *testing.T) {
325-
var rt []randTestStep = []randTestStep{
325+
var rt = []randTestStep{
326326
{op: 6, key: common.Hex2Bytes(""), value: common.Hex2Bytes("")}, // step 0
327327
{op: 6, key: common.Hex2Bytes(""), value: common.Hex2Bytes("")}, // step 1
328328
{op: 0, key: common.Hex2Bytes("d51b182b95d677e5f1c82508c0228de96b73092d78ce78b2230cd948674f66fd1483bd"), value: common.Hex2Bytes("0000000000000002")}, // step 2

0 commit comments

Comments
 (0)