Skip to content

Commit b196ad1

Browse files
jsvisakaralabe
andauthored
all: add whitespace linter (ethereum#25312)
* golangci: typo Signed-off-by: Delweng <[email protected]> * golangci: add whietspace Signed-off-by: Delweng <[email protected]> * *: rm whitesapce using golangci-lint Signed-off-by: Delweng <[email protected]> * cmd/puppeth: revert accidental resurrection Co-authored-by: Péter Szilágyi <[email protected]>
1 parent 6c4e5d0 commit b196ad1

File tree

90 files changed

+12
-164
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+12
-164
lines changed

.golangci.yml

+12-11
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,16 @@ linters:
2828
- durationcheck
2929
- exportloopref
3030
- gosec
31+
- whitespace
3132

32-
#- structcheck # lots of false positives
33-
#- errcheck #lot of false positives
34-
# - contextcheck
35-
# - errchkjson # lots of false positives
36-
# - errorlint # this check crashes
37-
# - exhaustive # silly check
38-
# - makezero # false positives
39-
# - nilerr # several intentional
33+
# - structcheck # lots of false positives
34+
# - errcheck #lot of false positives
35+
# - contextcheck
36+
# - errchkjson # lots of false positives
37+
# - errorlint # this check crashes
38+
# - exhaustive # silly check
39+
# - makezero # false positives
40+
# - nilerr # several intentional
4041

4142
linters-settings:
4243
gofmt:
@@ -46,9 +47,9 @@ linters-settings:
4647
min-occurrences: 6 # minimum number of occurrences
4748
gosec:
4849
excludes:
49-
- G404 # Use of weak random number generator - lots of FP
50-
- G107 # Potential http request -- those are intentional
51-
- G306 # G306: Expect WriteFile permissions to be 0600 or less
50+
- G404 # Use of weak random number generator - lots of FP
51+
- G107 # Potential http request -- those are intentional
52+
- G306 # G306: Expect WriteFile permissions to be 0600 or less
5253

5354
issues:
5455
exclude-rules:

accounts/abi/bind/base_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ func (mc *mockPendingCaller) PendingCallContract(ctx context.Context, call ether
115115
}
116116

117117
func TestPassingBlockNumber(t *testing.T) {
118-
119118
mc := &mockPendingCaller{
120119
mockCaller: &mockCaller{
121120
codeAtBytes: []byte{1, 2, 3},

accounts/abi/error_handling.go

-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ func typeCheck(t Type, value reflect.Value) error {
7373
} else {
7474
return nil
7575
}
76-
7776
}
7877

7978
// typeErr returns a formatted type casting error.

accounts/abi/event_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ func TestEventMultiValueWithArrayUnpack(t *testing.T) {
161161
}
162162

163163
func TestEventTupleUnpack(t *testing.T) {
164-
165164
type EventTransfer struct {
166165
Value *big.Int
167166
}

accounts/abi/reflect.go

-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ func mapArgNamesToStructFields(argNames []string, value reflect.Value) (map[stri
220220

221221
// second round ~~~
222222
for _, argName := range argNames {
223-
224223
structFieldName := ToCamelCase(argName)
225224

226225
if structFieldName == "" {

accounts/abi/unpack.go

-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ func ReadFixedBytes(t Type, word []byte) (interface{}, error) {
115115

116116
reflect.Copy(array, reflect.ValueOf(word[0:t.Size]))
117117
return array.Interface(), nil
118-
119118
}
120119

121120
// forEachUnpack iteratively unpack elements.

accounts/keystore/keystore_test.go

-2
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,6 @@ func TestImportExport(t *testing.T) {
377377
if _, err = ks2.Import(json, "new", "new"); err == nil {
378378
t.Errorf("importing a key twice succeeded")
379379
}
380-
381380
}
382381

383382
// TestImportRace tests the keystore on races.
@@ -402,7 +401,6 @@ func TestImportRace(t *testing.T) {
402401
if _, err := ks2.Import(json, "new", "new"); err != nil {
403402
atomic.AddUint32(&atom, 1)
404403
}
405-
406404
}()
407405
}
408406
wg.Wait()

accounts/keystore/passphrase.go

-2
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ func (ks keyStorePassphrase) JoinPath(filename string) string {
138138

139139
// Encryptdata encrypts the data given as 'data' with the password 'auth'.
140140
func EncryptDataV3(data, auth []byte, scryptN, scryptP int) (CryptoJSON, error) {
141-
142141
salt := make([]byte, 32)
143142
if _, err := io.ReadFull(rand.Reader, salt); err != nil {
144143
panic("reading from crypto/rand failed: " + err.Error())
@@ -341,7 +340,6 @@ func getKDFKey(cryptoJSON CryptoJSON, auth string) ([]byte, error) {
341340
r := ensureInt(cryptoJSON.KDFParams["r"])
342341
p := ensureInt(cryptoJSON.KDFParams["p"])
343342
return scrypt.Key(authArray, salt, n, r, p, dkLen)
344-
345343
} else if cryptoJSON.KDF == "pbkdf2" {
346344
c := ensureInt(cryptoJSON.KDFParams["c"])
347345
prf := cryptoJSON.KDFParams["prf"].(string)

accounts/usbwallet/wallet.go

-1
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,6 @@ func (w *wallet) signHash(account accounts.Account, hash []byte) ([]byte, error)
526526

527527
// SignData signs keccak256(data). The mimetype parameter describes the type of data being signed
528528
func (w *wallet) SignData(account accounts.Account, mimeType string, data []byte) ([]byte, error) {
529-
530529
// Unless we are doing 712 signing, simply dispatch to signHash
531530
if !(mimeType == accounts.MimetypeTypedData && len(data) == 66 && data[0] == 0x19 && data[1] == 0x01) {
532531
return w.signHash(account, crypto.Keccak256(data))

cmd/clef/main.go

-5
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,6 @@ func confirm(text string) bool {
759759
}
760760

761761
func testExternalUI(api *core.SignerAPI) {
762-
763762
ctx := context.WithValue(context.Background(), "remote", "clef binary")
764763
ctx = context.WithValue(ctx, "scheme", "in-proc")
765764
ctx = context.WithValue(ctx, "local", "main")
@@ -859,7 +858,6 @@ func testExternalUI(api *core.SignerAPI) {
859858
expectDeny("signdata - text", err)
860859
}
861860
{ // Sign transaction
862-
863861
api.UI.ShowInfo("Please reject next transaction")
864862
time.Sleep(delay)
865863
data := hexutil.Bytes([]byte{})
@@ -902,7 +900,6 @@ func testExternalUI(api *core.SignerAPI) {
902900
}
903901
result := fmt.Sprintf("Tests completed. %d errors:\n%s\n", len(errs), strings.Join(errs, "\n"))
904902
api.UI.ShowInfo(result)
905-
906903
}
907904

908905
type encryptedSeedStorage struct {
@@ -939,7 +936,6 @@ func decryptSeed(keyjson []byte, auth string) ([]byte, error) {
939936

940937
// GenDoc outputs examples of all structures used in json-rpc communication
941938
func GenDoc(ctx *cli.Context) error {
942-
943939
var (
944940
a = common.HexToAddress("0xdeadbeef000000000000000000000000deadbeef")
945941
b = common.HexToAddress("0x1111111122222222222233333333334444444444")
@@ -1049,7 +1045,6 @@ func GenDoc(ctx *cli.Context) error {
10491045
var tx types.Transaction
10501046
tx.UnmarshalBinary(rlpdata)
10511047
add("OnApproved - SignTransactionResult", desc, &ethapi.SignTransactionResult{Raw: rlpdata, Tx: &tx})
1052-
10531048
}
10541049
{ // User input
10551050
add("UserInputRequest", "Sent when clef needs the user to provide data. If 'password' is true, the input field should be treated accordingly (echo-free)",

cmd/devp2p/dns_cloudflare.go

-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ func (c *cloudflareClient) uploadRecords(name string, records map[string]string)
134134
ttl := rootTTL
135135
if path != name {
136136
ttl = treeNodeTTLCloudflare // Max TTL permitted by Cloudflare
137-
138137
}
139138
record := cloudflare.DNSRecord{Type: "TXT", Name: path, Content: val, TTL: ttl}
140139
_, err = c.CreateDNSRecord(context.Background(), c.zoneID, record)

cmd/devp2p/internal/ethtest/chain.go

-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ func (c *Chain) GetHeaders(req GetBlockHeaders) (BlockHeaders, error) {
119119
for i := 1; i < int(req.Amount); i++ {
120120
blockNumber -= (1 - req.Skip)
121121
headers[i] = c.blocks[blockNumber].Header()
122-
123122
}
124123

125124
return headers, nil

cmd/devp2p/internal/ethtest/snap.go

-1
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,6 @@ func hexToCompact(hex []byte) []byte {
350350

351351
// TestSnapTrieNodes various forms of GetTrieNodes requests.
352352
func (s *Suite) TestSnapTrieNodes(t *utesting.T) {
353-
354353
key := common.FromHex("0x00bf49f440a1cd0527e4d06e2765654c0f56452257516d793a9b8d604dcfdf2a")
355354
// helper function to iterate the key, and generate the compact-encoded
356355
// trie paths along the way.

cmd/devp2p/internal/ethtest/types.go

-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,6 @@ func (c *Conn) ReadSnap(id uint64) (Message, error) {
315315
return nil, fmt.Errorf("could not rlp decode message: %v", err)
316316
}
317317
return snpMsg.(Message), nil
318-
319318
}
320319
return nil, fmt.Errorf("request timed out")
321320
}

cmd/evm/internal/t8ntool/execution.go

-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ type rejectedTx struct {
100100
func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
101101
txs types.Transactions, miningReward int64,
102102
getTracerFn func(txIndex int, txHash common.Hash) (tracer vm.EVMLogger, err error)) (*state.StateDB, *ExecutionResult, error) {
103-
104103
// Capture errors for BLOCKHASH operation, if we haven't been supplied the
105104
// required blockhashes
106105
var hashError error

cmd/evm/t8n_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ func TestT8n(t *testing.T) {
244244
expExitCode: 3,
245245
},
246246
} {
247-
248247
args := []string{"t8n"}
249248
args = append(args, tc.output.get()...)
250249
args = append(args, tc.input.get(tc.base)...)
@@ -355,7 +354,6 @@ func TestT9n(t *testing.T) {
355354
expExitCode: t8ntool.ErrorIO,
356355
},
357356
} {
358-
359357
args := []string{"t9n"}
360358
args = append(args, tc.input.get(tc.base)...)
361359

@@ -475,7 +473,6 @@ func TestB11r(t *testing.T) {
475473
expOut: "exp.json",
476474
},
477475
} {
478-
479476
args := []string{"b11r"}
480477
args = append(args, tc.input.get(tc.base)...)
481478

cmd/geth/version_check_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ func TestMatching(t *testing.T) {
118118
version, vuln.Introduced, vuln.Fixed, vuln.Name, vulnIntro, current, vulnFixed)
119119
}
120120
}
121-
122121
}
123122
}
124123
for major := 1; major < 2; major++ {

common/math/big_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ func BenchmarkByteAt(b *testing.B) {
171171
}
172172

173173
func BenchmarkByteAtOld(b *testing.B) {
174-
175174
bigint := MustParseBig256("0x18F8F8F1000111000110011100222004330052300000000000000000FEFCF3CC")
176175
for i := 0; i < b.N; i++ {
177176
PaddedBigBytes(bigint, 32)
@@ -244,7 +243,6 @@ func TestBigEndianByteAt(t *testing.T) {
244243
if actual != test.exp {
245244
t.Fatalf("Expected [%v] %v:th byte to be %v, was %v.", test.x, test.y, test.exp, actual)
246245
}
247-
248246
}
249247
}
250248
func TestLittleEndianByteAt(t *testing.T) {
@@ -277,7 +275,6 @@ func TestLittleEndianByteAt(t *testing.T) {
277275
if actual != test.exp {
278276
t.Fatalf("Expected [%v] %v:th byte to be %v, was %v.", test.x, test.y, test.exp, actual)
279277
}
280-
281278
}
282279
}
283280

common/types_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ func BenchmarkAddressHex(b *testing.B) {
155155
}
156156

157157
func TestMixedcaseAccount_Address(t *testing.T) {
158-
159158
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-55.md
160159
// Note: 0X{checksum_addr} is not valid according to spec above
161160

@@ -192,9 +191,7 @@ func TestMixedcaseAccount_Address(t *testing.T) {
192191
if err := json.Unmarshal([]byte(r), &r2); err == nil {
193192
t.Errorf("Expected failure, input %v", r)
194193
}
195-
196194
}
197-
198195
}
199196

200197
func TestHash_Scan(t *testing.T) {

core/blockchain_test.go

-4
Original file line numberDiff line numberDiff line change
@@ -1235,7 +1235,6 @@ func TestSideLogRebirth(t *testing.T) {
12351235
chain, _ := GenerateChain(params.TestChainConfig, genesis, ethash.NewFaker(), db, 2, func(i int, gen *BlockGen) {
12361236
if i == 1 {
12371237
gen.OffsetTime(-9) // higher block difficulty
1238-
12391238
}
12401239
})
12411240
if _, err := blockchain.InsertChain(chain); err != nil {
@@ -1364,7 +1363,6 @@ done:
13641363
t.Errorf("unexpected event fired: %v", e)
13651364
case <-time.After(250 * time.Millisecond):
13661365
}
1367-
13681366
}
13691367

13701368
// Tests if the canonical block can be fetched from the database during chain insertion.
@@ -2753,7 +2751,6 @@ func benchmarkLargeNumberOfValueToNonexisting(b *testing.B, numTxs, numBlocks in
27532751
b.StopTimer()
27542752
if got := chain.CurrentBlock().Transactions().Len(); got != numTxs*numBlocks {
27552753
b.Fatalf("Transactions were not included, expected %d, got %d", numTxs*numBlocks, got)
2756-
27572754
}
27582755
}
27592756
}
@@ -3522,7 +3519,6 @@ func TestEIP2718Transition(t *testing.T) {
35223519
vm.GasQuickStep*2 + params.WarmStorageReadCostEIP2929 + params.ColdSloadCostEIP2929
35233520
if block.GasUsed() != expected {
35243521
t.Fatalf("incorrect amount of gas spent: expected %d, got %d", expected, block.GasUsed())
3525-
35263522
}
35273523
}
35283524

core/state/snapshot/difflayer_test.go

-2
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,6 @@ func BenchmarkFlatten(b *testing.B) {
332332
value := make([]byte, 32)
333333
rand.Read(value)
334334
accStorage[randomHash()] = value
335-
336335
}
337336
storage[accountKey] = accStorage
338337
}
@@ -382,7 +381,6 @@ func BenchmarkJournal(b *testing.B) {
382381
value := make([]byte, 32)
383382
rand.Read(value)
384383
accStorage[randomHash()] = value
385-
386384
}
387385
storage[accountKey] = accStorage
388386
}

core/state/statedb_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,6 @@ func TestDeleteCreateRevert(t *testing.T) {
699699
// the Commit operation fails with an error
700700
// If we are missing trie nodes, we should not continue writing to the trie
701701
func TestMissingTrieNodes(t *testing.T) {
702-
703702
// Create an initial state with a few accounts
704703
memDb := rawdb.NewMemoryDatabase()
705704
db := NewDatabase(memDb)

core/tx_pool_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,6 @@ func TestTransactionPostponing(t *testing.T) {
669669
// Add a batch consecutive pending transactions for validation
670670
txs := []*types.Transaction{}
671671
for i, key := range keys {
672-
673672
for j := 0; j < 100; j++ {
674673
var tx *types.Transaction
675674
if (i+j)%2 == 0 {

core/types/bloom9_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ func BenchmarkBloom9Lookup(b *testing.B) {
9292
}
9393

9494
func BenchmarkCreateBloom(b *testing.B) {
95-
9695
var txs = Transactions{
9796
NewContractCreation(1, big.NewInt(1), 1, big.NewInt(1), nil),
9897
NewTransaction(2, common.HexToAddress("0x2"), big.NewInt(2), 2, big.NewInt(2), nil),

core/types/transaction_signing_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ func TestEIP155SigningVitalik(t *testing.T) {
111111
if from != addr {
112112
t.Errorf("%d: expected %x got %x", i, addr, from)
113113
}
114-
115114
}
116115
}
117116

core/types/transaction_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ func TestEIP2718TransactionSigHash(t *testing.T) {
114114

115115
// This test checks signature operations on access list transactions.
116116
func TestEIP2930Signer(t *testing.T) {
117-
118117
var (
119118
key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
120119
keyAddr = crypto.PubkeyToAddress(key.PublicKey)

core/vm/instructions_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ var commonParams []*twoOperandParams
4646
var twoOpMethods map[string]executionFunc
4747

4848
func init() {
49-
5049
// Params is a list of common edgecases that should be used for some common tests
5150
params := []string{
5251
"0000000000000000000000000000000000000000000000000000000000000000", // 0
@@ -92,7 +91,6 @@ func init() {
9291
}
9392

9493
func testTwoOperandOp(t *testing.T, tests []TwoOperandTestcase, opFn executionFunc, name string) {
95-
9694
var (
9795
env = NewEVM(BlockContext{}, TxContext{}, nil, params.TestChainConfig, Config{})
9896
stack = newstack()
@@ -641,7 +639,6 @@ func TestCreate2Addreses(t *testing.T) {
641639
expected: "0xE33C0C7F7df4809055C3ebA6c09CFe4BaF1BD9e0",
642640
},
643641
} {
644-
645642
origin := common.BytesToAddress(common.FromHex(tt.origin))
646643
salt := common.BytesToHash(common.FromHex(tt.salt))
647644
code := common.FromHex(tt.code)

core/vm/interpreter.go

-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ func NewEVMInterpreter(evm *EVM, cfg Config) *EVMInterpreter {
114114
// considered a revert-and-consume-all-gas operation except for
115115
// ErrExecutionReverted which means revert-and-keep-gas-left.
116116
func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (ret []byte, err error) {
117-
118117
// Increment the call depth which is restricted to 1024
119118
in.evm.depth++
120119
defer func() { in.evm.depth-- }()

core/vm/interpreter_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,4 @@ func TestLoopInterrupt(t *testing.T) {
7373
}
7474
}
7575
}
76-
7776
}

0 commit comments

Comments
 (0)