Showing 82 of 91 total issues

File resources.py has 695 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
The :mod:`~kotti.resources` module contains all the classes for Kotti's
persistence layer, which is based on SQLAlchemy.

Inheritance Diagram
Severity: Major
Found in kotti/resources.py - About 1 day to fix

    File filedepot.py has 538 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import logging
    import mimetypes
    import uuid
    from cgi import FieldStorage
    from datetime import datetime
    Severity: Major
    Found in kotti/filedepot.py - About 1 day to fix

      File users.py has 528 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      """ User management screens """
      import re
      from urllib.parse import urlencode
      
      import colander
      Severity: Major
      Found in kotti/views/users.py - About 1 day to fix

        File actions.py has 518 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        """
        Action views
        """
        from pyramid.exceptions import Forbidden
        from pyramid.httpexceptions import HTTPFound
        Severity: Major
        Found in kotti/views/edit/actions.py - About 1 day to fix

          Function change_state has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
          Open

              def change_state(self):
                  """ Change state view. Renders either a view to handle workflow changes
                  for multiple nodes or handle the selected workflow changes and get
                  back to the referrer of the request.
          
          
          Severity: Minor
          Found in kotti/views/edit/actions.py - About 6 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 security.py has 427 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          from collections.abc import MutableMapping
          from contextlib import contextmanager
          from datetime import datetime
          from typing import Dict
          from typing import Iterable
          Severity: Minor
          Found in kotti/security.py - About 6 hrs to fix

            File util.py has 413 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import hashlib
            from collections import defaultdict
            from datetime import datetime
            from urllib.parse import urlencode
            
            
            Severity: Minor
            Found in kotti/views/util.py - About 5 hrs to fix

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

              """This module includes a simple events system that allows users to
              subscribe to specific events, and more particularly to *object events*
              of specific object types.
              
              See also: :ref:`events`.
              Severity: Minor
              Found in kotti/events.py - About 5 hrs to fix

                Function UploadController has 106 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function UploadController($scope, $http, $log) {
                
                    $log.info("Initializing UploadController...");
                
                    $scope.files = [];
                Severity: Major
                Found in kotti/static/upload.js - About 4 hrs to fix

                  Function roles_form_handler has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def roles_form_handler(context, request, available_role_names, groups_lister):
                      changed = []
                  
                      if "apply" in request.POST:
                          p_to_r = {}
                  Severity: Minor
                  Found in kotti/views/users.py - About 3 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 login.py has 302 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  """
                  Login / logout and forbidden views and forms.
                  """
                  from datetime import datetime
                  
                  
                  Severity: Minor
                  Found in kotti/views/login.py - About 3 hrs to fix

                    TemplateAPI has 27 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    class TemplateAPI:
                        """This implements the ``api`` object that's passed to all templates.
                    
                        Use dict-access as a shortcut to retrieve template macros from templates.
                        """
                    Severity: Minor
                    Found in kotti/views/util.py - About 3 hrs to fix

                      Function paste_nodes has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def paste_nodes(self):
                              """ Paste nodes view.  Paste formerly copied or cutted nodes into the
                              current context.  Note that a cutted node can not be pasted into itself.
                      
                              :result: Redirect response to the referrer of the request.
                      Severity: Minor
                      Found in kotti/views/edit/actions.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 util.py has 270 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      """
                      Inheritance Diagram
                      -------------------
                      
                      .. inheritance-diagram:: kotti.util
                      Severity: Minor
                      Found in kotti/util.py - About 2 hrs to fix

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

                        def search_principals(request, context=None, ignore=None, extra=()):
                            flash = request.session.flash
                            principals = get_principals()
                        
                            if ignore is None:
                        Severity: Minor
                        Found in kotti/views/users.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_paste_items has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                        Open

                        def get_paste_items(context, request):
                            from kotti.resources import Node
                        
                            items = []
                            info = request.session.get("kotti.paste")
                        Severity: Minor
                        Found in kotti/util.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 list_groups_ext has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                        Open

                        def list_groups_ext(name, context=None, _seen=None, _inherited=None):
                            name = name
                            groups = set()
                            recursing = _inherited is not None
                            _inherited = _inherited or set()
                        Severity: Minor
                        Found in kotti/security.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__ has 13 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            def __init__(
                        Severity: Major
                        Found in kotti/resources.py - About 1 hr to fix

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

                              def __call__(self, request):
                                  """The first part of this function is copied without changes from
                                  :meth:`pyramid.traversal.ResourceTreeTraverser.__call__`.
                          
                                  :param request: Current request
                          Severity: Minor
                          Found in kotti/traversal.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 set_max_age has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                          Open

                          def set_max_age(response, delta, cache_ctrl=None):
                              """Sets max-age and expires headers based on the timedelta `delta`.
                          
                              If `cache_ctrl` is not None, I'll add items found therein to the
                              Cache-Control header.
                          Severity: Minor
                          Found in kotti/views/cache.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