aergoio/aergo

View on GitHub

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

Severity: Minor
Found in cmd/aergocli/cmd/contract.go - About 2 hrs to fix

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)))
Severity: Minor
Found in contract/ethstorageproof.go - About 2 hrs to fix

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 (
Severity: Minor
Found in p2p/peermanager.go - About 2 hrs to fix

    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++
    Severity: Major
    Found in p2p/synctx.go - About 2 hrs to fix

      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{
      Severity: Major
      Found in chain/chainhandle.go - About 2 hrs to fix

        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)
        Severity: Major
        Found in mempool/mempool.go - About 2 hrs to fix

          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)
          Severity: Major
          Found in consensus/impl/raftv2/raftserver.go - About 2 hrs to fix

            Function luaDeployContract has 23 return statements (exceeds 4 allowed).
            Open

            func luaDeployContract(
                L *LState,
                service C.int,
                contract *C.char,
                args *C.char,
            Severity: Major
            Found in contract/vm_callback.go - About 2 hrs to fix

              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
              Severity: Major
              Found in consensus/chain/tx.go - About 2 hrs to fix

                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) {
                Severity: Major
                Found in contract/vm.go - About 2 hrs to fix

                  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()
                  Severity: Minor
                  Found in account/accountservice.go - About 2 hrs to fix

                    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)
                    Severity: Minor
                    Found in p2p/p2p.go - About 1 hr to fix

                      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),
                      Severity: Minor
                      Found in rpc/rpc.go - About 1 hr to fix

                        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)
                        Severity: Minor
                        Found in rpc/rpc.go - About 1 hr to fix

                          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
                          Severity: Minor
                          Found in p2p/synctx.go - About 1 hr to fix

                          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 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
                              }
                          
                          
                          Severity: Minor
                          Found in mempool/mempool.go - About 1 hr to fix

                          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 {
                          Severity: Minor
                          Found in contract/sqlite3.go - About 1 hr to fix

                          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
                              }
                          
                          
                          Severity: Minor
                          Found in types/transaction.go - About 1 hr to fix

                            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)
                            Severity: Minor
                            Found in contract/vm_dummy/vm_dummy.go - About 1 hr to fix

                              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
                              Severity: Major
                              Found in chain/chainhandle.go - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language