lbryio/chainquery

View on GitHub
daemon/processing/address.go

Summary

Maintainability
B
6 hrs
Test Coverage

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 createUpdateVinAddresses has 7 return statements (exceeds 4 allowed).
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: Major
Found in daemon/processing/address.go - About 45 mins to fix

Function createUpdateVoutAddresses has 6 return statements (exceeds 4 allowed).
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: Major
Found in daemon/processing/address.go - About 40 mins to fix

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

func getFirstAddressFromVout(vout lbrycrd.Vout) (scriptAddress string, err error) {
    if vout.ScriptPubKey.Type == lbrycrd.NonStandard {
        scriptAddress, err = getAddressFromNonStandardVout(vout.ScriptPubKey.Hex)
        if errors.Is(err, lbrycrd.ErrNotClaimScript) {
            logrus.Warning(err)
Severity: Major
Found in daemon/processing/address.go - About 35 mins to fix

There are no issues that match your filters.

Category
Status