Showing 291 of 829 total issues
Method row.Position
has 8 return statements (exceeds 4 allowed). Open
Open
func (r *row) Position(i int) position {
// if left
if i < r.Self {
if i < r.First {
return none
Function lachesisOperaMigrationMain
has 8 return statements (exceeds 4 allowed). Open
Open
func lachesisOperaMigrationMain(ctx *cli.Context) error {
if args := ctx.Args(); len(args) > 0 {
return fmt.Errorf("invalid command: %q", args[0])
}
Method Checker.Validate
has 8 return statements (exceeds 4 allowed). Open
Open
func (v *Checker) Validate(e *inter.Event, parents []*inter.EventHeaderData) error {
if len(e.Parents) != len(parents) {
panic("parentscheck: expected event's parents as an argument")
}
Function importFile
has 8 return statements (exceeds 4 allowed). Open
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)
Method Emitter.isSynced
has 8 return statements (exceeds 4 allowed). Open
Open
func (em *Emitter) isSynced() (bool, string, time.Duration) {
if em.intervals.SelfForkProtection == 0 {
return true, "", 0 // protection disabled
}
if em.world.PeersNum() == 0 {
Method ContractClaimedValidatorRewardIterator.Next
has 7 return statements (exceeds 4 allowed). Open
Open
func (it *ContractClaimedValidatorRewardIterator) Next() bool {
// If the iterator failed, stop iterating
if it.fail != nil {
return false
}
Function File
has 7 return statements (exceeds 4 allowed). Open
Open
func File(src, dst string) (err error) {
in, err := os.Open(src)
if err != nil {
return
}
Avoid deeply nested control flow statements. Open
Open
if createdTime <= stats.End {
createdEpoch = e
break
}
Method Index.fetchSync
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
Open
func (tt *Index) fetchSync(topics [][]common.Hash) (res []*types.Log, err error) {
if len(topics) > MaxCount {
err = ErrTooManyTopics
return
}
- 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 PrivateAccountAPI.SignTransaction
has 7 return statements (exceeds 4 allowed). Open
Open
func (s *PrivateAccountAPI) SignTransaction(ctx context.Context, args SendTxArgs, passwd string) (*SignTransactionResult, error) {
// No need to obtain the noncelock mutex, since we won't be sending this
// tx into the transaction pool, but right back to the user
if args.Gas == nil {
return nil, fmt.Errorf("gas not specified")
Function New
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func New(path string, cache int, handles int, namespace string, close func() error, drop func()) (*Database, error) {
Method Index.fetchAsync
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
Open
func (tt *Index) fetchAsync(topics [][]common.Hash) (res []*types.Log, err error) {
if len(topics) > MaxCount {
err = ErrTooManyTopics
return
}
- 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
Avoid deeply nested control flow statements. Open
Open
if pool.locals.contains(offenders[i]) {
localGauge.Dec(int64(len(caps)))
}
Avoid deeply nested control flow statements. Open
Open
if err != nil {
return genStore, errors.Wrap(err, "failed to get storage trie node")
}
Function DoCall
has 7 return statements (exceeds 4 allowed). Open
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 {
Method Poset.checkAndSaveEvent
has 7 return statements (exceeds 4 allowed). Open
Open
func (p *Poset) checkAndSaveEvent(e *inter.Event) error {
if e.Seq <= 1 && e.PrevEpochHash != p.PrevEpoch.Hash() {
return ErrWrongEpochHash
}
if e.Seq > 1 && e.PrevEpochHash != hash.Zero {
Avoid deeply nested control flow statements. Open
Open
if dataIt.Leaf() || dataIt.Hash() == emptyNodeHash {
continue
}
Method ContractBurntRewardStashIterator.Next
has 7 return statements (exceeds 4 allowed). Open
Open
func (it *ContractBurntRewardStashIterator) Next() bool {
// If the iterator failed, stop iterating
if it.fail != nil {
return false
}
Method ContractClaimedDelegationRewardIterator.Next
has 7 return statements (exceeds 4 allowed). Open
Open
func (it *ContractClaimedDelegationRewardIterator) Next() bool {
// If the iterator failed, stop iterating
if it.fail != nil {
return false
}
Method ContractCreatedDelegationIterator.Next
has 7 return statements (exceeds 4 allowed). Open
Open
func (it *ContractCreatedDelegationIterator) Next() bool {
// If the iterator failed, stop iterating
if it.fail != nil {
return false
}