aergoio/aergo

View on GitHub

Showing 1,051 of 1,052 total issues

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

func (api *Web3APIv1) GetBlock() (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 Trie.verifyInclusionC has 5 return statements (exceeds 4 allowed).
    Open

    func (s *Trie) verifyInclusionC(bitmap, key, leafHash []byte, ap [][]byte, length, keyIndex, apIndex int) []byte {
        if keyIndex == length {
            return leafHash
        }
        if bitIsSet(key, keyIndex) {
    Severity: Major
    Found in pkg/trie/trie_merkle_proof.go - About 35 mins to fix

      Method Trie.loadCache has 5 return statements (exceeds 4 allowed).
      Open

      func (s *Trie) loadCache(root []byte, batch [][]byte, iBatch, height int, ch chan<- (error)) {
          if height < s.CacheHeightLimit || len(root) == 0 {
              ch <- nil
              return
          }
      Severity: Major
      Found in pkg/trie/trie_tools.go - About 35 mins to fix

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

        func CalculateMerkleTree(entries []MerkleEntry) [][]byte {
            var merkles [][]byte
            entriesLen := len(entries)
        
            if entriesLen == 0 {
        Severity: Major
        Found in internal/merkle/merkle.go - About 35 mins to fix

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

          func (cdb *ChainDB) dropBlock(dropNo types.BlockNo) error {
              logger.Info().Uint64("no", dropNo).Msg("drop block")
          
              dbTx := cdb.NewTx()
              defer dbTx.Discard()
          Severity: Major
          Found in chain/chaindb.go - About 35 mins to fix

            Method topVoters.dump has 5 return statements (exceeds 4 allowed).
            Open

            func (tv *topVoters) dump(w io.Writer, topN int) error {
                if tv == nil {
                    fmt.Fprintf(w, "nothing to dump!")
                    return nil
                }
            Severity: Major
            Found in contract/system/vprt.go - About 35 mins to fix

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

              func getCore(dataDir string) *chain.Core {
                  // if initpath is feeded, gaurantee initpath is accessible directory
                  fi, err := os.Stat(dataDir)
                  if err == nil && !fi.IsDir() {
                      fmt.Printf("%s is not a directory\n", dataDir)
              Severity: Major
              Found in cmd/aergosvr/init.go - About 35 mins to fix

                Method ChainVerifier.VerifyChain has 5 return statements (exceeds 4 allowed).
                Open

                func (cv *ChainVerifier) VerifyChain() error {
                    var (
                        err   error
                        block *types.Block
                    )
                Severity: Major
                Found in chain/chainverifier.go - About 35 mins to fix

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

                  func (cs *ChainService) executeBlock(bstate *state.BlockState, block *types.Block) error {
                      // Caution: block must belong to the main chain.
                      logger.Debug().Str("hash", block.ID()).Uint64("no", block.GetHeader().BlockNo).Msg("start to execute")
                  
                      var (
                  Severity: Major
                  Found in chain/chainhandle.go - About 35 mins to fix

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

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

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

                      func (api *Web3APIv1) GetBlockTransactionCount() (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 deployContract.parse has 5 return statements (exceeds 4 allowed).
                        Open

                        func (c *deployContract) parse(args string) (string, *big.Int, string, string, string, error) {
                            splitArgs := context.SplitSpaceAndAccent(args, false)
                            if len(splitArgs) < 4 {
                                return "", nil, "", "", "", fmt.Errorf("need 4 arguments. usage: %s", c.Usage())
                            }
                        Severity: Major
                        Found in cmd/brick/exec/deployContract.go - About 35 mins to fix

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

                          func runQueryCmd(cmd *cobra.Command, args []string) error {
                              cmd.SilenceUsage = true
                          
                              contract, err := types.DecodeAddress(args[0])
                              if err != nil {
                          Severity: Major
                          Found in cmd/aergocli/cmd/contract.go - About 35 mins to fix

                            Function execVote has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
                            Open

                            func execVote(cmd *cobra.Command, args []string) {
                                account, err := types.DecodeAddress(address)
                                if err != nil {
                                    cmd.Printf("Failed: %s\n", err.Error())
                                    return
                            Severity: Minor
                            Found in cmd/aergocli/cmd/vote.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 Web3APIv1.GetState has 5 return statements (exceeds 4 allowed).
                            Open

                            func (api *Web3APIv1) GetState() (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 ChainService.listEvents has 5 return statements (exceeds 4 allowed).
                              Open

                              func (cs *ChainService) listEvents(filter *types.FilterInfo) ([]*types.Event, error) {
                                  from := filter.Blockfrom
                                  to := filter.Blockto
                              
                                  if filter.RecentBlockCnt > 0 {
                              Severity: Major
                              Found in chain/chainhandle.go - About 35 mins to fix

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

                                func (api *Web3APIv1) GetBlockMetadata() (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

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

                                  func execSendTX(cmd *cobra.Command, args []string) error {
                                      account, err := types.DecodeAddress(from)
                                      if err != nil {
                                          return errors.New("Wrong address in --from flag\n" + err.Error())
                                      }
                                  Severity: Major
                                  Found in cmd/aergocli/cmd/sendtx.go - About 35 mins to fix

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

                                    func validateForUnstaking(account []byte, txBody *types.TxBody, scs *statedb.ContractState, blockNo uint64) (*types.Staking, error) {
                                        staked, err := checkStakingBefore(account, scs)
                                        if err != nil {
                                            return nil, types.ErrMustStakeBeforeUnstake
                                        }
                                    Severity: Major
                                    Found in contract/system/validation.go - About 35 mins to fix

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

                                      func newVprCmd(ctx *SystemContext, vr *VoteResult) *vprCmd {
                                          cmd := &vprCmd{SystemContext: ctx, voteResult: vr}
                                      
                                          if vprLogger.IsDebugEnabled() {
                                              vprLogger.Debug().
                                      Severity: Major
                                      Found in contract/system/vote.go - About 35 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language