lbryio/chainquery

View on GitHub

Showing 68 of 112 total issues

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
Severity: Minor
Found in daemon/processing/claim.go - About 35 mins 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 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)
    }
Severity: Major
Found in e2e/claim.go - About 35 mins to fix

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))
Severity: Major
Found in daemon/jobs/certificatesync.go - About 35 mins to fix

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)
Severity: Major
Found in daemon/jobs/chainsync.go - About 35 mins to fix

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
Severity: Major
Found in daemon/processing/claim.go - About 35 mins to fix

Function ProcessVout has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
Open

func ProcessVout(jsonVout *lbrycrd.Vout, tx *m.Transaction, txDC *txDebitCredits, blockHeight uint64) error {
    defer metrics.Processing(time.Now(), "vout")
    vout := &m.Output{}
    foundVout := ds.GetOutput(tx.Hash, uint(jsonVout.N))
    if foundVout != nil {
Severity: Minor
Found in daemon/processing/outpoint.go - About 25 mins 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 CertificateSync has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
Open

func CertificateSync() {
    if !certificateSyncRunning {
        metrics.JobLoad.WithLabelValues("certificate_sync").Inc()
        defer metrics.JobLoad.WithLabelValues("certificate_sync").Dec()
        defer metrics.Job(time.Now(), "certificate_sync")
Severity: Minor
Found in daemon/jobs/certificatesync.go - About 25 mins 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 SyncClaimCntInChannel has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
Open

func SyncClaimCntInChannel() error {
    latestBlock, err := model.Blocks(qm.Select(model.BlockColumns.Height), qm.OrderBy(model.BlockColumns.Height+" DESC")).OneG()
    if err != nil {
        return errors.Prefix(syncClaimsInChannel, err)
    }
Severity: Minor
Found in daemon/jobs/valuesync.go - About 25 mins 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

Severity
Category
Status
Source
Language