Showing 291 of 829 total issues
Method Oracle.SuggestPrice
has 64 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (gpo *Oracle) SuggestPrice(ctx context.Context) (*big.Int, error) {
head, _ := gpo.backend.HeaderByNumber(ctx, rpc.LatestBlockNumber)
headHash := head.Hash
// If the latest gasprice is still available, return it.
Method rows.Optimize
has 62 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (rr *rows) Optimize() {
for curr, row := range rr.rows {
REFS:
for iRef, ref := range row.Refs {
Method iterator.Next
has 61 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (it *iterator) Next() bool {
it.lock.Lock()
defer it.lock.Unlock()
if it.Error() != nil {
Method ProtocolManager.makeFetcher
has 61 lines of code (exceeds 50 allowed). Consider refactoring. 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
Method TxPool.truncatePending
has 61 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (pool *TxPool) truncatePending() {
pending := uint64(0)
for _, list := range pool.pending {
pending += uint64(list.Len())
}
Function importFile
has 60 lines of code (exceeds 50 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)
Function startNode
has 60 lines of code (exceeds 50 allowed). Consider refactoring. Open
func startNode(ctx *cli.Context, stack *node.Node) {
debug.Memsize.Add("node", stack)
// Start up the node itself
utils.StartNode(stack)
Method TxPool.add
has 59 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (pool *TxPool) add(tx *types.Transaction, local bool) (replaced bool, err error) {
// If the transaction is already known, discard it
hash := tx.Hash()
if pool.all.Get(hash) != nil {
log.Trace("Discarding already known transaction", "hash", hash)
Method Service.processEvent
has 59 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (s *Service) processEvent(realEngine Consensus, e *inter.Event) error {
// s.engineMu is locked here
if s.stopped {
return errStopped
}
Method Emitter.createEvent
has 14 return statements (exceeds 4 allowed). Open
func (em *Emitter) createEvent(poolTxs map[common.Address]types.Transactions) *inter.Event {
if em.myStakerID == 0 {
// not a validator
return nil
}
Function writeTo
has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring. Open
func writeTo(parent string, t *ast.Table, w io.Writer) (err error) {
var fullName string
if parent != "" {
fullName = parent + "." + t.Name
} else {
- 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 ApplyTransaction
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
config *params.ChainConfig,
bc DummyChain,
author *common.Address,
gp *GasPool,
statedb *state.StateDB,
Method PublicTransactionPoolAPI.Resend
has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring. 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 {
- 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 filterLogs
has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring. Open
func filterLogs(logs []*types.Log, fromBlock, toBlock *big.Int, addresses []common.Address, topics [][]common.Hash) []*types.Log {
var ret []*types.Log
Logs:
for _, log := range logs {
if fromBlock != nil && fromBlock.Int64() >= 0 && fromBlock.Uint64() > log.BlockNumber {
- 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 DoCall
has 55 lines of code (exceeds 50 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 {
Method TxPool.loop
has 55 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (pool *TxPool) loop() {
defer pool.wg.Done()
var (
prevPending, prevQueued, prevStales int
Method ProtocolManager.txsyncLoop
has 54 lines of code (exceeds 50 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
Function NewProtocolManager
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
config *Config,
notifier dagNotifier,
txpool txPool,
engineMu *sync.RWMutex,
checkers *eventcheck.Checkers,
Method Index.fetchSync
has 53 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (tt *Index) fetchSync(topics [][]common.Hash) (res []*types.Log, err error) {
if len(topics) > MaxCount {
err = ErrTooManyTopics
return
}
Method Index.fetchAsync
has 53 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (tt *Index) fetchAsync(topics [][]common.Hash) (res []*types.Log, err error) {
if len(topics) > MaxCount {
err = ErrTooManyTopics
return
}