divio/django-cms

View on GitHub

Showing 579 of 869 total issues

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

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 create_alias has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def create_alias(self, request):
        if not request.user.is_staff:
            return HttpResponseForbidden("not enough privileges")
        if "plugin_id" not in request.POST and "placeholder_id" not in request.POST:
            return HttpResponseBadRequest("plugin_id or placeholder_id POST parameter missing.")
Severity: Minor
Found in cms/cms_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 prepareOpts has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        prepareOpts: function () {
            var opts = this.parent.prepareOpts.apply(this, arguments),
                self=this;

            // TODO validate placeholder is a string if specified
Severity: Minor
Found in cms/static/cms/js/select2/select2.js - About 1 hr to fix

    Function addSelectedChoice has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            addSelectedChoice: function (data) {
                var enableChoice = !data.locked,
                    enabledItem = $(
                        "<li class='select2-search-choice'>" +
                        "    <div></div>" +
    Severity: Minor
    Found in cms/static/cms/js/select2/select2.js - About 1 hr to fix

      Function isAllowed has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                      isAllowed: function(placeholder, placeholderParent, originalItem) {
                          // cancel if action is executed
                          if (CMS.API.locked) {
                              return false;
                          }
      Severity: Minor
      Found in cms/static/cms/js/modules/cms.structureboard.js - About 1 hr to fix

        Function val has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                val: function () {
                    var val,
                        triggerChange = false,
                        data = null,
                        self = this,
        Severity: Minor
        Found in cms/static/cms/js/select2/select2.js - About 1 hr to fix

          Consider simplifying this complex logical expression.
          Open

                      if (this.floating && horizontalDirection) {
                          return ((horizontalDirection == "right" && isOverRightHalf) || (horizontalDirection == "left" && !isOverRightHalf));
                      } else {
                          return verticalDirection && ((verticalDirection == "down" && isOverBottomHalf) || (verticalDirection == "up" && isOverTopHalf));
                      }
          Severity: Critical
          Found in cms/static/cms/js/modules/jquery.ui.nestedsortable.js - About 1 hr to fix

            Function _setSettingsMenu has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                _setSettingsMenu: function _setSettingsMenu(nav) {
                    var that = this;
            
                    this.ui.dropdown = nav.siblings('.cms-submenu-dropdown-settings');
                    var dropdown = this.ui.dropdown;
            Severity: Minor
            Found in cms/static/cms/js/modules/cms.plugins.js - About 1 hr to fix

              Function populateResults has 40 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                              populateResults: function(container, results, query) {
                                  var populate, id=this.opts.id, liveRegion=this.liveRegion;
              
                                  populate=function(results, container, depth) {
              
              
              Severity: Minor
              Found in cms/static/cms/js/select2/select2.js - About 1 hr to fix

                Function _initialStates has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    _initialStates: function _initialStates() {
                        var publishBtn = $('.cms-btn-publish').parent();
                
                        this._show({ duration: 0 });
                
                
                Severity: Minor
                Found in cms/static/cms/js/modules/cms.toolbar.js - About 1 hr to fix

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

                      _events() {
                          var that = this;
                  
                          // modal behaviours
                          this.ui.minimizeButton
                  Severity: Minor
                  Found in cms/static/cms/js/modules/cms.modal.js - About 1 hr to fix

                    Function _calculateNewPosition has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        _calculateNewPosition(opts) {
                            // lets set the modal width and height to the size of the browser
                            var widthOffset = 300; // adds margin left and right
                            var heightOffset = 300; // adds margin top and bottom;
                            var screenWidth = this.ui.window.width();
                    Severity: Minor
                    Found in cms/static/cms/js/modules/cms.modal.js - About 1 hr to fix

                      Function setupUI has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                      Open

                          _setupUI: function setupUI(container) {
                              var wrapper = $(`.${container}`);
                              var contents;
                      
                              // have to check for cms-plugin, there can be a case when there are multiple
                      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 getDistPath has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                      Open

                      var getDistPath = function(scriptFileName) {
                          var fileNameReplaceRegExp = new RegExp(scriptFileName + '.*$', 'gi');
                      
                          if (document.currentScript) {
                              return document.currentScript.src.replace(fileNameReplaceRegExp, '');
                      Severity: Minor
                      Found in cms/static/cms/js/modules/get-dist-path.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 get_formset has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def get_formset(self, request, obj=None, **kwargs):
                              """
                              Some fields may be excluded here. User can change only
                              permissions which are available for them. E.g. if user does not have
                              can_publish flag, they can't change assign can_publish permissions.
                      Severity: Minor
                      Found in cms/admin/permissionadmin.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 keydown has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                      Open

                      Dropdown.prototype.keydown = function (e) {
                          if (!/(38|40|27|32)/.test(e.which) || /input|textarea/i.test(e.target.tagName)) return
                      
                          var $this = $(this)
                      
                      
                      Severity: Minor
                      Found in cms/static/cms/js/modules/dropdown.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 render_tag has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def render_tag(self, context, page, language):
                              page_pending_publication = page.get_publisher_state(language) == PUBLISHER_STATE_PENDING
                      
                              if page.is_published(language) and not page_pending_publication:
                                  if page.is_dirty(language):
                      Severity: Minor
                      Found in cms/templatetags/cms_admin.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 cms_perms has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def cms_perms(func):
                          def inner(request, *args, **kwargs):
                              page = request.current_page
                              if page:
                                  if page.login_required and not request.user.is_authenticated:
                      Severity: Minor
                      Found in cms/utils/decorators.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 check_sekizai has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def check_sekizai(output):
                          with output.section("Sekizai") as section:
                              sekizai_installed = is_installed('sekizai')
                      
                              if sekizai_installed:
                      Severity: Minor
                      Found in cms/utils/check.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