Skip to content

Commit 1ff3d7c

Browse files
gballetfjl
authored andcommitted
cmd/faucet, cmd/geth: fix staticcheck warnings (#20374)
1 parent 08611cf commit 1ff3d7c

2 files changed

Lines changed: 13 additions & 10 deletions

File tree

‎cmd/faucet/faucet.go‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ func (f *faucet) apiHandler(w http.ResponseWriter, r *http.Request) {
351351

352352
if head == nil || balance == nil {
353353
// Report the faucet offline until initial stats are ready
354+
//lint:ignore ST1005 This error is to be displayed in the browser
354355
if err = sendError(conn, errors.New("Faucet offline")); err != nil {
355356
log.Warn("Failed to send faucet error to client", "err", err)
356357
return
@@ -392,6 +393,7 @@ func (f *faucet) apiHandler(w http.ResponseWriter, r *http.Request) {
392393
continue
393394
}
394395
if msg.Tier >= uint(*tiersFlag) {
396+
//lint:ignore ST1005 This error is to be displayed in the browser
395397
if err = sendError(conn, errors.New("Invalid funding tier requested")); err != nil {
396398
log.Warn("Failed to send tier error to client", "err", err)
397399
return
@@ -429,6 +431,7 @@ func (f *faucet) apiHandler(w http.ResponseWriter, r *http.Request) {
429431
}
430432
if !result.Success {
431433
log.Warn("Captcha verification failed", "err", string(result.Errors))
434+
//lint:ignore ST1005 it's funny and the robot won't mind
432435
if err = sendError(conn, errors.New("Beep-bop, you're a robot!")); err != nil {
433436
log.Warn("Failed to send captcha failure to client", "err", err)
434437
return
@@ -450,6 +453,7 @@ func (f *faucet) apiHandler(w http.ResponseWriter, r *http.Request) {
450453
}
451454
continue
452455
case strings.HasPrefix(msg.URL, "https://plus.google.com/"):
456+
//lint:ignore ST1005 Google is a company name and should be capitalized.
453457
if err = sendError(conn, errors.New("Google+ authentication discontinued as the service was sunset")); err != nil {
454458
log.Warn("Failed to send Google+ deprecation to client", "err", err)
455459
return
@@ -462,6 +466,7 @@ func (f *faucet) apiHandler(w http.ResponseWriter, r *http.Request) {
462466
case *noauthFlag:
463467
username, avatar, address, err = authNoAuth(msg.URL)
464468
default:
469+
//lint:ignore ST1005 This error is to be displayed in the browser
465470
err = errors.New("Something funky happened, please open an issue at https://github.com/ethereum/go-ethereum/issues")
466471
}
467472
if err != nil {
@@ -520,7 +525,7 @@ func (f *faucet) apiHandler(w http.ResponseWriter, r *http.Request) {
520525

521526
// Send an error if too frequent funding, othewise a success
522527
if !fund {
523-
if err = sendError(conn, fmt.Errorf("%s left until next allowance", common.PrettyDuration(timeout.Sub(time.Now())))); err != nil { // nolint: gosimple
528+
if err = sendError(conn, fmt.Errorf("%s left until next allowance", common.PrettyDuration(time.Until(timeout)))); err != nil { // nolint: gosimple
524529
log.Warn("Failed to send funding error to client", "err", err)
525530
return
526531
}
@@ -682,6 +687,7 @@ func authTwitter(url string) (string, string, common.Address, error) {
682687
// Ensure the user specified a meaningful URL, no fancy nonsense
683688
parts := strings.Split(url, "/")
684689
if len(parts) < 4 || parts[len(parts)-2] != "status" {
690+
//lint:ignore ST1005 This error is to be displayed in the browser
685691
return "", "", common.Address{}, errors.New("Invalid Twitter status URL")
686692
}
687693
// Twitter's API isn't really friendly with direct links. Still, we don't
@@ -696,6 +702,7 @@ func authTwitter(url string) (string, string, common.Address, error) {
696702
// Resolve the username from the final redirect, no intermediate junk
697703
parts = strings.Split(res.Request.URL.String(), "/")
698704
if len(parts) < 4 || parts[len(parts)-2] != "status" {
705+
//lint:ignore ST1005 This error is to be displayed in the browser
699706
return "", "", common.Address{}, errors.New("Invalid Twitter status URL")
700707
}
701708
username := parts[len(parts)-3]
@@ -706,6 +713,7 @@ func authTwitter(url string) (string, string, common.Address, error) {
706713
}
707714
address := common.HexToAddress(string(regexp.MustCompile("0x[0-9a-fA-F]{40}").Find(body)))
708715
if address == (common.Address{}) {
716+
//lint:ignore ST1005 This error is to be displayed in the browser
709717
return "", "", common.Address{}, errors.New("No Ethereum address found to fund")
710718
}
711719
var avatar string
@@ -721,6 +729,7 @@ func authFacebook(url string) (string, string, common.Address, error) {
721729
// Ensure the user specified a meaningful URL, no fancy nonsense
722730
parts := strings.Split(url, "/")
723731
if len(parts) < 4 || parts[len(parts)-2] != "posts" {
732+
//lint:ignore ST1005 This error is to be displayed in the browser
724733
return "", "", common.Address{}, errors.New("Invalid Facebook post URL")
725734
}
726735
username := parts[len(parts)-3]
@@ -740,6 +749,7 @@ func authFacebook(url string) (string, string, common.Address, error) {
740749
}
741750
address := common.HexToAddress(string(regexp.MustCompile("0x[0-9a-fA-F]{40}").Find(body)))
742751
if address == (common.Address{}) {
752+
//lint:ignore ST1005 This error is to be displayed in the browser
743753
return "", "", common.Address{}, errors.New("No Ethereum address found to fund")
744754
}
745755
var avatar string
@@ -755,6 +765,7 @@ func authFacebook(url string) (string, string, common.Address, error) {
755765
func authNoAuth(url string) (string, string, common.Address, error) {
756766
address := common.HexToAddress(regexp.MustCompile("0x[0-9a-fA-F]{40}").FindString(url))
757767
if address == (common.Address{}) {
768+
//lint:ignore ST1005 This error is to be displayed in the browser
758769
return "", "", common.Address{}, errors.New("No Ethereum address found to fund")
759770
}
760771
return address.Hex() + "@noauth", "", address, nil

‎cmd/geth/retesteth.go‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,6 @@ func (api *RetestethAPI) mineBlock() error {
495495
txCount := 0
496496
var txs []*types.Transaction
497497
var receipts []*types.Receipt
498-
var coalescedLogs []*types.Log
499498
var blockFull = gasPool.Gas() < params.TxGas
500499
for address := range api.txSenders {
501500
if blockFull {
@@ -522,7 +521,6 @@ func (api *RetestethAPI) mineBlock() error {
522521
}
523522
txs = append(txs, tx)
524523
receipts = append(receipts, receipt)
525-
coalescedLogs = append(coalescedLogs, receipt.Logs...)
526524
delete(m, nonce)
527525
if len(m) == 0 {
528526
// Last tx for the sender
@@ -682,9 +680,6 @@ func (api *RetestethAPI) AccountRange(ctx context.Context,
682680
for i := 0; i < int(maxResults) && it.Next(); i++ {
683681
if preimage := accountTrie.GetKey(it.Key); preimage != nil {
684682
result.AddressMap[common.BytesToHash(it.Key)] = common.BytesToAddress(preimage)
685-
//fmt.Printf("%x: %x\n", it.Key, preimage)
686-
} else {
687-
//fmt.Printf("could not find preimage for %x\n", it.Key)
688683
}
689684
}
690685
//fmt.Printf("Number of entries returned: %d\n", len(result.AddressMap))
@@ -808,9 +803,6 @@ func (api *RetestethAPI) StorageRangeAt(ctx context.Context,
808803
Key: string(ks),
809804
Value: string(vs),
810805
}
811-
//fmt.Printf("Key: %s, Value: %s\n", ks, vs)
812-
} else {
813-
//fmt.Printf("Did not find preimage for %x\n", it.Key)
814806
}
815807
}
816808
if it.Next() {
@@ -889,7 +881,7 @@ func retesteth(ctx *cli.Context) error {
889881
log.Info("HTTP endpoint closed", "url", httpEndpoint)
890882
}()
891883

892-
abortChan := make(chan os.Signal)
884+
abortChan := make(chan os.Signal, 11)
893885
signal.Notify(abortChan, os.Interrupt)
894886

895887
sig := <-abortChan

0 commit comments

Comments
 (0)