divio/django-cms

View on GitHub

Showing 579 of 869 total issues

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

def set_local_revision(revision):
    if use_threadlocal:
        if revision:
            _urlconf_revision_threadlocal.value = revision
        else:
Severity: Minor
Found in cms/utils/apphook_reload.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

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

    def is_new_dirty(self):
        if self.pk:
            fields = [
                'publication_date', 'publication_end_date', 'in_navigation', 'soft_root', 'reverse_id',
                'navigation_extenders', 'template', 'login_required', 'limit_visibility_in_menu'
Severity: Minor
Found in cms/models/pagemodel.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

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

def admin_reverse(viewname, urlconf=None, args=None, kwargs=None, prefix=None,
Severity: Minor
Found in cms/utils/urlutils.py - About 45 mins to fix

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

    def get_available_slug(site, path, language, suffix='copy', modified=False, current=None):
    Severity: Minor
    Found in cms/utils/page.py - About 45 mins to fix

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

      def get_view_restrictions(pages):
          """
          Load all view restrictions for the pages
          """
          restricted_pages = defaultdict(list)
      Severity: Minor
      Found in cms/utils/permissions.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 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

        Avoid deeply nested control flow statements.
        Open

                                if extnode.namespace == ext and not extnode.parent_id:
                                    # if home has nav extenders but home is not visible
                                    if node == home and not node.visible:
                                        # extnode.parent_id = None
                                        extnode.parent_namespace = None
        Severity: Major
        Found in cms/cms_menus.py - About 45 mins to fix

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

              def publish(self, language):
                  """
                  :returns: True if page was successfully published.
                  """
                  from cms.utils.permissions import get_current_user_name
          Severity: Minor
          Found in cms/models/pagemodel.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 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 render_change_form has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def render_change_form(self, request, context, add=False, change=False, form_url='', obj=None):
            Severity: Minor
            Found in cms/plugin_base.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                          if str(e) == template:
                                              raise ImproperlyConfigured(
                                                  "CMS Plugins must define a render template (%s) that exists: %s"
                                                  % (plugin, template)
                                              )
              Severity: Major
              Found in cms/plugin_pool.py - About 45 mins to fix

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

                    def save(self, no_signals=False, *args, **kwargs):
                        if not self.depth:
                            if self.parent_id or self.parent:
                                self.parent.add_child(instance=self)
                            else:
                Severity: Minor
                Found in cms/models/pluginmodel.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 fallback_plugins:
                                        fallbacks[placeholder.pk] += fallback_plugins
                                        break
                    # These placeholders have no fallback
                    non_fallback_phs = [ph for ph in placeholders if ph.pk not in fallbacks]
                Severity: Major
                Found in cms/utils/plugins.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

                    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 cms/cms_menus.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

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

                            def _create_user(self, username, email, password,
                        Severity: Minor
                        Found in cms/test_utils/project/customuserapp/models.py - About 45 mins to fix

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

                              def get_request(self, path=None, language=None, post_data=None, enforce_csrf_checks=False, page=None, domain=None):
                          Severity: Minor
                          Found in cms/test_utils/testcases.py - About 45 mins to fix

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

                                def failUnlessWarns(self, category, message, f, *args, **kwargs):
                            Severity: Minor
                            Found in cms/test_utils/testcases.py - About 45 mins to fix

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

                                  def failUnlessWarns(self, category, message, f, *args, **kwargs):
                                      warningsShown = []
                                      cleanwarningsShown = []
                                      result = _collectWarnings(warningsShown.append, f, *args, **kwargs)
                              
                              
                              Severity: Minor
                              Found in cms/test_utils/testcases.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

                              Severity
                              Category
                              Status
                              Source
                              Language