divio/django-cms

View on GitHub

Showing 579 of 869 total issues

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

    def init_toolbar(self, request, request_path=None):
        self.request = request
        self.is_staff = self.request.user.is_staff
        self.show_toolbar = self.is_staff or self.request.session.get('cms_edit', False)

Severity: Minor
Found in cms/toolbar/toolbar.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 recurse_patterns has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

def recurse_patterns(path, pattern_list, page_id, default_args=None,
                     nested=False):
    """
    Recurse over a list of to-be-hooked patterns for a given path prefix
    """
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 _handleResize has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    _handleResize() {
        var remainingWidth;
        var availableWidth = this._calculateAvailableWidth();

        if (availableWidth > this.items.leftTotalWidth + this.items.rightTotalWidth) {
Severity: Minor
Found in cms/static/cms/js/modules/cms.navigation.js - About 1 hr to fix

    Function openAjax has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        openAjax: function(opts) {
            var that = this;
            // url, post, text, callback, onSuccess
            var url = opts.url;
            var post = opts.post || '{}';
    Severity: Minor
    Found in cms/static/cms/js/modules/cms.toolbar.js - About 1 hr to fix

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

        Function _startResize has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            _startResize(pointerEvent) {
                // cancel if in fullscreen
                if (this.maximized) {
                    return false;
                }
        Severity: Minor
        Found in cms/static/cms/js/modules/cms.modal.js - About 1 hr to fix

          Function callback has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                              callback: this.bind(function (data) {
                          var def; // default choice
          
                          // ignore old responses
                          if (queryNumber != this.queryCount) {
          Severity: Minor
          Found in cms/static/cms/js/select2/select2.js - About 1 hr to fix

            Function update has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                            update: function(event, ui) {
                                // cancel if isAllowed returns false
                                if (!that.state) {
                                    return false;
                                }
            Severity: Minor
            Found in cms/static/cms/js/modules/cms.structureboard.js - About 1 hr to fix

              Function _checkIfPasteAllowed has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  _checkIfPasteAllowed: function _checkIfPasteAllowed() {
                      var pasteButton = this.ui.dropdown.find('[data-rel=paste]');
                      var pasteItem = pasteButton.parent();
              
                      if (!clipboardDraggable.length) {
              Severity: Minor
              Found in cms/static/cms/js/modules/cms.plugins.js - About 1 hr to fix

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

                        val: function (val, triggerChange) {
                            var oldData, self=this;
                
                            if (arguments.length === 0) {
                                return this.getVal();
                Severity: Minor
                Found in cms/static/cms/js/select2/select2.js - About 1 hr to fix

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

                      _events() {
                          var that = this;
                  
                          that.modal = new Modal({
                              minWidth: MIN_WIDTH,
                  Severity: Minor
                  Found in cms/static/cms/js/modules/cms.clipboard.js - About 1 hr to fix

                    Function get_copy_dialog has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def get_copy_dialog(self, request, page_id):
                            if not get_cms_setting('PERMISSION'):
                                return HttpResponse('')
                    
                            page = self.get_page_from_id(page_id)
                    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 get_title_extension_admin has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def get_title_extension_admin(self, language=None):
                            """
                            Get the admin urls for the title extensions menu items, depending on whether a TitleExtension instance exists
                            for each Title in the current page.
                            A single language can be passed to only work on a single title.
                    Severity: Minor
                    Found in cms/extensions/toolbar.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 move_page has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def move_page(self, target_node, position='first-child'):
                            """
                            Called from admin interface when page is moved. Should be used on
                            all the places which are changing page position. Used like an interface
                            to django-treebeard, but after move is done page_moved signal is fired.
                    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 copy_to_public has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def copy_to_public(self, public_object, language):
                            """
                            This method is used to "publish" this extension as part of the a larger
                            operation on the target. If you intend to copy this extension to an
                            unrelated object, use copy() instead.
                    Severity: Minor
                    Found in cms/extensions/models.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_title_cache has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def _get_title_cache(self, language, fallback, force_reload):
                            if not language:
                                language = get_language()
                    
                            force_reload = (force_reload or language not in self.title_cache)
                    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 get_page_from_path has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def get_page_from_path(site, path, preview=False, draft=False, language_code=None):
                        """
                        Resolves a url path to a single page object.
                        Returns None if page does not exist
                    
                    
                    Severity: Minor
                    Found in cms/utils/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 modify has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb):
                            if post_cut or breadcrumb:
                                return nodes
                            final = []
                            for node in nodes:
                    Severity: Minor
                    Found in menus/modifiers.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 __call__ has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def __call__(self, lang):
                            page_language = get_language_from_request(self.request)
                            with force_language(page_language):
                                try:
                                    view = resolve(self.request.path_info)
                    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

                    Severity
                    Category
                    Status
                    Source
                    Language