divio/django-cms

View on GitHub

Showing 579 of 869 total issues

Function edit_title_fields has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def edit_title_fields(self, request, page_id, language):
        page, translation = self.get_object_with_translation(
            request=request,
            object_id=page_id,
            language=language,
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 copy_plugins_to_placeholder has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def copy_plugins_to_placeholder(plugins, placeholder, language=None, root_plugin=None):
    plugin_pairs = []
    plugins_by_id = {}

    for source_plugin in get_bound_plugins(plugins):
Severity: Minor
Found in cms/utils/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 modify has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb):
        # only apply this modifier if we're pre-cut (since what we do is cut)
        # or if no id argument is provided, indicating {% show_menu_below_id %}
        if post_cut or root_id:
            return nodes
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 copy_with_descendants has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def copy_with_descendants(self, target_node=None, position=None,
                              copy_permissions=True, target_site=None):
        """
        Copy a page [ and all its descendants to a new location ]
        """
Severity: Minor
Found in cms/models/pagemodel.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 search has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def search(self, q, language=None, current_site_only=True):
        """Simple search function

        Plugins can define a 'search_fields' tuple similar to ModelAdmin classes
        """
Severity: Minor
Found in cms/models/managers.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_placeholder_fields has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def check_placeholder_fields(output):
    """
    ModelAdmin instances that are using PlaceholderField fields
    should be also a subclass of PlaceholderAdminMixin
    """
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

Function applications_page_check has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def applications_page_check(request, path=None):
    """Tries to find if given path was resolved over application.
    Applications have higher priority than other cms pages.
    """
    if path is None:
Severity: Minor
Found in cms/appresolver.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 cut_after has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def cut_after(node, levels, removed):
    """
    given a tree of nodes cuts after N levels
    """
    if levels == 0:
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 validate_url_uniqueness has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def validate_url_uniqueness(site, path, language, exclude_page=None):
    """ Checks for conflicting urls
    """
    if '/' in path:
        validate_url(path)
Severity: Minor
Found in cms/forms/validators.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 initialize has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    initialize: function initialize(container, options) {
        this.options = $.extend(true, {}, this.options, options);

        // create an unique for this component to use it internally
        this.uid = uid();
Severity: Minor
Found in cms/static/cms/js/modules/cms.plugins.js - About 1 hr to fix

    Function monitorSource has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            monitorSource: function () {
                var el = this.opts.element, observer, self = this;
    
                el.on("change.select2", this.bind(function (e) {
                    if (this.opts.element.data("select2-change-triggered") !== true) {
    Severity: Minor
    Found in cms/static/cms/js/select2/select2.js - About 1 hr to fix

      Function defaultTokenizer has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function defaultTokenizer(input, selection, selectCallback, opts) {
              var original = input, // store the original so we can compare and know if we need to tell the search to update its text
                  dupe = false, // check for whether a token we extracted represents a duplicate selected choice
                  token, // token
                  index, // position at which the separator was found
      Severity: Minor
      Found in cms/static/cms/js/select2/select2.js - About 1 hr to fix

        Function _showAndHighlightPlugin has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            _showAndHighlightPlugin(successTimeout = 200, seeThrough = false) {
                // cancel show if live modus is active
                if (CMS.config.mode === 'live') {
                    return Promise.resolve(false);
                }
        Severity: Minor
        Found in cms/static/cms/js/modules/cms.structureboard.js - About 1 hr to fix

          Function _getWidths has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              _getWidths() {
                  var that = this;
          
                  that.items = {
                      left: [],
          Severity: Minor
          Found in cms/static/cms/js/modules/cms.navigation.js - About 1 hr to fix

            Function getSettings has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                getSettings: function() {
                    var settings;
            
            
                    // use local storage or session
            Severity: Minor
            Found in cms/static/cms/js/modules/cms.base.js - About 1 hr to fix

              Function refreshContent has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  refreshContent(contentMarkup) {
                      this._requestcontent = null;
                      if (!this._loadedStructure) {
                          this._requeststructure = null;
                      }
              Severity: Minor
              Found in cms/static/cms/js/modules/cms.structureboard.js - About 1 hr to fix

                Function processTab has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    function processTab(container, elt, goReverse) {
                        var $focussable = getFocusableElementsInContainer(container),
                            curElt = elt,
                            index, nextIndex, prevIndex, lastIndex;
                
                
                Severity: Minor
                Found in cms/static/cms/js/modules/jquery.trap.js - About 1 hr to fix

                  Function getDistPath has 30 lines of code (exceeds 25 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

                    Function setSettings has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        setSettings: function(newSettings) {
                            // merge settings
                            var settings = JSON.stringify($.extend({}, window.CMS.config.settings, newSettings));
                    
                            // use local storage or session
                    Severity: Minor
                    Found in cms/static/cms/js/modules/cms.base.js - About 1 hr to fix

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

                              opening: function () {
                                  var el, range, len;
                      
                                  if (this.opts.minimumResultsForSearch >= 0) {
                                      this.showSearch(true);
                      Severity: Minor
                      Found in cms/static/cms/js/select2/select2.js - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language