Showing 68 of 114 total issues
Function AutoUpdateAction
has 7 return statements (exceeds 4 allowed). Open
func AutoUpdateAction(r *http.Request) api.Response {
err := travis.ValidateSignature(true, r)
if err != nil {
logrus.Error(err)
return api.Response{Error: err, Status: http.StatusBadRequest}
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
if err != nil {
return err
}
- Create a ticketCreate a ticket
Function checkHandleReorg
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
func checkHandleReorg(height uint64, chainPrevHash string) (uint64, error) {
prevHeight := height - 1
depth := 0
if height > 0 {
prevBlock, err := model.Blocks(qm.Where(model.BlockColumns.Height+"=?", prevHeight), qm.Load("BlockHashTransactions")).OneG()
- Read upRead up
- Create a ticketCreate a ticket
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
Avoid deeply nested control flow statements. Open
} else if txscript.IsPayToWitnessScriptHash(script) {
return p2WSH
}
- Create a ticketCreate a ticket
Method chainSyncStatus.alignClaim
has 6 return statements (exceeds 4 allowed). Open
func (c *chainSyncStatus) alignClaim() error {
storedClaim := datastore.GetClaim(c.Vout.ClaimID.String)
if storedClaim == nil {
return errors.Err("could not find claim with id %s", c.Vout.ClaimID.String)
}
- Create a ticketCreate a ticket
Function createUpdateVoutAddresses
has 6 return statements (exceeds 4 allowed). Open
func createUpdateVoutAddresses(tx *model.Transaction, outputs *[]lbrycrd.Vout, blockSeconds uint64) (map[string]uint64, error) {
addressIDMap := make(map[string]uint64)
for _, output := range *outputs {
address, err := getFirstAddressFromVout(output)
if err != nil {
- Create a ticketCreate a ticket
Function checkHandleReorg
has 6 return statements (exceeds 4 allowed). Open
func checkHandleReorg(height uint64, chainPrevHash string) (uint64, error) {
prevHeight := height - 1
depth := 0
if height > 0 {
prevBlock, err := model.Blocks(qm.Where(model.BlockColumns.Height+"=?", prevHeight), qm.Load("BlockHashTransactions")).OneG()
- Create a ticketCreate a ticket
Function getPublicKeyScriptType
has 6 return statements (exceeds 4 allowed). Open
func getPublicKeyScriptType(script []byte) string {
if isPayToPublicKey(script) {
return p2PK
} else if isPayToPublicKeyHashScript(script) {
return p2PKH
- Create a ticketCreate a ticket
Function processSupport
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func processSupport(claimID string, value []byte, support *model.Support, output model.Output, tx model.Transaction) (*model.Support, error) {
- Create a ticketCreate a ticket
Function processClaim
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func processClaim(helper *c.StakeHelper, claim *model.Claim, value []byte, output model.Output, tx model.Transaction) (*model.Claim, error) {
- Create a ticketCreate a ticket
Function decodeFloat
has 5 return statements (exceeds 4 allowed). Open
func decodeFloat(data interface{}) (interface{}, error) {
if n, ok := data.(json.Number); ok {
val, err := n.Float64()
if err != nil {
return nil, errors.Wrap(err, 0)
- Create a ticketCreate a ticket
Function signClaim
has 5 return statements (exceeds 4 allowed). Open
func signClaim(rawTx *wire.MsgTx, privKey btcec.PrivateKey, claim, channel *c.StakeHelper, channelClaimID string) error {
claimIDHexBytes, err := hex.DecodeString(channelClaimID)
if err != nil {
return errors.Err(err)
}
- Create a ticketCreate a ticket
Function processAsClaim
has 5 return statements (exceeds 4 allowed). Open
func processAsClaim(script []byte, vout model.Output, tx model.Transaction, blockHeight uint64) (address *string, claimID *string, err error) {
defer metrics.Processing(time.Now(), "claim")
var pubkeyscript []byte
var name string
var claimid string
- Create a ticketCreate a ticket
Function certifyClaim
has 5 return statements (exceeds 4 allowed). Open
func certifyClaim(claimToBeSynced claimToBeSynced) (bool, error) {
signedHelper, err := c.DecodeClaimHex(claimToBeSynced.SignedClaimHex, global.BlockChainName)
if err != nil {
return false, errors.Err(errors.Prefix(certificateSyncPrefix, err))
- Create a ticketCreate a ticket
Function processClaimUpdateScript
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
func processClaimUpdateScript(script *[]byte, vout model.Output, tx model.Transaction, blockHeight uint64) (name string, claimID string, pubkeyscript []byte, err error) {
name, claimID, value, pubkeyscript, err := lbrycrd.ParseClaimUpdateScript(*script)
if err != nil {
err := errors.Prefix("Claim update processing error", err)
return name, claimID, pubkeyscript, err
- Read upRead up
- Create a ticketCreate a ticket
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 updateSpentClaims
has 5 return statements (exceeds 4 allowed). Open
func updateSpentClaims() error {
var lastProcessed uint64
for {
//Claims without updates
claims, newLastProcessed, err := getSpentClaimsToUpdate(false, lastProcessed)
- Create a ticketCreate a ticket
Function checkTxs
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
func checkTxs(missingData []BlockData, lbryBlock *lbrycrd.GetBlockResponse, transactions model.TransactionSlice) ([]BlockData, error) {
for _, lbryTxHash := range lbryBlock.Tx {
var tx *model.Transaction
for _, transaction := range transactions {
if transaction.Hash == lbryTxHash {
- Read upRead up
- Create a ticketCreate a ticket
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 getChainSyncJobStatus
has 5 return statements (exceeds 4 allowed). Open
func getChainSyncJobStatus() (*model.JobStatus, error) {
jobStatus, err := model.FindJobStatusG(chainSyncJob)
if errors.Is(sql.ErrNoRows, err) {
syncState := chainSyncStatus{LastHeight: 0}
bytes, err := json.Marshal(syncState)
- Create a ticketCreate a ticket
Function GetIsExpiredAtHeight
has 5 return statements (exceeds 4 allowed). Open
func GetIsExpiredAtHeight(height, blockHeight uint) bool {
if height == 0 {
return false
}
if height >= expirationHardForkHeight {
- Create a ticketCreate a ticket
Method chainSyncStatus.alignTxs
has 5 return statements (exceeds 4 allowed). Open
func (c *chainSyncStatus) alignTxs(block *model.Block, txHashes []string) error {
for _, txHash := range txHashes {
lbrycrdTx, err := lbrycrd.GetRawTransactionResponse(txHash)
if err != nil {
return c.recordAndReturnError(c.LastHeight, "tx-hash-creation", err)
- Create a ticketCreate a ticket