divio/django-cms

View on GitHub

Showing 579 of 869 total issues

Function get_tree_rows has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    def get_tree_rows(self, request, pages, language, depth=1,
                      follow_descendants=True):
        """
        Used for rendering the page tree, inserts into context everything what
        we need for single item
Severity: Minor
Found in cms/admin/pageadmin.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 create_page has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

def create_page(title, template, language, menu_title=None, slug=None,
                apphook=None, apphook_namespace=None, redirect=None, meta_description=None,
                created_by='python-api', parent=None,
                publication_date=None, publication_end_date=None,
                in_navigation=False, soft_root=False, reverse_id=None,
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 get_context has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    def get_context(self, context, start_level, template, only_visible):
        try:
            # If there's an exception (500), default context_processors may not be called.
            request = context['request']
        except KeyError:
Severity: Minor
Found in menus/templatetags/menu_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

File permissions.py has 260 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from collections import defaultdict
from contextlib import contextmanager
from functools import lru_cache, wraps

from asgiref.local import Local
Severity: Minor
Found in cms/utils/permissions.py - About 2 hrs to fix

    Function invalidateState has 55 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        invalidateState(action, data, { propagate = true } = {}) {
            // eslint-disable-next-line default-case
            switch (action) {
                case 'COPY': {
                    this.handleCopyPlugin(data);
    Severity: Major
    Found in cms/static/cms/js/modules/cms.structureboard.js - About 2 hrs to fix

      Function _setPluginStructureEvents has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          _setPluginStructureEvents: function _setPluginStructureEvents() {
              var that = this;
      
              // filling up ui object
              this.ui.draggable = $('.cms-draggable-' + this.options.plugin_id);
      Severity: Major
      Found in cms/static/cms/js/modules/cms.plugins.js - About 2 hrs to fix

        Function movePlugin has 53 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            movePlugin: function(opts) {
                // cancel request if already in progress
                if (CMS.API.locked) {
                    return false;
                }
        Severity: Major
        Found in cms/static/cms/js/modules/cms.plugins.js - About 2 hrs to fix

          Function _loadStructure has 53 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              _loadStructure() {
                  // case when structure mode is already loaded
                  if (CMS.config.settings.mode === 'structure' || this._loadedStructure) {
                      return Promise.resolve();
                  }
          Severity: Major
          Found in cms/static/cms/js/modules/cms.structureboard.js - About 2 hrs to fix

            Function setupUI has 53 lines of code (exceeds 25 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: Major
            Found in cms/static/cms/js/modules/cms.plugins.js - About 2 hrs to fix

              Function delete_translation has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
              Open

                  def delete_translation(self, request, object_id, extra_context=None):
                      if 'delete_language' in request.GET:
                          language = request.GET['delete_language']
                      elif 'delete_language' in request.POST:
                          language = request.POST['delete_language']
              Severity: Minor
              Found in cms/admin/pageadmin.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 _build_nodes_inner_for_one_menu has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
              Open

              def _build_nodes_inner_for_one_menu(nodes, menu_class_name):
                  """
                  This is an easier to test "inner loop" building the menu tree structure
                  for one menu (one language, one site)
                  """
              Severity: Minor
              Found in menus/menu_pool.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 toggleCollapsable has 51 lines of code (exceeds 25 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: Major
              Found in cms/static/cms/js/modules/cms.plugins.js - About 2 hrs to fix

                Function _copyNode has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    _copyNode: function _copyNode(obj) {
                        var that = this;
                        var node = { position: 0 };
                
                        if (obj) {
                Severity: Major
                Found in cms/static/cms/js/modules/cms.pagetree.js - About 2 hrs to fix

                  Function copyPlugin has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      copyPlugin: function(opts, source_language) {
                          // cancel request if already in progress
                          if (CMS.API.locked) {
                              return false;
                          }
                  Severity: Minor
                  Found in cms/static/cms/js/modules/cms.plugins.js - About 2 hrs to fix

                    Function _setupModeSwitcher has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        _setupModeSwitcher() {
                            const modes = this.ui.toolbarModeLinks;
                            let cmdPressed;
                    
                            $(Helpers._getWindow())
                    Severity: Minor
                    Found in cms/static/cms/js/modules/cms.structureboard.js - About 2 hrs to fix

                      Function ajax has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          function ajax(options) {
                              var timeout, // current scheduled but not yet executed request
                                  handler = null,
                                  quietMillis = options.quietMillis || 100,
                                  ajaxUrl = options.url,
                      Severity: Minor
                      Found in cms/static/cms/js/select2/select2.js - About 1 hr to fix

                        Function open has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            open(opts) {
                                // setup internals
                                if (!((opts && opts.url) || (opts && opts.html))) {
                                    throw new Error('The arguments passed to "open" were invalid.');
                                }
                        Severity: Minor
                        Found in cms/static/cms/js/modules/cms.modal.js - About 1 hr to fix

                          Function local has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              function local(options) {
                                  var data = options, // data elements
                                      dataText,
                                      tmp,
                                      text = function (item) { return ""+item.text; }; // function used to retrieve the text portion of a data item that is matched against the search
                          Severity: Minor
                          Found in cms/static/cms/js/select2/select2.js - About 1 hr to fix

                            Function _setupSearch has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                _setupSearch: function _setupSearch() {
                                    var that = this;
                                    var click = this.click + '.search';
                            
                                    var filterActive = false;
                            Severity: Minor
                            Found in cms/static/cms/js/modules/cms.pagetree.js - About 1 hr to fix

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

                                  reloadBrowser: function(url, timeout, ajax, data) {
                                      var that = this;
                                      // is there a parent window?
                                      var win = this._getWindow();
                                      var parent = win.parent ? win.parent : win;
                              Severity: Minor
                              Found in cms/static/cms/js/modules/cms.base.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

                              Severity
                              Category
                              Status
                              Source
                              Language