Rule guard linter enable (#3168)

This commit is contained in:
Alex Sharov 2021-12-26 10:54:26 +07:00 committed by GitHub
parent d45325c324
commit f3973afee8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 23 additions and 28 deletions

View File

@ -23,16 +23,17 @@ linters-settings:
gocritic:
# Which checks should be enabled; can't be combined with 'disabled-checks';
# See https://go-critic.github.io/overview#checks-overview
# To check which checks are enabled run `GL_DEBUG=gocritic golangci-lint run`
# To check which checks are enabled run `GL_DEBUG=gocritic ./build/bin/golangci-lint run`
# By default list of stable checks is used.
enabled-checks:
- ruleguard
- truncateCmp
# - defaultCaseOrder
# - defaultCaseOrder
# Which checks should be disabled; can't be combined with 'enabled-checks'; default is empty
disabled-checks:
- regexpMust
- appendAssign
# - hugeParam
- rangeValCopy
- exitAfterDefer
@ -44,17 +45,22 @@ linters-settings:
- captLocal
- commentFormatting
- ifElseChain
- appendAssign
- importShadow
- paramTypeCombine
- builtinShadow
- typeUnparen
# Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.
# Empty list by default. See https://github.com/go-critic/go-critic#usage -> section "Tags".
enabled-tags:
- performance
- diagnostic
- opinionated
disabled-tags:
- experimental
ruleguard:
rules: "rules.go"
settings:
ruleguard:
rules: "rules.go"
hugeParam:
# size in bytes that makes the warning trigger (default 80)
sizeThreshold: 1000

View File

@ -143,6 +143,7 @@ clean:
go clean -cache
rm -fr build/*
cd libmdbx/ && make clean
./build/bin/golangci-lint cache clean
# The devtools target installs tools required for 'go generate'.
# You need to put $GOBIN (or $GOPATH/bin) in your PATH to use 'go generate'.

View File

@ -401,7 +401,7 @@ func (api *APIImpl) CreateAccessList(ctx context.Context, args ethapi.CallArgs,
if res.Err != nil {
errString = res.Err.Error()
}
return &accessListResult{Accesslist: &accessList, Error: errString, GasUsed: (hexutil.Uint64)(res.UsedGas)}, nil
return &accessListResult{Accesslist: &accessList, Error: errString, GasUsed: hexutil.Uint64(res.UsedGas)}, nil
}
prevTracer = tracer
}

View File

@ -56,19 +56,3 @@ func HashData(data []byte) (Hash, error) {
}
return buf, nil
}
func HashTo(data []byte, to []byte) {
h := NewHasher()
defer ReturnHasherToPool(h)
h.Sha.Reset()
_, err := h.Sha.Write(data)
if err != nil {
panic(err)
}
_, err = h.Sha.Read(to)
if err != nil {
panic(err)
}
}

View File

@ -41,7 +41,7 @@ func FileExist(filePath string) bool {
}
// AbsolutePath returns datadir + filename, or filename if it is absolute.
func AbsolutePath(datadir string, filename string) string {
func AbsolutePath(datadir, filename string) string {
if filepath.IsAbs(filename) {
return filename
}

View File

@ -259,7 +259,9 @@ func UnwindCallTraces(u *UnwindState, s *StageState, tx kv.RwTx, cfg CallTracesC
func DoUnwindCallTraces(logPrefix string, db kv.RwTx, from, to uint64, ctx context.Context, tmpdir string) error {
froms := etl.NewCollector(logPrefix, tmpdir, etl.NewOldestEntryBuffer(etl.BufferOptimalSize))
defer froms.Close()
tos := etl.NewCollector(logPrefix, tmpdir, etl.NewOldestEntryBuffer(etl.BufferOptimalSize))
defer tos.Close()
logEvery := time.NewTicker(30 * time.Second)
defer logEvery.Stop()
@ -359,7 +361,9 @@ func pruneCallTraces(tx kv.RwTx, logPrefix string, pruneTo uint64, ctx context.C
defer logEvery.Stop()
froms := etl.NewCollector(logPrefix, tmpdir, etl.NewOldestEntryBuffer(etl.BufferOptimalSize))
defer froms.Close()
tos := etl.NewCollector(logPrefix, tmpdir, etl.NewOldestEntryBuffer(etl.BufferOptimalSize))
defer tos.Close()
{
traceCursor, err := tx.CursorDupSort(kv.CallTraceSet)

View File

@ -160,11 +160,9 @@ func readPlainStateOnce(
bufferSize := etl.BufferOptimalSize
accCollector := etl.NewCollector(logPrefix, tmpdir, etl.NewSortableBuffer(bufferSize))
defer accCollector.Close()
storageCollector := etl.NewCollector(logPrefix, tmpdir, etl.NewSortableBuffer(bufferSize))
defer func() {
accCollector.Close()
storageCollector.Close()
}()
defer storageCollector.Close()
t := time.Now()
logEvery := time.NewTicker(30 * time.Second)

View File

@ -222,10 +222,10 @@ func HeadersPOS(
prevProgress := headerNumber
headerCollector := etl.NewCollector(logPrefix, cfg.tmpdir, etl.NewSortableBuffer(etl.BufferOptimalSize))
defer headerCollector.Close()
cfg.hd.SetHeadersCollector(headerCollector)
// Cleanup after we finish backward sync
defer func() {
headerCollector.Close()
cfg.hd.SetHeadersCollector(nil)
cfg.hd.Unsync()
cfg.hd.SetFetching(false)

View File

@ -1,8 +1,10 @@
//go:build gorules
// +build gorules
package gorules
// https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module
// to apply changes in this file, please do: ./build/bin/golangci-lint cache clean
import (
"github.com/quasilyte/go-ruleguard/dsl"
//quasilyterules "github.com/quasilyte/ruleguard-rules-test"