aergoio/aergo

View on GitHub

Showing 1,051 of 1,052 total issues

Method BlockFactory.ClusterInfo has 5 return statements (exceeds 4 allowed).
Open

func (bf *BlockFactory) ClusterInfo(bestBlockHash []byte) *types.GetClusterInfoResponse {
    var (
        hardStateInfo *types.HardStateInfo
        mbrAttrs      []*types.MemberAttr
        bestBlock     *types.Block
Severity: Major
Found in consensus/impl/raftv2/blockfactory.go - About 35 mins to fix

    Method AergoRPCService.UnlockAccount has 5 return statements (exceeds 4 allowed).
    Open

    func (rpc *AergoRPCService) UnlockAccount(ctx context.Context, in *types.Personal) (*types.Account, error) {
        if err := rpc.checkAuth(ctx, WriteBlockChain); err != nil {
            return nil, err
        }
        result, err := rpc.hub.RequestFutureResult(message.AccountsSvc,
    Severity: Major
    Found in rpc/grpcserver.go - About 35 mins to fix

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

      func (api *Web3APIv1) GetReceipt() (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.WriteRaftEntry has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
        Open

        func (cdb *ChainDB) WriteRaftEntry(ents []*consensus.WalEntry, blocks []*types.Block, ccProposes []*raftpb.ConfChange) error {
            var data []byte
            var err error
            var lastIdx uint64
        
        
        Severity: Minor
        Found in chain/chaindbForRaft.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.GetBalance has 5 return statements (exceeds 4 allowed).
        Open

        func (api *Web3APIv1) GetBalance() (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 pingChecker.DoCall has 5 return statements (exceeds 4 allowed).
          Open

          func (pc *pingChecker) DoCall(done chan<- interface{}) {
              var pingResp *types.Ping = nil
              defer func() {
                  if pingResp != nil {
                      atomic.StoreInt32(&pc.contFail, 0)
          Severity: Major
          Found in cmd/polaris/server/peerstate.go - About 35 mins to fix

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

            func (cdb *ChainDB) checkBlockDropped(dropBlock *types.Block) error {
                no := dropBlock.GetHeader().GetBlockNo()
                hash := dropBlock.GetHash()
                txLen := len(dropBlock.GetBody().GetTxs())
            
            
            Severity: Major
            Found in chain/chaindb.go - About 35 mins to fix

              Method ChainService.listEvents has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
              Open

              func (cs *ChainService) listEvents(filter *types.FilterInfo) ([]*types.Event, error) {
                  from := filter.Blockfrom
                  to := filter.Blockto
              
                  if filter.RecentBlockCnt > 0 {
              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

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

              func importWif(cmd *cobra.Command) ([]byte, error) {
                  var err error
                  var address []byte
                  importBuf, err := types.DecodePrivKey(importFormat)
                  if err != nil {
              Severity: Major
              Found in cmd/aergocli/cmd/accounts.go - About 35 mins to fix

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

                func exportKeystore(cmd *cobra.Command, param *types.Personal) ([]byte, error) {
                    if rootConfig.KeyStorePath == "" {
                        msg, err := client.ExportAccountKeystore(context.Background(), param)
                        if err != nil {
                            return nil, fmt.Errorf("node request returned error: %s", err.Error())
                Severity: Major
                Found in cmd/aergocli/cmd/accounts.go - About 35 mins to fix

                  Method reorganizer.gatherReco has 5 return statements (exceeds 4 allowed).
                  Open

                  func (reorg *reorganizer) gatherReco() error {
                      var err error
                  
                      cdb := reorg.cs.cdb
                  
                  
                  Severity: Major
                  Found in chain/reorg.go - About 35 mins to fix

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

                    func (cs *ChainService) executeBlockReco(_ *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 for reco")
                    
                        var (
                    Severity: Major
                    Found in chain/chainhandle.go - About 35 mins to fix

                      Method unstakeCmd.run has 5 return statements (exceeds 4 allowed).
                      Open

                      func (c *unstakeCmd) run() (*types.Event, error) {
                          var (
                              scs               = c.scs
                              staked            = c.Staked
                              sender            = c.Sender
                      Severity: Major
                      Found in contract/system/staking.go - About 35 mins to fix

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

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

                          func GasLimit(version int32, isFeeDelegation bool, txGasLimit uint64, payloadSize int, gasPrice, usedFee, senderBalance, receiverBalance *big.Int) (gasLimit uint64, err error) {
                              // 1. no gas limit
                              if GasEnabled(version) != true {
                                  return
                              }
                          Severity: Major
                          Found in fee/gas.go - About 35 mins to fix

                            Method queryContract.Run has 5 return statements (exceeds 4 allowed).
                            Open

                            func (c *queryContract) Run(args string) (string, uint64, []*types.Event, error) {
                                contractName, funcName, queryCode, expectedResult, expectedError, _ := c.parse(args)
                            
                                formattedQuery := fmt.Sprintf("{\"name\":\"%s\",\"args\":%s}", funcName, queryCode)
                            
                            
                            Severity: Major
                            Found in cmd/brick/exec/queryContract.go - About 35 mins to fix

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

                              func execNameUpdate(cmd *cobra.Command, args []string) error {
                                  account, err := types.DecodeAddress(from)
                                  if err != nil {
                                      return fmt.Errorf("Wrong address in --from flag: %v", err.Error())
                                  }
                              Severity: Major
                              Found in cmd/aergocli/cmd/name.go - About 35 mins to fix

                                Method reorganizer.initRecovery has 5 return statements (exceeds 4 allowed).
                                Open

                                func (reorg *reorganizer) initRecovery(marker *ReorgMarker) error {
                                    var startBlock, bestBlock, topBlock *types.Block
                                    var err error
                                
                                    if marker == nil {
                                Severity: Major
                                Found in chain/reorg.go - About 35 mins to fix

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

                                  func completerBroker(d prompt.Document) []prompt.Suggest {
                                      var s []prompt.Suggest
                                      // parse first word. it is represent a command
                                      cmd, args := context.ParseFirstWord(d.Lines()[0])
                                  
                                  
                                  Severity: Minor
                                  Found in cmd/brick/brick.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.GetVotes has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
                                  Open

                                  func (api *Web3APIv1) GetVotes() (handler http.Handler, ok bool) {
                                      values, err := url.ParseQuery(api.request.URL.RawQuery)
                                      if err != nil {
                                          return commonResponseHandler(&types.Empty{}, err), true
                                      }
                                  Severity: Minor
                                  Found in rpc/web3/v1.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