lbryio/chainquery

View on GitHub

Showing 64 of 97 total issues

File claim.go has 615 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 4 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

File claimtriesync.go has 511 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 2 hrs to fix

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 ProcessVin has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring.
Open

func ProcessVin(jsonVin *lbrycrd.Vin, tx *m.Transaction, txDC *txDebitCredits, n uint64) error {
    defer metrics.Processing(time.Now(), "vin")
    vin := &m.Input{}
    foundVin := ds.GetInput(tx.Hash, len(jsonVin.Coinbase) > 0, jsonVin.TxID, uint(jsonVin.Vout))
    if foundVin != nil {
Severity: Minor
Found in daemon/processing/outpoint.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 70 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")
    vin := &m.Input{}
    foundVin := ds.GetInput(tx.Hash, len(jsonVin.Coinbase) > 0, jsonVin.TxID, uint(jsonVin.Vout))
    if foundVin != nil {
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

Method chainSyncStatus.alignBlock has 63 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 getUpdatedClaims has 63 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func getUpdatedClaims(jobStatus *model.JobStatus) (model.ClaimSlice, error) {
    prevNamesLength := 0
    // CLAIMS THAT HAVE SUPPORTS THAT WERE MODIFIED [SELECT support.supported_claim_id FROM support WHERE support.modified_at >= '2019-11-03 19:48:58';]
    s := model.SupportColumns
    supports, err := model.Supports(qm.Select(s.SupportedClaimID), model.SupportWhere.ModifiedAt.GTE(jobStatus.LastSync)).AllG()
Severity: Minor
Found in daemon/jobs/claimtriesync.go - About 1 hr to fix

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

func setStreamMetadata(claim *model.Claim, stream pb.Stream) {
    claim.Type.SetValid(global.StreamClaimType)
    claim.Author.SetValid(stream.GetAuthor())
    setLicense(claim, stream)
    claim.Preview.SetValid("") //Never set
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 processClaimNameScript has 56 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 setStreamMetadata has 54 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func setStreamMetadata(claim *model.Claim, stream pb.Stream) {
    claim.Type.SetValid(global.StreamClaimType)
    claim.Author.SetValid(stream.GetAuthor())
    setLicense(claim, stream)
    claim.Preview.SetValid("") //Never set
Severity: Minor
Found in daemon/processing/claim.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 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 SyncClaimCntInChannel has 52 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func SyncClaimCntInChannel() error {

    t := model.TableNames
    c := model.ClaimColumns

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 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 {
Severity: Major
Found in daemon/processing/outpoint.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")
    vin := &m.Input{}
    foundVin := ds.GetInput(tx.Hash, len(jsonVin.Coinbase) > 0, jsonVin.TxID, uint(jsonVin.Vout))
    if foundVin != nil {
Severity: Major
Found in daemon/processing/outpoint.go - About 1 hr to fix
Severity
Category
Status
Source
Language