Showing 91 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

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                    def upgrade():
                        op.alter_column('nodes',
                                        'title',
                                        type_=sa.Unicode(250),
                                        )
                    kotti/alembic/versions/37a05f6246af_enlarge_name_title_path.py on lines 32..43

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 64.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    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

                      Similar blocks of code found in 2 locations. Consider refactoring.
                      Open

                      def downgrade():
                          op.alter_column('nodes',
                                          'title',
                                          type_=sa.Unicode(100),
                                          )
                      kotti/alembic/versions/37a05f6246af_enlarge_name_title_path.py on lines 17..28

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 64.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      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

                        Similar blocks of code found in 2 locations. Consider refactoring.
                        Open

                            @classmethod
                            def coerce(cls, key, value):
                                if not isinstance(value, MutationDict):
                                    if isinstance(value, dict):
                                        return cls(value)
                        Severity: Major
                        Found in kotti/sqla.py and 1 other location - About 2 hrs to fix
                        kotti/sqla.py on lines 117..124

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 53.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 2 locations. Consider refactoring.
                        Open

                            @classmethod
                            def coerce(cls, key, value):
                                if not isinstance(value, MutationList):
                                    if isinstance(value, list):
                                        return cls(value)
                        Severity: Major
                        Found in kotti/sqla.py and 1 other location - About 2 hrs to fix
                        kotti/sqla.py on lines 89..96

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 53.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        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

                        Severity
                        Category
                        Status
                        Source
                        Language