aergoio/aergo

View on GitHub

Showing 1,051 of 1,052 total issues

Method SignVerifier.isExistInMempool has 5 return statements (exceeds 4 allowed).
Open

func (sv *SignVerifier) isExistInMempool(comm component.IComponentRequester, tx *types.Tx) (bool, error) {
    if !sv.useMempool {
        return false, nil
    }

Severity: Major
Found in chain/signVerifier.go - About 35 mins to fix

    Method ChainService.addBlockInternal has a Cognitive Complexity of 22 (exceeds 20 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: Minor
    Found in chain/chainhandle.go - About 35 mins 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 ChainWorker.Receive has 5 return statements (exceeds 4 allowed).
    Open

    func (cw *ChainWorker) Receive(context actor.Context) {
        var sdb *statedb.StateDB
    
        getAccProof := func(sdb *statedb.StateDB, account, root []byte, compressed bool) (*types.AccountProof, error) {
            address, err := getAddressNameResolved(sdb, account)
    Severity: Major
    Found in chain/chainservice.go - About 35 mins to fix

      Method Web3APIv1.GetAccountVotes has 5 return statements (exceeds 4 allowed).
      Open

      func (api *Web3APIv1) GetAccountVotes() (handler http.Handler, ok bool) {
          values, err := url.ParseQuery(api.request.URL.RawQuery)
          if err != nil {
              return commonResponseHandler(&types.Empty{}, err), true
          }
      Severity: Major
      Found in rpc/web3/v1.go - About 35 mins to fix

        Method ChainDB.ResetWAL has 5 return statements (exceeds 4 allowed).
        Open

        func (cdb *ChainDB) ResetWAL(hardStateInfo *types.HardStateInfo) error {
            if hardStateInfo == nil {
                return ErrNilHardState
            }
        
        
        Severity: Major
        Found in chain/chaindbForRaft.go - About 35 mins to fix

          Method vpr.equals has 5 return statements (exceeds 4 allowed).
          Open

          func (v *vpr) equals(rhs *vpr) bool {
              if !reflect.DeepEqual(v.getTotalPower(), rhs.getTotalPower()) {
                  return false
              }
          
          
          Severity: Major
          Found in contract/system/vprt.go - About 35 mins to fix

            Method PeerMapService.onConnect has 5 return statements (exceeds 4 allowed).
            Open

            func (pms *PeerMapService) onConnect(s types.Stream) {
                defer s.Close()
                peerID := s.Conn().RemotePeer()
                remoteIP, port, err := types.GetIPPortFromMultiaddr(s.Conn().RemoteMultiaddr())
                if err != nil {
            Severity: Major
            Found in cmd/polaris/server/mapservice.go - About 35 mins to fix

              Method ChainService.getAccountVote has 5 return statements (exceeds 4 allowed).
              Open

              func (cs *ChainService) getAccountVote(addr []byte) (*types.AccountVoteInfo, error) {
                  if cs.GetType() != consensus.ConsensusDPOS {
                      return nil, ErrNotSupportedConsensus
                  }
              
              
              Severity: Major
              Found in chain/chainservice.go - About 35 mins to fix

                Method Web3APIv1.CommitTX has 5 return statements (exceeds 4 allowed).
                Open

                func (api *Web3APIv1) CommitTX() (handler http.Handler, ok bool) {
                    body, err := io.ReadAll(api.request.Body)
                    if err != nil {
                        return commonResponseHandler(&types.Empty{}, err), true
                    }
                Severity: Major
                Found in rpc/web3/v1.go - About 35 mins to fix

                  Method PRPCServer.AddBLEntry has 5 return statements (exceeds 4 allowed).
                  Open

                  func (rs *PRPCServer) AddBLEntry(ctx context.Context, entInfo *types.AddEntryParams) (*types.SingleString, error) {
                      ret := &types.SingleString{}
                  
                      if len(entInfo.PeerID) == 0 && len(entInfo.Cidr) == 0 && len(entInfo.Address) == 0 {
                          ret.Value = "at least one flags is required"
                  Severity: Major
                  Found in cmd/polaris/server/prpc.go - About 35 mins to fix

                    Method Core.init has 5 return statements (exceeds 4 allowed).
                    Open

                    func (core *Core) init(dbType string, dataDir string, testModeOn bool, forceResetHeight types.BlockNo) error {
                        // init chaindb
                        if err := core.cdb.Init(dbType, dataDir); err != nil {
                            logger.Fatal().Err(err).Msg("failed to initialize chaindb")
                            return err
                    Severity: Major
                    Found in chain/chainservice.go - About 35 mins to fix

                      Function newVoteCmd has 5 return statements (exceeds 4 allowed).
                      Open

                      func newVoteCmd(ctx *SystemContext) (sysCmd, error) {
                          var (
                              scs = ctx.scs
                      
                              err error
                      Severity: Major
                      Found in contract/system/vote.go - About 35 mins to fix

                        Method litetree.restoreRecoveryPoint has 5 return statements (exceeds 4 allowed).
                        Open

                        func (db *litetree) restoreRecoveryPoint(stateRp uint64) error {
                            lastRp := db.recoveryPoint()
                            if sqlLgr.IsDebugEnabled() {
                                sqlLgr.Debug().Str("db_name", db.name).
                                    Uint64("state_rp", stateRp).
                        Severity: Major
                        Found in contract/statesql.go - About 35 mins to fix

                          Function resolveFunction has 5 return statements (exceeds 4 allowed).
                          Open

                          func resolveFunction(contractState *statedb.ContractState, bs *state.BlockState, name string, constructor bool) (*types.Function, error) {
                              abi, err := GetABI(contractState, bs)
                              if err != nil {
                                  return nil, err
                              }
                          Severity: Major
                          Found in contract/vm.go - About 35 mins to fix

                            Function getAddressNameResolved has 5 return statements (exceeds 4 allowed).
                            Open

                            func getAddressNameResolved(account string, bs *state.BlockState) ([]byte, error) {
                                accountLen := len(account)
                                if accountLen == types.EncodedAddressLength {
                                    return types.DecodeAddress(account)
                                } else if accountLen == types.NameLength {
                            Severity: Major
                            Found in contract/vm_callback.go - About 35 mins to fix

                              Method FilterInfo.ValidateCheck has 5 return statements (exceeds 4 allowed).
                              Open

                              func (fi *FilterInfo) ValidateCheck(to uint64) error {
                                  if fi.ContractAddress == nil {
                                      return errors.New("invalid contractAddress:" + string(fi.ContractAddress))
                                  }
                                  if len(fi.ContractAddress) < AddressLength {
                              Severity: Major
                              Found in types/receipt.go - About 35 mins to fix

                                Method executor.commitCalledContract has 5 return statements (exceeds 4 allowed).
                                Open

                                func (ce *executor) commitCalledContract() error {
                                    ctx := ce.ctx
                                
                                    if ctx == nil || ctx.callState == nil {
                                        return nil
                                Severity: Major
                                Found in contract/vm.go - About 35 mins to fix

                                  Function luaDelDB has 5 return statements (exceeds 4 allowed).
                                  Open

                                  func luaDelDB(L *LState, service C.int, key unsafe.Pointer, keyLen C.int) *C.char {
                                      ctx := contexts[service]
                                      if ctx == nil {
                                          return C.CString("[System.LuaDelDB] contract state not found")
                                      }
                                  Severity: Major
                                  Found in contract/vm_callback.go - About 35 mins to fix

                                    Method Syncer.handleFinderResult has 5 return statements (exceeds 4 allowed).
                                    Open

                                    func (syncer *Syncer) handleFinderResult(msg *message.FinderResult) error {
                                        logger.Debug().Msg("syncer received finder result message")
                                    
                                        if err := chain.TestDebugger.Check(chain.DEBUG_SYNCER_CRASH, 0, nil); err != nil {
                                            chain.TestDebugger.Unset(chain.DEBUG_SYNCER_CRASH)
                                    Severity: Major
                                    Found in syncer/syncerservice.go - About 35 mins to fix

                                      Function contractFrame has a Cognitive Complexity of 22 (exceeds 20 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 35 mins 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

                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language