divio/django-cms

View on GitHub

Showing 579 of 869 total issues

File plugin_rendering.py has 495 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import contextlib
from collections import OrderedDict
from functools import partial

from classytags.utils import flatten_context
Severity: Minor
Found in cms/plugin_rendering.py - About 7 hrs to fix

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

    /*
     * Copyright https://github.com/divio/django-cms
     */
    
    import $ from 'jquery';
    Severity: Minor
    Found in cms/static/cms/js/modules/cms.toolbar.js - About 7 hrs to fix

      Function _events has 194 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          _events: function _events() {
              var that = this;
              var LONG_MENUS_THROTTLE = 10;
      
              // attach event to the navigation elements
      Severity: Major
      Found in cms/static/cms/js/modules/cms.toolbar.js - About 7 hrs to fix

        Function _mouseDrag has 189 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                _mouseDrag: function(event) {
                    var i, item, itemElement, intersection,
                        o = this.options,
                        scrolled = false;
        
        
        Severity: Major
        Found in cms/static/cms/js/modules/jquery.ui.nestedsortable.js - About 7 hrs to fix

          Function modify has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
          Open

              def modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb):
                  if post_cut or breadcrumb:
                      return nodes
                  selected = None
                  root_nodes = []
          Severity: Minor
          Found in menus/modifiers.py - About 7 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

          BaseCMSTestCase has 51 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class BaseCMSTestCase:
              counter = 1
          
              def _fixture_setup(self):
                  super()._fixture_setup()
          Severity: Major
          Found in cms/test_utils/testcases.py - About 7 hrs to fix

            Function publish_page has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
            Open

                def publish_page(self, request, page_id, language):
                    page = self.get_object(request, object_id=page_id)
            
                    if page and not self.has_publish_permission(request, obj=page):
                        return HttpResponseForbidden(force_str(_("You do not have permission to publish this page")))
            Severity: Minor
            Found in cms/admin/pageadmin.py - About 7 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 modify has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
            Open

                def modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb):
                    if post_cut:
                        return nodes
                    # rearrange the parent relations
                    # Find home
            Severity: Minor
            Found in cms/cms_menus.py - About 7 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 placeholdermodel.py has 460 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import warnings
            from datetime import datetime, timedelta
            
            from django.contrib import admin
            from django.db import models
            Severity: Minor
            Found in cms/models/placeholdermodel.py - About 7 hrs to fix

              Function clean has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
              Open

                  def clean(self):
                      cleaned_data = super().clean()
                      if cleaned_data.get("overwrite_url"):
                          # Assuming that the user enters a full URL in the overwrite_url input.
                          # Here we validate it before publishing the page and if it contains
              Severity: Minor
              Found in cms/admin/forms.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 handle has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
              Open

                  def handle(self, *args, **options):
                      verbose = options.get('verbosity') > 1
                      only_empty = options.get('only_empty')
                      copy_content = options.get('copy_content')
                      from_lang = options.get('from_lang')
              Severity: Minor
              Found in cms/management/commands/subcommands/copy.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 _ensure_languages_settings has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
              Open

              def _ensure_languages_settings(languages):
                  valid_language_keys = ['code', 'name', 'fallbacks', 'hide_untranslated', 'redirect_on_fallback', 'public']
                  required_language_keys = ['code', 'name']
                  simple_defaults = ['public', 'redirect_on_fallback', 'hide_untranslated']
              
              
              Severity: Minor
              Found in cms/utils/conf.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

              File jquery.ui.nestedsortable.js has 437 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              /*
               * jQuery UI Nested Sortable
               * v 2.0 / 29 oct 2012
               * http://mjsarfatti.com/sandbox/nestedSortable
               *
              Severity: Minor
              Found in cms/static/cms/js/modules/jquery.ui.nestedsortable.js - About 6 hrs to fix

                File items.py has 437 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import json
                from abc import ABCMeta
                from collections import defaultdict
                
                from django.template.loader import render_to_string
                Severity: Minor
                Found in cms/toolbar/items.py - About 6 hrs to fix

                  Function _loadIframe has 160 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      _loadIframe(opts) {
                          var that = this;
                          const SHOW_LOADER_TIMEOUT = 500;
                  
                          opts.url = Helpers.makeURL(opts.url);
                  Severity: Major
                  Found in cms/static/cms/js/modules/cms.modal.js - About 6 hrs to fix

                    StructureBoard has 46 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    class StructureBoard {
                        constructor() {
                            // elements
                            this._setupUI();
                    
                    
                    Severity: Minor
                    Found in cms/static/cms/js/modules/cms.structureboard.js - About 6 hrs to fix

                      File api.py has 430 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      """
                      Public Python API to create CMS contents.
                      
                      WARNING: None of the functions defined in this module checks for permissions.
                      You must implement the necessary permission checks in your own code before
                      Severity: Minor
                      Found in cms/api.py - About 6 hrs to fix

                        Function _events has 157 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            _events: function _events() {
                                var that = this;
                        
                                // set events for the nodeId updates
                                this.ui.tree.on('after_close.jstree', function(e, el) {
                        Severity: Major
                        Found in cms/static/cms/js/modules/cms.pagetree.js - About 6 hrs to fix

                          Function resolve has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def resolve(self, request):
                                  if not request.user.is_staff:
                                      return HttpResponse('/', content_type='text/plain')
                                  obj = False
                                  url = False
                          Severity: Minor
                          Found in cms/admin/pageadmin.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

                          File pluginmodel.py has 423 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          import inspect
                          import json
                          import os
                          import warnings
                          from datetime import date
                          Severity: Minor
                          Found in cms/models/pluginmodel.py - About 6 hrs to fix
                            Severity
                            Category
                            Status
                            Source
                            Language