aergoio/aergo

View on GitHub

Showing 1,051 of 1,052 total issues

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

func (m *MockReadCloser) Read(arg0 []byte) (int, error) {
    m.ctrl.T.Helper()
    ret := m.ctrl.Call(m, "Read", arg0)
    ret0, _ := ret[0].(int)
    ret1, _ := ret[1].(error)
Severity: Major
Found in p2p/p2pmock/mock_io.go and 7 other locations - About 40 mins to fix
p2p/p2pmock/mock_io.go on lines 36..42
p2p/p2pmock/mock_io.go on lines 126..132
p2p/p2pmock/mock_io.go on lines 178..184
p2p/p2pmock/mock_io.go on lines 230..236
p2p/p2pmock/mock_io.go on lines 245..251
p2p/p2pmock/mock_stream.go on lines 127..133
p2p/p2pmock/mock_stream.go on lines 224..230

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

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

func (m *MockWriter) Write(arg0 []byte) (int, error) {
    m.ctrl.T.Helper()
    ret := m.ctrl.Call(m, "Write", arg0)
    ret0, _ := ret[0].(int)
    ret1, _ := ret[1].(error)
Severity: Major
Found in p2p/p2pmock/mock_io.go and 7 other locations - About 40 mins to fix
p2p/p2pmock/mock_io.go on lines 36..42
p2p/p2pmock/mock_io.go on lines 88..94
p2p/p2pmock/mock_io.go on lines 178..184
p2p/p2pmock/mock_io.go on lines 230..236
p2p/p2pmock/mock_io.go on lines 245..251
p2p/p2pmock/mock_stream.go on lines 127..133
p2p/p2pmock/mock_stream.go on lines 224..230

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

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

func (m *MockWriteCloser) Write(arg0 []byte) (int, error) {
    m.ctrl.T.Helper()
    ret := m.ctrl.Call(m, "Write", arg0)
    ret0, _ := ret[0].(int)
    ret1, _ := ret[1].(error)
Severity: Major
Found in p2p/p2pmock/mock_io.go and 7 other locations - About 40 mins to fix
p2p/p2pmock/mock_io.go on lines 36..42
p2p/p2pmock/mock_io.go on lines 88..94
p2p/p2pmock/mock_io.go on lines 126..132
p2p/p2pmock/mock_io.go on lines 230..236
p2p/p2pmock/mock_io.go on lines 245..251
p2p/p2pmock/mock_stream.go on lines 127..133
p2p/p2pmock/mock_stream.go on lines 224..230

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

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

func (m *MockStream) Read(arg0 []byte) (int, error) {
    m.ctrl.T.Helper()
    ret := m.ctrl.Call(m, "Read", arg0)
    ret0, _ := ret[0].(int)
    ret1, _ := ret[1].(error)
Severity: Major
Found in p2p/p2pmock/mock_stream.go and 7 other locations - About 40 mins to fix
p2p/p2pmock/mock_io.go on lines 36..42
p2p/p2pmock/mock_io.go on lines 88..94
p2p/p2pmock/mock_io.go on lines 126..132
p2p/p2pmock/mock_io.go on lines 178..184
p2p/p2pmock/mock_io.go on lines 230..236
p2p/p2pmock/mock_io.go on lines 245..251
p2p/p2pmock/mock_stream.go on lines 224..230

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

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

func (m *MockStream) Write(arg0 []byte) (int, error) {
    m.ctrl.T.Helper()
    ret := m.ctrl.Call(m, "Write", arg0)
    ret0, _ := ret[0].(int)
    ret1, _ := ret[1].(error)
Severity: Major
Found in p2p/p2pmock/mock_stream.go and 7 other locations - About 40 mins to fix
p2p/p2pmock/mock_io.go on lines 36..42
p2p/p2pmock/mock_io.go on lines 88..94
p2p/p2pmock/mock_io.go on lines 126..132
p2p/p2pmock/mock_io.go on lines 178..184
p2p/p2pmock/mock_io.go on lines 230..236
p2p/p2pmock/mock_io.go on lines 245..251
p2p/p2pmock/mock_stream.go on lines 127..133

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

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

func (m *MockReader) Read(arg0 []byte) (int, error) {
    m.ctrl.T.Helper()
    ret := m.ctrl.Call(m, "Read", arg0)
    ret0, _ := ret[0].(int)
    ret1, _ := ret[1].(error)
Severity: Major
Found in p2p/p2pmock/mock_io.go and 7 other locations - About 40 mins to fix
p2p/p2pmock/mock_io.go on lines 88..94
p2p/p2pmock/mock_io.go on lines 126..132
p2p/p2pmock/mock_io.go on lines 178..184
p2p/p2pmock/mock_io.go on lines 230..236
p2p/p2pmock/mock_io.go on lines 245..251
p2p/p2pmock/mock_stream.go on lines 127..133
p2p/p2pmock/mock_stream.go on lines 224..230

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

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 (h *baseWireHandshaker) writeWireHSRequest(hsHeader p2pcommon.HSHeadReq, wr io.Writer) (err error) {
    bytes := hsHeader.Marshal()
    sent, err := wr.Write(bytes)
    if err != nil {
        return
Severity: Minor
Found in p2p/handshakev2.go and 1 other location - About 40 mins to fix
p2p/handshakev2.go on lines 202..212

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

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

func (m *MockReadWriteCloser) Read(arg0 []byte) (int, error) {
    m.ctrl.T.Helper()
    ret := m.ctrl.Call(m, "Read", arg0)
    ret0, _ := ret[0].(int)
    ret1, _ := ret[1].(error)
Severity: Major
Found in p2p/p2pmock/mock_io.go and 7 other locations - About 40 mins to fix
p2p/p2pmock/mock_io.go on lines 36..42
p2p/p2pmock/mock_io.go on lines 88..94
p2p/p2pmock/mock_io.go on lines 126..132
p2p/p2pmock/mock_io.go on lines 178..184
p2p/p2pmock/mock_io.go on lines 245..251
p2p/p2pmock/mock_stream.go on lines 127..133
p2p/p2pmock/mock_stream.go on lines 224..230

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

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

func (m *MockReadWriteCloser) Write(arg0 []byte) (int, error) {
    m.ctrl.T.Helper()
    ret := m.ctrl.Call(m, "Write", arg0)
    ret0, _ := ret[0].(int)
    ret1, _ := ret[1].(error)
Severity: Major
Found in p2p/p2pmock/mock_io.go and 7 other locations - About 40 mins to fix
p2p/p2pmock/mock_io.go on lines 36..42
p2p/p2pmock/mock_io.go on lines 88..94
p2p/p2pmock/mock_io.go on lines 126..132
p2p/p2pmock/mock_io.go on lines 178..184
p2p/p2pmock/mock_io.go on lines 230..236
p2p/p2pmock/mock_stream.go on lines 127..133
p2p/p2pmock/mock_stream.go on lines 224..230

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

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 (tx *writableSqlTx) savepoint() error {
    if sqlLgr.IsDebugEnabled() {
        sqlLgr.Debug().Str("db_name", tx.litetree.name).Msg("savepoint")
    }
    _, err := tx.Tx.Exec("SAVEPOINT \"" + tx.litetree.name + "\"")
Severity: Minor
Found in contract/statesql.go and 1 other location - About 40 mins to fix
contract/statesql.go on lines 458..464

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

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 (h *baseWireHandshaker) writeWireHSResponse(hsHeader p2pcommon.HSHeadResp, wr io.Writer) (err error) {
    bytes := hsHeader.Marshal()
    sent, err := wr.Write(bytes)
    if err != nil {
        return
Severity: Minor
Found in p2p/handshakev2.go and 1 other location - About 40 mins to fix
p2p/handshakev2.go on lines 150..160

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

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 (tx *writableSqlTx) rollbackToSavepoint() error {
    if sqlLgr.IsDebugEnabled() {
        sqlLgr.Debug().Str("db_name", tx.litetree.name).Msg("rollback to savepoint")
    }
    _, err := tx.Tx.Exec("ROLLBACK TO SAVEPOINT \"" + tx.litetree.name + "\"")
Severity: Minor
Found in contract/statesql.go and 1 other location - About 40 mins to fix
contract/statesql.go on lines 422..428

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

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 (br *BlockHashesReceiver) ReceiveResp(msg p2pcommon.Message, msgBody p2pcommon.MessageBody) (ret bool) {
    // TODO this code is exact copy of BlocksChunkReceiver, so be lots of other codes in this file. consider refactoring
    ret = true
    switch br.status {
    case receiverStatusWaiting:
Severity: Minor
Found in p2p/hashreceiver.go and 2 other locations - About 40 mins to fix
p2p/blkreceiver.go on lines 64..84
p2p/txreceiver.go on lines 64..84

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

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 (br *BlocksChunkReceiver) ReceiveResp(msg p2pcommon.Message, msgBody p2pcommon.MessageBody) (ret bool) {
    // cases in waiting
    //   normal not status => wait
    //   normal status (last response)  => finish
    //   abnormal resp (no following resp expected): hasNext is true => cancel
Severity: Minor
Found in p2p/blkreceiver.go and 2 other locations - About 40 mins to fix
p2p/hashreceiver.go on lines 50..65
p2p/txreceiver.go on lines 64..84

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

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 (br *GetTxsReceiver) ReceiveResp(msg p2pcommon.Message, msgBody p2pcommon.MessageBody) (ret bool) {
    // cases in waiting
    //   normal not status => wait
    //   normal status (last response)  => finish
    //   abnormal resp (no following resp expected): hasNext is true => cancel
Severity: Minor
Found in p2p/txreceiver.go and 2 other locations - About 40 mins to fix
p2p/blkreceiver.go on lines 64..84
p2p/hashreceiver.go on lines 50..65

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

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

func NewAddressesRespHandler(pm p2pcommon.PeerManager, peer p2pcommon.RemotePeer, logger *log.Logger, actor p2pcommon.ActorService) *addressesResponseHandler {
    ph := &addressesResponseHandler{BaseMsgHandler{protocol: p2pcommon.AddressesResponse, pm: pm, peer: peer, actor: actor, logger: logger}}
    return ph
}
Severity: Major
Found in p2p/subproto/addrs.go and 4 other locations - About 35 mins to fix
p2p/subproto/addrs.go on lines 29..32
p2p/subproto/block.go on lines 127..130
p2p/subproto/getcluster.go on lines 68..71
p2p/subproto/tx.go on lines 65..68

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

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

func NewTxRespHandler(pm p2pcommon.PeerManager, peer p2pcommon.RemotePeer, logger *log.Logger, actor p2pcommon.ActorService) *txResponseHandler {
    th := &txResponseHandler{BaseMsgHandler{protocol: p2pcommon.GetTXsResponse, pm: pm, peer: peer, actor: actor, logger: logger}}
    return th
}
Severity: Major
Found in p2p/subproto/tx.go and 4 other locations - About 35 mins to fix
p2p/subproto/addrs.go on lines 29..32
p2p/subproto/addrs.go on lines 103..106
p2p/subproto/block.go on lines 127..130
p2p/subproto/getcluster.go on lines 68..71

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

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 c.SystemContext.BlockInfo.ForkVersion < 2 {
        jsonArgs = `{"who":"` + types.EncodeAddress(sender.ID()) + `", "amount":"` + balanceAdjustment.String() + `"}`
    } else {
        jsonArgs = `["` + types.EncodeAddress(sender.ID()) + `", {"_bignum":"` + balanceAdjustment.String() + `"}]`
    }
Severity: Minor
Found in contract/system/staking.go and 1 other location - About 35 mins to fix
contract/system/staking.go on lines 59..63

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

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 block.Size() > int(chain.MaxBlockSize()) {
        sm.logger.Info().Str(p2putil.LogPeerName, peer.Name()).Str(p2putil.LogBlkHash, block.BlockID().String()).Int("size", block.Size()).Msg("cancel to add block. block size exceed limit")
        return
    }
Severity: Minor
Found in p2p/syncmanager.go and 1 other location - About 35 mins to fix
p2p/syncmanager.go on lines 61..64

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

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

func NewGetBlockHeaderRespHandler(pm p2pcommon.PeerManager, peer p2pcommon.RemotePeer, logger *log.Logger, actor p2pcommon.ActorService) *getBlockHeadersResponseHandler {
    bh := &getBlockHeadersResponseHandler{BaseMsgHandler{protocol: p2pcommon.GetBlockHeadersResponse, pm: pm, peer: peer, actor: actor, logger: logger}}
    return bh
}
Severity: Major
Found in p2p/subproto/block.go and 4 other locations - About 35 mins to fix
p2p/subproto/addrs.go on lines 29..32
p2p/subproto/addrs.go on lines 103..106
p2p/subproto/getcluster.go on lines 68..71
p2p/subproto/tx.go on lines 65..68

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

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