aergoio/aergo

View on GitHub

Showing 1,051 of 1,052 total issues

MockRemotePeerMockRecorder has 25 methods (exceeds 20 allowed). Consider refactoring.
Open

type MockRemotePeerMockRecorder struct {
    mock *MockRemotePeer
}
Severity: Minor
Found in p2p/p2pmock/mock_remotepeer.go - About 2 hrs to fix

    LiteContainerService has 25 methods (exceeds 20 allowed). Consider refactoring.
    Open

    type LiteContainerService struct {
        *component.BaseComponent
    
        dummySetting p2pcommon.LocalSettings
        chainID      *types.ChainID
    Severity: Minor
    Found in cmd/polaris/server/litentcontainer.go - About 2 hrs to fix

      Function ExecuteEnterpriseTx has 95 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func ExecuteEnterpriseTx(bs *state.BlockState, ccc consensus.ChainConsensusCluster, scs *statedb.ContractState, txBody *types.TxBody,
          sender, receiver *state.AccountState, blockNo types.BlockNo) ([]*types.Event, error) {
      
          context, err := ValidateEnterpriseTx(txBody, sender, scs, blockNo)
          if err != nil {
      Severity: Major
      Found in contract/enterprise/execute.go - About 2 hrs to fix

        Method syncTxManager.handleTxReq has 94 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (tm *syncTxManager) handleTxReq(remotePeer p2pcommon.RemotePeer, mID p2pcommon.MsgID, reqHashes [][]byte) {
            // NOTE size estimation is tied to protobuf3 it should be changed when protobuf is changed.
            // find transactions from chainservice
            idx := 0
            status := types.ResultStatus_OK
        Severity: Major
        Found in p2p/synctx.go - About 2 hrs to fix

          Function ValidateEnterpriseTx has 31 return statements (exceeds 4 allowed).
          Open

          func ValidateEnterpriseTx(tx *types.TxBody, sender *state.AccountState,
              scs *statedb.ContractState, blockNo types.BlockNo) (*EnterpriseContext, error) {
              var ci types.CallInfo
              if err := json.Unmarshal(tx.Payload, &ci); err != nil {
                  return nil, err
          Severity: Major
          Found in contract/enterprise/validate.go - About 2 hrs to fix

            Method SQLiteConn.RegisterAggregator has 93 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (c *SQLiteConn) RegisterAggregator(name string, impl interface{}, pure bool) error {
                var ai aggInfo
                ai.constructor = reflect.ValueOf(impl)
                t := ai.constructor.Type()
                if t.Kind() != reflect.Func {
            Severity: Major
            Found in contract/sqlite3.go - About 2 hrs to fix

              Function newExecutor has 92 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func newExecutor(
                  contract []byte,
                  contractId []byte,
                  ctx *vmContext,
                  ci *types.CallInfo,
              Severity: Major
              Found in contract/vm.go - About 2 hrs to fix

                MockContextMockRecorder has 24 methods (exceeds 20 allowed). Consider refactoring.
                Open

                type MockContextMockRecorder struct {
                    mock *MockContext
                }
                Severity: Minor
                Found in p2p/p2pmock/mock_actorcontext.go - About 2 hrs to fix

                  StateDB has 24 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                  type StateDB struct {
                      lock     sync.RWMutex
                      Buffer   *stateBuffer
                      Cache    *storageCache
                      Trie     *trie.Trie
                  Severity: Minor
                  Found in state/statedb/statedb.go - About 2 hrs to fix

                    Function luaCallContract has 91 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func luaCallContract(L *LState, service C.int, contractId *C.char, fname *C.char, args *C.char,
                        amount *C.char, gas uint64) (C.int, *C.char) {
                        fnameStr := C.GoString(fname)
                        argsStr := C.GoString(args)
                    
                    
                    Severity: Major
                    Found in contract/vm_callback.go - About 2 hrs to fix

                      Function luaGovernance has 90 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func luaGovernance(L *LState, service C.int, gType C.char, arg *C.char) *C.char {
                      
                          ctx := contexts[service]
                          if ctx == nil {
                              return C.CString("[Contract.LuaGovernance] contract state not found")
                      Severity: Major
                      Found in contract/vm_callback.go - About 2 hrs to fix

                        Method HashFetcher.Start has a Cognitive Complexity of 34 (exceeds 20 allowed). Consider refactoring.
                        Open

                        func (hf *HashFetcher) Start() {
                            hf.waitGroup = &sync.WaitGroup{}
                            hf.waitGroup.Add(1)
                        
                            hf.isRunning = true
                        Severity: Minor
                        Found in syncer/hashfetcher.go - About 2 hrs 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 ExecuteEnterpriseTx has a Cognitive Complexity of 34 (exceeds 20 allowed). Consider refactoring.
                        Open

                        func ExecuteEnterpriseTx(bs *state.BlockState, ccc consensus.ChainConsensusCluster, scs *statedb.ContractState, txBody *types.TxBody,
                            sender, receiver *state.AccountState, blockNo types.BlockNo) ([]*types.Event, error) {
                        
                            context, err := ValidateEnterpriseTx(txBody, sender, scs, blockNo)
                            if err != nil {
                        Severity: Minor
                        Found in contract/enterprise/execute.go - About 2 hrs 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 luaGetDB has a Cognitive Complexity of 34 (exceeds 20 allowed). Consider refactoring.
                        Open

                        func luaGetDB(L *LState, service C.int, key unsafe.Pointer, keyLen C.int, blkno *C.char) (*C.char, *C.char) {
                            ctx := contexts[service]
                            if ctx == nil {
                                return nil, C.CString("[System.LuaGetDB] contract state not found")
                            }
                        Severity: Minor
                        Found in contract/vm_callback.go - About 2 hrs to fix

                        Cognitive Complexity

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

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

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

                        Further reading

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

                            if ctx.traceFile != nil {
                                _, _ = ctx.traceFile.WriteString(fmt.Sprintf("[ret] : %s\n", ce.jsonRet))
                                _, _ = ctx.traceFile.WriteString(fmt.Sprintf("[usedFee] : %s\n", ctx.usedFee().String()))
                                events := ce.getEvents()
                                if events != nil {
                        Severity: Major
                        Found in contract/vm.go and 1 other location - About 2 hrs to fix
                        contract/vm.go on lines 1007..1021

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

                        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 ctx.traceFile != nil {
                                _, _ = ctx.traceFile.WriteString(fmt.Sprintf("[ret] : %s\n", ce.jsonRet))
                                _, _ = ctx.traceFile.WriteString(fmt.Sprintf("[usedFee] : %s\n", ctx.usedFee().String()))
                                events := ce.getEvents()
                                if events != nil {
                        Severity: Major
                        Found in contract/vm.go and 1 other location - About 2 hrs to fix
                        contract/vm.go on lines 861..875

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

                        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

                        File chaindb.go has 523 lines of code (exceeds 500 allowed). Consider refactoring.
                        Open

                        /**
                         *  @file
                         *  @copyright defined in aergo/LICENSE.txt
                         */
                        
                        
                        Severity: Minor
                        Found in chain/chaindb.go - About 2 hrs to fix

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

                          // Code generated by "stringer -type=OpSysTx"; DO NOT EDIT.
                          
                          package types
                          
                          import "strconv"
                          Severity: Major
                          Found in types/opsystx_string.go and 1 other location - About 2 hrs to fix
                          contract/system/sysparamindex_string.go on lines 1..27

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

                          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

                          // Code generated by "stringer -type=sysParamIndex"; DO NOT EDIT.
                          
                          package system
                          
                          import "strconv"
                          Severity: Major
                          Found in contract/system/sysparamindex_string.go and 1 other location - About 2 hrs to fix
                          types/opsystx_string.go on lines 1..27

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

                          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 ValidateSystemTx has 88 lines of code (exceeds 50 allowed). Consider refactoring.
                          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 2 hrs to fix
                            Severity
                            Category
                            Status
                            Source
                            Language