getwtxt/getwtxt

View on GitHub
registry/fetch.go

Summary

Maintainability
A
3 hrs
Test Coverage

Function ParseRegistryTwtxt has 54 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func ParseRegistryTwtxt(twtxt []byte) ([]*User, error) {
    var erz []byte
    if len(twtxt) == 0 {
        return nil, fmt.Errorf("received no data")
    }
Severity: Minor
Found in registry/fetch.go - About 1 hr to fix

Function GetTwtxt has 7 return statements (exceeds 4 allowed).
Open

func GetTwtxt(urlKey string, client *http.Client) ([]byte, bool, error) {
    if !strings.HasPrefix(urlKey, "http://") && !strings.HasPrefix(urlKey, "https://") {
        return nil, false, fmt.Errorf("invalid URL: %v", urlKey)
    }

Severity: Major
Found in registry/fetch.go - About 45 mins to fix

Method Registry.DiffTwtxt has 5 return statements (exceeds 4 allowed).
Open

func (registry *Registry) DiffTwtxt(urlKey string) (bool, error) {
    if !strings.HasPrefix(urlKey, "http://") && !strings.HasPrefix(urlKey, "https://") {
        return false, fmt.Errorf("invalid URL: %v", urlKey)
    }

Severity: Major
Found in registry/fetch.go - About 35 mins to fix

Function ParseRegistryTwtxt has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
Open

func ParseRegistryTwtxt(twtxt []byte) ([]*User, error) {
    var erz []byte
    if len(twtxt) == 0 {
        return nil, fmt.Errorf("received no data")
    }
Severity: Minor
Found in registry/fetch.go - About 25 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

Function ParseUserTwtxt has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
Open

func ParseUserTwtxt(twtxt []byte, nickname, urlKey string) (TimeMap, error) {
    var erz []byte
    if len(twtxt) == 0 {
        return nil, fmt.Errorf("no data to parse in twtxt file")
    }
Severity: Minor
Found in registry/fetch.go - About 25 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

There are no issues that match your filters.

Category
Status