divio/django-cms

View on GitHub

Showing 579 of 869 total issues

Function _prepare_grid has 150 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        this._prepare_grid = function (obj) {
            var gs = this._gridSettings, c = gs.treeClass, _this = this, t, cols = gs.columns || [], width, tr = gs.isThemeroller,
            tree = this.element, rootid = this.rootid,
            classAdd = (tr?"themeroller":"regular"), img, objData = this.get_node(obj),
            defaultWidth = gs.columnWidth, conf = gs.defaultConf, cellClickHandler = function (tree,node,val,col,t) {
Severity: Major
Found in cms/static/cms/js/libs/jstree/jstree.grid.min.js - About 6 hrs to fix

    Placeholder has 44 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Placeholder(models.Model):
        """
        Attributes:
            is_static       Set to "True" for static placeholders by the template tag
            is_editable     If False the content of the placeholder is not editable in the frontend
    Severity: Minor
    Found in cms/models/placeholdermodel.py - About 6 hrs to fix

      Function _get_editable_context has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
      Open

          def _get_editable_context(self, context, instance, language, edit_fields,
                                    view_method, view_url, querystring, editmode=True):
              """
              Populate the context with the requested attributes to trigger the change form
              """
      Severity: Minor
      Found in cms/templatetags/cms_tags.py - About 5 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 initContainer has 143 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              initContainer: function () {
      
                  var selector = ".select2-choices", selection;
      
                  this.searchContainer = this.container.find(".select2-search-field");
      Severity: Major
      Found in cms/static/cms/js/select2/select2.js - About 5 hrs to fix

        Function _drag has 143 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            _drag(elem = this.ui.sortables) {
                var that = this;
        
                elem
                    .nestedSortable({
        Severity: Major
        Found in cms/static/cms/js/modules/cms.structureboard.js - About 5 hrs to fix

          Function initContainer has 142 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  initContainer: function () {
          
                      var selection,
                          container = this.container,
                          dropdown = this.dropdown,
          Severity: Major
          Found in cms/static/cms/js/select2/select2.js - About 5 hrs to fix

            Function prepareOpts has 140 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    prepareOpts: function (opts) {
                        var element, select, idKey, ajaxUrl, self = this;
            
                        element = opts.element;
            
            
            Severity: Major
            Found in cms/static/cms/js/select2/select2.js - About 5 hrs to fix

              Function validate_templates has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
              Open

                  def validate_templates(self, plugin=None):
                      """
                      Plugins templates are validated at this stage
                      """
                      if plugin:
              Severity: Minor
              Found in cms/plugin_pool.py - About 5 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

              Plugin has 41 functions (exceeds 20 allowed). Consider refactoring.
              Open

              var Plugin = new Class({
                  implement: [Helpers],
              
                  options: {
                      type: '', // bar, plugin or generic
              Severity: Minor
              Found in cms/static/cms/js/modules/cms.plugins.js - About 5 hrs to fix

                File page_permissions.py has 395 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                from functools import wraps
                
                from cms.api import get_page_draft
                from cms.cache.permissions import get_permission_cache, set_permission_cache
                from cms.constants import GRANT_ALL_PERMISSIONS
                Severity: Minor
                Found in cms/utils/page_permissions.py - About 5 hrs to fix

                  File toolbar.py has 395 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import functools
                  import operator
                  from collections import OrderedDict
                  
                  from classytags.utils import flatten_context
                  Severity: Minor
                  Found in cms/toolbar/toolbar.py - About 5 hrs to fix

                    Function change_language_menu has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def change_language_menu(self):
                            if self.toolbar.edit_mode_active and self.page:
                                can_change = page_permissions.user_can_change_page(
                                    user=self.request.user,
                                    page=self.page,
                    Severity: Minor
                    Found in cms/cms_toolbars.py - About 5 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 plugin_base.py has 388 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import json
                    import re
                    
                    from django import forms
                    from django.contrib import admin, messages
                    Severity: Minor
                    Found in cms/plugin_base.py - About 5 hrs to fix

                      Function _drag has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
                      Open

                          _drag(elem = this.ui.sortables) {
                              var that = this;
                      
                              elem
                                  .nestedSortable({
                      Severity: Minor
                      Found in cms/static/cms/js/modules/cms.structureboard.js - About 5 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 add_plugin has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def add_plugin(placeholder, plugin_type, language, position='last-child',
                                     target=None, **data):
                          """
                          Add a plugin to a placeholder
                      
                      
                      Severity: Minor
                      Found in cms/api.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_vary_cache_on has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def get_vary_cache_on(self, request):
                              """
                              Returns a list of VARY headers.
                              """
                              def inner_plugin_iterator(lang):
                      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 handleMovePlugin has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
                      Open

                          handleMovePlugin(data) {
                              if (data.plugin_parent) {
                                  if (data.plugin_id) {
                                      const draggable = $(`.cms-draggable-${data.plugin_id}:last`);
                      
                      
                      Severity: Minor
                      Found in cms/static/cms/js/modules/cms.structureboard.js - 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 exports has 112 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      module.exports = function(opts) {
                          'use strict';
                      
                          var PROJECT_PATH = opts.PROJECT_PATH;
                          var CMS_VERSION = opts.CMS_VERSION;
                      Severity: Major
                      Found in webpack.config.js - About 4 hrs to fix

                        File cms_menus.py has 353 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        from django.db.models.query import Prefetch, prefetch_related_objects
                        from django.urls import reverse
                        from django.utils.functional import SimpleLazyObject
                        from django.utils.translation import override as force_language
                        
                        
                        Severity: Minor
                        Found in cms/cms_menus.py - About 4 hrs to fix

                          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
                            Severity
                            Category
                            Status
                            Source
                            Language