lbryio/chainquery

View on GitHub
daemon/processing/claim.go

Summary

Maintainability
D
1 day
Test Coverage

File claim.go has 624 lines of code (exceeds 500 allowed). Consider refactoring.
Open

package processing

import (
    "encoding/hex"
    "encoding/json"
Severity: Minor
Found in daemon/processing/claim.go - About 5 hrs to fix

Function processClaimNameScript has 59 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func processClaimNameScript(script *[]byte, vout model.Output, tx model.Transaction, blockHeight uint64) (name string, claimid string, pkscript []byte, err error) {
    claimid, err = util.ClaimIDFromOutpoint(vout.TransactionHash, int(vout.Vout))
    if err != nil {
        return name, "", pkscript, err
    }
Severity: Minor
Found in daemon/processing/claim.go - About 1 hr to fix

Function setChannelMetadata has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
Open

func setChannelMetadata(claim *model.Claim, channel pb.Channel) {
    claim.Type.SetValid(global.ChannelClaimType)
    if channel.GetCover() != nil {
        c := channel.GetCover()
        if c.GetName() != "" {
Severity: Minor
Found in daemon/processing/claim.go - About 1 hr 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 processClaimUpdateScript has 51 lines of code (exceeds 50 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 1 hr to fix

Function setChannelMetadata has 51 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func setChannelMetadata(claim *model.Claim, channel pb.Channel) {
    claim.Type.SetValid(global.ChannelClaimType)
    if channel.GetCover() != nil {
        c := channel.GetCover()
        if c.GetName() != "" {
Severity: Minor
Found in daemon/processing/claim.go - About 1 hr to fix

Function setStreamMetadata has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
Open

func setStreamMetadata(claim *model.Claim, stream pb.Stream) {
    claim.Type.SetValid(global.StreamClaimType)
    if stream.GetAuthor() != "" {
        claim.Author.SetValid(stream.GetAuthor())
    }
Severity: Minor
Found in daemon/processing/claim.go - About 55 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 processClaimNameScript has 7 return statements (exceeds 4 allowed).
Open

func processClaimNameScript(script *[]byte, vout model.Output, tx model.Transaction, blockHeight uint64) (name string, claimid string, pkscript []byte, err error) {
    claimid, err = util.ClaimIDFromOutpoint(vout.TransactionHash, int(vout.Vout))
    if err != nil {
        return name, "", pkscript, err
    }
Severity: Major
Found in daemon/processing/claim.go - About 45 mins to fix

Function saveUnknownClaim has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

func saveUnknownClaim(name string, claimid string, isUpdate bool, value []byte, vout model.Output, tx model.Transaction) {
Severity: Minor
Found in daemon/processing/claim.go - About 45 mins to fix

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

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) {
Severity: Minor
Found in daemon/processing/claim.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 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 processClaimUpdateScript has 5 return statements (exceeds 4 allowed).
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: Major
Found in daemon/processing/claim.go - About 35 mins to fix

There are no issues that match your filters.

Category
Status