aergoio/aergo

View on GitHub

Showing 1,051 of 1,052 total issues

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

func (m *MockAergoRPCServiceClient) GetChainInfo(arg0 context.Context, arg1 *types.Empty, arg2 ...grpc.CallOption) (*types.ChainInfo, error) {
    m.ctrl.T.Helper()
    varargs := []interface{}{arg0, arg1}
    for _, a := range arg2 {
        varargs = append(varargs, a)
Severity: Major
Found in cmd/aergocli/cmd/mock_types/mock_types.go and 39 other locations - About 1 hr to fix
cmd/aergocli/cmd/mock_types/mock_types.go on lines 40..50
cmd/aergocli/cmd/mock_types/mock_types.go on lines 60..70
cmd/aergocli/cmd/mock_types/mock_types.go on lines 80..90
cmd/aergocli/cmd/mock_types/mock_types.go on lines 100..110
cmd/aergocli/cmd/mock_types/mock_types.go on lines 120..130
cmd/aergocli/cmd/mock_types/mock_types.go on lines 140..150
cmd/aergocli/cmd/mock_types/mock_types.go on lines 160..170
cmd/aergocli/cmd/mock_types/mock_types.go on lines 180..190
cmd/aergocli/cmd/mock_types/mock_types.go on lines 200..210
cmd/aergocli/cmd/mock_types/mock_types.go on lines 220..230
cmd/aergocli/cmd/mock_types/mock_types.go on lines 240..250
cmd/aergocli/cmd/mock_types/mock_types.go on lines 260..270
cmd/aergocli/cmd/mock_types/mock_types.go on lines 280..290
cmd/aergocli/cmd/mock_types/mock_types.go on lines 300..310
cmd/aergocli/cmd/mock_types/mock_types.go on lines 340..350
cmd/aergocli/cmd/mock_types/mock_types.go on lines 360..370
cmd/aergocli/cmd/mock_types/mock_types.go on lines 380..390
cmd/aergocli/cmd/mock_types/mock_types.go on lines 400..410
cmd/aergocli/cmd/mock_types/mock_types.go on lines 420..430
cmd/aergocli/cmd/mock_types/mock_types.go on lines 440..450
cmd/aergocli/cmd/mock_types/mock_types.go on lines 460..470
cmd/aergocli/cmd/mock_types/mock_types.go on lines 480..490
cmd/aergocli/cmd/mock_types/mock_types.go on lines 500..510
cmd/aergocli/cmd/mock_types/mock_types.go on lines 520..530
cmd/aergocli/cmd/mock_types/mock_types.go on lines 540..550
cmd/aergocli/cmd/mock_types/mock_types.go on lines 560..570
cmd/aergocli/cmd/mock_types/mock_types.go on lines 580..590
cmd/aergocli/cmd/mock_types/mock_types.go on lines 600..610
cmd/aergocli/cmd/mock_types/mock_types.go on lines 620..630
cmd/aergocli/cmd/mock_types/mock_types.go on lines 700..710
cmd/aergocli/cmd/mock_types/mock_types.go on lines 720..730
cmd/aergocli/cmd/mock_types/mock_types.go on lines 740..750
cmd/aergocli/cmd/mock_types/mock_types.go on lines 760..770
cmd/aergocli/cmd/mock_types/mock_types.go on lines 780..790
cmd/aergocli/cmd/mock_types/mock_types.go on lines 800..810
cmd/aergocli/cmd/mock_types/mock_types.go on lines 820..830
cmd/aergocli/cmd/mock_types/mock_types.go on lines 840..850
cmd/aergocli/cmd/mock_types/mock_types.go on lines 860..870
cmd/aergocli/cmd/mock_types/mock_types.go on lines 880..890

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

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

func (m *MockAergoRPCServiceClient) ListBlockHeaders(arg0 context.Context, arg1 *types.ListParams, arg2 ...grpc.CallOption) (*types.BlockHeaderList, error) {
    m.ctrl.T.Helper()
    varargs := []interface{}{arg0, arg1}
    for _, a := range arg2 {
        varargs = append(varargs, a)
Severity: Major
Found in cmd/aergocli/cmd/mock_types/mock_types.go and 39 other locations - About 1 hr to fix
cmd/aergocli/cmd/mock_types/mock_types.go on lines 40..50
cmd/aergocli/cmd/mock_types/mock_types.go on lines 60..70
cmd/aergocli/cmd/mock_types/mock_types.go on lines 80..90
cmd/aergocli/cmd/mock_types/mock_types.go on lines 100..110
cmd/aergocli/cmd/mock_types/mock_types.go on lines 120..130
cmd/aergocli/cmd/mock_types/mock_types.go on lines 140..150
cmd/aergocli/cmd/mock_types/mock_types.go on lines 160..170
cmd/aergocli/cmd/mock_types/mock_types.go on lines 180..190
cmd/aergocli/cmd/mock_types/mock_types.go on lines 200..210
cmd/aergocli/cmd/mock_types/mock_types.go on lines 220..230
cmd/aergocli/cmd/mock_types/mock_types.go on lines 240..250
cmd/aergocli/cmd/mock_types/mock_types.go on lines 260..270
cmd/aergocli/cmd/mock_types/mock_types.go on lines 280..290
cmd/aergocli/cmd/mock_types/mock_types.go on lines 300..310
cmd/aergocli/cmd/mock_types/mock_types.go on lines 320..330
cmd/aergocli/cmd/mock_types/mock_types.go on lines 340..350
cmd/aergocli/cmd/mock_types/mock_types.go on lines 360..370
cmd/aergocli/cmd/mock_types/mock_types.go on lines 380..390
cmd/aergocli/cmd/mock_types/mock_types.go on lines 400..410
cmd/aergocli/cmd/mock_types/mock_types.go on lines 420..430
cmd/aergocli/cmd/mock_types/mock_types.go on lines 440..450
cmd/aergocli/cmd/mock_types/mock_types.go on lines 460..470
cmd/aergocli/cmd/mock_types/mock_types.go on lines 480..490
cmd/aergocli/cmd/mock_types/mock_types.go on lines 500..510
cmd/aergocli/cmd/mock_types/mock_types.go on lines 520..530
cmd/aergocli/cmd/mock_types/mock_types.go on lines 540..550
cmd/aergocli/cmd/mock_types/mock_types.go on lines 560..570
cmd/aergocli/cmd/mock_types/mock_types.go on lines 580..590
cmd/aergocli/cmd/mock_types/mock_types.go on lines 620..630
cmd/aergocli/cmd/mock_types/mock_types.go on lines 700..710
cmd/aergocli/cmd/mock_types/mock_types.go on lines 720..730
cmd/aergocli/cmd/mock_types/mock_types.go on lines 740..750
cmd/aergocli/cmd/mock_types/mock_types.go on lines 760..770
cmd/aergocli/cmd/mock_types/mock_types.go on lines 780..790
cmd/aergocli/cmd/mock_types/mock_types.go on lines 800..810
cmd/aergocli/cmd/mock_types/mock_types.go on lines 820..830
cmd/aergocli/cmd/mock_types/mock_types.go on lines 840..850
cmd/aergocli/cmd/mock_types/mock_types.go on lines 860..870
cmd/aergocli/cmd/mock_types/mock_types.go on lines 880..890

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

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

func (m *MockAergoRPCServiceClient) GetAccounts(arg0 context.Context, arg1 *types.Empty, arg2 ...grpc.CallOption) (*types.AccountList, error) {
    m.ctrl.T.Helper()
    varargs := []interface{}{arg0, arg1}
    for _, a := range arg2 {
        varargs = append(varargs, a)
Severity: Major
Found in cmd/aergocli/cmd/mock_types/mock_types.go and 39 other locations - About 1 hr to fix
cmd/aergocli/cmd/mock_types/mock_types.go on lines 40..50
cmd/aergocli/cmd/mock_types/mock_types.go on lines 60..70
cmd/aergocli/cmd/mock_types/mock_types.go on lines 80..90
cmd/aergocli/cmd/mock_types/mock_types.go on lines 100..110
cmd/aergocli/cmd/mock_types/mock_types.go on lines 120..130
cmd/aergocli/cmd/mock_types/mock_types.go on lines 140..150
cmd/aergocli/cmd/mock_types/mock_types.go on lines 160..170
cmd/aergocli/cmd/mock_types/mock_types.go on lines 180..190
cmd/aergocli/cmd/mock_types/mock_types.go on lines 200..210
cmd/aergocli/cmd/mock_types/mock_types.go on lines 240..250
cmd/aergocli/cmd/mock_types/mock_types.go on lines 260..270
cmd/aergocli/cmd/mock_types/mock_types.go on lines 280..290
cmd/aergocli/cmd/mock_types/mock_types.go on lines 300..310
cmd/aergocli/cmd/mock_types/mock_types.go on lines 320..330
cmd/aergocli/cmd/mock_types/mock_types.go on lines 340..350
cmd/aergocli/cmd/mock_types/mock_types.go on lines 360..370
cmd/aergocli/cmd/mock_types/mock_types.go on lines 380..390
cmd/aergocli/cmd/mock_types/mock_types.go on lines 400..410
cmd/aergocli/cmd/mock_types/mock_types.go on lines 420..430
cmd/aergocli/cmd/mock_types/mock_types.go on lines 440..450
cmd/aergocli/cmd/mock_types/mock_types.go on lines 460..470
cmd/aergocli/cmd/mock_types/mock_types.go on lines 480..490
cmd/aergocli/cmd/mock_types/mock_types.go on lines 500..510
cmd/aergocli/cmd/mock_types/mock_types.go on lines 520..530
cmd/aergocli/cmd/mock_types/mock_types.go on lines 540..550
cmd/aergocli/cmd/mock_types/mock_types.go on lines 560..570
cmd/aergocli/cmd/mock_types/mock_types.go on lines 580..590
cmd/aergocli/cmd/mock_types/mock_types.go on lines 600..610
cmd/aergocli/cmd/mock_types/mock_types.go on lines 620..630
cmd/aergocli/cmd/mock_types/mock_types.go on lines 700..710
cmd/aergocli/cmd/mock_types/mock_types.go on lines 720..730
cmd/aergocli/cmd/mock_types/mock_types.go on lines 740..750
cmd/aergocli/cmd/mock_types/mock_types.go on lines 760..770
cmd/aergocli/cmd/mock_types/mock_types.go on lines 780..790
cmd/aergocli/cmd/mock_types/mock_types.go on lines 800..810
cmd/aergocli/cmd/mock_types/mock_types.go on lines 820..830
cmd/aergocli/cmd/mock_types/mock_types.go on lines 840..850
cmd/aergocli/cmd/mock_types/mock_types.go on lines 860..870
cmd/aergocli/cmd/mock_types/mock_types.go on lines 880..890

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

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

func (m *MockAergoRPCServiceClient) SignTX(arg0 context.Context, arg1 *types.Tx, arg2 ...grpc.CallOption) (*types.Tx, error) {
    m.ctrl.T.Helper()
    varargs := []interface{}{arg0, arg1}
    for _, a := range arg2 {
        varargs = append(varargs, a)
Severity: Major
Found in cmd/aergocli/cmd/mock_types/mock_types.go and 39 other locations - About 1 hr to fix
cmd/aergocli/cmd/mock_types/mock_types.go on lines 40..50
cmd/aergocli/cmd/mock_types/mock_types.go on lines 60..70
cmd/aergocli/cmd/mock_types/mock_types.go on lines 80..90
cmd/aergocli/cmd/mock_types/mock_types.go on lines 100..110
cmd/aergocli/cmd/mock_types/mock_types.go on lines 120..130
cmd/aergocli/cmd/mock_types/mock_types.go on lines 140..150
cmd/aergocli/cmd/mock_types/mock_types.go on lines 160..170
cmd/aergocli/cmd/mock_types/mock_types.go on lines 180..190
cmd/aergocli/cmd/mock_types/mock_types.go on lines 200..210
cmd/aergocli/cmd/mock_types/mock_types.go on lines 220..230
cmd/aergocli/cmd/mock_types/mock_types.go on lines 240..250
cmd/aergocli/cmd/mock_types/mock_types.go on lines 260..270
cmd/aergocli/cmd/mock_types/mock_types.go on lines 280..290
cmd/aergocli/cmd/mock_types/mock_types.go on lines 300..310
cmd/aergocli/cmd/mock_types/mock_types.go on lines 320..330
cmd/aergocli/cmd/mock_types/mock_types.go on lines 340..350
cmd/aergocli/cmd/mock_types/mock_types.go on lines 360..370
cmd/aergocli/cmd/mock_types/mock_types.go on lines 380..390
cmd/aergocli/cmd/mock_types/mock_types.go on lines 400..410
cmd/aergocli/cmd/mock_types/mock_types.go on lines 420..430
cmd/aergocli/cmd/mock_types/mock_types.go on lines 440..450
cmd/aergocli/cmd/mock_types/mock_types.go on lines 460..470
cmd/aergocli/cmd/mock_types/mock_types.go on lines 480..490
cmd/aergocli/cmd/mock_types/mock_types.go on lines 500..510
cmd/aergocli/cmd/mock_types/mock_types.go on lines 520..530
cmd/aergocli/cmd/mock_types/mock_types.go on lines 540..550
cmd/aergocli/cmd/mock_types/mock_types.go on lines 560..570
cmd/aergocli/cmd/mock_types/mock_types.go on lines 580..590
cmd/aergocli/cmd/mock_types/mock_types.go on lines 600..610
cmd/aergocli/cmd/mock_types/mock_types.go on lines 620..630
cmd/aergocli/cmd/mock_types/mock_types.go on lines 700..710
cmd/aergocli/cmd/mock_types/mock_types.go on lines 720..730
cmd/aergocli/cmd/mock_types/mock_types.go on lines 740..750
cmd/aergocli/cmd/mock_types/mock_types.go on lines 760..770
cmd/aergocli/cmd/mock_types/mock_types.go on lines 780..790
cmd/aergocli/cmd/mock_types/mock_types.go on lines 800..810
cmd/aergocli/cmd/mock_types/mock_types.go on lines 820..830
cmd/aergocli/cmd/mock_types/mock_types.go on lines 860..870
cmd/aergocli/cmd/mock_types/mock_types.go on lines 880..890

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

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

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

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

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

Refactorings

Further Reading

Function NewChainService has 70 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func NewChainService(cfg *cfg.Config) *ChainService {
    cs := &ChainService{
        cfg:  cfg,
        op:   NewOrphanPool(DfltOrphanPoolSize),
        stat: newStats(),
Severity: Minor
Found in chain/chainservice.go - About 1 hr to fix

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

    func (m *LogPeersMarshaller) MarshalZerologArray(a *zerolog.Array) {
        size := len(m.metas)
        if size > m.limit {
            for i := 0; i < m.limit-1; i++ {
                a.Str(m.metas[i].Name())
    Severity: Major
    Found in p2p/p2putil/loggingutil.go and 1 other location - About 1 hr to fix
    p2p/p2putil/loggingutil.go on lines 70..82

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

    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 (m *LogStringersMarshaller) MarshalZerologArray(a *zerolog.Array) {
        size := len(m.arr)
        if size > m.limit {
            for i := 0; i < m.limit-1; i++ {
                a.Str(m.arr[i].String())
    Severity: Major
    Found in p2p/p2putil/loggingutil.go and 1 other location - About 1 hr to fix
    p2p/p2putil/loggingutil.go on lines 117..129

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

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

    func (m ListEntriesMarshaller) MarshalZerologArray(a *zerolog.Array) {
        size := len(m.arr)
        if size > m.limit {
            for i := 0; i < m.limit-1; i++ {
                a.Str(m.arr[i].String())
    Severity: Major
    Found in cmd/polaris/server/listmanager.go and 3 other locations - About 1 hr to fix
    p2p/p2putil/loggingutil.go on lines 186..198
    types/p2plogging.go on lines 75..87
    types/p2plogging.go on lines 94..106

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

    func (m RaftMbrsMarshaller) MarshalZerologArray(a *zerolog.Array) {
        size := len(m.arr)
        if size > m.limit {
            for i := 0; i < m.limit-1; i++ {
                a.Str(m.arr[i].GetName())
    Severity: Major
    Found in types/p2plogging.go and 3 other locations - About 1 hr to fix
    cmd/polaris/server/listmanager.go on lines 196..208
    p2p/p2putil/loggingutil.go on lines 186..198
    types/p2plogging.go on lines 75..87

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

    func (m LogIPNetMarshaller) MarshalZerologArray(a *zerolog.Array) {
        size := len(m.arr)
        if size > m.limit {
            for i := 0; i < m.limit-1; i++ {
                a.Str(m.arr[i].String())
    Severity: Major
    Found in p2p/p2putil/loggingutil.go and 3 other locations - About 1 hr to fix
    cmd/polaris/server/listmanager.go on lines 196..208
    types/p2plogging.go on lines 75..87
    types/p2plogging.go on lines 94..106

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

    func (m LogTxIDsMarshaller) MarshalZerologArray(a *zerolog.Array) {
        size := len(m.arr)
        if size > m.limit {
            for i := 0; i < m.limit-1; i++ {
                a.Str(m.arr[i].String())
    Severity: Major
    Found in types/p2plogging.go and 3 other locations - About 1 hr to fix
    cmd/polaris/server/listmanager.go on lines 196..208
    p2p/p2putil/loggingutil.go on lines 186..198
    types/p2plogging.go on lines 94..106

    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

    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 Trie.maybeDeleteSubTree has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
      Open

      func (s *Trie) maybeDeleteSubTree(original, maybeDelete []byte, height, iBatch int, batch, batch2 [][]byte, ch chan<- (error)) {
          if height == 0 {
              if !bytes.Equal(original, maybeDelete) && len(maybeDelete) != 0 {
                  s.maybeDeleteRevertedNode(maybeDelete, 0)
              }
      Severity: Minor
      Found in pkg/trie/trie_revert.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 luaGovernance has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
      Open

      func luaGovernance(L *LState, service C.int, gType C.char, arg *C.char) *C.char {
      
          ctx := contexts[service]
          if ctx == nil {
              return C.CString("[Contract.LuaGovernance] contract state not found")
      Severity: Minor
      Found in contract/vm_callback.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 ValidateSystemTx has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
      Open

      func ValidateSystemTx(tx *TxBody) error {
          var ci CallInfo
          if err := json.Unmarshal(tx.Payload, &ci); err != nil {
              return ErrTxInvalidPayload
          }
      Severity: Minor
      Found in types/transaction.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 Create has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
      Open

      func Create(
          contractState *statedb.ContractState,
          code, contractAddress []byte,
          ctx *vmContext,
      ) (string, []*types.Event, *big.Int, error) {
      Severity: Minor
      Found in contract/vm.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

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

      func (m *MockAergoRPCServiceClient) ListEventStream(arg0 context.Context, arg1 *types.FilterInfo, arg2 ...grpc.CallOption) (types.AergoRPCService_ListEventStreamClient, error) {
          m.ctrl.T.Helper()
          varargs := []interface{}{arg0, arg1}
          for _, a := range arg2 {
              varargs = append(varargs, a)
      Severity: Major
      Found in cmd/aergocli/cmd/mock_types/mock_types.go and 2 other locations - About 1 hr to fix
      cmd/aergocli/cmd/mock_types/mock_types.go on lines 640..650
      cmd/aergocli/cmd/mock_types/mock_types.go on lines 660..670

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

      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 (m *MockAergoRPCServiceClient) ListBlockStream(arg0 context.Context, arg1 *types.Empty, arg2 ...grpc.CallOption) (types.AergoRPCService_ListBlockStreamClient, error) {
          m.ctrl.T.Helper()
          varargs := []interface{}{arg0, arg1}
          for _, a := range arg2 {
              varargs = append(varargs, a)
      Severity: Major
      Found in cmd/aergocli/cmd/mock_types/mock_types.go and 2 other locations - About 1 hr to fix
      cmd/aergocli/cmd/mock_types/mock_types.go on lines 640..650
      cmd/aergocli/cmd/mock_types/mock_types.go on lines 680..690

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

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

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

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

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

      Refactorings

      Further Reading

      Severity
      Category
      Status
      Source
      Language