divio/django-cms

View on GitHub
cms/plugin_rendering.py

Summary

Maintainability
D
2 days
Test Coverage

File plugin_rendering.py has 495 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import contextlib
from collections import OrderedDict
from functools import partial

from classytags.utils import flatten_context
Severity: Minor
Found in cms/plugin_rendering.py - About 7 hrs to fix

    Function render_placeholder has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

        def render_placeholder(self, placeholder, context, language=None, page=None,
                               editable=False, use_cache=False, nodelist=None, width=None):
            from sekizai.helpers import Watcher
    
            language = language or self.request_language
    Severity: Minor
    Found in cms/plugin_rendering.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 _preload_placeholders_for_page has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def _preload_placeholders_for_page(self, page, slots=None, inherit=False):
            """
            Populates the internal plugin cache of each placeholder
            in the given page if the placeholder has not been
            previously cached.
    Severity: Minor
    Found in cms/plugin_rendering.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 render_page_placeholder has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def render_page_placeholder(self, slot, context, inherit,
                                    page=None, nodelist=None, editable=True):
            if not self.current_page:
                # This method should only be used when rendering a cms page.
                return ''
    Severity: Minor
    Found in cms/plugin_rendering.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 render_placeholder has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def render_placeholder(self, placeholder, context, language=None, page=None,
    Severity: Major
    Found in cms/plugin_rendering.py - About 1 hr to fix

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

          def render_page_placeholder(self, slot, context, inherit,
      Severity: Minor
      Found in cms/plugin_rendering.py - About 45 mins to fix

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

            def __init__(self, placeholder, language, site_id, cached=False,
        Severity: Minor
        Found in cms/plugin_rendering.py - About 45 mins to fix

          Function render_plugins has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def render_plugins(self, placeholder, language, context, editable=False, template=None):
          Severity: Minor
          Found in cms/plugin_rendering.py - About 35 mins to fix

            Function __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def __init__(self, dict_, instance, placeholder, processors=None, current_app=None):
            Severity: Minor
            Found in cms/plugin_rendering.py - About 35 mins to fix

              There are no issues that match your filters.

              Category
              Status