divio/django-cms

View on GitHub

Showing 579 of 869 total issues

Function updateResults has 109 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        updateResults: function (initial) {
            var search = this.search,
                results = this.results,
                opts = this.opts,
                data,
Severity: Major
Found in cms/static/cms/js/select2/select2.js - About 4 hrs to fix

    Function _get_page_by_untyped_arg has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

    def _get_page_by_untyped_arg(page_lookup, request, site_id):
        """
        The `page_lookup` argument can be of any of the following types:
        - Integer: interpreted as `pk` of the desired page
        - String: interpreted as `reverse_id` of the desired page
    Severity: Minor
    Found in cms/templatetags/cms_tags.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 get_cache_expiration has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_cache_expiration(self, request, response_timestamp):
            """
            Returns the number of seconds (from «response_timestamp») that this
            placeholder can be cached. This is derived from the plugins it contains.
    
    
    Severity: Minor
    Found in cms/models/placeholdermodel.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 check_copy_relations has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

    def check_copy_relations(output):
        from cms.extensions import extension_pool
        from cms.extensions.models import BaseExtension
        from cms.models.pluginmodel import CMSPlugin
        from cms.plugin_pool import plugin_pool
    Severity: Minor
    Found in cms/utils/check.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 _setButtons has 105 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        _setButtons(iframe) {
            var djangoSuit = iframe.contents().find('.suit-columns').length > 0;
            var that = this;
            var group = $('<div class="cms-modal-item-buttons"></div>');
            var render = $('<div class="cms-modal-buttons-inner"></div>');
    Severity: Major
    Found in cms/static/cms/js/modules/cms.modal.js - About 4 hrs to fix

      Function init has 104 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              init: function (opts) {
                  var results, search, resultsSelector = ".select2-results";
      
                  // prepare options
                  this.opts = opts = this.prepareOpts(opts);
      Severity: Major
      Found in cms/static/cms/js/select2/select2.js - About 4 hrs to fix

        File menu_tags.py has 339 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        from urllib.parse import unquote
        
        from classytags.arguments import Argument, IntegerArgument, StringArgument
        from classytags.core import Options
        from classytags.helpers import InclusionTag
        Severity: Minor
        Found in menus/templatetags/menu_tags.py - About 4 hrs to fix

          Function bind has 102 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  this.bind = function () {
                      parent.bind.call(this);
                      this._initialize();
                      this.element
                      .on("move_node.jstree create_node.jstree clean_node.jstree change_node.jstree", $.proxy(function (e, data) {
          Severity: Major
          Found in cms/static/cms/js/libs/jstree/jstree.grid.min.js - About 4 hrs to fix

            File check.py has 334 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import inspect
            from contextlib import contextmanager
            from itertools import chain
            
            from django.conf import settings
            Severity: Minor
            Found in cms/utils/check.py - About 4 hrs to fix

              Function set_or_create has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
              Open

                  def set_or_create(self, request, page, form, language):
                      """
                      set or create a title for a particular page and language
                      """
                      base_fields = [
              Severity: Minor
              Found in cms/models/managers.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 get_context has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
              Open

                  def get_context(self, context, levels, root_level, nephews, template):
                      # Django 1.4 doesn't accept 'None' as a tag value and resolve to ''
                      # So we need to force it to None again
                      if not root_level and root_level != 0:
                          root_level = None
              Severity: Minor
              Found in menus/templatetags/menu_tags.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 _setup has 95 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  _setup: function _setup() {
                      var that = this;
                      var columns = [];
                      var obj = {
                          language: this.options.lang.code,
              Severity: Major
              Found in cms/static/cms/js/modules/cms.pagetree.js - About 3 hrs to fix

                Function _initializeGlobalHandlers has 94 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                Plugin._initializeGlobalHandlers = function _initializeGlobalHandlers() {
                    var timer;
                    var clickCounter = 0;
                
                    Plugin._updateClipboard();
                Severity: Major
                Found in cms/static/cms/js/modules/cms.plugins.js - About 3 hrs to fix

                  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

                  Function resolve_page_id has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def resolve_page_id(self, path):
                          """Resolves requested path similar way how resolve does, but instead
                          of return callback,.. returns page_id to which was application
                          assigned.
                          """
                  Severity: Minor
                  Found in cms/appresolver.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

                  Consider simplifying this complex logical expression.
                  Open

                              if (a.length === 1) {
                                  closed = !objData.state.opened;
                                  gridCellName = GRIDCELLID_PREFIX+escapeId(lid)+GRIDCELLID_POSTFIX;
                                  gridCellParentId = objData.parent === "#" ? null : objData.parent;
                                  a.addClass(c);
                  Severity: Critical
                  Found in cms/static/cms/js/libs/jstree/jstree.grid.min.js - About 3 hrs to fix

                    CMSPluginBase has 30 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    class CMSPluginBase(admin.ModelAdmin, metaclass=CMSPluginBaseMetaclass):
                    
                        name = ""
                        module = _("Generic")  # To be overridden in child classes
                    
                    
                    Severity: Minor
                    Found in cms/plugin_base.py - About 3 hrs to fix

                      CMSToolbar has 30 functions (exceeds 20 allowed). Consider refactoring.
                      Open

                      class CMSToolbar(BaseToolbar):
                          """
                          The default CMS Toolbar
                          """
                      
                      
                      Severity: Minor
                      Found in cms/toolbar/toolbar.py - About 3 hrs to fix

                        Function __call__ has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def __call__(self, request):
                        
                                if not self.is_cms_request(request):
                                    return self.get_response(request)
                        
                        
                        Severity: Minor
                        Found in cms/middleware/toolbar.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 get_menu_node_for_page has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
                        Open

                        def get_menu_node_for_page(renderer, page, language, fallbacks=None):
                            """
                            Transform a CMS page into a navigation node.
                        
                            :param renderer: MenuRenderer instance bound to the request
                        Severity: Minor
                        Found in cms/cms_menus.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

                        Severity
                        Category
                        Status
                        Source
                        Language