Showing 291 of 829 total issues
Function importFile
has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring. Open
func importFile(srv *gossip.Service, check bool, fn string) error {
// Watch for Ctrl-C while the import is running.
// If a signal is received, the import will stop.
interrupt := make(chan os.Signal, 1)
signal.Notify(interrupt, syscall.SIGINT, syscall.SIGTERM)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method Election.String
has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring. Open
func (el *Election) String(voters []hash.Event) string {
if voters == nil {
votersM := make(map[hash.Event]bool)
for vid := range el.votes {
votersM[vid.fromRoot] = true
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method ProtocolManager.makeFetcher
has 11 return statements (exceeds 4 allowed). Open
func (pm *ProtocolManager) makeFetcher(checkers *eventcheck.Checkers) (*fetcher.Fetcher, *ordering.EventBuffer) {
// checkers
firstCheck := func(e *inter.Event) error {
if err := checkers.Basiccheck.Validate(e); err != nil {
return err
Function DoEstimateGas
has 11 return statements (exceeds 4 allowed). Open
func DoEstimateGas(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.BlockNumberOrHash, gasCap uint64) (hexutil.Uint64, error) {
// Binary search the gas requirement, as it may be higher than the amount used
var (
lo uint64 = params.TxGas - 1
hi uint64
Method TxPool.validateTx
has 11 return statements (exceeds 4 allowed). Open
func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
// Reject transactions over defined size to prevent DOS attacks
if uint64(tx.Size()) > txMaxSize {
return ErrOversizedData
}
Function DoCall
has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring. Open
func DoCall(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.BlockNumberOrHash, overrides map[common.Address]account, vmCfg vm.Config, timeout time.Duration, globalGasCap uint64) (*evmcore.ExecutionResult, error) {
defer func(start time.Time) { log.Debug("Executing EVM call finished", "runtime", time.Since(start)) }(time.Now())
state, header, err := b.StateAndHeaderByNumberOrHash(ctx, blockNrOrHash)
if state == nil || err != nil {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method SendTxArgs.setDefaults
has 52 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (args *SendTxArgs) setDefaults(ctx context.Context, b Backend) error {
if args.GasPrice == nil {
price, err := b.SuggestPrice(ctx)
if err != nil {
return err
Method Emitter.isAllowedToEmit
has 52 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (em *Emitter) isAllowedToEmit(e *inter.Event, selfParent *inter.EventHeaderData) bool {
passedTime := e.ClaimedTime.Time().Sub(em.prevEmittedTime)
// Slow down emitting if power is low
{
threshold := em.config.NoTxsThreshold
Method PublicTransactionPoolAPI.GetTransactionReceipt
has 51 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (s *PublicTransactionPoolAPI) GetTransactionReceipt(ctx context.Context, hash common.Hash) (map[string]interface{}, error) {
tx, blockNumber, index, err := s.b.GetTransaction(ctx, hash)
if tx == nil || err != nil {
return nil, err
}
Function DoCall
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
func DoCall(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.BlockNumberOrHash, overrides map[common.Address]account, vmCfg vm.Config, timeout time.Duration, globalGasCap uint64) (*evmcore.ExecutionResult, error) {
Function precacheTransaction
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
func precacheTransaction(config *params.ChainConfig, bc DummyChain, author *common.Address, gaspool *GasPool, statedb *state.StateDB, header *EvmHeader, tx *types.Transaction, cfg vm.Config) error {
Function Dir
has 9 return statements (exceeds 4 allowed). Open
func Dir(src string, dst string) (err error) {
src = filepath.Clean(src)
dst = filepath.Clean(dst)
si, err := os.Stat(src)
Method FilterCriteria.UnmarshalJSON
has 9 return statements (exceeds 4 allowed). Open
func (args *FilterCriteria) UnmarshalJSON(data []byte) error {
type input struct {
BlockHash *common.Hash `json:"blockHash"`
FromBlock *rpc.BlockNumber `json:"fromBlock"`
ToBlock *rpc.BlockNumber `json:"toBlock"`
Method ProtocolManager.txsyncLoop
has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring. Open
func (pm *ProtocolManager) txsyncLoop() {
var (
pending = make(map[enode.ID]*txsync)
sending = false // whether a send is active
pack = new(txsync) // the pack that is being sent
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function ForEachRandFork
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
nodes []idx.StakerID,
cheatersArr []idx.StakerID,
eventCount int,
parentCount int,
forksCount int,
Method Emitter.isMyTxTurn
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
func (em *Emitter) isMyTxTurn(txHash common.Hash, sender common.Address, accountNonce uint64, now time.Time, validatorsArr []idx.StakerID, validatorsArrStakes []pos.Stake, me idx.StakerID) bool {
Method PublicSfcAPI.addStakerMetricFields
has 8 return statements (exceeds 4 allowed). Open
func (s *PublicSfcAPI) addStakerMetricFields(ctx context.Context, res map[string]interface{}, stakerID idx.StakerID) (map[string]interface{}, error) {
blocks, period, err := s.b.GetDowntime(ctx, idx.StakerID(stakerID))
if err != nil {
return nil, err
}
Method peer.readStatus
has 8 return statements (exceeds 4 allowed). Open
func (p *peer) readStatus(network uint64, status *ethStatusData, genesis common.Hash) (err error) {
msg, err := p.rw.ReadMsg()
if err != nil {
return err
}
Method PublicTransactionPoolAPI.Resend
has 8 return statements (exceeds 4 allowed). Open
func (s *PublicTransactionPoolAPI) Resend(ctx context.Context, sendArgs SendTxArgs, gasPrice *hexutil.Big, gasLimit *hexutil.Uint64) (common.Hash, error) {
if sendArgs.Nonce == nil {
return common.Hash{}, fmt.Errorf("missing transaction nonce in transaction spec")
}
if err := sendArgs.setDefaults(ctx, s.b); err != nil {
Method PublicTransactionPoolAPI.SignTransaction
has 8 return statements (exceeds 4 allowed). Open
func (s *PublicTransactionPoolAPI) SignTransaction(ctx context.Context, args SendTxArgs) (*SignTransactionResult, error) {
if args.Gas == nil {
return nil, fmt.Errorf("gas not specified")
}
if args.GasPrice == nil {