aergoio/aergo

View on GitHub

Showing 1,051 of 1,052 total issues

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

func (mr *MockAergoRPCServiceClientMockRecorder) ExportAccountKeystore(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call {
    mr.mock.ctrl.T.Helper()
    varargs := append([]interface{}{arg0, arg1}, arg2...)
    return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExportAccountKeystore", reflect.TypeOf((*MockAergoRPCServiceClient)(nil).ExportAccountKeystore), varargs...)
}
Severity: Major
Found in cmd/aergocli/cmd/mock_types/mock_types.go and 45 other locations - About 1 hr to fix
cmd/aergocli/cmd/mock_types/mock_types.go on lines 53..57
cmd/aergocli/cmd/mock_types/mock_types.go on lines 73..77
cmd/aergocli/cmd/mock_types/mock_types.go on lines 93..97
cmd/aergocli/cmd/mock_types/mock_types.go on lines 113..117
cmd/aergocli/cmd/mock_types/mock_types.go on lines 133..137
cmd/aergocli/cmd/mock_types/mock_types.go on lines 153..157
cmd/aergocli/cmd/mock_types/mock_types.go on lines 193..197
cmd/aergocli/cmd/mock_types/mock_types.go on lines 213..217
cmd/aergocli/cmd/mock_types/mock_types.go on lines 233..237
cmd/aergocli/cmd/mock_types/mock_types.go on lines 253..257
cmd/aergocli/cmd/mock_types/mock_types.go on lines 273..277
cmd/aergocli/cmd/mock_types/mock_types.go on lines 293..297
cmd/aergocli/cmd/mock_types/mock_types.go on lines 313..317
cmd/aergocli/cmd/mock_types/mock_types.go on lines 333..337
cmd/aergocli/cmd/mock_types/mock_types.go on lines 353..357
cmd/aergocli/cmd/mock_types/mock_types.go on lines 373..377
cmd/aergocli/cmd/mock_types/mock_types.go on lines 393..397
cmd/aergocli/cmd/mock_types/mock_types.go on lines 413..417
cmd/aergocli/cmd/mock_types/mock_types.go on lines 433..437
cmd/aergocli/cmd/mock_types/mock_types.go on lines 453..457
cmd/aergocli/cmd/mock_types/mock_types.go on lines 473..477
cmd/aergocli/cmd/mock_types/mock_types.go on lines 493..497
cmd/aergocli/cmd/mock_types/mock_types.go on lines 513..517
cmd/aergocli/cmd/mock_types/mock_types.go on lines 533..537
cmd/aergocli/cmd/mock_types/mock_types.go on lines 553..557
cmd/aergocli/cmd/mock_types/mock_types.go on lines 573..577
cmd/aergocli/cmd/mock_types/mock_types.go on lines 593..597
cmd/aergocli/cmd/mock_types/mock_types.go on lines 613..617
cmd/aergocli/cmd/mock_types/mock_types.go on lines 633..637
cmd/aergocli/cmd/mock_types/mock_types.go on lines 653..657
cmd/aergocli/cmd/mock_types/mock_types.go on lines 673..677
cmd/aergocli/cmd/mock_types/mock_types.go on lines 693..697
cmd/aergocli/cmd/mock_types/mock_types.go on lines 713..717
cmd/aergocli/cmd/mock_types/mock_types.go on lines 733..737
cmd/aergocli/cmd/mock_types/mock_types.go on lines 753..757
cmd/aergocli/cmd/mock_types/mock_types.go on lines 773..777
cmd/aergocli/cmd/mock_types/mock_types.go on lines 793..797
cmd/aergocli/cmd/mock_types/mock_types.go on lines 813..817
cmd/aergocli/cmd/mock_types/mock_types.go on lines 833..837
cmd/aergocli/cmd/mock_types/mock_types.go on lines 853..857
cmd/aergocli/cmd/mock_types/mock_types.go on lines 873..877
cmd/aergocli/cmd/mock_types/mock_types.go on lines 893..897
p2p/p2pmock/mock_host.go on lines 169..173
p2p/p2pmock/mock_networktransport.go on lines 269..273
p2p/p2pmock/mock_networktransport.go on lines 331..335

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

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 46 locations. Consider refactoring.
Open

func (mr *MockAergoRPCServiceClientMockRecorder) ListEventStream(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call {
    mr.mock.ctrl.T.Helper()
    varargs := append([]interface{}{arg0, arg1}, arg2...)
    return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListEventStream", reflect.TypeOf((*MockAergoRPCServiceClient)(nil).ListEventStream), varargs...)
}
Severity: Major
Found in cmd/aergocli/cmd/mock_types/mock_types.go and 45 other locations - About 1 hr to fix
cmd/aergocli/cmd/mock_types/mock_types.go on lines 53..57
cmd/aergocli/cmd/mock_types/mock_types.go on lines 73..77
cmd/aergocli/cmd/mock_types/mock_types.go on lines 93..97
cmd/aergocli/cmd/mock_types/mock_types.go on lines 113..117
cmd/aergocli/cmd/mock_types/mock_types.go on lines 133..137
cmd/aergocli/cmd/mock_types/mock_types.go on lines 153..157
cmd/aergocli/cmd/mock_types/mock_types.go on lines 173..177
cmd/aergocli/cmd/mock_types/mock_types.go on lines 193..197
cmd/aergocli/cmd/mock_types/mock_types.go on lines 213..217
cmd/aergocli/cmd/mock_types/mock_types.go on lines 233..237
cmd/aergocli/cmd/mock_types/mock_types.go on lines 253..257
cmd/aergocli/cmd/mock_types/mock_types.go on lines 273..277
cmd/aergocli/cmd/mock_types/mock_types.go on lines 293..297
cmd/aergocli/cmd/mock_types/mock_types.go on lines 313..317
cmd/aergocli/cmd/mock_types/mock_types.go on lines 333..337
cmd/aergocli/cmd/mock_types/mock_types.go on lines 353..357
cmd/aergocli/cmd/mock_types/mock_types.go on lines 373..377
cmd/aergocli/cmd/mock_types/mock_types.go on lines 393..397
cmd/aergocli/cmd/mock_types/mock_types.go on lines 413..417
cmd/aergocli/cmd/mock_types/mock_types.go on lines 433..437
cmd/aergocli/cmd/mock_types/mock_types.go on lines 453..457
cmd/aergocli/cmd/mock_types/mock_types.go on lines 473..477
cmd/aergocli/cmd/mock_types/mock_types.go on lines 493..497
cmd/aergocli/cmd/mock_types/mock_types.go on lines 513..517
cmd/aergocli/cmd/mock_types/mock_types.go on lines 533..537
cmd/aergocli/cmd/mock_types/mock_types.go on lines 553..557
cmd/aergocli/cmd/mock_types/mock_types.go on lines 573..577
cmd/aergocli/cmd/mock_types/mock_types.go on lines 593..597
cmd/aergocli/cmd/mock_types/mock_types.go on lines 613..617
cmd/aergocli/cmd/mock_types/mock_types.go on lines 633..637
cmd/aergocli/cmd/mock_types/mock_types.go on lines 653..657
cmd/aergocli/cmd/mock_types/mock_types.go on lines 673..677
cmd/aergocli/cmd/mock_types/mock_types.go on lines 713..717
cmd/aergocli/cmd/mock_types/mock_types.go on lines 733..737
cmd/aergocli/cmd/mock_types/mock_types.go on lines 753..757
cmd/aergocli/cmd/mock_types/mock_types.go on lines 773..777
cmd/aergocli/cmd/mock_types/mock_types.go on lines 793..797
cmd/aergocli/cmd/mock_types/mock_types.go on lines 813..817
cmd/aergocli/cmd/mock_types/mock_types.go on lines 833..837
cmd/aergocli/cmd/mock_types/mock_types.go on lines 853..857
cmd/aergocli/cmd/mock_types/mock_types.go on lines 873..877
cmd/aergocli/cmd/mock_types/mock_types.go on lines 893..897
p2p/p2pmock/mock_host.go on lines 169..173
p2p/p2pmock/mock_networktransport.go on lines 269..273
p2p/p2pmock/mock_networktransport.go on lines 331..335

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

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 46 locations. Consider refactoring.
Open

func (mr *MockAergoRPCServiceClientMockRecorder) SignTX(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call {
    mr.mock.ctrl.T.Helper()
    varargs := append([]interface{}{arg0, arg1}, arg2...)
    return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SignTX", reflect.TypeOf((*MockAergoRPCServiceClient)(nil).SignTX), varargs...)
}
Severity: Major
Found in cmd/aergocli/cmd/mock_types/mock_types.go and 45 other locations - About 1 hr to fix
cmd/aergocli/cmd/mock_types/mock_types.go on lines 53..57
cmd/aergocli/cmd/mock_types/mock_types.go on lines 73..77
cmd/aergocli/cmd/mock_types/mock_types.go on lines 93..97
cmd/aergocli/cmd/mock_types/mock_types.go on lines 113..117
cmd/aergocli/cmd/mock_types/mock_types.go on lines 133..137
cmd/aergocli/cmd/mock_types/mock_types.go on lines 153..157
cmd/aergocli/cmd/mock_types/mock_types.go on lines 173..177
cmd/aergocli/cmd/mock_types/mock_types.go on lines 193..197
cmd/aergocli/cmd/mock_types/mock_types.go on lines 213..217
cmd/aergocli/cmd/mock_types/mock_types.go on lines 233..237
cmd/aergocli/cmd/mock_types/mock_types.go on lines 253..257
cmd/aergocli/cmd/mock_types/mock_types.go on lines 273..277
cmd/aergocli/cmd/mock_types/mock_types.go on lines 293..297
cmd/aergocli/cmd/mock_types/mock_types.go on lines 313..317
cmd/aergocli/cmd/mock_types/mock_types.go on lines 333..337
cmd/aergocli/cmd/mock_types/mock_types.go on lines 353..357
cmd/aergocli/cmd/mock_types/mock_types.go on lines 373..377
cmd/aergocli/cmd/mock_types/mock_types.go on lines 393..397
cmd/aergocli/cmd/mock_types/mock_types.go on lines 413..417
cmd/aergocli/cmd/mock_types/mock_types.go on lines 433..437
cmd/aergocli/cmd/mock_types/mock_types.go on lines 453..457
cmd/aergocli/cmd/mock_types/mock_types.go on lines 473..477
cmd/aergocli/cmd/mock_types/mock_types.go on lines 493..497
cmd/aergocli/cmd/mock_types/mock_types.go on lines 513..517
cmd/aergocli/cmd/mock_types/mock_types.go on lines 533..537
cmd/aergocli/cmd/mock_types/mock_types.go on lines 553..557
cmd/aergocli/cmd/mock_types/mock_types.go on lines 573..577
cmd/aergocli/cmd/mock_types/mock_types.go on lines 593..597
cmd/aergocli/cmd/mock_types/mock_types.go on lines 613..617
cmd/aergocli/cmd/mock_types/mock_types.go on lines 633..637
cmd/aergocli/cmd/mock_types/mock_types.go on lines 653..657
cmd/aergocli/cmd/mock_types/mock_types.go on lines 673..677
cmd/aergocli/cmd/mock_types/mock_types.go on lines 693..697
cmd/aergocli/cmd/mock_types/mock_types.go on lines 713..717
cmd/aergocli/cmd/mock_types/mock_types.go on lines 733..737
cmd/aergocli/cmd/mock_types/mock_types.go on lines 753..757
cmd/aergocli/cmd/mock_types/mock_types.go on lines 773..777
cmd/aergocli/cmd/mock_types/mock_types.go on lines 793..797
cmd/aergocli/cmd/mock_types/mock_types.go on lines 813..817
cmd/aergocli/cmd/mock_types/mock_types.go on lines 833..837
cmd/aergocli/cmd/mock_types/mock_types.go on lines 873..877
cmd/aergocli/cmd/mock_types/mock_types.go on lines 893..897
p2p/p2pmock/mock_host.go on lines 169..173
p2p/p2pmock/mock_networktransport.go on lines 269..273
p2p/p2pmock/mock_networktransport.go on lines 331..335

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

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 46 locations. Consider refactoring.
Open

func (mr *MockAergoRPCServiceClientMockRecorder) Blockchain(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call {
    mr.mock.ctrl.T.Helper()
    varargs := append([]interface{}{arg0, arg1}, arg2...)
    return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Blockchain", reflect.TypeOf((*MockAergoRPCServiceClient)(nil).Blockchain), varargs...)
}
Severity: Major
Found in cmd/aergocli/cmd/mock_types/mock_types.go and 45 other locations - About 1 hr to fix
cmd/aergocli/cmd/mock_types/mock_types.go on lines 73..77
cmd/aergocli/cmd/mock_types/mock_types.go on lines 93..97
cmd/aergocli/cmd/mock_types/mock_types.go on lines 113..117
cmd/aergocli/cmd/mock_types/mock_types.go on lines 133..137
cmd/aergocli/cmd/mock_types/mock_types.go on lines 153..157
cmd/aergocli/cmd/mock_types/mock_types.go on lines 173..177
cmd/aergocli/cmd/mock_types/mock_types.go on lines 193..197
cmd/aergocli/cmd/mock_types/mock_types.go on lines 213..217
cmd/aergocli/cmd/mock_types/mock_types.go on lines 233..237
cmd/aergocli/cmd/mock_types/mock_types.go on lines 253..257
cmd/aergocli/cmd/mock_types/mock_types.go on lines 273..277
cmd/aergocli/cmd/mock_types/mock_types.go on lines 293..297
cmd/aergocli/cmd/mock_types/mock_types.go on lines 313..317
cmd/aergocli/cmd/mock_types/mock_types.go on lines 333..337
cmd/aergocli/cmd/mock_types/mock_types.go on lines 353..357
cmd/aergocli/cmd/mock_types/mock_types.go on lines 373..377
cmd/aergocli/cmd/mock_types/mock_types.go on lines 393..397
cmd/aergocli/cmd/mock_types/mock_types.go on lines 413..417
cmd/aergocli/cmd/mock_types/mock_types.go on lines 433..437
cmd/aergocli/cmd/mock_types/mock_types.go on lines 453..457
cmd/aergocli/cmd/mock_types/mock_types.go on lines 473..477
cmd/aergocli/cmd/mock_types/mock_types.go on lines 493..497
cmd/aergocli/cmd/mock_types/mock_types.go on lines 513..517
cmd/aergocli/cmd/mock_types/mock_types.go on lines 533..537
cmd/aergocli/cmd/mock_types/mock_types.go on lines 553..557
cmd/aergocli/cmd/mock_types/mock_types.go on lines 573..577
cmd/aergocli/cmd/mock_types/mock_types.go on lines 593..597
cmd/aergocli/cmd/mock_types/mock_types.go on lines 613..617
cmd/aergocli/cmd/mock_types/mock_types.go on lines 633..637
cmd/aergocli/cmd/mock_types/mock_types.go on lines 653..657
cmd/aergocli/cmd/mock_types/mock_types.go on lines 673..677
cmd/aergocli/cmd/mock_types/mock_types.go on lines 693..697
cmd/aergocli/cmd/mock_types/mock_types.go on lines 713..717
cmd/aergocli/cmd/mock_types/mock_types.go on lines 733..737
cmd/aergocli/cmd/mock_types/mock_types.go on lines 753..757
cmd/aergocli/cmd/mock_types/mock_types.go on lines 773..777
cmd/aergocli/cmd/mock_types/mock_types.go on lines 793..797
cmd/aergocli/cmd/mock_types/mock_types.go on lines 813..817
cmd/aergocli/cmd/mock_types/mock_types.go on lines 833..837
cmd/aergocli/cmd/mock_types/mock_types.go on lines 853..857
cmd/aergocli/cmd/mock_types/mock_types.go on lines 873..877
cmd/aergocli/cmd/mock_types/mock_types.go on lines 893..897
p2p/p2pmock/mock_host.go on lines 169..173
p2p/p2pmock/mock_networktransport.go on lines 269..273
p2p/p2pmock/mock_networktransport.go on lines 331..335

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

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 getGenesis(path string) *types.Genesis {
    file, err := os.Open(path)
    if err != nil {
        fmt.Printf("fail to open %s \n", path)
        return nil
Severity: Major
Found in tools/genesisdump/main.go and 1 other location - About 1 hr to fix
cmd/aergosvr/init.go on lines 79..92

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

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 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 Web3APIv1.GetState has 54 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (api *Web3APIv1) GetState() (handler http.Handler, ok bool) {
        values, err := url.ParseQuery(api.request.URL.RawQuery)
        if err != nil {
            return commonResponseHandler(&types.Empty{}, err), true
        }
    Severity: Minor
    Found in rpc/web3/v1.go - About 1 hr to fix

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

      func (cp *CommitProgress) UpdateRequest(ce *commitEntry) {
          logger.Debug().Uint64("term", ce.term).Uint64("index", ce.index).Uint64("no", ce.block.BlockNo()).Str("hash", ce.block.ID()).Msg("set progress of last request block")
      
          cp.Lock()
          defer cp.Unlock()
      Severity: Major
      Found in consensus/impl/raftv2/raftserver.go and 1 other location - About 1 hr to fix
      consensus/impl/raftv2/raftserver.go on lines 148..155

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

      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 (cp *CommitProgress) UpdateConnect(ce *commitEntry) {
          logger.Debug().Uint64("term", ce.term).Uint64("index", ce.index).Uint64("no", ce.block.BlockNo()).Str("hash", ce.block.ID()).Msg("set progress of last connected block")
      
          cp.Lock()
          defer cp.Unlock()
      Severity: Major
      Found in consensus/impl/raftv2/raftserver.go and 1 other location - About 1 hr to fix
      consensus/impl/raftv2/raftserver.go on lines 157..164

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

      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 BaseComponent.Start has 53 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (base *BaseComponent) Start() {
          // call a init func, defined at an actor's implementation
          base.IActor.BeforeStart()
      
          skipResumeStrategy := actor.NewOneForOneStrategy(0, 0, resumeDecider)
      Severity: Minor
      Found in pkg/component/component.go - About 1 hr to fix

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

        func (r *Receipt) marshalStoreBinary() ([]byte, error) {
            var b bytes.Buffer
        
            err := r.marshalBody(&b, false)
            if err != nil {
        Severity: Major
        Found in types/receipt.go and 1 other location - About 1 hr to fix
        types/receipt.go on lines 146..162

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

        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) marshalStoreBinaryV2() ([]byte, error) {
            var b bytes.Buffer
        
            err := r.marshalBodyV2(&b, false)
            if err != nil {
        Severity: Major
        Found in types/receipt.go and 1 other location - About 1 hr to fix
        types/receipt.go on lines 128..144

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

        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 3 locations. Consider refactoring.
        Open

        func (api *Web3APIv1) GetConsensusInfo() (handler http.Handler, ok bool) {
            request := &types.Empty{}
        
            result, err := api.rpc.GetConsensusInfo(api.request.Context(), request)
            if err != nil {
        Severity: Major
        Found in rpc/web3/v1.go and 2 other locations - About 1 hr to fix
        rpc/web3/v1.go on lines 608..618
        rpc/web3/v1.go on lines 620..630

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

        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 3 locations. Consider refactoring.
        Open

        func (api *Web3APIv1) GetChainInfo() (handler http.Handler, ok bool) {
            request := &types.Empty{}
        
            result, err := api.rpc.GetChainInfo(api.request.Context(), request)
            if err != nil {
        Severity: Major
        Found in rpc/web3/v1.go and 2 other locations - About 1 hr to fix
        rpc/web3/v1.go on lines 620..630
        rpc/web3/v1.go on lines 632..642

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

        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 3 locations. Consider refactoring.
        Open

        func (api *Web3APIv1) ChainStat() (handler http.Handler, ok bool) {
            request := &types.Empty{}
        
            result, err := api.rpc.ChainStat(api.request.Context(), request)
            if err != nil {
        Severity: Major
        Found in rpc/web3/v1.go and 2 other locations - About 1 hr to fix
        rpc/web3/v1.go on lines 608..618
        rpc/web3/v1.go on lines 632..642

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

        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 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 Cluster.isEnableChangeMembership has 11 return statements (exceeds 4 allowed).
        Open

        func (cl *Cluster) isEnableChangeMembership(cc *raftpb.ConfChange) error {
            status := cl.rs.Status()
            if status.ID == 0 {
                logger.Debug().Msg("raft node is not initialized")
                return ErrRaftStatusEmpty
        Severity: Major
        Found in consensus/impl/raftv2/cluster.go - About 1 hr to fix

          Method channelPipe.run has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
          Open

          func (c *channelPipe) run() {
          LOOP:
              for {
                  select {
                  case mo := <-c.in:
          Severity: Minor
          Found in p2p/p2putil/channelpipe.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

          Function CheckAndGetV1 has 11 return statements (exceeds 4 allowed).
          Open

          func CheckAndGetV1(cert *types.AgentCertificate) (*p2pcommon.AgentCertificateV1, error) {
              var err error
          
              wrap := &p2pcommon.AgentCertificateV1{Version: cert.CertVersion}
              wrap.BPID, err = peer.IDFromBytes(cert.BPID)
          Severity: Major
          Found in p2p/p2putil/certificate.go - About 1 hr to fix

            Method reorganizer.gather has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
            Open

            func (reorg *reorganizer) gather() error {
                //find branch root block , gather rollforward Target block
                var err error
                cdb := reorg.cs.cdb
            
            
            Severity: Minor
            Found in chain/reorg.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

            Severity
            Category
            Status
            Source
            Language