Showing 107 of 112 total issues
Function ClaimEvent
has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring. Open
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() {
- 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 ValidateChainRange
has 8 return statements (exceeds 4 allowed). Open
Open
func ValidateChainRange(from, to *uint64) ([]BlockData, error) {
if from == nil {
start := uint64(0)
from = &start
- 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 readCompactSize
has 8 return statements (exceeds 4 allowed). Open
Open
func readCompactSize(bs *bytes.Buffer) (uint64, []byte, error) {
var readBuf []byte
bSize := make([]byte, 1)
_, err := bs.Read(bSize)
if err != nil {
- Create a ticketCreate a ticket
Function createUpdateVinAddresses
has 7 return statements (exceeds 4 allowed). Open
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 {
- Create a ticketCreate a ticket
Function ProcessTx
has 7 return statements (exceeds 4 allowed). Open
Open
func ProcessTx(jsonTx *lbrycrd.TxRawResult, blockTime uint64, blockHeight uint64) error {
defer metrics.Processing(time.Now(), "transaction")
defer util.TimeTrack(time.Now(), "processTx "+jsonTx.Txid+" -- ", "daemonprofile")
//Save transaction before the id is used anywhere else otherwise it will be 0
- Create a ticketCreate a ticket
Function GetPubKeyScriptFromClaimPKS
has 7 return statements (exceeds 4 allowed). Open
Open
func GetPubKeyScriptFromClaimPKS(script []byte) (pubkeyscript []byte, err error) {
if IsClaimScript(script) {
if IsClaimNameScript(script) {
_, _, pubkeyscript, err = ParseClaimNameScript(script)
if err != nil {
- Create a ticketCreate a ticket
Function processClaimNameScript
has 7 return statements (exceeds 4 allowed). Open
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 SyncName
has 7 return statements (exceeds 4 allowed). Open
Open
func SyncName(r *http.Request) api.Response {
params := struct {
Name string
Key string
- Create a ticketCreate a ticket
Method chainSyncStatus.alignVout
has 7 return statements (exceeds 4 allowed). Open
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)
- Create a ticketCreate a ticket
Function RunBlockProcessing
has 7 return statements (exceeds 4 allowed). Open
Open
func RunBlockProcessing(stopper *stop.Group, height uint64) uint64 {
defer metrics.Processing(time.Now(), "block")
defer util.TimeTrack(time.Now(), "runBlockProcessing", "daemonprofile")
if height == 0 {
err := processGenesisBlock()
- Create a ticketCreate a ticket
Function SyncClaimCntInChannel
has 7 return statements (exceeds 4 allowed). Open
Open
func SyncClaimCntInChannel() error {
latestBlock, err := model.Blocks(qm.Select(model.BlockColumns.Height), qm.OrderBy(model.BlockColumns.Height+" DESC")).OneG()
if err != nil {
return errors.Prefix(syncClaimsInChannel, err)
}
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
Open
if err != nil {
return err
}
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
Open
if len(value) > 0 {
s, err := stake.DecodeSupportBytes(value, global.BlockChainName)
if err != nil {
return err
}
- Create a ticketCreate a ticket
Function setClaimAddresses
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
Open
func setClaimAddresses() {
type claimForClaimAddress struct {
ID uint64 `boil:"id"`
ScriptPubKeyHex string `boil:"script_pub_key_hex"`
ClaimAddress string `boil:"claim_address"`
- 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
Avoid deeply nested control flow statements. Open
Open
} else if txscript.IsPayToWitnessScriptHash(script) {
return p2WSH
}
- Create a ticketCreate a ticket
Method chainSyncStatus.processNextBlock
has 7 return statements (exceeds 4 allowed). Open
Open
func (c *chainSyncStatus) processNextBlock() error {
c.LastHeight = c.LastHeight + 1
blockHash, err := lbrycrd.LBRYcrdClient.GetBlockHash(c.LastHeight)
if err != nil {
return c.recordAndReturnError(c.LastHeight, "lbrycrd-getblockhash", err)
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
Open
if err != nil {
return
}
- Create a ticketCreate a ticket
Function AutoUpdateAction
has 7 return statements (exceeds 4 allowed). Open
Open
func AutoUpdateAction(r *http.Request) api.Response {
err := travis.ValidateSignature(true, r)
if err != nil {
logrus.Error(err)
return api.Response{Error: err, Status: http.StatusBadRequest}
- Create a ticketCreate a ticket
Function saveUnknownClaim
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func saveUnknownClaim(name string, claimid string, isUpdate bool, value []byte, vout model.Output, tx model.Transaction) {
- Create a ticketCreate a ticket