lbryio/chainquery

View on GitHub

Showing 68 of 114 total issues

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

File claimtriesync.go has 556 lines of code (exceeds 500 allowed). Consider refactoring.
Open

package jobs

import (
    "database/sql"
    "encoding/json"
Severity: Minor
Found in daemon/jobs/claimtriesync.go - About 3 hrs to fix

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)
Severity: Minor
Found in daemon/jobs/chainsync.go - About 2 hrs 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 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)
Severity: Minor
Found in daemon/jobs/claimtriesync.go - About 2 hrs 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 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 {
Severity: Minor
Found in daemon/processing/address.go - About 2 hrs 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 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 {
Severity: Minor
Found in daemon/processing/address.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 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,
Severity: Minor
Found in daemon/processing/outpoint.go - About 1 hr to fix

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 {
Severity: Minor
Found in daemon/processing/outpoint.go - About 1 hr to fix

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
Severity: Minor
Found in daemon/jobs/outputfixsync.go - About 1 hr to fix

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)
Severity: Minor
Found in daemon/jobs/chainsync.go - About 1 hr 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 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
Severity: Minor
Found in daemon/jobs/chainvalidation.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 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() {
Severity: Minor
Found in notifications/events.go - About 1 hr to fix

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"`
Severity: Minor
Found in daemon/upgrademanager/script.go - About 1 hr to fix

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)
Severity: Minor
Found in daemon/jobs/claimtriesync.go - About 1 hr to fix

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
Severity: Minor
Found in daemon/jobs/valuesync.go - About 1 hr to fix

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 ProcessVin has 10 return statements (exceeds 4 allowed).
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,
Severity: Major
Found in daemon/processing/outpoint.go - About 1 hr to fix
Severity
Category
Status
Source
Language