Update lintci and fix lints (#1217)

This commit is contained in:
Manav Darji 2024-04-12 18:52:17 +05:30 committed by GitHub
parent a31a41d47a
commit ffe810e55a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 9 additions and 14 deletions

View file

@ -6,8 +6,6 @@ run:
# default is true. Enables skipping of directories: # default is true. Enables skipping of directories:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$ # vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
skip-dirs-use-default: true skip-dirs-use-default: true
skip-files:
- core/genesis_alloc.go
linters: linters:
disable-all: true disable-all: true
@ -44,6 +42,8 @@ linters-settings:
min-occurrences: 6 # minimum number of occurrences min-occurrences: 6 # minimum number of occurrences
issues: issues:
exclude-files:
- core/genesis_alloc.go
exclude-rules: exclude-rules:
- path: crypto/bn256/cloudflare/optate.go - path: crypto/bn256/cloudflare/optate.go
linters: linters:
@ -64,4 +64,4 @@ issues:
- 'SA1029: should not use built-in type string as key for value' - 'SA1029: should not use built-in type string as key for value'
- 'SA1019: "io/ioutil" has been deprecated since Go 1.19: As of Go 1.16, the same functionality is now provided by package [io] or package [os], and those implementations should be preferred in new code. See the specific function documentation for details' - 'SA1019: "io/ioutil" has been deprecated since Go 1.19: As of Go 1.16, the same functionality is now provided by package [io] or package [os], and those implementations should be preferred in new code. See the specific function documentation for details'
- 'SA1019: grpc.WithInsecure is deprecated: use WithTransportCredentials and insecure.NewCredentials() instead. Will be supported throughout 1.x' - 'SA1019: grpc.WithInsecure is deprecated: use WithTransportCredentials and insecure.NewCredentials() instead. Will be supported throughout 1.x'
- "SA1019: rand.Read has been deprecated since Go 1.20 because it shouldn't be used: For almost all use cases, crypto/rand.Read is more appropriate" - "SA1019: rand.Read has been deprecated since Go 1.20 because it shouldn't be used: For almost all use cases, crypto/rand.Read is more appropriate"

View file

@ -80,7 +80,7 @@ lint:
lintci-deps: lintci-deps:
rm -f ./build/bin/golangci-lint rm -f ./build/bin/golangci-lint
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./build/bin v1.53.3 curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./build/bin v1.57.2
goimports: goimports:
goimports -local "$(PACKAGE)" -w . goimports -local "$(PACKAGE)" -w .

View file

@ -18,6 +18,7 @@ package legacypool
import ( import (
"crypto/ecdsa" "crypto/ecdsa"
crand "crypto/rand"
"errors" "errors"
"fmt" "fmt"
"io" "io"
@ -30,7 +31,7 @@ import (
"time" "time"
"github.com/holiman/uint256" "github.com/holiman/uint256"
"github.com/maticnetwork/crand" crand2 "github.com/maticnetwork/crand"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core"
@ -115,7 +116,7 @@ func pricedTransaction(nonce uint64, gaslimit uint64, gasprice *big.Int, key *ec
func pricedDataTransaction(nonce uint64, gaslimit uint64, gasprice *big.Int, key *ecdsa.PrivateKey, bytes uint64) *types.Transaction { func pricedDataTransaction(nonce uint64, gaslimit uint64, gasprice *big.Int, key *ecdsa.PrivateKey, bytes uint64) *types.Transaction {
data := make([]byte, bytes) data := make([]byte, bytes)
rand.Read(data) crand.Read(data)
tx, _ := types.SignTx(types.NewTransaction(nonce, common.Address{}, big.NewInt(0), gaslimit, gasprice, data), types.HomesteadSigner{}, key) tx, _ := types.SignTx(types.NewTransaction(nonce, common.Address{}, big.NewInt(0), gaslimit, gasprice, data), types.HomesteadSigner{}, key)
@ -3801,7 +3802,7 @@ func BenchmarkBigs(b *testing.B) {
var over bool var over bool
for i := 0; i < len(ints); i++ { for i := 0; i < len(ints); i++ {
ints[i] = crand.BigInt(max) ints[i] = crand2.BigInt(max)
intUs[i], over = uint256.FromBig(ints[i]) intUs[i], over = uint256.FromBig(ints[i])
if over { if over {

View file

@ -26,11 +26,5 @@ import (
// byteArrayBytes returns a slice of the byte array v. // byteArrayBytes returns a slice of the byte array v.
func byteArrayBytes(v reflect.Value, length int) []byte { func byteArrayBytes(v reflect.Value, length int) []byte {
var s []byte return unsafe.Slice((*byte)(unsafe.Pointer(v.UnsafeAddr())), length)
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&s))
hdr.Data = v.UnsafeAddr()
hdr.Cap = length
hdr.Len = length
return s
} }