mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 03:30:37 +00:00
Enable gocritic linter (#5173)
* Enable gocritic linter * Remove dead linters * Make gosec shut up
This commit is contained in:
parent
a6d92130a6
commit
3b1d4d9c1b
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@ -60,7 +60,7 @@ jobs:
|
||||
if: runner.os == 'Linux'
|
||||
uses: golangci/golangci-lint-action@v3
|
||||
with:
|
||||
version: v1.48
|
||||
version: v1.49
|
||||
|
||||
- name: Test
|
||||
run: make test
|
||||
@ -148,4 +148,4 @@ jobs:
|
||||
if: always()
|
||||
with:
|
||||
name: test-results
|
||||
path: results/*.xml
|
||||
path: results/*.xml
|
||||
|
@ -5,7 +5,6 @@ linters:
|
||||
disable-all: true
|
||||
enable:
|
||||
- gofmt
|
||||
- deadcode
|
||||
- errcheck
|
||||
- gosimple
|
||||
- govet
|
||||
@ -13,8 +12,7 @@ linters:
|
||||
- staticcheck
|
||||
# - structcheck # 1.18
|
||||
# - unused # 1.18
|
||||
- varcheck
|
||||
# - gocritic
|
||||
- gocritic
|
||||
# - bodyclose # 1.18
|
||||
- gosec
|
||||
# - forcetypeassert
|
||||
|
@ -102,7 +102,7 @@ func setFlagsFromConfigFile(ctx *cli.Context, filePath string) error {
|
||||
for i, v := range sliceInterface {
|
||||
s[i] = v.(string)
|
||||
}
|
||||
err := ctx.GlobalSet(key, strings.Join(s[:], ","))
|
||||
err := ctx.GlobalSet(key, strings.Join(s, ","))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -277,11 +277,7 @@ func Main(ctx *cli.Context) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
if tx != nil {
|
||||
tx.Rollback()
|
||||
}
|
||||
}()
|
||||
defer tx.Rollback()
|
||||
|
||||
reader, writer := MakePreState(chainConfig.Rules(0), tx, prestate.Pre)
|
||||
engine := ethash.NewFaker()
|
||||
|
@ -519,6 +519,7 @@ func Recon(genesis *core.Genesis, logger log.Logger) error {
|
||||
)
|
||||
}
|
||||
accountCollectorX := etl.NewCollector("account scan total X", datadir, etl.NewSortableBuffer(etl.BufferOptimalSize))
|
||||
defer accountCollectorX.Close()
|
||||
for i := 0; i < workerCount; i++ {
|
||||
if err = accountCollectorsX[i].Load(nil, "", func(k, v []byte, table etl.CurrentTableReader, next etl.LoadNextFunc) error {
|
||||
return accountCollectorX.Collect(k, v)
|
||||
@ -564,6 +565,7 @@ func Recon(genesis *core.Genesis, logger log.Logger) error {
|
||||
)
|
||||
}
|
||||
storageCollectorX := etl.NewCollector("storage scan total X", datadir, etl.NewSortableBuffer(etl.BufferOptimalSize))
|
||||
defer storageCollectorX.Close()
|
||||
for i := 0; i < workerCount; i++ {
|
||||
if err = storageCollectorsX[i].Load(nil, "", func(k, v []byte, table etl.CurrentTableReader, next etl.LoadNextFunc) error {
|
||||
return storageCollectorX.Collect(k, v)
|
||||
@ -609,6 +611,7 @@ func Recon(genesis *core.Genesis, logger log.Logger) error {
|
||||
)
|
||||
}
|
||||
codeCollectorX := etl.NewCollector("code scan total X", datadir, etl.NewSortableBuffer(etl.BufferOptimalSize))
|
||||
defer codeCollectorX.Close()
|
||||
var bitmap roaring64.Bitmap
|
||||
for i := 0; i < workerCount; i++ {
|
||||
bitmap.Or(&fillWorkers[i].bitmap)
|
||||
@ -709,11 +712,8 @@ func Recon(genesis *core.Genesis, logger log.Logger) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
if rwTx != nil {
|
||||
rwTx.Rollback()
|
||||
}
|
||||
}()
|
||||
defer rwTx.Rollback()
|
||||
|
||||
if err = rs.Flush(rwTx); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -778,11 +778,8 @@ func Recon(genesis *core.Genesis, logger log.Logger) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
if rwTx != nil {
|
||||
rwTx.Rollback()
|
||||
}
|
||||
}()
|
||||
defer rwTx.Rollback()
|
||||
|
||||
if err = rs.Flush(rwTx); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -953,11 +950,8 @@ func Recon(genesis *core.Genesis, logger log.Logger) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
if rwTx != nil {
|
||||
rwTx.Rollback()
|
||||
}
|
||||
}()
|
||||
defer rwTx.Rollback()
|
||||
|
||||
if err = rwTx.ClearBucket(kv.PlainState); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ func (hr *HistoryReaderNoState) ReadAccountStorage(address common.Address, incar
|
||||
}
|
||||
copy(hr.composite, address.Bytes())
|
||||
copy(hr.composite[20:], key.Bytes())
|
||||
txKey, err := hr.tx.GetOne(kv.XStorage, hr.composite[:])
|
||||
txKey, err := hr.tx.GetOne(kv.XStorage, hr.composite)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ func StartPProf(address string, withMetrics bool) {
|
||||
heapMsg := fmt.Sprintf("go tool pprof -lines -http=: http://%s/%s", address, "debug/pprof/heap")
|
||||
log.Info("Starting pprof server", "cpu", cpuMsg, "heap", heapMsg)
|
||||
go func() {
|
||||
if err := http.ListenAndServe(address, nil); err != nil {
|
||||
if err := http.ListenAndServe(address, nil); err != nil { // nolint:gosec
|
||||
log.Error("Failure in running pprof server", "err", err)
|
||||
}
|
||||
}()
|
||||
|
@ -23,7 +23,7 @@ func Setup(address string) {
|
||||
//}))
|
||||
log.Info("Starting metrics server", "addr", fmt.Sprintf("http://%s/debug/metrics/prometheus", address))
|
||||
go func() {
|
||||
if err := http.ListenAndServe(address, nil); err != nil {
|
||||
if err := http.ListenAndServe(address, nil); err != nil { // nolint:gosec
|
||||
log.Error("Failure in running metrics server", "err", err)
|
||||
}
|
||||
}()
|
||||
|
@ -544,7 +544,7 @@ func (h *handshakeState) runInitiator(conn io.ReadWriter, prv *ecdsa.PrivateKey,
|
||||
func (h *handshakeState) makeAuthMsg(prv *ecdsa.PrivateKey) (*authMsgV4, error) {
|
||||
// Generate random initiator nonce.
|
||||
h.initNonce = make([]byte, shaLen)
|
||||
_, err := rand.Read(h.initNonce)
|
||||
_, err := rand.Read(h.initNonce) // nolint: gosec
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -582,7 +582,7 @@ func (h *handshakeState) handleAuthResp(msg *authRespV4) (err error) {
|
||||
func (h *handshakeState) makeAuthResp() (msg *authRespV4, err error) {
|
||||
// Generate random nonce.
|
||||
h.respNonce = make([]byte, shaLen)
|
||||
if _, err = rand.Read(h.respNonce); err != nil {
|
||||
if _, err = rand.Read(h.respNonce); err != nil { // nolint: gosec
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user