File claim.go
has 624 lines of code (exceeds 500 allowed). Consider refactoring. Open
package processing
import (
"encoding/hex"
"encoding/json"
- Create a ticketCreate a ticket
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
}
- Create a ticketCreate a ticket
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() != "" {
- 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 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() != "" {
- Create a ticketCreate a ticket
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
- Create a ticketCreate a ticket
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())
}
- 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 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) {
- Create a ticketCreate a ticket
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
}
- 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 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 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
- 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 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