daemon/processing/address.go
Function createUpdateVoutAddresses
has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring. Open
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 {
- 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 createUpdateVinAddresses
has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring. 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 {
- 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 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 createUpdateVoutAddresses
has 6 return statements (exceeds 4 allowed). Open
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 {
- Create a ticketCreate a ticket
Function getFirstAddressFromVout
has 5 return statements (exceeds 4 allowed). Open
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)
- Create a ticketCreate a ticket