Skip to content

Commit 86f6568

Browse files
ferhatelmaskaralabe
authored andcommitted
build: enable unconvert linter (#15456)
* build: enable unconvert linter - fixes #15453 - update code base for failing cases * cmd/puppeth: replace syscall.Stdin with os.Stdin.Fd() for unconvert linter
1 parent 3ee86a5 commit 86f6568

31 files changed

Lines changed: 56 additions & 53 deletions

File tree

‎accounts/abi/unpack.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type unpacker interface {
3838
func readInteger(kind reflect.Kind, b []byte) interface{} {
3939
switch kind {
4040
case reflect.Uint8:
41-
return uint8(b[len(b)-1])
41+
return b[len(b)-1]
4242
case reflect.Uint16:
4343
return binary.BigEndian.Uint16(b[len(b)-2:])
4444
case reflect.Uint32:

‎build/ci.go‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,15 @@ func doLint(cmdline []string) {
322322
build.MustRun(goTool("get", "gopkg.in/alecthomas/gometalinter.v1"))
323323
build.MustRunCommand(filepath.Join(GOBIN, "gometalinter.v1"), "--install")
324324

325+
// Run fast linters batched together
325326
configs := []string{"--vendor", "--disable-all", "--enable=vet", "--enable=gofmt", "--enable=misspell"}
326-
327327
build.MustRunCommand(filepath.Join(GOBIN, "gometalinter.v1"), append(configs, packages...)...)
328+
329+
// Run slow linters one by one
330+
for _, linter := range []string{"unconvert"} {
331+
configs = []string{"--vendor", "--deadline=10m", "--disable-all", "--enable=" + linter}
332+
build.MustRunCommand(filepath.Join(GOBIN, "gometalinter.v1"), append(configs, packages...)...)
333+
}
328334
}
329335

330336
// Release Packaging

‎cmd/puppeth/module_faucet.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func deployFaucet(client *sshClient, network string, bootnodes []string, config
133133
})
134134
files[filepath.Join(workdir, "docker-compose.yaml")] = composefile.Bytes()
135135

136-
files[filepath.Join(workdir, "genesis.json")] = []byte(config.node.genesis)
136+
files[filepath.Join(workdir, "genesis.json")] = config.node.genesis
137137
files[filepath.Join(workdir, "account.json")] = []byte(config.node.keyJSON)
138138
files[filepath.Join(workdir, "account.pass")] = []byte(config.node.keyPass)
139139

‎cmd/puppeth/module_node.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func deployNode(client *sshClient, network string, bootv4, bootv5 []string, conf
128128
files[filepath.Join(workdir, "docker-compose.yaml")] = composefile.Bytes()
129129

130130
//genesisfile, _ := json.MarshalIndent(config.genesis, "", " ")
131-
files[filepath.Join(workdir, "genesis.json")] = []byte(config.genesis)
131+
files[filepath.Join(workdir, "genesis.json")] = config.genesis
132132

133133
if config.keyJSON != "" {
134134
files[filepath.Join(workdir, "signer.json")] = []byte(config.keyJSON)

‎cmd/puppeth/ssh.go‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import (
2727
"os/user"
2828
"path/filepath"
2929
"strings"
30-
"syscall"
3130

3231
"github.com/ethereum/go-ethereum/log"
3332
"golang.org/x/crypto/ssh"
@@ -85,7 +84,7 @@ func dial(server string, pubkey []byte) (*sshClient, error) {
8584
}
8685
auths = append(auths, ssh.PasswordCallback(func() (string, error) {
8786
fmt.Printf("What's the login password for %s at %s? (won't be echoed)\n> ", login, server)
88-
blob, err := terminal.ReadPassword(int(syscall.Stdin))
87+
blob, err := terminal.ReadPassword(int(os.Stdin.Fd()))
8988

9089
fmt.Println()
9190
return string(blob), err

‎cmd/puppeth/wizard.go‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828
"sort"
2929
"strconv"
3030
"strings"
31-
"syscall"
3231

3332
"github.com/ethereum/go-ethereum/common"
3433
"github.com/ethereum/go-ethereum/core"
@@ -231,7 +230,7 @@ func (w *wizard) readDefaultFloat(def float64) float64 {
231230
// line and returns it. The input will not be echoed.
232231
func (w *wizard) readPassword() string {
233232
fmt.Printf("> ")
234-
text, err := terminal.ReadPassword(int(syscall.Stdin))
233+
text, err := terminal.ReadPassword(int(os.Stdin.Fd()))
235234
if err != nil {
236235
log.Crit("Failed to read password", "err", err)
237236
}

‎common/hexutil/hexutil.go‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ var (
5353

5454
type decError struct{ msg string }
5555

56-
func (err decError) Error() string {
57-
return string(err.msg)
58-
}
56+
func (err decError) Error() string { return err.msg }
5957

6058
// Decode decodes a hex string with 0x prefix.
6159
func Decode(input string) ([]byte, error) {

‎common/hexutil/json.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ func (b *Uint64) UnmarshalText(input []byte) error {
223223
return ErrSyntax
224224
}
225225
dec *= 16
226-
dec += uint64(nib)
226+
dec += nib
227227
}
228228
*b = Uint64(dec)
229229
return nil

‎consensus/ethash/algorithm_go1.8.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func cacheSize(block uint64) uint64 {
3131
return cacheSizes[epoch]
3232
}
3333
// No known cache size, calculate manually (sanity branch only)
34-
size := uint64(cacheInitBytes + cacheGrowthBytes*uint64(epoch) - hashBytes)
34+
size := cacheInitBytes + cacheGrowthBytes*uint64(epoch) - hashBytes
3535
for !new(big.Int).SetUint64(size / hashBytes).ProbablyPrime(1) { // Always accurate for n < 2^64
3636
size -= 2 * hashBytes
3737
}
@@ -49,7 +49,7 @@ func datasetSize(block uint64) uint64 {
4949
return datasetSizes[epoch]
5050
}
5151
// No known dataset size, calculate manually (sanity branch only)
52-
size := uint64(datasetInitBytes + datasetGrowthBytes*uint64(epoch) - mixBytes)
52+
size := datasetInitBytes + datasetGrowthBytes*uint64(epoch) - mixBytes
5353
for !new(big.Int).SetUint64(size / mixBytes).ProbablyPrime(1) { // Always accurate for n < 2^64
5454
size -= 2 * mixBytes
5555
}

‎core/vm/interpreter.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ func (in *Interpreter) Run(snapshot int, contract *Contract, input []byte) (ret
161161

162162
if in.cfg.Debug {
163163
logged = false
164-
pcCopy = uint64(pc)
165-
gasCopy = uint64(contract.Gas)
164+
pcCopy = pc
165+
gasCopy = contract.Gas
166166
stackCopy = newstack()
167167
for _, val := range stack.data {
168168
stackCopy.push(val)

0 commit comments

Comments
 (0)