Showing 1,051 of 1,052 total issues
Function luaDeployContract
has a Cognitive Complexity of 48 (exceeds 20 allowed). Consider refactoring. Open
func luaDeployContract(
L *LState,
service C.int,
contract *C.char,
args *C.char,
- Read upRead up
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
BlockFactory
has 37 methods (exceeds 20 allowed). Consider refactoring. Open
type BlockFactory struct {
*component.ComponentHub
consensus.ChainWAL
bpc *Cluster
Function ValidateEnterpriseTx
has 144 lines of code (exceeds 50 allowed). Consider refactoring. 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
Method SQLiteRows.Next
has a Cognitive Complexity of 47 (exceeds 20 allowed). Consider refactoring. 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
- Read upRead up
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 peerManager.runManagePeers
has a Cognitive Complexity of 46 (exceeds 20 allowed). Consider refactoring. Open
func (pm *peerManager) runManagePeers() {
pm.logger.Info().Str("p2p_proto", p2putil.ProtocolIDsToString([]protocol.ID{p2pcommon.P2PSubAddr})).Msg("Starting p2p listening")
pm.nt.AddStreamHandler(p2pcommon.P2PSubAddr, pm.wpManager.OnInboundConn)
- Read upRead up
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 executeTx
has 138 lines of code (exceeds 50 allowed). Consider refactoring. Open
func executeTx(execCtx context.Context, ccc consensus.ChainConsensusCluster, cdb contract.ChainAccessor, bs *state.BlockState, tx types.Transaction, bi *types.BlockHeaderInfo, executionMode int) error {
var (
txBody = tx.GetBody()
isQuirkTx = types.IsQuirkTx(tx.GetHash())
account []byte
Function luaDeployContract
has 136 lines of code (exceeds 50 allowed). Consider refactoring. Open
func luaDeployContract(
L *LState,
service C.int,
contract *C.char,
args *C.char,
File vm_dummy.go
has 599 lines of code (exceeds 500 allowed). Consider refactoring. Open
package vm_dummy
// helper functions
import (
"context"
P2P
has 34 methods (exceeds 20 allowed). Consider refactoring. Open
type P2P struct {
*component.BaseComponent
cfg *config.Config
Web3APIv1
has 34 methods (exceeds 20 allowed). Consider refactoring. Open
type Web3APIv1 struct {
rpc *rpc.AergoRPCService
request *http.Request
handlerMap map[string]map[string]APIHandler
Method executor.call
has a Cognitive Complexity of 44 (exceeds 20 allowed). Consider refactoring. Open
func (ce *executor) call(instLimit C.int, target *LState) (ret C.int) {
defer func() {
if ret == 0 && target != nil {
if C.luaL_hasuncatchablerror(ce.L) != C.int(0) {
C.luaL_setuncatchablerror(target)
- Read upRead up
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
MemPool
has 33 methods (exceeds 20 allowed). Consider refactoring. Open
type MemPool struct {
*component.BaseComponent
sync.RWMutex
cfg *cfg.Config
File vprt.go
has 587 lines of code (exceeds 500 allowed). Consider refactoring. Open
package system
import (
"bytes"
"container/list"
Function luaSendAmount
has a Cognitive Complexity of 43 (exceeds 20 allowed). Consider refactoring. Open
func luaSendAmount(L *LState, service C.int, contractId *C.char, amount *C.char) *C.char {
ctx := contexts[service]
if ctx == nil {
return C.CString("[Contract.LuaSendAmount] contract state not found")
- Read upRead up
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
File blockfetcher.go
has 576 lines of code (exceeds 500 allowed). Consider refactoring. Open
package syncer
import (
"bytes"
"container/list"
Similar blocks of code found in 2 locations. Consider refactoring. Open
func (api *Web3APIv1) GetBalance() (handler http.Handler, ok bool) {
values, err := url.ParseQuery(api.request.URL.RawQuery)
if err != nil {
return commonResponseHandler(&types.Empty{}, err), true
}
- Read upRead up
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 295.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
func (api *Web3APIv1) GetAccountVotes() (handler http.Handler, ok bool) {
values, err := url.ParseQuery(api.request.URL.RawQuery)
if err != nil {
return commonResponseHandler(&types.Empty{}, err), true
}
- Read upRead up
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 295.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method MemPool.validateTx
has 118 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (mp *MemPool) validateTx(tx types.Transaction, account types.Address) error {
if !mp.whitelist.Check(types.EncodeAddress(account)) {
return types.ErrTxNotAllowedAccount
}
ns, err := mp.getAccountState(account)
peerManager
has 29 methods (exceeds 20 allowed). Consider refactoring. Open
type peerManager struct {
status int32
is p2pcommon.InternalService
nt p2pcommon.NetworkTransport
hsFactory p2pcommon.HSHandlerFactory
ChainService
has 29 methods (exceeds 20 allowed). Consider refactoring. Open
type ChainService struct {
*component.BaseComponent
consensus.ChainConsensus
*Core