aergoio/aergo

View on GitHub

Showing 1,051 of 1,052 total issues

Method AergoRPCService.GetReceipts has 65 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (rpc *AergoRPCService) GetReceipts(ctx context.Context, in *types.ReceiptsParams) (*types.ReceiptsPaged, error) {
    if err := rpc.checkAuth(ctx, ReadBlockChain); err != nil {
        return nil, err
    }

Severity: Minor
Found in rpc/grpcserver.go - About 1 hr to fix

    Method SQLiteDriver.Open has 65 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) {
        if C.sqlite3_threadsafe() == 0 {
            return nil, errors.New("sqlite library was not compiled for thread-safe operation")
        }
    
    
    Severity: Minor
    Found in contract/sqlite3.go - About 1 hr to fix

      Function CheckFeeDelegation has 65 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func CheckFeeDelegation(contractAddress []byte, bs *state.BlockState, bi *types.BlockHeaderInfo, cdb ChainAccessor,
          contractState *statedb.ContractState, payload, txHash, sender, amount []byte) (err error) {
          var ci types.CallInfo
      
          err = getCallInfo(&ci, payload, contractAddress)
      Severity: Minor
      Found in contract/vm.go - About 1 hr to fix

        Function luaECVerify has 65 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func luaECVerify(L *LState, service C.int, msg *C.char, sig *C.char, addr *C.char) (C.int, *C.char) {
            bMsg, err := decodeHex(C.GoString(msg))
            if err != nil {
                return -1, C.CString("[Contract.LuaEcVerify] invalid message format: " + err.Error())
            }
        Severity: Minor
        Found in contract/vm_callback.go - About 1 hr to fix

          Method ChainService.addBlockInternal has 17 return statements (exceeds 4 allowed).
          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 1 hr to fix

            Function luaSendAmount has 17 return statements (exceeds 4 allowed).
            Open

            func luaSendAmount(L *LState, service C.int, contractId *C.char, amount *C.char) *C.char {
            
                ctx := contexts[service]
                if ctx == nil {
                    return C.CString("[Contract.LuaSendAmount] contract state not found")
            Severity: Major
            Found in contract/vm_callback.go - About 1 hr to fix

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

              func (rpc *AergoRPCService) BroadcastToListBlockMetadataStream(meta *types.BlockMetadata) {
                  var err error
                  rpc.blockMetadataStreamLock.RLock()
                  defer rpc.blockMetadataStreamLock.RUnlock()
              
              
              Severity: Major
              Found in rpc/grpcserver.go and 1 other location - About 1 hr to fix
              rpc/grpcserver.go on lines 344..358

              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 165.

              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

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

              func (rpc *AergoRPCService) BroadcastToListBlockStream(block *types.Block) {
                  var err error
                  rpc.blockStreamLock.RLock()
                  defer rpc.blockStreamLock.RUnlock()
                  for _, stream := range rpc.blockStream {
              Severity: Major
              Found in rpc/grpcserver.go and 1 other location - About 1 hr to fix
              rpc/grpcserver.go on lines 360..375

              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 165.

              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

              Method WalDB.convertFromRaft has 64 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func (wal *WalDB) convertFromRaft(entries []raftpb.Entry) ([]*consensus.WalEntry, []*types.Block, []*raftpb.ConfChange) {
                  lenEnts := len(entries)
                  if lenEnts == 0 {
                      return nil, nil, nil
                  }
              Severity: Minor
              Found in consensus/impl/raftv2/waldb.go - About 1 hr to fix

                Method Web3APIv1.ListEvents has 64 lines of code (exceeds 50 allowed). Consider refactoring.
                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: Minor
                Found in rpc/web3/v1.go - About 1 hr to fix

                  Function ExecuteNameTx has 64 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  func ExecuteNameTx(bs *state.BlockState, scs *statedb.ContractState, txBody *types.TxBody,
                      sender, receiver *state.AccountState, blockInfo *types.BlockHeaderInfo) ([]*types.Event, error) {
                  
                      ci, err := ValidateNameTx(txBody, sender, scs)
                      if err != nil {
                  Severity: Minor
                  Found in contract/name/execute.go - About 1 hr to fix

                    Function Execute has 64 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func Execute(execCtx context.Context, bs *state.BlockState, cdb ChainAccessor, tx *types.Tx, sender, receiver *state.AccountState, bi *types.BlockHeaderInfo, executionMode int, isFeeDelegation bool) (rv string, events []*types.Event, usedFee *big.Int, err error) {
                    
                        var (
                            txBody     = tx.GetBody()
                            txType     = txBody.GetType()
                    Severity: Minor
                    Found in contract/contract.go - About 1 hr to fix

                      Method blockRequestHandler.handleBlkReq has 63 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func (bh *blockRequestHandler) handleBlkReq(msg p2pcommon.Message, data *types.GetBlockRequest) {
                          defer bh.release()
                          remotePeer := bh.peer
                      
                          requestID := msg.ID()
                      Severity: Minor
                      Found in p2p/subproto/getblock.go - About 1 hr to fix

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

                        func (r *Receipt) unmarshalStoreBinary(data []byte) ([]byte, error) {
                            evData, evCount := r.unmarshalBody(data)
                        
                            r.Events = make([]*Event, evCount)
                            var err error
                        Severity: Major
                        Found in types/receipt.go and 1 other location - About 1 hr to fix
                        types/receipt.go on lines 267..281

                        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 161.

                        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

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

                        func (r *Receipt) unmarshalStoreBinaryV2(data []byte) ([]byte, error) {
                            evData, evCount := r.unmarshalBodyV2(data)
                        
                            r.Events = make([]*Event, evCount)
                            var err error
                        Severity: Major
                        Found in types/receipt.go and 1 other location - About 1 hr to fix
                        types/receipt.go on lines 251..265

                        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 161.

                        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

                        Method SQLiteConn.RegisterAggregator has 16 return statements (exceeds 4 allowed).
                        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: Major
                        Found in contract/sqlite3.go - About 1 hr to fix

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

                                      if ctx.traceFile != nil {
                                          _, _ = ctx.traceFile.WriteString(fmt.Sprintf("[GOVERNANCE]aid(%s)\n", aid.String()))
                                          _, _ = ctx.traceFile.WriteString(fmt.Sprintf("snapshot set %d\n", seq))
                                          _, _ = ctx.traceFile.WriteString(fmt.Sprintf("unstaking : %s\n", amountBig.String()))
                                          _, _ = ctx.traceFile.WriteString(fmt.Sprintf("After sender: %s receiver: %s\n",
                          Severity: Major
                          Found in contract/vm_callback.go and 1 other location - About 1 hr to fix
                          contract/vm_callback.go on lines 1372..1378

                          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 159.

                          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

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

                                      if ctx.traceFile != nil {
                                          _, _ = ctx.traceFile.WriteString(fmt.Sprintf("[GOVERNANCE]aid(%s)\n", aid.String()))
                                          _, _ = ctx.traceFile.WriteString(fmt.Sprintf("snapshot set %d\n", seq))
                                          _, _ = ctx.traceFile.WriteString(fmt.Sprintf("staking : %s\n", amountBig.String()))
                                          _, _ = ctx.traceFile.WriteString(fmt.Sprintf("After sender: %s receiver: %s\n",
                          Severity: Major
                          Found in contract/vm_callback.go and 1 other location - About 1 hr to fix
                          contract/vm_callback.go on lines 1381..1387

                          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 159.

                          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

                          Function execVote has 62 lines of code (exceeds 50 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 1 hr to fix

                            Method AergoRPCService.getChainInfo has 61 lines of code (exceeds 50 allowed). Consider refactoring.
                            Open

                            func (rpc *AergoRPCService) getChainInfo(ctx context.Context) (*types.ChainInfo, error) {
                                chainInfo := &types.ChainInfo{}
                            
                                if genesisInfo := rpc.actorHelper.GetChainAccessor().GetGenesisInfo(); genesisInfo != nil {
                                    ca := rpc.actorHelper.GetChainAccessor()
                            Severity: Minor
                            Found in rpc/grpcserver.go - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language