divio/django-cms

View on GitHub
cms/utils/placeholder.py

Summary

Maintainability
D
2 days
Test Coverage

Function _scan_placeholders has a Cognitive Complexity of 67 (exceeds 5 allowed). Consider refactoring.
Open

def _scan_placeholders(nodelist, node_class=None, current_block=None, ignore_blocks=None):
    from cms.templatetags.cms_tags import Placeholder

    if not node_class:
        node_class = Placeholder
Severity: Minor
Found in cms/utils/placeholder.py - About 1 day 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_placeholder_conf has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

def get_placeholder_conf(setting, placeholder, template=None, default=None):
    """
    Returns the placeholder configuration for a given setting. The key would for
    example be 'plugins' or 'name'.

Severity: Minor
Found in cms/utils/placeholder.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

Avoid deeply nested control flow statements.
Open

                    if isinstance(node, BlockNode):
                        current_block = node
                    nodes += _scan_placeholders(obj, node_class, current_block, ignore_blocks)
Severity: Major
Found in cms/utils/placeholder.py - About 45 mins to fix

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

        def copy(self, target_placeholder, source_language, fieldname, model, target_language, **kwargs):
    Severity: Minor
    Found in cms/utils/placeholder.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if isinstance(node.template.var, Variable):
                              continue
                          else:
                              template = get_template(node.template.var)
                      else:
      Severity: Major
      Found in cms/utils/placeholder.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if isinstance(subnodelist, NodeList):
                                if isinstance(node, BlockNode):
                                    current_block = node
                                nodes += _scan_placeholders(subnodelist, node_class, current_block, ignore_blocks)
                # else just scan the node for nodelist instance attributes
        Severity: Major
        Found in cms/utils/placeholder.py - About 45 mins to fix

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

          def _get_block_nodes(extend_node, previous_context=None):
              if not previous_context:
                  previous_context = get_context(extend_node)
              parent = extend_node.get_parent(previous_context)
              parent_nodelist = _get_nodelist(parent)
          Severity: Minor
          Found in cms/utils/placeholder.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

          There are no issues that match your filters.

          Category
          Status