divio/django-cms

View on GitHub
menus/modifiers.py

Summary

Maintainability
D
1 day
Test Coverage

Function modify has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
Open

    def modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb):
        if post_cut or breadcrumb:
            return nodes
        selected = None
        root_nodes = []
Severity: Minor
Found in menus/modifiers.py - About 7 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 modify has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb):
        if post_cut or breadcrumb:
            return nodes
        final = []
        for node in nodes:
Severity: Minor
Found in menus/modifiers.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 not sibling.selected:
                            sibling.sibling = True
                else:
Severity: Major
Found in menus/modifiers.py - About 45 mins to fix

    Function modify has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb):
    Severity: Minor
    Found in menus/modifiers.py - About 45 mins to fix

      Function modify has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb):
              if breadcrumb:
                  return nodes
              for node in nodes:
      
      
      Severity: Minor
      Found in menus/modifiers.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 not root_node.selected:
                                  root_node.sibling = True
                      if node.children:
      Severity: Major
      Found in menus/modifiers.py - About 45 mins to fix

        Function modify has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb):
        Severity: Minor
        Found in menus/modifiers.py - About 45 mins to fix

          Function modify has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb):
          Severity: Minor
          Found in menus/modifiers.py - About 45 mins to fix

            There are no issues that match your filters.

            Category
            Status