batiste/django-page-cms

View on GitHub

Showing 118 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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

              if (document.cookie && document.cookie != '') {
                  var cookies = document.cookie.split(';');
                  for (var i = 0; i < cookies.length; i++) {
                      var cookie = jQuery.trim(cookies[i]);
                      // Does this cookie string begin with the name we want?
      Severity: Major
      Found in pages/static/pages/javascript/pages.js and 1 other location - About 5 hrs to fix
      pages/static/pages/javascript/pages.js on lines 7..17

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 152.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

              if (document.cookie && document.cookie != '') {
                  var cookies = document.cookie.split(';');
                  for (var i = 0; i < cookies.length; i++) {
                      var cookie = jQuery.trim(cookies[i]);
                      // Does this cookie string begin with the name we want?
      Severity: Major
      Found in pages/static/pages/javascript/pages.js and 1 other location - About 5 hrs to fix
      pages/static/pages/javascript/pages.js on lines 55..65

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 152.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          def pages_menu(context, page, url='/'):
              """Render a nested list of all the descendents of the given page,
              including this page.
          
              :param page: the page where to start the menu from.
          Severity: Major
          Found in pages/templatetags/pages_tags.py and 1 other location - About 3 hrs to fix
          pages/templatetags/pages_tags.py on lines 121..133

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 68.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          def pages_siblings_menu(context, page, url='/'):
              """Get the parent page of the given page and render a nested list of its
              child pages. Good for rendering a secondary menu.
          
              :param page: the page where to start the menu from.
          Severity: Major
          Found in pages/templatetags/pages_tags.py and 1 other location - About 3 hrs to fix
          pages/templatetags/pages_tags.py on lines 81..93

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 68.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          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
                  Severity
                  Category
                  Status
                  Source
                  Language