divio/django-cms

View on GitHub

Showing 579 of 869 total issues

Avoid deeply nested control flow statements.
Open

                        if not sibling.selected:
                            sibling.sibling = True
                else:
Severity: Major
Found in menus/modifiers.py - About 45 mins to fix

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

        def save(self, **kwargs):
            from cms.api import add_plugin
    
            new_page = super().save(**kwargs)
    
    
    Severity: Minor
    Found in cms/forms/wizards.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 _set_placeholder_cache_version has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def _set_placeholder_cache_version(placeholder, lang, site_id, version, vary_on_list=None, duration=None):
    Severity: Minor
    Found in cms/cache/placeholder.py - About 45 mins to fix

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

      def find_selected(nodes):
          """
          Finds a selected nav_extender node
          """
          for node in nodes:
      Severity: Minor
      Found in menus/utils.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

      Consider simplifying this complex logical expression.
      Open

              if (childRestrictions && childRestrictions.length) {
                  resultElements = resultElements.filter(function() {
                      var item = $(this);
      
                      return (
      Severity: Major
      Found in cms/static/cms/js/modules/cms.plugins.js - About 40 mins to fix

        Consider simplifying this complex logical expression.
        Open

                        if (selected.length &&
                            (e.which == KEY.LEFT || e.which == KEY.RIGHT || e.which == KEY.BACKSPACE || e.which == KEY.DELETE || e.which == KEY.ENTER)) {
                            var selectedChoice = selected;
                            if (e.which == KEY.LEFT && prev.length) {
                                selectedChoice = prev;
        Severity: Major
        Found in cms/static/cms/js/select2/select2.js - About 40 mins to fix

          Consider simplifying this complex logical expression.
          Open

          !function(a){function f(a,b){if(!(a.originalEvent.touches.length>1)){a.preventDefault();var c=a.originalEvent.changedTouches[0],d=document.createEvent("MouseEvents");d.initMouseEvent(b,!0,!0,window,1,c.screenX,c.screenY,c.clientX,c.clientY,!1,!1,!1,!1,0,null),a.target.dispatchEvent(d)}}if(a.support.touch="ontouchend"in document,a.support.touch){var e,b=a.ui.mouse.prototype,c=b._mouseInit,d=b._mouseDestroy;b._touchStart=function(a){var b=this;!e&&b._mouseCapture(a.originalEvent.changedTouches[0])&&(e=!0,b._touchMoved=!1,f(a,"mouseover"),f(a,"mousemove"),f(a,"mousedown"))},b._touchMove=function(a){e&&(this._touchMoved=!0,f(a,"mousemove"))},b._touchEnd=function(a){e&&(f(a,"mouseup"),f(a,"mouseout"),this._touchMoved||f(a,"click"),e=!1)},b._mouseInit=function(){var b=this;b.element.bind({touchstart:a.proxy(b,"_touchStart"),touchmove:a.proxy(b,"_touchMove"),touchend:a.proxy(b,"_touchEnd")}),c.call(b)},b._mouseDestroy=function(){var b=this;b.element.unbind({touchstart:a.proxy(b,"_touchStart"),touchmove:a.proxy(b,"_touchMove"),touchend:a.proxy(b,"_touchEnd")}),d.call(b)}}}(jQuery);
          Severity: Major
          Found in cms/static/cms/js/modules/jquery.ui.touchpunch.js - About 40 mins to fix

            Consider simplifying this complex logical expression.
            Open

                if language_is_unavailable and not fallback_languages:
                    # There is no page with the requested language
                    # and there's no configured fallbacks
                    return _handle_no_page(request)
                elif language_is_unavailable and (redirect_on_fallback or page.is_home):
            Severity: Major
            Found in cms/views.py - About 40 mins to fix

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

                          }, cellRightClickHandler = function (tree,node,val,col,t) {
              Severity: Minor
              Found in cms/static/cms/js/libs/jstree/jstree.grid.min.js - About 35 mins to fix

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

                            defaultWidth = gs.columnWidth, conf = gs.defaultConf, cellClickHandler = function (tree,node,val,col,t) {
                Severity: Minor
                Found in cms/static/cms/js/libs/jstree/jstree.grid.min.js - About 35 mins to fix

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

                      def _paste_placeholder(self, request, plugin, target_language,
                  Severity: Minor
                  Found in cms/admin/placeholderadmin.py - About 35 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 get_tree_rows has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          def get_tree_rows(self, request, pages, language, depth=1,
                      Severity: Minor
                      Found in cms/admin/pageadmin.py - About 35 mins to fix

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

                            def _get_content(self, context, instance, attribute, language, filters):
                        Severity: Minor
                        Found in cms/templatetags/cms_tags.py - About 35 mins to fix

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

                                          check_callback: function(operation, node, node_parent, node_position, more) {
                          Severity: Minor
                          Found in cms/static/cms/js/modules/cms.pagetree.js - 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

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

                              def has_reached_plugin_limit(placeholder, plugin_type, language, template=None, parent_plugin=None):
                              Severity: Minor
                              Found in cms/utils/plugins.py - About 35 mins to fix

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

                                def copy_plugins_to(old_plugins, to_placeholder,
                                Severity: Minor
                                Found in cms/utils/copy_plugins.py - About 35 mins to fix

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

                                  def assign_plugins(request, placeholders, template=None, lang=None, is_fallback=False):
                                  Severity: Minor
                                  Found in cms/utils/plugins.py - About 35 mins to fix

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

                                    def _get_page_ids_for_action(user, site, action, check_global=True, use_cache=True):
                                    Severity: Minor
                                    Found in cms/utils/page_permissions.py - About 35 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language