divio/django-cms

View on GitHub

Showing 579 of 869 total issues

File cms.base.js has 285 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * CMS.API.Helpers
 * Multiple helpers used across all CMS features
 */
import $ from 'jquery';
Severity: Minor
Found in cms/static/cms/js/modules/cms.base.js - About 2 hrs to fix

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

    import functools
    import operator
    
    from django.contrib.sites.models import Site
    from django.db import models
    Severity: Minor
    Found in cms/models/managers.py - About 2 hrs to fix

      Function _content has 70 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          _content: function _content(url) {
              var that = this;
              var iframe = $('<iframe src="' + url + '" class="" frameborder="0" />');
              var holder = this.ui.frame;
              var contents;
      Severity: Major
      Found in cms/static/cms/js/modules/cms.sideframe.js - About 2 hrs to fix

        Function _delegate has 69 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            _delegate: function _delegate(e) {
                e.preventDefault();
                e.stopPropagation();
        
                var nav;
        Severity: Major
        Found in cms/static/cms/js/modules/cms.plugins.js - About 2 hrs to fix

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

              def get_nodes(self, request):
                  from cms.models import Title
          
                  site = self.renderer.site
                  lang = self.renderer.request_language
          Severity: Minor
          Found in cms/cms_menus.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 plugins.py has 278 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          from collections import defaultdict
          from copy import deepcopy
          from functools import lru_cache
          from itertools import groupby, starmap
          from operator import attrgetter, itemgetter
          Severity: Minor
          Found in cms/utils/plugins.py - About 2 hrs to fix

            Modal has 24 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class Modal {
                constructor(options) {
                    this.options = $.extend(true, {}, Modal.options, options);
            
                    // elements
            Severity: Minor
            Found in cms/static/cms/js/modules/cms.modal.js - About 2 hrs to fix

              PageToolbar has 24 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class PageToolbar(CMSToolbar):
                  _changed_admin_menu = None
                  watch_models = [Page, PageType]
              
                  def init_placeholders(self):
              Severity: Minor
              Found in cms/cms_toolbars.py - About 2 hrs to fix

                Function _loadContent has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    _loadContent() {
                        var that = this;
                
                        // case when content mode is already loaded
                        if (CMS.config.settings.mode === 'edit' || this._loadedContent) {
                Severity: Major
                Found in cms/static/cms/js/modules/cms.structureboard.js - About 2 hrs to fix

                  Function _get_data_context has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def _get_data_context(self, context, instance, attribute, edit_fields,
                                            language, filters, view_url, view_method):
                          """
                          Renders the requested attribute and attach changeform trigger to it
                  
                  
                  Severity: Minor
                  Found in cms/templatetags/cms_tags.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_visible_nodes has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def get_visible_nodes(request, pages, site):
                      """
                       This code is basically a many-pages-at-once version of
                       cms.utils.page_permissions.user_can_view_page
                       pages contains all published pages
                  Severity: Minor
                  Found in cms/cms_menus.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_title has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def get_title(self, page, language, language_fallback=False):
                          """
                          Gets the latest content for a particular page and language. Falls back
                          to another language if wanted.
                          """
                  Severity: Minor
                  Found in cms/models/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

                  Function _initialize has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          this._initialize = function () {
                              if (!this._initialized) {
                                  var s = this.settings.grid || {}, styles,    container = this.element, gridparent = container.parent(), i,
                                  gs = this._gridSettings = {
                                      columns : s.columns || [],
                  Severity: Major
                  Found in cms/static/cms/js/libs/jstree/jstree.grid.min.js - About 2 hrs to fix

                    Function handleMovePlugin has 61 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        handleMovePlugin(data) {
                            if (data.plugin_parent) {
                                if (data.plugin_id) {
                                    const draggable = $(`.cms-draggable-${data.plugin_id}:last`);
                    
                    
                    Severity: Major
                    Found in cms/static/cms/js/modules/cms.structureboard.js - About 2 hrs to fix

                      Function get_templates has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def get_templates():
                          if getattr(settings, 'CMS_TEMPLATES_DIR', False):
                              tpldir = getattr(settings, 'CMS_TEMPLATES_DIR', False)
                              # CMS_TEMPLATES_DIR can either be a string pointing to the templates directory
                              # or a dictionary holding 'site: template dir' entries
                      Severity: Minor
                      Found in cms/utils/conf.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 copy_plugins_to has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def copy_plugins_to(old_plugins, to_placeholder,
                                          to_language=None, parent_plugin_id=None, no_signals=False):
                          """
                          Copies a list of plugins to a placeholder to a language.
                          """
                      Severity: Minor
                      Found in cms/utils/copy_plugins.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_app_patterns has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def _get_app_patterns(site):
                          """
                          Get a list of patterns for all hooked apps.
                      
                          How this works:
                      Severity: Minor
                      Found in cms/appresolver.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 publish_pages has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def publish_pages(include_unpublished=False, language=None, site=None):
                          """
                          Create published public version of selected drafts.
                          """
                          warnings.warn('This API function will be removed in django CMS 4. For publishing functionality use a package '
                      Severity: Minor
                      Found in cms/api.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 open has 60 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          open: function open(opts) {
                              if (!(opts && opts.message)) {
                                  throw new Error('The arguments passed to "open" were invalid.');
                              }
                      
                      
                      Severity: Major
                      Found in cms/static/cms/js/modules/cms.messages.js - About 2 hrs to fix

                        Consider simplifying this complex logical expression.
                        Open

                                    else if (previousItem != null
                                             && ! previousItem.hasClass(o.disableNestingClass)
                                             &&
                                                (previousItem.children(o.listType).length && previousItem.children(o.listType).is(':visible')
                                                 || ! previousItem.children(o.listType).length)
                        Severity: Critical
                        Found in cms/static/cms/js/modules/jquery.ui.nestedsortable.js - About 2 hrs to fix
                          Severity
                          Category
                          Status
                          Source
                          Language