aergoio/aergo

View on GitHub

Showing 1,051 of 1,052 total issues

Method V030Handshaker.receiveRemoteStatus has 8 return statements (exceeds 4 allowed).
Open

func (h *V030Handshaker) receiveRemoteStatus(ctx context.Context) (*types.Status, error) {
    // and wait to response status
    data, err := h.msgRW.ReadMsg()
    if err != nil {
        h.sendGoAway("malformed message")
Severity: Major
Found in p2p/v030/v030handshake.go - About 50 mins to fix

    Method V200Handshaker.checkRemoteStatus has 8 return statements (exceeds 4 allowed).
    Open

    func (h *V200Handshaker) checkRemoteStatus(remotePeerStatus *types.Status) error {
        // check if chainID is same or not
        remoteChainID := types.NewChainID()
        err := remoteChainID.Read(remotePeerStatus.ChainID)
        if err != nil {
    Severity: Major
    Found in p2p/v200/v200handshake.go - About 50 mins to fix

      Method AergoRPCService.GetConfChangeProgress has 8 return statements (exceeds 4 allowed).
      Open

      func (rpc *AergoRPCService) GetConfChangeProgress(ctx context.Context, in *types.SingleBytes) (*types.ConfChangeProgress, error) {
          var (
              progress *types.ConfChangeProgress
              err      error
          )
      Severity: Major
      Found in rpc/grpcserver.go - About 50 mins to fix

        Method baseWireHandshaker.readWireHSRequest has 8 return statements (exceeds 4 allowed).
        Open

        func (h *baseWireHandshaker) readWireHSRequest(rd io.Reader) (header p2pcommon.HSHeadReq, err error) {
            buf := make([]byte, p2pcommon.HSMagicLength)
            readn, err := p2putil.ReadToLen(rd, buf[:p2pcommon.HSMagicLength])
            if err != nil {
                return
        Severity: Major
        Found in p2p/handshakev2.go - About 50 mins to fix

          Method Cluster.validateChangeMembership has 8 return statements (exceeds 4 allowed).
          Open

          func (cl *Cluster) validateChangeMembership(cc *raftpb.ConfChange, member *consensus.Member, needlock bool) error {
              if member == nil {
                  return ErrCCMemberIsNil
              }
          
          
          Severity: Major
          Found in consensus/impl/raftv2/cluster.go - About 50 mins to fix

            Method InboundWireHandshaker.handleInboundPeer has 8 return statements (exceeds 4 allowed).
            Open

            func (h *InboundWireHandshaker) handleInboundPeer(ctx context.Context, rwc io.ReadWriteCloser) (*p2pcommon.HandshakeResult, error) {
                // wait initial hs message
                hsReq, err := h.readWireHSRequest(rwc)
                select {
                case <-ctx.Done():
            Severity: Major
            Found in p2p/handshakev2.go - About 50 mins to fix

              Method reorganizer.gather has 8 return statements (exceeds 4 allowed).
              Open

              func (reorg *reorganizer) gather() error {
                  //find branch root block , gather rollforward Target block
                  var err error
                  cdb := reorg.cs.cdb
              
              
              Severity: Major
              Found in chain/reorg.go - About 50 mins to fix

                Method Web3APIv1.ListEvents has 8 return statements (exceeds 4 allowed).
                Open

                func (api *Web3APIv1) ListEvents() (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 50 mins to fix

                  Function sendTX has 8 return statements (exceeds 4 allowed).
                  Open

                  func sendTX(cmd *cobra.Command, tx *types.Tx, account []byte) string {
                      if rootConfig.KeyStorePath != "" {
                          var err error
                          if pw == "" {
                              pw, err = getPasswd(cmd, false)
                  Severity: Major
                  Found in cmd/aergocli/cmd/sendtx.go - About 50 mins to fix

                    Function execVote has 8 return statements (exceeds 4 allowed).
                    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: Major
                    Found in cmd/aergocli/cmd/vote.go - About 50 mins to fix

                      Method blockExecutor.execute has 8 return statements (exceeds 4 allowed).
                      Open

                      func (e *blockExecutor) execute() error {
                          // Receipt must be committed unconditionally.
                          if !e.commitOnly {
                              defer contract.CloseDatabase()
                              logger.Trace().Int("txCount", len(e.txs)).Msg("executing txs")
                      Severity: Major
                      Found in chain/chainhandle.go - About 50 mins to fix

                        Method PeerMapService.handleQuery has 8 return statements (exceeds 4 allowed).
                        Open

                        func (pms *PeerMapService) handleQuery(conn p2pcommon.RemoteConn, container p2pcommon.Message, query *types.MapQuery) (*types.MapResponse, error) {
                            if query.Status == nil {
                                return nil, fmt.Errorf("malformed query %v", query)
                            }
                            receivedMeta := p2pcommon.NewMetaFromStatus(query.Status)
                        Severity: Major
                        Found in cmd/polaris/server/mapservice.go - About 50 mins to fix

                          Method ChainStateDB.SetGenesis has 8 return statements (exceeds 4 allowed).
                          Open

                          func (sdb *ChainStateDB) SetGenesis(genesis *types.Genesis, bpInit func(*statedb.StateDB, *types.Genesis) error) error {
                              block := genesis.Block()
                              stateDB := sdb.OpenNewStateDB(sdb.GetRoot())
                          
                              // create state of genesis block
                          Severity: Major
                          Found in state/chain.go - About 50 mins to fix

                            Method BlockFetcher.searchCandidateTask has 8 return statements (exceeds 4 allowed).
                            Open

                            func (bf *BlockFetcher) searchCandidateTask() (*FetchTask, error) {
                                getNewHashSet := func() (*HashSet, error) {
                                    if bf.curHashSet == nil { //blocking
                                        logger.Info().Msg("BlockFetcher waiting first hashset")
                            
                            
                            Severity: Major
                            Found in syncer/blockfetcher.go - About 50 mins to fix

                              Function ValidateNameTx has 8 return statements (exceeds 4 allowed).
                              Open

                              func ValidateNameTx(tx *types.TxBody, sender *state.AccountState, scs *statedb.ContractState) (*types.CallInfo, error) {
                                  if sender != nil && sender.Balance().Cmp(tx.GetAmountBigInt()) < 0 {
                                      return nil, types.ErrInsufficientBalance
                                  }
                              
                              
                              Severity: Major
                              Found in contract/name/execute.go - About 50 mins to fix

                                Method SQLiteConn.RegisterFunc has 8 return statements (exceeds 4 allowed).
                                Open

                                func (c *SQLiteConn) RegisterFunc(name string, impl interface{}, pure bool) error {
                                    var fi functionInfo
                                    fi.f = reflect.ValueOf(impl)
                                    t := fi.f.Type()
                                    if t.Kind() != reflect.Func {
                                Severity: Major
                                Found in contract/sqlite3.go - About 50 mins to fix

                                  Method transaction.ValidateWithSenderState has 8 return statements (exceeds 4 allowed).
                                  Open

                                  func (tx *transaction) ValidateWithSenderState(senderState *State, gasPrice *big.Int, version int32) error {
                                      if (senderState.GetNonce() + 1) > tx.GetBody().GetNonce() {
                                          return ErrTxNonceTooLow
                                      }
                                      amount := tx.GetBody().GetAmountBigInt()
                                  Severity: Major
                                  Found in types/transaction.go - About 50 mins to fix

                                    Function Create has 8 return statements (exceeds 4 allowed).
                                    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 50 mins to fix

                                      Function refreshAllVote has 8 return statements (exceeds 4 allowed).
                                      Open

                                      func refreshAllVote(context *SystemContext) error {
                                          var (
                                              scs          = context.scs
                                              account      = context.Sender.ID()
                                              staked       = context.Staked
                                      Severity: Major
                                      Found in contract/system/vote.go - About 50 mins to fix

                                        Similar blocks of code found in 2 locations. Consider refactoring.
                                        Open

                                                } else {
                                                    for i := start; i >= end; i-- {
                                                        foundBlock, futureErr := extractBlockFromFuture(rpc.hub.RequestFuture(message.ChainSvc,
                                                            &message.GetBlockByNo{BlockNo: i}, defaultActorTimeout, "rpc.(*AergoRPCService).ListBlockHeaders#2"))
                                                        if nil != futureErr {
                                        Severity: Minor
                                        Found in rpc/grpcserver.go and 1 other location - About 50 mins to fix
                                        rpc/grpcserver.go on lines 311..325

                                        Duplicated Code

                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                        Tuning

                                        This issue has a mass of 120.

                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                        Refactorings

                                        Further Reading

                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language