daemon/jobs/claimtriesync.go
File claimtriesync.go
has 556 lines of code (exceeds 500 allowed). Consider refactoring. Open
Open
package jobs
import (
"database/sql"
"encoding/json"
- Create a ticketCreate a ticket
Function ClaimTrieSync
has 92 lines of code (exceeds 50 allowed). Consider refactoring. Wontfix
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() {
- Create a ticketCreate a ticket
Function updateSpentClaims
has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring. Open
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 updateSpentClaims
has 53 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func updateSpentClaims() error {
var lastProcessed uint64
for {
//Claims without updates
claims, newLastProcessed, err := getSpentClaimsToUpdate(false, lastProcessed)
- Create a ticketCreate a ticket
Function ClaimTrieSync
has 8 return statements (exceeds 4 allowed). Open
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() {
- Create a ticketCreate a ticket
Function updateSpentClaims
has 5 return statements (exceeds 4 allowed). Open
Open
func updateSpentClaims() error {
var lastProcessed uint64
for {
//Claims without updates
claims, newLastProcessed, err := getSpentClaimsToUpdate(false, lastProcessed)
- Create a ticketCreate a ticket
Function reprocessUpdatedClaims
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
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 {
- 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 GetIsExpiredAtHeight
has 5 return statements (exceeds 4 allowed). Open
Open
func GetIsExpiredAtHeight(height, blockHeight uint) bool {
if height == 0 {
return false
}
if height >= expirationHardForkHeight {
- Create a ticketCreate a ticket
Your code does not pass gofmt in 1 place. Go fmt your code! Open
Open
package jobs
- Create a ticketCreate a ticket
- Exclude checks