divio/django-cms

View on GitHub
menus/menu_pool.py

Summary

Maintainability
B
5 hrs
Test Coverage

Function _build_nodes_inner_for_one_menu has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

def _build_nodes_inner_for_one_menu(nodes, menu_class_name):
    '''
    This is an easier to test "inner loop" building the menu tree structure
    for one menu (one language, one site)
    '''
Severity: Minor
Found in menus/menu_pool.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 get_registered_menus has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def get_registered_menus(self, for_rendering=False):
        """
        Returns all registered menu classes.

        :param for_rendering: Flag that when True forces us to include
Severity: Minor
Found in menus/menu_pool.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 _build_nodes has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def _build_nodes(self):
        """
        This is slow. Caching must be used.
        One menu is built per language and per site.

Severity: Minor
Found in menus/menu_pool.py - About 55 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 apply_modifiers has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def apply_modifiers(self, nodes, namespace=None, root_id=None,
Severity: Minor
Found in menus/menu_pool.py - About 35 mins to fix

    There are no issues that match your filters.

    Category
    Status