aergoio/aergo

View on GitHub

Showing 1,051 of 1,052 total issues

Function SetContractOwner has 5 return statements (exceeds 4 allowed).
Open

func SetContractOwner(bs *state.BlockState, scs *statedb.ContractState,
    address string, nameState *state.AccountState) (*state.AccountState, error) {

    rawaddr, err := types.DecodeAddress(address)
    if err != nil {
Severity: Major
Found in contract/name/execute.go - About 35 mins to fix

    Method luaTxSend.run has 5 return statements (exceeds 4 allowed).
    Open

    func (l *luaTxSend) run(execCtx context.Context, bs *state.BlockState, bc *DummyChain, bi *types.BlockHeaderInfo, receiptTx db.Transaction) error {
        senderID := types.ToAccountID(l.sender)
        receiverID := types.ToAccountID(l.receiver)
    
        if senderID == receiverID {
    Severity: Major
    Found in contract/vm_dummy/vm_dummy.go - About 35 mins to fix

      Method ChainID.Read has 5 return statements (exceeds 4 allowed).
      Open

      func (cid *ChainID) Read(data []byte) error {
          r := bytes.NewBuffer(data)
      
          // warning: when any field added to ChainID, the corresponding
          // deserialization code must be written here.
      Severity: Major
      Found in types/genesis.go - About 35 mins to fix

        Function Execute has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
        Open

        func Execute(execCtx context.Context, bs *state.BlockState, cdb ChainAccessor, tx *types.Tx, sender, receiver *state.AccountState, bi *types.BlockHeaderInfo, executionMode int, isFeeDelegation bool) (rv string, events []*types.Event, usedFee *big.Int, err error) {
        
            var (
                txBody     = tx.GetBody()
                txType     = txBody.GetType()
        Severity: Minor
        Found in contract/contract.go - About 35 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Method Conf.Validate has 5 return statements (exceeds 4 allowed).
        Open

        func (c *Conf) Validate(key []byte, context *EnterpriseContext) error {
            if !c.On {
                return nil
            }
            strKey := strings.ToUpper(string(key))
        Severity: Major
        Found in contract/enterprise/config.go - About 35 mins to fix

          Function luaEvent has 5 return statements (exceeds 4 allowed).
          Open

          func luaEvent(L *LState, service C.int, eventName *C.char, args *C.char) *C.char {
              ctx := contexts[service]
              if ctx.isQuery == true || ctx.nestedView > 0 {
                  return C.CString("[Contract.Event] event not permitted in query")
              }
          Severity: Major
          Found in contract/vm_callback.go - About 35 mins to fix

            Function ExecuteNameTx has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
            Open

            func ExecuteNameTx(bs *state.BlockState, scs *statedb.ContractState, txBody *types.TxBody,
                sender, receiver *state.AccountState, blockInfo *types.BlockHeaderInfo) ([]*types.Event, error) {
            
                ci, err := ValidateNameTx(txBody, sender, scs)
                if err != nil {
            Severity: Minor
            Found in contract/name/execute.go - About 35 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Function decodeRlpTrieNode has 5 return statements (exceeds 4 allowed).
            Open

            func decodeRlpTrieNode(data []byte) rlpNode {
                var (
                    dataLen = uint64(len(data))
                    node    rlpNode
                )
            Severity: Major
            Found in contract/ethstorageproof.go - About 35 mins to fix

              Function luaGetBalance has 5 return statements (exceeds 4 allowed).
              Open

              func luaGetBalance(L *LState, service C.int, contractId *C.char) (*C.char, *C.char) {
                  ctx := contexts[service]
                  if contractId == nil {
                      return C.CString(ctx.curContract.callState.ctrState.GetBalanceBigInt().String()), nil
                  }
              Severity: Major
              Found in contract/vm_callback.go - About 35 mins to fix

                Method SQLiteDriver.Open has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
                Open

                func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) {
                    if C.sqlite3_threadsafe() == 0 {
                        return nil, errors.New("sqlite library was not compiled for thread-safe operation")
                    }
                
                
                Severity: Minor
                Found in contract/sqlite3.go - About 35 mins to fix

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

                Function LuaGetDbHandleSnap has 5 return statements (exceeds 4 allowed).
                Open

                func LuaGetDbHandleSnap(service C.int, snap *C.char) *C.char {
                
                    stateSet := contexts[service]
                    curContract := stateSet.curContract
                    callState := curContract.callState
                Severity: Major
                Found in contract/vm_callback.go - About 35 mins to fix

                  Method FilterInfo.GetExArgFilter has 5 return statements (exceeds 4 allowed).
                  Open

                  func (fi *FilterInfo) GetExArgFilter() ([]ArgFilter, error) {
                      if len(fi.ArgFilter) == 0 {
                          return nil, nil
                      }
                  
                  
                  Severity: Major
                  Found in types/receipt.go - About 35 mins to fix

                    Method SQLiteRows.Next has 5 return statements (exceeds 4 allowed).
                    Open

                    func (rc *SQLiteRows) Next(dest []driver.Value) error {
                        rc.s.mu.Lock()
                        defer rc.s.mu.Unlock()
                        if rc.s.closed {
                            return io.EOF
                    Severity: Major
                    Found in contract/sqlite3.go - About 35 mins to fix

                      Function luaSetDB has 5 return statements (exceeds 4 allowed).
                      Open

                      func luaSetDB(L *LState, service C.int, key unsafe.Pointer, keyLen C.int, value *C.char) *C.char {
                          ctx := contexts[service]
                          if ctx == nil {
                              return C.CString("[System.LuaSetDB] contract state not found")
                          }
                      Severity: Major
                      Found in contract/vm_callback.go - About 35 mins to fix

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

                            if err != nil {
                                p.logger.Warn().Str(p2putil.LogPeerName, p.Name()).Stringer(p2putil.LogProtoID, pr.GetProtocolID()).Str(p2putil.LogMsgID, pr.GetMsgID().String()).Err(err).Msg("fail to SendTo")
                                return err
                            }
                        Severity: Major
                        Found in p2p/msgorder.go and 4 other locations - About 35 mins to fix
                        p2p/msgorder.go on lines 94..97
                        p2p/msgorder.go on lines 144..147
                        p2p/msgorder.go on lines 166..169
                        p2p/msgorder.go on lines 233..236

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

                        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

                            if err != nil {
                                p.logger.Warn().Str(p2putil.LogPeerName, p.Name()).Stringer(p2putil.LogProtoID, pr.GetProtocolID()).Str(p2putil.LogMsgID, pr.GetMsgID().String()).Err(err).Msg("fail to SendTo")
                                return err
                            }
                        Severity: Major
                        Found in p2p/msgorder.go and 4 other locations - About 35 mins to fix
                        p2p/msgorder.go on lines 94..97
                        p2p/msgorder.go on lines 144..147
                        p2p/msgorder.go on lines 186..189
                        p2p/msgorder.go on lines 233..236

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

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

                                p.logger.Debug().Str(p2putil.LogPeerName, p.Name()).Stringer(p2putil.LogProtoID, msg.GetProtocolID()).
                                    Str(p2putil.LogMsgID, msg.GetMsgID().String()).Str("current_state", p.State().String()).Msg("Cancel sending message, since peer is not running state")
                        Severity: Minor
                        Found in p2p/remotepeer.go and 2 other locations - About 35 mins to fix
                        p2p/remotepeer.go on lines 338..339
                        p2p/remotepeer.go on lines 370..371

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

                        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

                            if rMeta.ID != h.peerID {
                                h.logger.Debug().Str("received_peer_id", rMeta.ID.Pretty()).Stringer(p2putil.LogPeerID, types.LogPeerShort(h.peerID)).Msg("Inconsistent peerID")
                                h.sendGoAway("Inconsistent peerID")
                                return fmt.Errorf("inconsistent peerID")
                            }
                        Severity: Minor
                        Found in p2p/v200/v200handshake.go and 2 other locations - About 35 mins to fix
                        p2p/v030/v030handshake.go on lines 177..181
                        p2p/v030/v033handshake.go on lines 68..72

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

                        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 *MockVersionedManager) GetChainID(no types.BlockNo) *types.ChainID {
                            m.ctrl.T.Helper()
                            ret := m.ctrl.Call(m, "GetChainID", no)
                            ret0, _ := ret[0].(*types.ChainID)
                            return ret0
                        Severity: Minor
                        Found in p2p/p2pmock/mock_handshake.go and 1 other location - About 35 mins to fix
                        p2p/p2pmock/mock_consensus.go on lines 152..157

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

                        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

                            if rMeta.ID != h.peerID {
                                h.logger.Debug().Str("received_peer_id", rMeta.ID.Pretty()).Stringer(p2putil.LogPeerID, types.LogPeerShort(h.peerID)).Msg("Inconsistent peerID")
                                h.sendGoAway("Inconsistent peerID")
                                return fmt.Errorf("inconsistent peerID")
                            }
                        Severity: Minor
                        Found in p2p/v030/v033handshake.go and 2 other locations - About 35 mins to fix
                        p2p/v030/v030handshake.go on lines 177..181
                        p2p/v200/v200handshake.go on lines 185..189

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

                        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