aergoio/aergo

View on GitHub

Showing 1,051 of 1,052 total issues

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

func (c *delb) parse(args string) (uint64, string, error) {
    splitArgs := context.SplitSpaceAndAccent(args, false)
    if len(splitArgs) < 2 {
        return 0, "", fmt.Errorf("need 2 arguments. usage: %s", c.Usage())
    }
Severity: Major
Found in cmd/brick/exec/debug.go and 1 other location - About 1 hr to fix
cmd/brick/exec/debug.go on lines 56..70

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

func (c *setb) parse(args string) (uint64, string, error) {
    splitArgs := context.SplitSpaceAndAccent(args, false)
    if len(splitArgs) < 2 {
        return 0, "", fmt.Errorf("need 2 arguments. usage: %s", c.Usage())
    }
Severity: Major
Found in cmd/brick/exec/debug.go and 1 other location - About 1 hr to fix
cmd/brick/exec/debug.go on lines 114..128

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) ListBlockMetadataStream(arg0 context.Context, arg1 *types.Empty, arg2 ...grpc.CallOption) (types.AergoRPCService_ListBlockMetadataStreamClient, 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 660..670
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

Method raftServer.serveChannels has 68 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (rs *raftServer) serveChannels() {
    defer RecoverExit()

    snapshot, err := rs.raftStorage.Snapshot()
    if err != nil {
Severity: Minor
Found in consensus/impl/raftv2/raftserver.go - About 1 hr to fix

    Method BlockFetcher.Start has 68 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (bf *BlockFetcher) Start() {
        bf.waitGroup = &sync.WaitGroup{}
        bf.waitGroup.Add(1)
    
        schedTicker := time.NewTicker(schedTick)
    Severity: Minor
    Found in syncer/blockfetcher.go - About 1 hr to fix

      Function Call has 68 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func Call(
          contractState *statedb.ContractState,
          payload, contractAddress []byte,
          ctx *vmContext,
      ) (string, []*types.Event, *big.Int, error) {
      Severity: Minor
      Found in contract/vm.go - About 1 hr to fix

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

        func (m *MockNetworkTransport) NewStream(arg0 context.Context, arg1 peer.ID, arg2 ...protocol.ID) (network.Stream, error) {
            m.ctrl.T.Helper()
            varargs := []interface{}{arg0, arg1}
            for _, a := range arg2 {
                varargs = append(varargs, a)
        Severity: Major
        Found in p2p/p2pmock/mock_networktransport.go and 2 other locations - About 1 hr to fix
        p2p/p2pmock/mock_host.go on lines 156..166
        p2p/p2pmock/mock_networktransport.go on lines 256..266

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

        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 *MockNetworkTransport) GetOrCreateStreamWithTTL(arg0 p2pcommon.PeerMeta, arg1 time.Duration, arg2 ...protocol.ID) (network.Stream, error) {
            m.ctrl.T.Helper()
            varargs := []interface{}{arg0, arg1}
            for _, a := range arg2 {
                varargs = append(varargs, a)
        Severity: Major
        Found in p2p/p2pmock/mock_networktransport.go and 2 other locations - About 1 hr to fix
        p2p/p2pmock/mock_host.go on lines 156..166
        p2p/p2pmock/mock_networktransport.go on lines 318..328

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

        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 *MockHost) NewStream(arg0 context.Context, arg1 peer.ID, arg2 ...protocol.ID) (network.Stream, error) {
            m.ctrl.T.Helper()
            varargs := []interface{}{arg0, arg1}
            for _, a := range arg2 {
                varargs = append(varargs, a)
        Severity: Major
        Found in p2p/p2pmock/mock_host.go and 2 other locations - About 1 hr to fix
        p2p/p2pmock/mock_networktransport.go on lines 256..266
        p2p/p2pmock/mock_networktransport.go on lines 318..328

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

        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 *V030Handshaker) handleGoAway(peerID types.PeerID, data p2pcommon.Message) (*types.Status, error) {
            goAway := &types.GoAwayNotice{}
            if err := p2putil.UnmarshalMessageBody(data.Payload(), goAway); err != nil {
                h.logger.Warn().Stringer(p2putil.LogPeerID, types.LogPeerShort(peerID)).Err(err).Msg("Remote peer sent goAway but failed to decode internal message")
                return nil, err
        Severity: Major
        Found in p2p/v030/v030handshake.go and 1 other location - About 1 hr to fix
        p2p/v200/v200handshake.go on lines 242..249

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

        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 *V200Handshaker) handleGoAway(peerID types.PeerID, data p2pcommon.Message) (*types.Status, error) {
            goAway := &types.GoAwayNotice{}
            if err := p2putil.UnmarshalMessageBody(data.Payload(), goAway); err != nil {
                h.logger.Warn().Stringer(p2putil.LogPeerID, types.LogPeerShort(peerID)).Err(err).Msg("Remote peer sent goAway but failed to decode internal message")
                return nil, err
        Severity: Major
        Found in p2p/v200/v200handshake.go and 1 other location - About 1 hr to fix
        p2p/v030/v030handshake.go on lines 219..226

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

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

        func LoadDummyChainEx(chainType ChainType) (*DummyChain, error) {
            var err error
            var gasPrice *big.Int
        
            switch chainType {
        Severity: Minor
        Found in contract/vm_direct/vm_direct.go - About 1 hr to fix

          Function luaDelegateCallContract has 67 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func luaDelegateCallContract(L *LState, service C.int, contractId *C.char,
              fname *C.char, args *C.char, gas uint64) (C.int, *C.char) {
              contractIdStr := C.GoString(contractId)
              fnameStr := C.GoString(fname)
              argsStr := C.GoString(args)
          Severity: Minor
          Found in contract/vm_callback.go - About 1 hr to fix

            Function ValidateSystemTx has 18 return statements (exceeds 4 allowed).
            Open

            func ValidateSystemTx(account []byte, txBody *types.TxBody, sender *state.AccountState,
                scs *statedb.ContractState, blockInfo *types.BlockHeaderInfo) (*SystemContext, error) {
                var ci types.CallInfo
                if err := json.Unmarshal(txBody.Payload, &ci); err != nil {
                    return nil, types.ErrTxInvalidPayload
            Severity: Major
            Found in contract/system/validation.go - About 1 hr to fix

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

              func (dpm *dynamicWPManager) OnPeerDisconnect(peer p2pcommon.RemotePeer) {
                  // if peer is designated peer or trusted enough , try reconnect by add peermeta to waiting peer
                  // TODO check by trust level is not implemented yet.
                  if _, ok := dpm.pm.designatedPeers[peer.ID()]; ok {
                      dpm.logger.Debug().Str(p2putil.LogPeerID, peer.Name()).Msg("server will try to reconnect designated peer after cooltime")
              Severity: Major
              Found in p2p/waitpeermanager.go and 1 other location - About 1 hr to fix
              p2p/waitpeermanager.go on lines 286..293

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

              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

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

                  if data.Subprotocol() != p2pcommon.StatusRequest {
                      if data.Subprotocol() == p2pcommon.GoAway {
                          return h.handleGoAway(h.peerID, data)
                      } else {
                          h.logger.Info().Stringer(p2putil.LogPeerID, types.LogPeerShort(h.peerID)).Str("expected", p2pcommon.StatusRequest.String()).Str("actual", data.Subprotocol().String()).Msg("unexpected message type")
              Severity: Major
              Found in p2p/v200/v200handshake.go and 1 other location - About 1 hr to fix
              p2p/v030/v030handshake.go on lines 116..124

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

              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

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

                  if data.Subprotocol() != p2pcommon.StatusRequest {
                      if data.Subprotocol() == p2pcommon.GoAway {
                          return h.handleGoAway(h.peerID, data)
                      } else {
                          h.logger.Info().Stringer(p2putil.LogPeerID, types.LogPeerShort(h.peerID)).Str("expected", p2pcommon.StatusRequest.String()).Str("actual", data.Subprotocol().String()).Msg("unexpected message type")
              Severity: Major
              Found in p2p/v030/v030handshake.go and 1 other location - About 1 hr to fix
              p2p/v200/v200handshake.go on lines 137..145

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

              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 (spm *staticWPManager) OnPeerDisconnect(peer p2pcommon.RemotePeer) {
                  // if peer is designated peer , try reconnect by add peermeta to waiting peer
                  if _, ok := spm.pm.designatedPeers[peer.ID()]; ok {
                      spm.logger.Debug().Str(p2putil.LogPeerID, peer.Name()).Msg("server will try to reconnect designated peer after cooltime")
                      // These peers must have cool time.
              Severity: Major
              Found in p2p/waitpeermanager.go and 1 other location - About 1 hr to fix
              p2p/waitpeermanager.go on lines 311..320

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

              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

                  case *message.UnlockAccount:
                      actualAddress := msg.Account.Address
                      var err error
                      if len(actualAddress) == types.NameLength {
                          actualAddress, err = as.resolveName(actualAddress)
              Severity: Major
              Found in account/accountservice.go and 1 other location - About 1 hr to fix
              account/accountservice.go on lines 83..96

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

              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

                  case *message.LockAccount:
                      actualAddress := msg.Account.Address
                      var err error
                      if len(actualAddress) == types.NameLength {
                          actualAddress, err = as.resolveName(actualAddress)
              Severity: Major
              Found in account/accountservice.go and 1 other location - About 1 hr to fix
              account/accountservice.go on lines 97..110

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

              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