From 589b6f1740b69ecb024381e68ee2988b736e3b7d Mon Sep 17 00:00:00 2001 From: Guillaume Ballet Date: Fri, 22 Nov 2019 17:41:44 +0100 Subject: [PATCH] cmd: fix staticcheck warnings --- cmd/faucet/faucet.go | 26 ++++++++++++++------------ cmd/geth/retesteth.go | 10 +--------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/cmd/faucet/faucet.go b/cmd/faucet/faucet.go index 3700ff9c59..03d787d7a6 100644 --- a/cmd/faucet/faucet.go +++ b/cmd/faucet/faucet.go @@ -351,8 +351,8 @@ func (f *faucet) apiHandler(w http.ResponseWriter, r *http.Request) { if head == nil || balance == nil { // Report the faucet offline until initial stats are ready - if err = sendError(conn, errors.New("Faucet offline")); err != nil { - log.Warn("Failed to send faucet error to client", "err", err) + if err = sendError(conn, errors.New("faucet offline")); err != nil { + log.Warn("failed to send faucet error to client", "err", err) return } time.Sleep(3 * time.Second) @@ -392,7 +392,7 @@ func (f *faucet) apiHandler(w http.ResponseWriter, r *http.Request) { continue } if msg.Tier >= uint(*tiersFlag) { - if err = sendError(conn, errors.New("Invalid funding tier requested")); err != nil { + if err = sendError(conn, errors.New("invalid funding tier requested")); err != nil { log.Warn("Failed to send tier error to client", "err", err) return } @@ -429,7 +429,8 @@ func (f *faucet) apiHandler(w http.ResponseWriter, r *http.Request) { } if !result.Success { log.Warn("Captcha verification failed", "err", string(result.Errors)) - if err = sendError(conn, errors.New("Beep-bop, you're a robot!")); err != nil { + //lint:ignore ST1005 it's funny and the robot won't mind + if err = sendError(conn, errors.New("beep-bop, you're a robot!")); err != nil { log.Warn("Failed to send captcha failure to client", "err", err) return } @@ -450,6 +451,7 @@ func (f *faucet) apiHandler(w http.ResponseWriter, r *http.Request) { } continue case strings.HasPrefix(msg.URL, "https://plus.google.com/"): + //lint:ignore ST1005 this is a company name if err = sendError(conn, errors.New("Google+ authentication discontinued as the service was sunset")); err != nil { log.Warn("Failed to send Google+ deprecation to client", "err", err) return @@ -462,7 +464,7 @@ func (f *faucet) apiHandler(w http.ResponseWriter, r *http.Request) { case *noauthFlag: username, avatar, address, err = authNoAuth(msg.URL) default: - err = errors.New("Something funky happened, please open an issue at https://github.com/ethereum/go-ethereum/issues") + err = errors.New("something funky happened, please open an issue at https://github.com/ethereum/go-ethereum/issues") } if err != nil { if err = sendError(conn, err); err != nil { @@ -520,7 +522,7 @@ func (f *faucet) apiHandler(w http.ResponseWriter, r *http.Request) { // Send an error if too frequent funding, othewise a success if !fund { - if err = sendError(conn, fmt.Errorf("%s left until next allowance", common.PrettyDuration(timeout.Sub(time.Now())))); err != nil { // nolint: gosimple + if err = sendError(conn, fmt.Errorf("%s left until next allowance", common.PrettyDuration(time.Until(timeout)))); err != nil { // nolint: gosimple log.Warn("Failed to send funding error to client", "err", err) return } @@ -682,7 +684,7 @@ func authTwitter(url string) (string, string, common.Address, error) { // Ensure the user specified a meaningful URL, no fancy nonsense parts := strings.Split(url, "/") if len(parts) < 4 || parts[len(parts)-2] != "status" { - return "", "", common.Address{}, errors.New("Invalid Twitter status URL") + return "", "", common.Address{}, errors.New("invalid Twitter status URL") } // Twitter's API isn't really friendly with direct links. Still, we don't // want to do ask read permissions from users, so just load the public posts and @@ -696,7 +698,7 @@ func authTwitter(url string) (string, string, common.Address, error) { // Resolve the username from the final redirect, no intermediate junk parts = strings.Split(res.Request.URL.String(), "/") if len(parts) < 4 || parts[len(parts)-2] != "status" { - return "", "", common.Address{}, errors.New("Invalid Twitter status URL") + return "", "", common.Address{}, errors.New("invalid Twitter status URL") } username := parts[len(parts)-3] @@ -706,7 +708,7 @@ func authTwitter(url string) (string, string, common.Address, error) { } address := common.HexToAddress(string(regexp.MustCompile("0x[0-9a-fA-F]{40}").Find(body))) if address == (common.Address{}) { - return "", "", common.Address{}, errors.New("No Ethereum address found to fund") + return "", "", common.Address{}, errors.New("no Ethereum address found to fund") } var avatar string if parts = regexp.MustCompile("src=\"([^\"]+twimg.com/profile_images[^\"]+)\"").FindStringSubmatch(string(body)); len(parts) == 2 { @@ -721,7 +723,7 @@ func authFacebook(url string) (string, string, common.Address, error) { // Ensure the user specified a meaningful URL, no fancy nonsense parts := strings.Split(url, "/") if len(parts) < 4 || parts[len(parts)-2] != "posts" { - return "", "", common.Address{}, errors.New("Invalid Facebook post URL") + return "", "", common.Address{}, errors.New("invalid Facebook post URL") } username := parts[len(parts)-3] @@ -740,7 +742,7 @@ func authFacebook(url string) (string, string, common.Address, error) { } address := common.HexToAddress(string(regexp.MustCompile("0x[0-9a-fA-F]{40}").Find(body))) if address == (common.Address{}) { - return "", "", common.Address{}, errors.New("No Ethereum address found to fund") + return "", "", common.Address{}, errors.New("no Ethereum address found to fund") } var avatar string if parts = regexp.MustCompile("src=\"([^\"]+fbcdn.net[^\"]+)\"").FindStringSubmatch(string(body)); len(parts) == 2 { @@ -755,7 +757,7 @@ func authFacebook(url string) (string, string, common.Address, error) { func authNoAuth(url string) (string, string, common.Address, error) { address := common.HexToAddress(regexp.MustCompile("0x[0-9a-fA-F]{40}").FindString(url)) if address == (common.Address{}) { - return "", "", common.Address{}, errors.New("No Ethereum address found to fund") + return "", "", common.Address{}, errors.New("no Ethereum address found to fund") } return address.Hex() + "@noauth", "", address, nil } diff --git a/cmd/geth/retesteth.go b/cmd/geth/retesteth.go index b6aa3706b2..2c3f8be78d 100644 --- a/cmd/geth/retesteth.go +++ b/cmd/geth/retesteth.go @@ -495,7 +495,6 @@ func (api *RetestethAPI) mineBlock() error { txCount := 0 var txs []*types.Transaction var receipts []*types.Receipt - var coalescedLogs []*types.Log var blockFull = gasPool.Gas() < params.TxGas for address := range api.txSenders { if blockFull { @@ -522,7 +521,6 @@ func (api *RetestethAPI) mineBlock() error { } txs = append(txs, tx) receipts = append(receipts, receipt) - coalescedLogs = append(coalescedLogs, receipt.Logs...) delete(m, nonce) if len(m) == 0 { // Last tx for the sender @@ -682,9 +680,6 @@ func (api *RetestethAPI) AccountRange(ctx context.Context, for i := 0; i < int(maxResults) && it.Next(); i++ { if preimage := accountTrie.GetKey(it.Key); preimage != nil { result.AddressMap[common.BytesToHash(it.Key)] = common.BytesToAddress(preimage) - //fmt.Printf("%x: %x\n", it.Key, preimage) - } else { - //fmt.Printf("could not find preimage for %x\n", it.Key) } } //fmt.Printf("Number of entries returned: %d\n", len(result.AddressMap)) @@ -808,9 +803,6 @@ func (api *RetestethAPI) StorageRangeAt(ctx context.Context, Key: string(ks), Value: string(vs), } - //fmt.Printf("Key: %s, Value: %s\n", ks, vs) - } else { - //fmt.Printf("Did not find preimage for %x\n", it.Key) } } if it.Next() { @@ -889,7 +881,7 @@ func retesteth(ctx *cli.Context) error { log.Info("HTTP endpoint closed", "url", httpEndpoint) }() - abortChan := make(chan os.Signal) + abortChan := make(chan os.Signal, 11) signal.Notify(abortChan, os.Interrupt) sig := <-abortChan