batiste/django-page-cms

View on GitHub

Showing 77 of 118 total issues

Function make_form has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring.
Open

def make_form(model_, placeholders):

    # a new form is needed every single time as some
    # initial data are bound
    class PageForm(forms.ModelForm):
Severity: Minor
Found in pages/admin/forms.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

File pages_tags.py has 488 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""Page CMS page_tags template tags"""
from django import template
from django.utils.safestring import SafeText
from django.template import TemplateSyntaxError
from django.conf import settings
Severity: Minor
Found in pages/templatetags/pages_tags.py - About 7 hrs to fix

    File models.py has 470 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    """Django page CMS ``models``."""
    
    from pages.cache import cache
    from pages.utils import get_placeholders, normalize_url, get_now
    from pages.managers import PageManager, ContentManager
    Severity: Minor
    Found in pages/models.py - About 7 hrs to fix

      Function _placeholders_recursif has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
      Open

      def _placeholders_recursif(nodelist, plist, blist):
          """Recursively search into a template node list for PlaceholderNode
          node."""
          # I needed to do this lazy import to compile the documentation
          from django.template.loader_tags import BlockNode
      Severity: Minor
      Found in pages/utils.py - About 6 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 create_and_update_from_json_data has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
      Open

      def create_and_update_from_json_data(d, user):
          """
          Create or update page based on python dict d loaded from JSON data.
          This applies all data except for redirect_to, which is done in a
          second pass after all pages have been imported,
      Severity: Minor
      Found in pages/plugins/jsonexport/utils.py - About 5 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

      File placeholders.py has 407 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      """Placeholder module, that's where the smart things happen."""
      from pages.widgets_registry import get_widget
      from pages import settings
      from pages.models import Content, Media
      from pages.widgets import ImageInput, FileInput
      Severity: Minor
      Found in pages/placeholders.py - About 5 hrs to fix

        Function validate_pages_json_data has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
        Open

        def validate_pages_json_data(d, preferred_lang):
            """
            Check if an import of d will succeed, and return errors.
        
            errors is a list of strings.  The import should proceed only if errors
        Severity: Minor
        Found in pages/plugins/jsonexport/utils.py - About 5 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 export_po_files has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
        Open

        def export_po_files(path='poexport', stdout=None):
            """
            Export all the content from the published pages into
            po files. The files will be automatically updated
            with the new content if you run the command again.
        Severity: Minor
        Found in pages/plugins/pofiles/utils.py - About 4 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 cookie has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
        Open

        pages.cookie = function(name, value, options) {
            if (typeof value != 'undefined') { // name and value given, set cookie
                options = options || {};
                if (value === null) {
                    value = '';
        Severity: Minor
        Found in pages/static/pages/javascript/pages.js - About 4 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 parse_placeholder has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
        Open

        def parse_placeholder(parser, token):
            """Parse the `PlaceholderNode` parameters.
        
            Return a tuple with the name and parameters."""
            params = {}
        Severity: Minor
        Found in pages/placeholders.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 bind_sortable has 96 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function bind_sortable() {
                // Initialise the table for drag and drop
                var down = false;
                var move_y = 0;
                var start_y = 0;
        Severity: Major
        Found in pages/static/pages/javascript/pages_list.js - About 3 hrs to fix

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

          def import_po_files(path='poexport', stdout=None):
              """
              Import all the content updates from the po files into
              the pages.
              """
          Severity: Minor
          Found in pages/plugins/pofiles/utils.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

          File __init__.py has 301 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          # -*- coding: utf-8 -*-
          """Page Admin module."""
          from pages import settings
          from pages.models import Page, Content, PageAlias, Media
          from pages.phttp import get_language_from_request, get_template_from_request
          Severity: Minor
          Found in pages/admin/__init__.py - About 3 hrs to fix

            File utils.py has 300 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            from django.db.models import Max
            from django.utils.translation import ugettext_lazy as _
            from django.contrib.sites.models import Site
            from django.conf import settings as global_settings
            from django.contrib.auth import get_user_model
            Severity: Minor
            Found in pages/plugins/jsonexport/utils.py - About 3 hrs to fix

              Page has 26 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class Page(MPTTModel):
                  """
                  This model contain the status, dates, author, template.
                  The real content of the page can be found in the
                  :class:`Content <pages.models.Content>` model.
              Severity: Minor
              Found in pages/models.py - About 3 hrs to fix

                File pages_list.js has 284 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                /* Initialization of the change_list page - this script is run once everything is ready. */
                $(function($) {
                    "use strict";
                
                    if(!$("body").hasClass("change-list-pages")) {
                Severity: Minor
                Found in pages/static/pages/javascript/pages_list.js - About 2 hrs to fix

                  Function modify_placeholder has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def modify_placeholder(request, page_id):
                      """Modify the content of a page."""
                      content_type = request.GET.get('content_type')
                      language_id = request.GET.get('language_id')
                      page = get_object_or_404(Page, pk=page_id)
                  Severity: Minor
                  Found in pages/admin/views.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 __call__ has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def __call__(
                              self, request, path=None, lang=None, delegation=True,
                              **kwargs):
                  
                          current_page = False
                  Severity: Minor
                  Found in pages/views.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_content has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def get_content(self, page, language, ctype, language_fallback=False):
                          """Gets the latest content string for a particular page, language and
                          placeholder.
                  
                          :param page: the concerned page object.
                  Severity: Minor
                  Found in pages/managers.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

                  File managers.py has 270 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  # -*- coding: utf-8 -*-
                  """Django page CMS ``managers``."""
                  from pages import settings
                  from pages.cache import cache
                  from pages.utils import normalize_url, get_now
                  Severity: Minor
                  Found in pages/managers.py - About 2 hrs to fix
                    Severity
                    Category
                    Status
                    Source
                    Language