aergoio/aergo

View on GitHub
rpc/grpcserver.go

Summary

Maintainability
F
1 wk
Test Coverage
F
1%

File grpcserver.go has 1174 lines of code (exceeds 500 allowed). Consider refactoring.
Open

/**
 *  @file
 *  @copyright defined in aergo/LICENSE.txt
 */

Severity: Major
Found in rpc/grpcserver.go - About 2 days to fix

    AergoRPCService has 55 methods (exceeds 20 allowed). Consider refactoring.
    Open

    type AergoRPCService struct {
        hub               *component.ComponentHub
        actorHelper       p2pcommon.ActorService
        consensusAccessor consensus.ConsensusAccessor //TODO refactor with actorHelper
        msgHelper         message.Helper
    Severity: Major
    Found in rpc/grpcserver.go - About 7 hrs to fix

      Method AergoRPCService.getBlocks has a Cognitive Complexity of 48 (exceeds 20 allowed). Consider refactoring.
      Open

      func (rpc *AergoRPCService) getBlocks(ctx context.Context, in *types.ListParams) ([]*types.Block, error) {
          var maxFetchSize uint32
          // TODO refactor with almost same code is in p2pcmdblock.go
          if in.Size > uint32(1000) {
              maxFetchSize = uint32(1000)
      Severity: Minor
      Found in rpc/grpcserver.go - About 4 hrs 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 AergoRPCService.getBlocks has 69 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (rpc *AergoRPCService) getBlocks(ctx context.Context, in *types.ListParams) ([]*types.Block, error) {
          var maxFetchSize uint32
          // TODO refactor with almost same code is in p2pcmdblock.go
          if in.Size > uint32(1000) {
              maxFetchSize = uint32(1000)
      Severity: Minor
      Found in rpc/grpcserver.go - About 1 hr to fix

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

            Method AergoRPCService.SendTX has 12 return statements (exceeds 4 allowed).
            Open

            func (rpc *AergoRPCService) SendTX(ctx context.Context, tx *types.Tx) (*types.CommitResult, error) {
                if err := rpc.checkAuth(ctx, WriteBlockChain); err != nil {
                    return nil, err
                }
                if tx.Body.Nonce == 0 {
            Severity: Major
            Found in rpc/grpcserver.go - About 1 hr to fix

              Method AergoRPCService.SendTX has 54 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func (rpc *AergoRPCService) SendTX(ctx context.Context, tx *types.Tx) (*types.CommitResult, error) {
                  if err := rpc.checkAuth(ctx, WriteBlockChain); err != nil {
                      return nil, err
                  }
                  if tx.Body.Nonce == 0 {
              Severity: Minor
              Found in rpc/grpcserver.go - About 1 hr to fix

                Method AergoRPCService.getChainInfo has a Cognitive Complexity of 25 (exceeds 20 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

                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 AergoRPCService.GetReceipts has 10 return statements (exceeds 4 allowed).
                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: Major
                Found in rpc/grpcserver.go - About 1 hr to fix

                  Method AergoRPCService.getChainInfo has 10 return statements (exceeds 4 allowed).
                  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: Major
                  Found in rpc/grpcserver.go - About 1 hr 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 AergoRPCService.GetBlock has 7 return statements (exceeds 4 allowed).
                      Open

                      func (rpc *AergoRPCService) GetBlock(ctx context.Context, in *types.SingleBytes) (*types.Block, error) {
                          if err := rpc.checkAuth(ctx, ReadBlockChain); err != nil {
                              return nil, err
                          }
                          var result interface{}
                      Severity: Major
                      Found in rpc/grpcserver.go - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                            if i == start {
                                                err = futureErr
                                            }
                        Severity: Major
                        Found in rpc/grpcserver.go - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                              if i == end {
                                                  err = futureErr
                                              }
                          Severity: Major
                          Found in rpc/grpcserver.go - About 45 mins to fix

                            Method AergoRPCService.ImportAccount has 6 return statements (exceeds 4 allowed).
                            Open

                            func (rpc *AergoRPCService) ImportAccount(ctx context.Context, in *types.ImportFormat) (*types.Account, error) {
                                if err := rpc.checkAuth(ctx, WriteBlockChain); err != nil {
                                    return nil, err
                                }
                                msg := &message.ImportAccount{OldPass: in.Oldpass, NewPass: in.Newpass}
                            Severity: Major
                            Found in rpc/grpcserver.go - About 40 mins to fix

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

                              func (rpc *AergoRPCService) VerifyTX(ctx context.Context, in *types.Tx) (*types.VerifyResult, error) {
                                  if err := rpc.checkAuth(ctx, ReadBlockChain); err != nil {
                                      return nil, err
                                  }
                                  //TODO : verify without account service
                              Severity: Major
                              Found in rpc/grpcserver.go - About 35 mins to fix

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

                                func (rpc *AergoRPCService) GetNameInfo(ctx context.Context, in *types.Name) (*types.NameInfo, error) {
                                    if err := rpc.checkAuth(ctx, ReadBlockChain); err != nil {
                                        return nil, err
                                    }
                                    result, err := rpc.hub.RequestFuture(message.ChainSvc,
                                Severity: Major
                                Found in rpc/grpcserver.go - About 35 mins to fix

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

                                  func (rpc *AergoRPCService) LockAccount(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 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 AergoRPCService.exportAccountWithFormat has 5 return statements (exceeds 4 allowed).
                                      Open

                                      func (rpc *AergoRPCService) exportAccountWithFormat(ctx context.Context, in *types.Personal, asKeystore bool) (*types.SingleBytes, 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 AergoRPCService.GetStaking has 5 return statements (exceeds 4 allowed).
                                        Open

                                        func (rpc *AergoRPCService) GetStaking(ctx context.Context, in *types.AccountAddress) (*types.Staking, error) {
                                            if err := rpc.checkAuth(ctx, ReadBlockChain); err != nil {
                                                return nil, err
                                            }
                                            var err error
                                        Severity: Major
                                        Found in rpc/grpcserver.go - About 35 mins to fix

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

                                          func (rpc *AergoRPCService) GetEnterpriseConfig(ctx context.Context, in *types.EnterpriseConfigKey) (*types.EnterpriseConfig, error) {
                                              genesis := rpc.actorHelper.GetChainAccessor().GetGenesisInfo()
                                              if genesis.PublicNet() {
                                                  return nil, status.Error(codes.Unavailable, "not supported in public")
                                              }
                                          Severity: Major
                                          Found in rpc/grpcserver.go - About 35 mins to fix

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

                                            func (rpc *AergoRPCService) GetTX(ctx context.Context, in *types.SingleBytes) (*types.Tx, error) {
                                                if err := rpc.checkAuth(ctx, ReadBlockChain); err != nil {
                                                    return nil, err
                                                }
                                                result, err := rpc.actorHelper.CallRequestDefaultTimeout(message.MemPoolSvc,
                                            Severity: Major
                                            Found in rpc/grpcserver.go - About 35 mins to fix

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

                                              func (rpc *AergoRPCService) CreateAccount(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 AergoRPCService.GetAccounts has 5 return statements (exceeds 4 allowed).
                                                Open

                                                func (rpc *AergoRPCService) GetAccounts(ctx context.Context, in *types.Empty) (*types.AccountList, error) {
                                                    if err := rpc.checkAuth(ctx, ShowNode); 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 AergoRPCService.SignTX has 5 return statements (exceeds 4 allowed).
                                                  Open

                                                  func (rpc *AergoRPCService) SignTX(ctx context.Context, in *types.Tx) (*types.Tx, 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 AergoRPCService.GetReceipts has a Cognitive Complexity of 21 (exceeds 20 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 25 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

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

                                                    func (rpc *AergoRPCService) ListBlockMetadataStream(in *types.Empty, stream types.AergoRPCService_ListBlockMetadataStreamServer) error {
                                                        streamID := atomic.AddUint32(&rpc.streamID, 1)
                                                        rpc.blockMetadataStreamLock.Lock()
                                                        metadataStream := NewListBlockMetaStream(streamID, stream)
                                                        rpc.blockMetadataStream[streamID] = metadataStream
                                                    Severity: Major
                                                    Found in rpc/grpcserver.go and 1 other location - About 3 hrs to fix
                                                    rpc/grpcserver.go on lines 378..401

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

                                                    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) ListBlockStream(in *types.Empty, stream types.AergoRPCService_ListBlockStreamServer) error {
                                                        streamId := atomic.AddUint32(&rpc.streamID, 1)
                                                        rpc.blockStreamLock.Lock()
                                                        blockStream := NewListBlockStream(streamId, stream)
                                                        rpc.blockStream[streamId] = blockStream
                                                    Severity: Major
                                                    Found in rpc/grpcserver.go and 1 other location - About 3 hrs to fix
                                                    rpc/grpcserver.go on lines 411..433

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

                                                    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) LockAccount(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 and 1 other location - About 3 hrs to fix
                                                    rpc/grpcserver.go on lines 801..820

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

                                                    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) 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 and 1 other location - About 3 hrs to fix
                                                    rpc/grpcserver.go on lines 779..798

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

                                                    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) GetABI(ctx context.Context, in *types.SingleBytes) (*types.ABI, error) {
                                                        if err := rpc.checkAuth(ctx, ReadBlockChain); err != nil {
                                                            return nil, err
                                                        }
                                                        result, err := rpc.hub.RequestFuture(message.ChainSvc,
                                                    Severity: Major
                                                    Found in rpc/grpcserver.go and 1 other location - About 2 hrs to fix
                                                    rpc/grpcserver.go on lines 1054..1068

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

                                                    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) GetReceipt(ctx context.Context, in *types.SingleBytes) (*types.Receipt, error) {
                                                        if err := rpc.checkAuth(ctx, ReadBlockChain); err != nil {
                                                            return nil, err
                                                        }
                                                        result, err := rpc.hub.RequestFuture(message.ChainSvc,
                                                    Severity: Major
                                                    Found in rpc/grpcserver.go and 1 other location - About 2 hrs to fix
                                                    rpc/grpcserver.go on lines 1148..1162

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

                                                    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 len(in.Value) == 32 {
                                                            result, err = rpc.hub.RequestFuture(message.ChainSvc, &message.GetBlock{BlockHash: in.Value},
                                                                defaultActorTimeout, "rpc.(*AergoRPCService).GetBlock#2").Result()
                                                        } else if len(in.Value) == 8 {
                                                            number := uint64(binary.LittleEndian.Uint64(in.Value))
                                                    Severity: Major
                                                    Found in rpc/grpcserver.go and 1 other location - About 1 hr to fix
                                                    rpc/grpcserver.go on lines 1081..1090

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

                                                    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 len(in.Hashornumber) == 32 {
                                                            result, err = rpc.hub.RequestFuture(message.ChainSvc, &message.GetReceipts{BlockHash: in.Hashornumber},
                                                                defaultActorTimeout, "rpc.(*AergoRPCService).GetReceipts#2").Result()
                                                        } else if len(in.Hashornumber) == 8 {
                                                            number := uint64(binary.LittleEndian.Uint64(in.Hashornumber))
                                                    Severity: Major
                                                    Found in rpc/grpcserver.go and 1 other location - About 1 hr to fix
                                                    rpc/grpcserver.go on lines 479..488

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

                                                    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) 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

                                                    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

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

                                                            if in.Asc {
                                                                for i := end; i <= start; 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 325..339

                                                    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

                                                    There are no issues that match your filters.

                                                    Category
                                                    Status