Showing 1,051 of 1,052 total issues
Method BlockFactory.ClusterInfo
has 5 return statements (exceeds 4 allowed). Open
func (bf *BlockFactory) ClusterInfo(bestBlockHash []byte) *types.GetClusterInfoResponse {
var (
hardStateInfo *types.HardStateInfo
mbrAttrs []*types.MemberAttr
bestBlock *types.Block
Method AergoRPCService.UnlockAccount
has 5 return statements (exceeds 4 allowed). Open
func (rpc *AergoRPCService) UnlockAccount(ctx context.Context, in *types.Personal) (*types.Account, error) {
if err := rpc.checkAuth(ctx, WriteBlockChain); err != nil {
return nil, err
}
result, err := rpc.hub.RequestFutureResult(message.AccountsSvc,
Method Web3APIv1.GetReceipt
has 5 return statements (exceeds 4 allowed). Open
func (api *Web3APIv1) GetReceipt() (handler http.Handler, ok bool) {
values, err := url.ParseQuery(api.request.URL.RawQuery)
if err != nil {
return commonResponseHandler(&types.Empty{}, err), true
}
Method ChainDB.WriteRaftEntry
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
func (cdb *ChainDB) WriteRaftEntry(ents []*consensus.WalEntry, blocks []*types.Block, ccProposes []*raftpb.ConfChange) error {
var data []byte
var err error
var lastIdx uint64
- 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 Web3APIv1.GetBalance
has 5 return statements (exceeds 4 allowed). 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
}
Method pingChecker.DoCall
has 5 return statements (exceeds 4 allowed). Open
func (pc *pingChecker) DoCall(done chan<- interface{}) {
var pingResp *types.Ping = nil
defer func() {
if pingResp != nil {
atomic.StoreInt32(&pc.contFail, 0)
Method ChainDB.checkBlockDropped
has 5 return statements (exceeds 4 allowed). Open
func (cdb *ChainDB) checkBlockDropped(dropBlock *types.Block) error {
no := dropBlock.GetHeader().GetBlockNo()
hash := dropBlock.GetHash()
txLen := len(dropBlock.GetBody().GetTxs())
Method ChainService.listEvents
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
func (cs *ChainService) listEvents(filter *types.FilterInfo) ([]*types.Event, error) {
from := filter.Blockfrom
to := filter.Blockto
if filter.RecentBlockCnt > 0 {
- 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 importWif
has 5 return statements (exceeds 4 allowed). Open
func importWif(cmd *cobra.Command) ([]byte, error) {
var err error
var address []byte
importBuf, err := types.DecodePrivKey(importFormat)
if err != nil {
Function exportKeystore
has 5 return statements (exceeds 4 allowed). Open
func exportKeystore(cmd *cobra.Command, param *types.Personal) ([]byte, error) {
if rootConfig.KeyStorePath == "" {
msg, err := client.ExportAccountKeystore(context.Background(), param)
if err != nil {
return nil, fmt.Errorf("node request returned error: %s", err.Error())
Method reorganizer.gatherReco
has 5 return statements (exceeds 4 allowed). Open
func (reorg *reorganizer) gatherReco() error {
var err error
cdb := reorg.cs.cdb
Method ChainService.executeBlockReco
has 5 return statements (exceeds 4 allowed). Open
func (cs *ChainService) executeBlockReco(_ *state.BlockState, block *types.Block) error {
// Caution: block must belong to the main chain.
logger.Debug().Str("hash", block.ID()).Uint64("no", block.GetHeader().BlockNo).Msg("start to execute for reco")
var (
Method unstakeCmd.run
has 5 return statements (exceeds 4 allowed). Open
func (c *unstakeCmd) run() (*types.Event, error) {
var (
scs = c.scs
staked = c.Staked
sender = c.Sender
Method Web3APIv1.GetPeers
has 5 return statements (exceeds 4 allowed). Open
func (api *Web3APIv1) GetPeers() (handler http.Handler, ok bool) {
values, err := url.ParseQuery(api.request.URL.RawQuery)
if err != nil {
return commonResponseHandler(&types.Empty{}, err), true
}
Function GasLimit
has 5 return statements (exceeds 4 allowed). Open
func GasLimit(version int32, isFeeDelegation bool, txGasLimit uint64, payloadSize int, gasPrice, usedFee, senderBalance, receiverBalance *big.Int) (gasLimit uint64, err error) {
// 1. no gas limit
if GasEnabled(version) != true {
return
}
Method queryContract.Run
has 5 return statements (exceeds 4 allowed). Open
func (c *queryContract) Run(args string) (string, uint64, []*types.Event, error) {
contractName, funcName, queryCode, expectedResult, expectedError, _ := c.parse(args)
formattedQuery := fmt.Sprintf("{\"name\":\"%s\",\"args\":%s}", funcName, queryCode)
Function execNameUpdate
has 5 return statements (exceeds 4 allowed). Open
func execNameUpdate(cmd *cobra.Command, args []string) error {
account, err := types.DecodeAddress(from)
if err != nil {
return fmt.Errorf("Wrong address in --from flag: %v", err.Error())
}
Method reorganizer.initRecovery
has 5 return statements (exceeds 4 allowed). Open
func (reorg *reorganizer) initRecovery(marker *ReorgMarker) error {
var startBlock, bestBlock, topBlock *types.Block
var err error
if marker == nil {
Function completerBroker
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
func completerBroker(d prompt.Document) []prompt.Suggest {
var s []prompt.Suggest
// parse first word. it is represent a command
cmd, args := context.ParseFirstWord(d.Lines()[0])
- 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 Web3APIv1.GetVotes
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
func (api *Web3APIv1) GetVotes() (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
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"