kotti/filedepot.py

Summary

Maintainability
D
1 day
Test Coverage

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

    Function migrate_storage has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def migrate_storage(from_storage: str, to_storage: str) -> None:
        log = logging.getLogger(__name__)
    
        old_default = DepotManager._default_depot
        DepotManager._default_depot = to_storage
    Severity: Minor
    Found in kotti/filedepot.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 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def __call__(self, request: Request) -> Response:
            """
            :param request: Current request
            :type request: :class:`kotti.request.Request`
    
    
    Severity: Minor
    Found in kotti/filedepot.py - About 55 mins 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 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(
    Severity: Minor
    Found in kotti/filedepot.py - About 45 mins to fix

      Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(
      Severity: Minor
      Found in kotti/filedepot.py - About 45 mins to fix

        Function __init__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def __init__(
                self,
                f: MemoryStoredFile,
                request: Request,
                disposition: str = "attachment",
        Severity: Minor
        Found in kotti/filedepot.py - About 35 mins 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

        Avoid too many return statements within this function.
        Open

                return response
        Severity: Major
        Found in kotti/filedepot.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return response
          Severity: Major
          Found in kotti/filedepot.py - About 30 mins to fix

            There are no issues that match your filters.

            Category
            Status