Skip to content

Commit 4d03752

Browse files
thomasmodeneiskimmyeonghun
authored andcommitted
build: enable goimports and varcheck linters (ethereum#16446)
1 parent 3c4d344 commit 4d03752

File tree

28 files changed

+54
-98
lines changed

28 files changed

+54
-98
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ ios:
3737
test: all
3838
build/env.sh go run build/ci.go test
3939

40+
lint: ## Run linters.
41+
build/env.sh go run build/ci.go lint
42+
4043
clean:
4144
rm -fr build/_workspace/pkg/ $(GOBIN)/*
4245

accounts/usbwallet/ledger.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,9 @@ const (
5353
ledgerOpGetConfiguration ledgerOpcode = 0x06 // Returns specific wallet application configuration
5454

5555
ledgerP1DirectlyFetchAddress ledgerParam1 = 0x00 // Return address directly from the wallet
56-
ledgerP1ConfirmFetchAddress ledgerParam1 = 0x01 // Require a user confirmation before returning the address
5756
ledgerP1InitTransactionData ledgerParam1 = 0x00 // First transaction data block for signing
5857
ledgerP1ContTransactionData ledgerParam1 = 0x80 // Subsequent transaction data block for signing
5958
ledgerP2DiscardAddressChainCode ledgerParam2 = 0x00 // Do not return the chain code along with the address
60-
ledgerP2ReturnAddressChainCode ledgerParam2 = 0x01 // Require a user confirmation before returning the address
6159
)
6260

6361
// errLedgerReplyInvalidHeader is the error message returned by a Ledger data exchange

build/ci.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,10 @@ func doLint(cmdline []string) {
340340
// Run fast linters batched together
341341
configs := []string{
342342
"--vendor",
343+
"--tests",
343344
"--disable-all",
345+
"--enable=goimports",
346+
"--enable=varcheck",
344347
"--enable=vet",
345348
"--enable=gofmt",
346349
"--enable=misspell",
@@ -351,7 +354,7 @@ func doLint(cmdline []string) {
351354

352355
// Run slow linters one by one
353356
for _, linter := range []string{"unconvert", "gosimple"} {
354-
configs = []string{"--vendor", "--deadline=10m", "--disable-all", "--enable=" + linter}
357+
configs = []string{"--vendor", "--tests", "--deadline=10m", "--disable-all", "--enable=" + linter}
355358
build.MustRunCommand(filepath.Join(GOBIN, "gometalinter.v2"), append(configs, packages...)...)
356359
}
357360
}

build/goimports.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
3+
find_files() {
4+
find . -not \( \
5+
\( \
6+
-wholename '.github' \
7+
-o -wholename './build/_workspace' \
8+
-o -wholename './build/bin' \
9+
-o -wholename './crypto/bn256' \
10+
-o -wholename '*/vendor/*' \
11+
\) -prune \
12+
\) -name '*.go'
13+
}
14+
15+
GOFMT="gofmt -s -w";
16+
GOIMPORTS="goimports -w";
17+
find_files | xargs $GOFMT;
18+
find_files | xargs $GOIMPORTS;

cmd/ethkey/main.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@ var (
5353
Name: "json",
5454
Usage: "output JSON instead of human-readable format",
5555
}
56-
messageFlag = cli.StringFlag{
57-
Name: "message",
58-
Usage: "the file that contains the message to sign/verify",
59-
}
6056
)
6157

6258
func main() {

consensus/consensus.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@
1818
package consensus
1919

2020
import (
21+
"math/big"
22+
2123
"github.com/ethersocial/go-esn/common"
2224
"github.com/ethersocial/go-esn/core/state"
2325
"github.com/ethersocial/go-esn/core/types"
2426
"github.com/ethersocial/go-esn/params"
2527
"github.com/ethersocial/go-esn/rpc"
26-
"math/big"
2728
)
2829

2930
// ChainReader defines a small collection of methods needed to access the local

core/asm/compiler.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package asm
1818

1919
import (
20-
"errors"
2120
"fmt"
2221
"math/big"
2322
"os"
@@ -264,11 +263,6 @@ func (err compileError) Error() string {
264263
return fmt.Sprintf("%d syntax error: unexpected %v, expected %v", err.lineno, err.got, err.want)
265264
}
266265

267-
var (
268-
errExpBol = errors.New("expected beginning of line")
269-
errExpElementOrLabel = errors.New("expected beginning of line")
270-
)
271-
272266
func compileErr(c token, got, want string) error {
273267
return compileError{
274268
got: got,

core/tx_pool.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ import (
3838
const (
3939
// chainHeadChanSize is the size of channel listening to ChainHeadEvent.
4040
chainHeadChanSize = 10
41-
// rmTxChanSize is the size of channel listening to RemovedTransactionEvent.
42-
rmTxChanSize = 10
4341
)
4442

4543
var (

core/types/transaction.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import (
3333

3434
var (
3535
ErrInvalidSig = errors.New("invalid transaction v, r, s values")
36-
errNoSigner = errors.New("missing signing methods")
3736
)
3837

3938
// deriveSigner makes a *best* guess about which signer to use.

core/vm/instructions.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import (
3131
var (
3232
bigZero = new(big.Int)
3333
tt255 = math.BigPow(2, 255)
34-
tt256 = math.BigPow(2, 256)
3534
errWriteProtection = errors.New("evm: write protection")
3635
errReturnDataOutOfBounds = errors.New("evm: return data out of bounds")
3736
errExecutionReverted = errors.New("evm: execution reverted")

0 commit comments

Comments
 (0)