divio/django-cms

View on GitHub

Showing 579 of 869 total issues

Function _setup has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    _setup: function _setup() {
        var that = this;
        var columns = [];
        var obj = {
            language: this.options.lang.code,
Severity: Minor
Found in cms/static/cms/js/modules/cms.pagetree.js - About 1 hr 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 handle has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def handle(self, *args, **options):
        """
        Obtains a plugin report -
        cms.management.commands.subcommands.list.plugin_report - and uses it
        to delete orphaned plugins from the database, i.e. ones that are no
Severity: Minor
Found in cms/management/commands/subcommands/delete_orphaned_plugins.py - About 1 hr 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_language_from_request has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

def get_language_from_request(request, current_page=None):
    """
    Return the most obvious language according the request
    """
    language = None
Severity: Minor
Found in cms/utils/__init__.py - About 1 hr 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 15 (exceeds 5 allowed). Consider refactoring.
Open

    def get_context(self, context, from_level, to_level, extra_inactive,
                    extra_active, template, namespace, root_id, next_page):
        try:
            # If there's an exception (500), default context_processors may not be called.
            request = context['request']
Severity: Minor
Found in menus/templatetags/menu_tags.py - About 1 hr 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_registered_menus has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def get_registered_menus(self, for_rendering=False):
        """
        Returns all registered menu classes.

        :param for_rendering: Flag that when True forces us to include
Severity: Minor
Found in menus/menu_pool.py - About 1 hr 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 toArray has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        toArray: function(options) {

            var o = $.extend({}, this.options, options),
                sDepth = o.startDepthCount || 0,
                ret = [],
Severity: Minor
Found in cms/static/cms/js/modules/jquery.ui.nestedsortable.js - About 1 hr to fix

    Function opening has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            opening: function() {
                var cid = this.containerEventName,
                    scroll = "scroll." + cid,
                    resize = "resize."+cid,
                    orient = "orientationchange."+cid,
    Severity: Minor
    Found in cms/static/cms/js/select2/select2.js - About 1 hr to fix

      Function initModal has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              var initModal = once(function initModal() {
                  var placeholder = $(
                      '<div class="cms-add-plugin-placeholder">' + CMS.config.lang.addPluginPlaceholder + '</div>'
                  );
                  var dragItem = nav.closest('.cms-dragitem');
      Severity: Minor
      Found in cms/static/cms/js/modules/cms.plugins.js - About 1 hr to fix

        Function select2 has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            $.fn.select2 = function () {
        
                var args = Array.prototype.slice.call(arguments, 0),
                    opts,
                    select2,
        Severity: Minor
        Found in cms/static/cms/js/select2/select2.js - About 1 hr to fix

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

              _delegate: function _delegate(el) {
                  // save local vars
                  var target = el.data('rel');
          
                  if (el.hasClass('cms-btn-disabled')) {
          Severity: Minor
          Found in cms/static/cms/js/modules/cms.toolbar.js - About 1 hr to fix

            Function _setup has 44 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    _setup: function _setup(options) {
                        $('#' + options.id).select2({
                            placeholder: options.text,
                            allowClear: true,
                            multiple: false,
            Severity: Minor
            Found in cms/static/cms/js/widgets/forms.pagesmartlinkwidget.js - About 1 hr to fix

              Function _show has 44 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  _show(opts) {
                      // we need to position the modal in the center
                      var that = this;
                      var width = opts.width;
                      var height = opts.height;
              Severity: Minor
              Found in cms/static/cms/js/modules/cms.modal.js - About 1 hr to fix

                Function toggleCollapsable has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                    _toggleCollapsable: function toggleCollapsable(el) {
                        var that = this;
                        var id = that._getId(el.parent());
                        var draggable = el.closest('.cms-draggable');
                        var items;
                Severity: Minor
                Found in cms/static/cms/js/modules/cms.plugins.js - About 1 hr 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 changelist_view has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                    def changelist_view(self, request, extra_context=None):
                        from django.contrib.admin.views.main import ERROR_FLAG
                
                        if not self.has_change_permission(request, obj=None):
                            raise PermissionDenied
                Severity: Minor
                Found in cms/admin/pageadmin.py - About 1 hr 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 render_extra_menu_items has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                def render_extra_menu_items(context, obj, template='cms/toolbar/dragitem_extra_menu.html'):
                    request = context['request']
                    toolbar = get_toolbar_from_request(request)
                    template = toolbar.templates.get_cached_template(template)
                
                
                Severity: Minor
                Found in cms/templatetags/cms_tags.py - About 1 hr 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 _paste has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                    _paste: function _paste(event) {
                        // hide helpers after we picked one
                        this._disablePaste();
                
                        var copyFromId = this._getNodeId(
                Severity: Minor
                Found in cms/static/cms/js/modules/cms.pagetree.js - About 1 hr 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 find_ancestors_and_remove_children has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                    def find_ancestors_and_remove_children(self, node, nodes):
                        """
                        Check ancestors of node for soft roots
                        """
                        if node.parent:
                Severity: Minor
                Found in cms/cms_menus.py - About 1 hr 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 clean has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                    def clean(self):
                        data = super().clean()
                
                        # Validate Page options
                        if not data.get('can_change_page'):
                Severity: Minor
                Found in cms/admin/forms.py - About 1 hr 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_page_path has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                    def get_page_path(self, lang):
                        page = getattr(self.request, 'current_page', None)
                
                        if not page:
                            return '/%s/' % lang if settings.USE_I18N else '/'
                Severity: Minor
                Found in menus/utils.py - About 1 hr 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_page_cache has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                def set_page_cache(response):
                    from django.core.cache import cache
                
                    request = response._request
                    toolbar = get_toolbar_from_request(request)
                Severity: Minor
                Found in cms/cache/page.py - About 1 hr 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