Skip to content

Commit

Permalink
all: add whitespace linter (ethereum#25312)
Browse files Browse the repository at this point in the history
* golangci: typo

Signed-off-by: Delweng <delweng@gmail.com>

* golangci: add whietspace

Signed-off-by: Delweng <delweng@gmail.com>

* *: rm whitesapce using golangci-lint

Signed-off-by: Delweng <delweng@gmail.com>

* cmd/puppeth: revert accidental resurrection

Co-authored-by: Péter Szilágyi <peterke@gmail.com>
  • Loading branch information
2 people authored and blakehhuynh committed Oct 7, 2022
1 parent bf80eb7 commit 45e0f84
Show file tree
Hide file tree
Showing 90 changed files with 12 additions and 164 deletions.
23 changes: 12 additions & 11 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,16 @@ linters:
- durationcheck
- exportloopref
- gosec
- whitespace

#- structcheck # lots of false positives
#- errcheck #lot of false positives
# - contextcheck
# - errchkjson # lots of false positives
# - errorlint # this check crashes
# - exhaustive # silly check
# - makezero # false positives
# - nilerr # several intentional
# - structcheck # lots of false positives
# - errcheck #lot of false positives
# - contextcheck
# - errchkjson # lots of false positives
# - errorlint # this check crashes
# - exhaustive # silly check
# - makezero # false positives
# - nilerr # several intentional

linters-settings:
gofmt:
Expand All @@ -46,9 +47,9 @@ linters-settings:
min-occurrences: 6 # minimum number of occurrences
gosec:
excludes:
- G404 # Use of weak random number generator - lots of FP
- G107 # Potential http request -- those are intentional
- G306 # G306: Expect WriteFile permissions to be 0600 or less
- G404 # Use of weak random number generator - lots of FP
- G107 # Potential http request -- those are intentional
- G306 # G306: Expect WriteFile permissions to be 0600 or less

issues:
exclude-rules:
Expand Down
1 change: 0 additions & 1 deletion accounts/abi/bind/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ func (mc *mockPendingCaller) PendingCallContract(ctx context.Context, call ether
}

func TestPassingBlockNumber(t *testing.T) {

mc := &mockPendingCaller{
mockCaller: &mockCaller{
codeAtBytes: []byte{1, 2, 3},
Expand Down
1 change: 0 additions & 1 deletion accounts/abi/error_handling.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ func typeCheck(t Type, value reflect.Value) error {
} else {
return nil
}

}

// typeErr returns a formatted type casting error.
Expand Down
1 change: 0 additions & 1 deletion accounts/abi/event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ func TestEventMultiValueWithArrayUnpack(t *testing.T) {
}

func TestEventTupleUnpack(t *testing.T) {

type EventTransfer struct {
Value *big.Int
}
Expand Down
1 change: 0 additions & 1 deletion accounts/abi/reflect.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ func mapArgNamesToStructFields(argNames []string, value reflect.Value) (map[stri

// second round ~~~
for _, argName := range argNames {

structFieldName := ToCamelCase(argName)

if structFieldName == "" {
Expand Down
1 change: 0 additions & 1 deletion accounts/abi/unpack.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ func ReadFixedBytes(t Type, word []byte) (interface{}, error) {

reflect.Copy(array, reflect.ValueOf(word[0:t.Size]))
return array.Interface(), nil

}

// forEachUnpack iteratively unpack elements.
Expand Down
2 changes: 0 additions & 2 deletions accounts/keystore/keystore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,6 @@ func TestImportExport(t *testing.T) {
if _, err = ks2.Import(json, "new", "new"); err == nil {
t.Errorf("importing a key twice succeeded")
}

}

// TestImportRace tests the keystore on races.
Expand All @@ -402,7 +401,6 @@ func TestImportRace(t *testing.T) {
if _, err := ks2.Import(json, "new", "new"); err != nil {
atomic.AddUint32(&atom, 1)
}

}()
}
wg.Wait()
Expand Down
2 changes: 0 additions & 2 deletions accounts/keystore/passphrase.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ func (ks keyStorePassphrase) JoinPath(filename string) string {

// Encryptdata encrypts the data given as 'data' with the password 'auth'.
func EncryptDataV3(data, auth []byte, scryptN, scryptP int) (CryptoJSON, error) {

salt := make([]byte, 32)
if _, err := io.ReadFull(rand.Reader, salt); err != nil {
panic("reading from crypto/rand failed: " + err.Error())
Expand Down Expand Up @@ -341,7 +340,6 @@ func getKDFKey(cryptoJSON CryptoJSON, auth string) ([]byte, error) {
r := ensureInt(cryptoJSON.KDFParams["r"])
p := ensureInt(cryptoJSON.KDFParams["p"])
return scrypt.Key(authArray, salt, n, r, p, dkLen)

} else if cryptoJSON.KDF == "pbkdf2" {
c := ensureInt(cryptoJSON.KDFParams["c"])
prf := cryptoJSON.KDFParams["prf"].(string)
Expand Down
1 change: 0 additions & 1 deletion accounts/usbwallet/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,6 @@ func (w *wallet) signHash(account accounts.Account, hash []byte) ([]byte, error)

// SignData signs keccak256(data). The mimetype parameter describes the type of data being signed
func (w *wallet) SignData(account accounts.Account, mimeType string, data []byte) ([]byte, error) {

// Unless we are doing 712 signing, simply dispatch to signHash
if !(mimeType == accounts.MimetypeTypedData && len(data) == 66 && data[0] == 0x19 && data[1] == 0x01) {
return w.signHash(account, crypto.Keccak256(data))
Expand Down
5 changes: 0 additions & 5 deletions cmd/clef/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,6 @@ func confirm(text string) bool {
}

func testExternalUI(api *core.SignerAPI) {

ctx := context.WithValue(context.Background(), "remote", "clef binary")
ctx = context.WithValue(ctx, "scheme", "in-proc")
ctx = context.WithValue(ctx, "local", "main")
Expand Down Expand Up @@ -859,7 +858,6 @@ func testExternalUI(api *core.SignerAPI) {
expectDeny("signdata - text", err)
}
{ // Sign transaction

api.UI.ShowInfo("Please reject next transaction")
time.Sleep(delay)
data := hexutil.Bytes([]byte{})
Expand Down Expand Up @@ -902,7 +900,6 @@ func testExternalUI(api *core.SignerAPI) {
}
result := fmt.Sprintf("Tests completed. %d errors:\n%s\n", len(errs), strings.Join(errs, "\n"))
api.UI.ShowInfo(result)

}

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

// GenDoc outputs examples of all structures used in json-rpc communication
func GenDoc(ctx *cli.Context) error {

var (
a = common.HexToAddress("0xdeadbeef000000000000000000000000deadbeef")
b = common.HexToAddress("0x1111111122222222222233333333334444444444")
Expand Down Expand Up @@ -1049,7 +1045,6 @@ func GenDoc(ctx *cli.Context) error {
var tx types.Transaction
tx.UnmarshalBinary(rlpdata)
add("OnApproved - SignTransactionResult", desc, &ethapi.SignTransactionResult{Raw: rlpdata, Tx: &tx})

}
{ // User input
add("UserInputRequest", "Sent when clef needs the user to provide data. If 'password' is true, the input field should be treated accordingly (echo-free)",
Expand Down
1 change: 0 additions & 1 deletion cmd/devp2p/dns_cloudflare.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ func (c *cloudflareClient) uploadRecords(name string, records map[string]string)
ttl := rootTTL
if path != name {
ttl = treeNodeTTLCloudflare // Max TTL permitted by Cloudflare

}
record := cloudflare.DNSRecord{Type: "TXT", Name: path, Content: val, TTL: ttl}
_, err = c.CreateDNSRecord(context.Background(), c.zoneID, record)
Expand Down
1 change: 0 additions & 1 deletion cmd/devp2p/internal/ethtest/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ func (c *Chain) GetHeaders(req GetBlockHeaders) (BlockHeaders, error) {
for i := 1; i < int(req.Amount); i++ {
blockNumber -= (1 - req.Skip)
headers[i] = c.blocks[blockNumber].Header()

}

return headers, nil
Expand Down
1 change: 0 additions & 1 deletion cmd/devp2p/internal/ethtest/snap.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,6 @@ func hexToCompact(hex []byte) []byte {

// TestSnapTrieNodes various forms of GetTrieNodes requests.
func (s *Suite) TestSnapTrieNodes(t *utesting.T) {

key := common.FromHex("0x00bf49f440a1cd0527e4d06e2765654c0f56452257516d793a9b8d604dcfdf2a")
// helper function to iterate the key, and generate the compact-encoded
// trie paths along the way.
Expand Down
1 change: 0 additions & 1 deletion cmd/devp2p/internal/ethtest/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,6 @@ func (c *Conn) ReadSnap(id uint64) (Message, error) {
return nil, fmt.Errorf("could not rlp decode message: %v", err)
}
return snpMsg.(Message), nil

}
return nil, fmt.Errorf("request timed out")
}
1 change: 0 additions & 1 deletion cmd/evm/internal/t8ntool/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ type rejectedTx struct {
func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
txs types.Transactions, miningReward int64,
getTracerFn func(txIndex int, txHash common.Hash) (tracer vm.EVMLogger, err error)) (*state.StateDB, *ExecutionResult, error) {

// Capture errors for BLOCKHASH operation, if we haven't been supplied the
// required blockhashes
var hashError error
Expand Down
3 changes: 0 additions & 3 deletions cmd/evm/t8n_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ func TestT8n(t *testing.T) {
expExitCode: 3,
},
} {

args := []string{"t8n"}
args = append(args, tc.output.get()...)
args = append(args, tc.input.get(tc.base)...)
Expand Down Expand Up @@ -355,7 +354,6 @@ func TestT9n(t *testing.T) {
expExitCode: t8ntool.ErrorIO,
},
} {

args := []string{"t9n"}
args = append(args, tc.input.get(tc.base)...)

Expand Down Expand Up @@ -475,7 +473,6 @@ func TestB11r(t *testing.T) {
expOut: "exp.json",
},
} {

args := []string{"b11r"}
args = append(args, tc.input.get(tc.base)...)

Expand Down
1 change: 0 additions & 1 deletion cmd/geth/version_check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ func TestMatching(t *testing.T) {
version, vuln.Introduced, vuln.Fixed, vuln.Name, vulnIntro, current, vulnFixed)
}
}

}
}
for major := 1; major < 2; major++ {
Expand Down
3 changes: 0 additions & 3 deletions common/math/big_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ func BenchmarkByteAt(b *testing.B) {
}

func BenchmarkByteAtOld(b *testing.B) {

bigint := MustParseBig256("0x18F8F8F1000111000110011100222004330052300000000000000000FEFCF3CC")
for i := 0; i < b.N; i++ {
PaddedBigBytes(bigint, 32)
Expand Down Expand Up @@ -244,7 +243,6 @@ func TestBigEndianByteAt(t *testing.T) {
if actual != test.exp {
t.Fatalf("Expected [%v] %v:th byte to be %v, was %v.", test.x, test.y, test.exp, actual)
}

}
}
func TestLittleEndianByteAt(t *testing.T) {
Expand Down Expand Up @@ -277,7 +275,6 @@ func TestLittleEndianByteAt(t *testing.T) {
if actual != test.exp {
t.Fatalf("Expected [%v] %v:th byte to be %v, was %v.", test.x, test.y, test.exp, actual)
}

}
}

Expand Down
3 changes: 0 additions & 3 deletions common/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ func BenchmarkAddressHex(b *testing.B) {
}

func TestMixedcaseAccount_Address(t *testing.T) {

// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-55.md
// Note: 0X{checksum_addr} is not valid according to spec above

Expand Down Expand Up @@ -192,9 +191,7 @@ func TestMixedcaseAccount_Address(t *testing.T) {
if err := json.Unmarshal([]byte(r), &r2); err == nil {
t.Errorf("Expected failure, input %v", r)
}

}

}

func TestHash_Scan(t *testing.T) {
Expand Down
4 changes: 0 additions & 4 deletions core/blockchain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1235,7 +1235,6 @@ func TestSideLogRebirth(t *testing.T) {
chain, _ := GenerateChain(params.TestChainConfig, genesis, ethash.NewFaker(), db, 2, func(i int, gen *BlockGen) {
if i == 1 {
gen.OffsetTime(-9) // higher block difficulty

}
})
if _, err := blockchain.InsertChain(chain); err != nil {
Expand Down Expand Up @@ -1364,7 +1363,6 @@ done:
t.Errorf("unexpected event fired: %v", e)
case <-time.After(250 * time.Millisecond):
}

}

// Tests if the canonical block can be fetched from the database during chain insertion.
Expand Down Expand Up @@ -2753,7 +2751,6 @@ func benchmarkLargeNumberOfValueToNonexisting(b *testing.B, numTxs, numBlocks in
b.StopTimer()
if got := chain.CurrentBlock().Transactions().Len(); got != numTxs*numBlocks {
b.Fatalf("Transactions were not included, expected %d, got %d", numTxs*numBlocks, got)

}
}
}
Expand Down Expand Up @@ -3522,7 +3519,6 @@ func TestEIP2718Transition(t *testing.T) {
vm.GasQuickStep*2 + params.WarmStorageReadCostEIP2929 + params.ColdSloadCostEIP2929
if block.GasUsed() != expected {
t.Fatalf("incorrect amount of gas spent: expected %d, got %d", expected, block.GasUsed())

}
}

Expand Down
2 changes: 0 additions & 2 deletions core/state/snapshot/difflayer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,6 @@ func BenchmarkFlatten(b *testing.B) {
value := make([]byte, 32)
rand.Read(value)
accStorage[randomHash()] = value

}
storage[accountKey] = accStorage
}
Expand Down Expand Up @@ -382,7 +381,6 @@ func BenchmarkJournal(b *testing.B) {
value := make([]byte, 32)
rand.Read(value)
accStorage[randomHash()] = value

}
storage[accountKey] = accStorage
}
Expand Down
1 change: 0 additions & 1 deletion core/state/statedb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,6 @@ func TestDeleteCreateRevert(t *testing.T) {
// the Commit operation fails with an error
// If we are missing trie nodes, we should not continue writing to the trie
func TestMissingTrieNodes(t *testing.T) {

// Create an initial state with a few accounts
memDb := rawdb.NewMemoryDatabase()
db := NewDatabase(memDb)
Expand Down
1 change: 0 additions & 1 deletion core/tx_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,6 @@ func TestTransactionPostponing(t *testing.T) {
// Add a batch consecutive pending transactions for validation
txs := []*types.Transaction{}
for i, key := range keys {

for j := 0; j < 100; j++ {
var tx *types.Transaction
if (i+j)%2 == 0 {
Expand Down
1 change: 0 additions & 1 deletion core/types/bloom9_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ func BenchmarkBloom9Lookup(b *testing.B) {
}

func BenchmarkCreateBloom(b *testing.B) {

var txs = Transactions{
NewContractCreation(1, big.NewInt(1), 1, big.NewInt(1), nil),
NewTransaction(2, common.HexToAddress("0x2"), big.NewInt(2), 2, big.NewInt(2), nil),
Expand Down
1 change: 0 additions & 1 deletion core/types/transaction_signing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ func TestEIP155SigningVitalik(t *testing.T) {
if from != addr {
t.Errorf("%d: expected %x got %x", i, addr, from)
}

}
}

Expand Down
1 change: 0 additions & 1 deletion core/types/transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ func TestEIP2718TransactionSigHash(t *testing.T) {

// This test checks signature operations on access list transactions.
func TestEIP2930Signer(t *testing.T) {

var (
key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
keyAddr = crypto.PubkeyToAddress(key.PublicKey)
Expand Down
3 changes: 0 additions & 3 deletions core/vm/instructions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ var commonParams []*twoOperandParams
var twoOpMethods map[string]executionFunc

func init() {

// Params is a list of common edgecases that should be used for some common tests
params := []string{
"0000000000000000000000000000000000000000000000000000000000000000", // 0
Expand Down Expand Up @@ -92,7 +91,6 @@ func init() {
}

func testTwoOperandOp(t *testing.T, tests []TwoOperandTestcase, opFn executionFunc, name string) {

var (
env = NewEVM(BlockContext{}, TxContext{}, nil, params.TestChainConfig, Config{})
stack = newstack()
Expand Down Expand Up @@ -641,7 +639,6 @@ func TestCreate2Addreses(t *testing.T) {
expected: "0xE33C0C7F7df4809055C3ebA6c09CFe4BaF1BD9e0",
},
} {

origin := common.BytesToAddress(common.FromHex(tt.origin))
salt := common.BytesToHash(common.FromHex(tt.salt))
code := common.FromHex(tt.code)
Expand Down
1 change: 0 additions & 1 deletion core/vm/interpreter.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ func NewEVMInterpreter(evm *EVM, cfg Config) *EVMInterpreter {
// considered a revert-and-consume-all-gas operation except for
// ErrExecutionReverted which means revert-and-keep-gas-left.
func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (ret []byte, err error) {

// Increment the call depth which is restricted to 1024
in.evm.depth++
defer func() { in.evm.depth-- }()
Expand Down
1 change: 0 additions & 1 deletion core/vm/interpreter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,4 @@ func TestLoopInterrupt(t *testing.T) {
}
}
}

}
Loading

0 comments on commit 45e0f84

Please sign in to comment.