lbryio/chainquery

View on GitHub
daemon/jobs/claimtriesync.go

Summary

Maintainability
C
1 day
Test Coverage

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

Function ClaimTrieSync has 92 lines of code (exceeds 50 allowed). Consider refactoring.
Wontfix

func ClaimTrieSync() {
    metrics.JobLoad.WithLabelValues("claimtrie_sync").Inc()
    defer metrics.JobLoad.WithLabelValues("claimtrie_sync").Dec()
    defer metrics.Job(time.Now(), "claimtrie_sync")
    defer func() {
Severity: Major
Found in daemon/jobs/claimtriesync.go - About 2 hrs to fix

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 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 ClaimTrieSync has 8 return statements (exceeds 4 allowed).
Open

func ClaimTrieSync() {
    metrics.JobLoad.WithLabelValues("claimtrie_sync").Inc()
    defer metrics.JobLoad.WithLabelValues("claimtrie_sync").Dec()
    defer metrics.Job(time.Now(), "claimtrie_sync")
    defer func() {
Severity: Major
Found in daemon/jobs/claimtriesync.go - About 50 mins to fix

Function updateSpentClaims has 5 return statements (exceeds 4 allowed).
Open

func updateSpentClaims() error {
    var lastProcessed uint64
    for {
        //Claims without updates
        claims, newLastProcessed, err := getSpentClaimsToUpdate(false, lastProcessed)
Severity: Major
Found in daemon/jobs/claimtriesync.go - About 35 mins to fix

Function GetIsExpiredAtHeight has 5 return statements (exceeds 4 allowed).
Open

func GetIsExpiredAtHeight(height, blockHeight uint) bool {
    if height == 0 {
        return false
    }
    if height >= expirationHardForkHeight {
Severity: Major
Found in daemon/jobs/claimtriesync.go - About 35 mins to fix

Function reprocessUpdatedClaims has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
Open

func reprocessUpdatedClaims(claimsChan chan *model.Claim, currentHeight uint64, processedClaims *int64) error {
    const BatchSize = 5000
    reprocessedNamesMap := make(map[string]bool, 500000)
    claimsBatch := make(model.ClaimSlice, 0, BatchSize)
    for {
Severity: Minor
Found in daemon/jobs/claimtriesync.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

Your code does not pass gofmt in 1 place. Go fmt your code!
Open

package jobs
Severity: Minor
Found in daemon/jobs/claimtriesync.go by gofmt

There are no issues that match your filters.

Category
Status