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))
}
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
}
Method blockExecutor.execute
has 6 return statements (exceeds 4 allowed). Open
func (e *blockExecutor) execute() error {
defer contract.CloseDatabase()
for _, tx := range e.txs {
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 {
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)
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) {
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)
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
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 {
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{}")
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
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 {
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])
}
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 {
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
- 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 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
- 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 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
}
- 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 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
- 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 (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
- 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 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
- 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
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")
}
- 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 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
- 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 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
}
- 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 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
- 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
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")
}
- 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 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
- 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