Nekmo/django-code-generator

View on GitHub

Showing 3 of 10 total issues

Function indent_items has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def indent_items(items, spaces, backslash=False, quote=False):
    """Prints elements of a list separated by commas. If the line length exceeds :const:`MAX_LENGTH` it
    breaks to another line. The new line is indented. The first line is not indented.

    :param items: items to print.
Severity: Minor
Found in django_code_generator/templatetags/code_generator_tags.py - 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 format_indent_line has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

def format_indent_line(items, spaces, indent, backslash, is_last):
Severity: Minor
Found in django_code_generator/templatetags/code_generator_tags.py - About 35 mins to fix

    Function read_requirements_files has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def read_requirements_files(files):
        reqs = []
        for file in files:
            if StrictVersion(setuptool_version) >= StrictVersion('20.2'):
                reqs.extend([('{};{}'.format(req, file['marker']) if file.get('marker') else req)
    Severity: Minor
    Found in setup_py2.py - About 35 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

    Severity
    Category
    Status
    Source
    Language