Showing 1,051 of 1,052 total issues
Function runDeployCmd
has a Cognitive Complexity of 32 (exceeds 20 allowed). Consider refactoring. Open
func runDeployCmd(cmd *cobra.Command, args []string) error {
var err error
var code []byte
var deployArgs []byte
- 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 verifyEthStorageProof
has a Cognitive Complexity of 32 (exceeds 20 allowed). Consider refactoring. Open
func verifyEthStorageProof(key []byte, value rlpObject, expectedHash []byte, proof [][]byte) bool {
if len(key) == 0 || value == nil || len(proof) == 0 {
return false
}
key = []byte(hex.Encode(keccak256(key)))
- 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
File peermanager.go
has 509 lines of code (exceeds 500 allowed). Consider refactoring. Open
/* @file @copyright defined in aergo/LICENSE.txt */
package p2p
import (
Method syncTxManager.refineFrontCache
has 80 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (tm *syncTxManager) refineFrontCache() {
now := time.Now()
expireTime := now.Add(-txQueryTimeout)
if tm.toNoticeIdQueue.Len() == 0 { // nothing to resend
cleanupCounter++
Method ChainService.addBlockInternal
has 80 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (cs *ChainService) addBlockInternal(newBlock *types.Block, usedBState *state.BlockState, peerID types.PeerID) (err error, cache bool) {
if !cs.VerifyTimestamp(newBlock) {
return &ErrBlock{
err: errBlockTimestamp,
block: &types.BlockInfo{
Method MemPool.validateTx
has 24 return statements (exceeds 4 allowed). Open
func (mp *MemPool) validateTx(tx types.Transaction, account types.Address) error {
if !mp.whitelist.Check(types.EncodeAddress(account)) {
return types.ErrTxNotAllowedAccount
}
ns, err := mp.getAccountState(account)
Method raftServer.startRaft
has 79 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (rs *raftServer) startRaft() {
var node raftlib.Node
getState := func() RaftServerState {
hasWal, err := rs.walDB.HasWal(rs.cluster.identity)
Function luaDeployContract
has 23 return statements (exceeds 4 allowed). Open
func luaDeployContract(
L *LState,
service C.int,
contract *C.char,
args *C.char,
Method BlockGenerator.GatherTXs
has 76 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (g *BlockGenerator) GatherTXs() ([]types.Transaction, error) {
var (
bState = g.bState
nCollected int
Function Create
has 76 lines of code (exceeds 50 allowed). Consider refactoring. Open
func Create(
contractState *statedb.ContractState,
code, contractAddress []byte,
ctx *vmContext,
) (string, []*types.Event, *big.Int, error) {
Method AccountService.Receive
has 75 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (as *AccountService) Receive(context actor.Context) {
switch msg := context.Message().(type) {
case *message.GetAccounts:
accountList := as.getAccounts()
Method P2P.Receive
has 74 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (p2ps *P2P) Receive(context actor.Context) {
rawMsg := context.Message()
switch msg := rawMsg.(type) {
case *message.GetAddressesMsg:
p2ps.GetAddresses(msg.ToWhom, msg.Size)
Function NewRPC
has 74 lines of code (exceeds 50 allowed). Consider refactoring. Open
func NewRPC(cfg *config.Config, chainAccessor types.ChainAccessor, version string) *RPC {
actualServer := &AergoRPCService{
msgHelper: message.GetHelper(),
blockStream: make(map[uint32]*ListBlockStream),
blockMetadataStream: make(map[uint32]*ListBlockMetaStream),
Method RPC.Receive
has 73 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (ns *RPC) Receive(context actor.Context) {
switch msg := context.Message().(type) {
case *types.Block:
server := ns.actualServer
server.BroadcastToListBlockStream(msg)
Method MemPool.setStateDB
has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring. Open
func (mp *MemPool) setStateDB(block *types.Block) (bool, bool) {
if mp.testConfig {
return true, false
}
- 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 syncTxManager.handleTxReq
has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring. Open
func (tm *syncTxManager) handleTxReq(remotePeer p2pcommon.RemotePeer, mID p2pcommon.MsgID, reqHashes [][]byte) {
// NOTE size estimation is tied to protobuf3 it should be changed when protobuf is changed.
// find transactions from chainservice
idx := 0
status := types.ResultStatus_OK
- 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 SQLiteConn.RegisterAggregator
has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring. Open
func (c *SQLiteConn) RegisterAggregator(name string, impl interface{}, pure bool) error {
var ai aggInfo
ai.constructor = reflect.ValueOf(impl)
t := ai.constructor.Type()
if t.Kind() != reflect.Func {
- 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 transaction.Validate
has 72 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (tx *transaction) Validate(chainidhash []byte, isPublic bool) error {
if tx.GetTx() == nil || tx.GetTx().GetBody() == nil {
return ErrTxFormatInvalid
}
Function contractFrame
has 71 lines of code (exceeds 50 allowed). Consider refactoring. Open
func contractFrame(l luaTxContract, bs *state.BlockState, cdb contract.ChainAccessor, receiptTx db.Transaction,
run func(s, c *state.AccountState, id types.AccountID, cs *statedb.ContractState) (string, []*types.Event, *big.Int, error)) error {
creatorId := types.ToAccountID(l.sender())
creatorState, err := state.GetAccountState(l.sender(), bs.StateDB)
Function executeTx
has 20 return statements (exceeds 4 allowed). Open
func executeTx(execCtx context.Context, ccc consensus.ChainConsensusCluster, cdb contract.ChainAccessor, bs *state.BlockState, tx types.Transaction, bi *types.BlockHeaderInfo, executionMode int) error {
var (
txBody = tx.GetBody()
isQuirkTx = types.IsQuirkTx(tx.GetHash())
account []byte