aergoio/aergo

View on GitHub

Showing 1,051 of 1,052 total issues

Function UpdateName has 6 return statements (exceeds 4 allowed).
Open

func UpdateName(bs *state.BlockState, scs *statedb.ContractState, tx *types.TxBody,
    sender, receiver *state.AccountState, name, to string) error {
    if len(getAddress(scs, []byte(name))) <= types.NameLength {
        return fmt.Errorf("%s is not created yet", string(name))
    }
Severity: Major
Found in contract/name/name.go - About 40 mins to fix

    Method DummyChain.QueryOnly has 6 return statements (exceeds 4 allowed).
    Open

    func (bc *DummyChain) QueryOnly(contract_name, queryInfo string, expectedErr string) (bool, string, error) {
        cState, err := statedb.OpenContractStateAccount(contract.StrHash(contract_name), bc.sdb.GetStateDB())
        if err != nil {
            return false, "", err
        }
    Severity: Major
    Found in contract/vm_dummy/vm_dummy.go - About 40 mins to fix

      Method blockExecutor.execute has 6 return statements (exceeds 4 allowed).
      Open

      func (e *blockExecutor) execute() error {
      
          defer contract.CloseDatabase()
      
          for _, tx := range e.txs {
      Severity: Major
      Found in contract/vm_direct/vm_direct.go - About 40 mins to fix

        Method BlockFetcher.schedule has 6 return statements (exceeds 4 allowed).
        Open

        func (bf *BlockFetcher) schedule() error {
            for bf.peers.free > 0 {
                //check max concurrent runing task count
                curRunning := bf.runningQueue.Len()
                if curRunning >= bf.maxFetchTasks {
        Severity: Major
        Found in syncer/blockfetcher.go - About 40 mins to fix

          Function _validateNameTx has 6 return statements (exceeds 4 allowed).
          Open

          func _validateNameTx(tx *TxBody, ci *CallInfo) error {
              if len(ci.Args) < 1 {
                  return fmt.Errorf("invalid arguments in %s", ci)
              }
              nameParam, ok := ci.Args[0].(string)
          Severity: Major
          Found in types/transaction.go - About 40 mins to fix

            Function checkValue has 6 return statements (exceeds 4 allowed).
            Open

            func checkValue(value interface{}, check interface{}) bool {
                if reflect.TypeOf(value) != reflect.TypeOf(check) {
                    return false
                }
                switch value.(type) {
            Severity: Major
            Found in types/receipt.go - About 40 mins to fix

              Method Finder.hasSameHash has 6 return statements (exceeds 4 allowed).
              Open

              func (finder *Finder) hasSameHash(no types.BlockNo, localHash []byte) (bool, error) {
                  finder.compRequester.TellTo(message.P2PSvc, &message.GetHashByNo{Seq: finder.GetSeq(), ToWhom: finder.ctx.PeerID, BlockNo: no})
              
                  recvHashRsp := func() (*message.GetHashByNoRsp, error) {
                      timer := time.NewTimer(finder.dfltTimeout)
              Severity: Major
              Found in syncer/finder.go - About 40 mins to fix

                Function DecodeAddress has 6 return statements (exceeds 4 allowed).
                Open

                func DecodeAddress(encodedAddr string) (Address, error) {
                    if IsSpecialAccount([]byte(encodedAddr)) {
                        return []byte(encodedAddr), nil
                    } else if len(encodedAddr) <= NameLength { // name address
                        name := encodedAddr
                Severity: Major
                Found in types/account.go - About 40 mins to fix

                  Function GetABI has 6 return statements (exceeds 4 allowed).
                  Open

                  func GetABI(contractState *statedb.ContractState, bs *state.BlockState) (*types.ABI, error) {
                      var abi *types.ABI
                  
                      abi = bs.GetABI(contractState.GetAccountID())
                      if abi != nil {
                  Severity: Major
                  Found in contract/vm.go - About 40 mins to fix

                    Function callbackArg has 6 return statements (exceeds 4 allowed).
                    Open

                    func callbackArg(typ reflect.Type) (callbackArgConverter, error) {
                        switch typ.Kind() {
                        case reflect.Interface:
                            if typ.NumMethod() != 0 {
                                return nil, errors.New("the only supported interface type is interface{}")
                    Severity: Major
                    Found in contract/callback.go - About 40 mins to fix

                      Function NewListEntry has 6 return statements (exceeds 4 allowed).
                      Open

                      func NewListEntry(raw RawEntry) (WhiteListEntry, error) {
                          literal, _ := json.Marshal(raw)
                      
                          if len(raw.Address) == 0 && len(raw.Cidr) == 0 && len(raw.PeerId) == 0 {
                              return dummyListEntry, InvalidEntryErr
                      Severity: Major
                      Found in types/listentry.go - About 40 mins to fix

                        Function ExecuteNameTx has 6 return statements (exceeds 4 allowed).
                        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: Major
                        Found in contract/name/execute.go - About 40 mins to fix

                          Function checkArgs has 6 return statements (exceeds 4 allowed).
                          Open

                          func checkArgs(context *EnterpriseContext, ci *types.CallInfo) error {
                              key := strings.ToUpper(ci.Args[0].(string))
                              if _, ok := enterpriseKeyDict[key]; !ok {
                                  return fmt.Errorf("not allowed key : %s", ci.Args[0])
                              }
                          Severity: Major
                          Found in contract/enterprise/validate.go - About 40 mins to fix

                            Method Event.Filter has 6 return statements (exceeds 4 allowed).
                            Open

                            func (ev *Event) Filter(filter *FilterInfo, argFilter []ArgFilter) bool {
                                if filter.ContractAddress != nil && !bytes.Equal(ev.ContractAddress, filter.ContractAddress) {
                                    return false
                                }
                                if len(filter.EventName) != 0 && ev.EventName != filter.EventName {
                            Severity: Major
                            Found in types/receipt.go - About 40 mins to fix

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

                              func (m *Helper) ExtractBlockFromResponseAndError(rawResponse interface{}, err error) (*types.Block, error) {
                                  ret := m.ctrl.Call(m, "ExtractBlockFromResponseAndError", rawResponse, err)
                                  ret0, _ := ret[0].(*types.Block)
                                  ret1, _ := ret[1].(error)
                                  return ret0, ret1
                              Severity: Minor
                              Found in types/message/messagemock/helper.go and 1 other location - About 40 mins to fix
                              types/message/messagemock/helper.go on lines 63..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 110.

                              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 NewGetBlockHeadersReqHandler(pm p2pcommon.PeerManager, peer p2pcommon.RemotePeer, logger *log.Logger, actor p2pcommon.ActorService) *getBlockHeadersRequestHandler {
                                  bh := &getBlockHeadersRequestHandler{BaseMsgHandler{protocol: p2pcommon.GetBlockHeadersRequest, pm: pm, peer: peer, actor: actor, logger: logger}, newAsyncHelper()}
                                  return bh
                              }
                              Severity: Minor
                              Found in p2p/subproto/block.go and 1 other location - About 40 mins to fix
                              p2p/subproto/block.go on lines 189..192

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

                              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 *Helper) ExtractTxFromResponseAndError(rawResponse interface{}, err error) (*types.Tx, error) {
                                  ret := m.ctrl.Call(m, "ExtractTxFromResponseAndError", rawResponse, err)
                                  ret0, _ := ret[0].(*types.Tx)
                                  ret1, _ := ret[1].(error)
                                  return ret0, ret1
                              Severity: Minor
                              Found in types/message/messagemock/helper.go and 1 other location - About 40 mins to fix
                              types/message/messagemock/helper.go on lines 37..42

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

                              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 err != nil {
                                          logger.Error().Err(err).Str("hash", base58.Encode(tx.GetHash())).Msg("tx failed")
                                          if err2 := blockState.Rollback(blockSnap); err2 != nil {
                                              logger.Panic().Err(err).Msg("failed to rollback block state")
                                          }
                              Severity: Minor
                              Found in contract/vm_direct/vm_direct.go and 1 other location - About 40 mins to fix
                              chain/chainhandle.go on lines 707..714

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

                              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 NewGetAncestorReqHandler(pm p2pcommon.PeerManager, peer p2pcommon.RemotePeer, logger *log.Logger, actor p2pcommon.ActorService) *getAncestorRequestHandler {
                                  bh := &getAncestorRequestHandler{BaseMsgHandler{protocol: p2pcommon.GetAncestorRequest, pm: pm, peer: peer, actor: actor, logger: logger}, newAsyncHelper()}
                                  return bh
                              }
                              Severity: Minor
                              Found in p2p/subproto/block.go and 1 other location - About 40 mins to fix
                              p2p/subproto/block.go on lines 50..53

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

                              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 err != nil {
                                          logger.Error().Err(err).Str("hash", base58.Encode(tx.GetHash())).Msg("tx failed")
                                          if err2 := bState.Rollback(blockSnap); err2 != nil {
                                              logger.Panic().Err(err).Msg("failed to rollback block state")
                                          }
                              Severity: Minor
                              Found in chain/chainhandle.go and 1 other location - About 40 mins to fix
                              contract/vm_direct/vm_direct.go on lines 293..299

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

                              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