evilsoapbox/walkscore_frontend

View on GitHub

Showing 4 of 4 total issues

Function regex_page_data_table has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

def regex_page_data_table(pattern, content):
    """
    Extract data from a table on the text based on an id and value.
    
    :param pattern: id and value of element to parse
Severity: Minor
Found in walkscore_frontend/regex.py - 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 regex_page_data has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def regex_page_data(pattern, content, rtype = None):
    """
    Get a value from page data based on a regex pattern.
    
    :param pattern: regex pattern to match against
Severity: Minor
Found in walkscore_frontend/regex.py - About 45 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 parse_data_points has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def parse_data_points(content):
    """
    Parse the page data and look for expected contents based on regular expressions.
    
    :param content: content to search
Severity: Minor
Found in walkscore_frontend/regex.py - About 45 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

Avoid deeply nested control flow statements.
Open

                    if last_element.replace('_', ' ') != row_data[headings[i]]:
                        row_data[headings[i]] = last_element.replace('_', ' ')
            table_data.append(row_data)
Severity: Major
Found in walkscore_frontend/regex.py - About 45 mins to fix
    Severity
    Category
    Status
    Source
    Language