Showing 68 of 112 total issues
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
File claimtriesync.go
has 556 lines of code (exceeds 500 allowed). Consider refactoring. Open
package jobs
import (
"database/sql"
"encoding/json"
- Create a ticketCreate a ticket
Method chainSyncStatus.alignVout
has a Cognitive Complexity of 33 (exceeds 20 allowed). Consider refactoring. Open
func (c *chainSyncStatus) alignVout(v lbrycrd.Vout) error {
colsToUpdate := make([]string, 0)
if c.Vout.Value.Float64 != v.Value {
c.Vout.Value.SetValid(v.Value)
colsToUpdate = append(colsToUpdate, model.OutputColumns.Value)
- 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 a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring. Open
func updateSpentClaims() error {
var lastProcessed uint64
for {
//Claims without updates
claims, newLastProcessed, err := getSpentClaimsToUpdate(false, lastProcessed)
- 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 createUpdateVoutAddresses
has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring. 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 {
- 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 createUpdateVinAddresses
has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring. Open
func createUpdateVinAddresses(tx *model.Transaction, inputs *[]lbrycrd.Vin, blockSeconds uint64) (map[string]uint64, error) {
addressIDMap := make(map[string]uint64)
for _, input := range *inputs {
srcOutput := datastore.GetOutput(input.TxID, uint(input.Vout))
if srcOutput == nil {
- 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 ProcessVin
has 71 lines of code (exceeds 50 allowed). Consider refactoring. Open
func ProcessVin(jsonVin *lbrycrd.Vin, tx *m.Transaction, txDC *txDebitCredits, n uint64) error {
defer metrics.Processing(time.Now(), "vin")
isVinCoinbase := len(jsonVin.Coinbase) > 0
vin := &m.Input{
TransactionID: tx.ID,
- Create a ticketCreate a ticket
Function ProcessVout
has 69 lines of code (exceeds 50 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 {
- Create a ticketCreate a ticket
Function fixOutputs
has 63 lines of code (exceeds 50 allowed). Consider refactoring. Open
func fixOutputs() error {
wg := sync.WaitGroup{}
spentClaimsChan := make(chan *model.Claim, 100)
errorsChan := make(chan error, runtime.NumCPU())
c := model.ClaimColumns
- Create a ticketCreate a ticket
Method chainSyncStatus.alignBlock
has 59 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (c *chainSyncStatus) alignBlock(l *lbrycrd.GetBlockResponse) error {
colsToUpdate := make([]string, 0)
if c.Block.Hash != l.Hash {
c.Block.Hash = l.Hash
colsToUpdate = append(colsToUpdate, model.BlockColumns.Hash)
- 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 ValidateChainRange
has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring. Open
func ValidateChainRange(from, to *uint64) ([]BlockData, error) {
if from == nil {
start := uint64(0)
from = &start
- 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 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 ClaimEvent
has 56 lines of code (exceeds 50 allowed). Consider refactoring. Open
func ClaimEvent(claim *model.Claim, tx model.Transaction, claimData *c.StakeHelper) {
values := url.Values{}
values.Add("claim_id", claim.ClaimID)
values.Add("name", claim.Name)
if !claim.Type.IsZero() {
- Create a ticketCreate a ticket
Function SyncTransactionValue
has 53 lines of code (exceeds 50 allowed). Consider refactoring. Open
func SyncTransactionValue() (int64, error) {
transactionTbl := model.TableNames.Transaction
transactionAddressTbl := model.TableNames.TransactionAddress
blockTbl := model.TableNames.Block
- Create a ticketCreate a ticket
Function updateSpentClaims
has 53 lines of code (exceeds 50 allowed). Consider refactoring. Open
func updateSpentClaims() error {
var lastProcessed uint64
for {
//Claims without updates
claims, newLastProcessed, err := getSpentClaimsToUpdate(false, lastProcessed)
- Create a ticketCreate a ticket
Function setClaimAddresses
has 53 lines of code (exceeds 50 allowed). Consider refactoring. Open
func setClaimAddresses() {
type claimForClaimAddress struct {
ID uint64 `boil:"id"`
ScriptPubKeyHex string `boil:"script_pub_key_hex"`
ClaimAddress string `boil:"claim_address"`
- 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 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 ProcessVout
has 10 return statements (exceeds 4 allowed). 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 {
- Create a ticketCreate a ticket