svthalia/concrexit

View on GitHub
website/thaliawebsite/templatetags/menu.py

Summary

Maintainability
C
1 day
Test Coverage

Function collect_menus has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

def collect_menus():
    categories = defaultdict(list)
    main_menu = []

    for app in apps.get_app_configs():
Severity: Minor
Found in website/thaliawebsite/templatetags/menu.py - About 3 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 collect_usermenu has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

def collect_usermenu():
    sections = defaultdict(list)

    for app in apps.get_app_configs():
        if hasattr(app, "user_menu_items"):
Severity: Minor
Found in website/thaliawebsite/templatetags/menu.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 render_main_menu has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

def render_main_menu(context):
    """Render the main menu in this place.

    Accounts for logged-in status and locale.
    """
Severity: Minor
Found in website/thaliawebsite/templatetags/menu.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

Avoid deeply nested control flow statements.
Open

                    if category["name"] not in categories:
                        categories[category["name"]] = {"items": [], **category}

Severity: Major
Found in website/thaliawebsite/templatetags/menu.py - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                    if section["name"] not in sections:
                        sections[section["name"]] = {"items": [], **section}

Severity: Major
Found in website/thaliawebsite/templatetags/menu.py - About 45 mins to fix

There are no issues that match your filters.

Category
Status