django/django

View on GitHub
django/db/backends/base/operations.py

Summary

Maintainability
D
2 days
Test Coverage

BaseDatabaseOperations has 74 functions (exceeds 20 allowed). Consider refactoring.
Open

class BaseDatabaseOperations:
    """
    Encapsulate backend-specific differences, such as the way a backend
    performs ordering or calculates the ID of a recently-inserted row.
    """
Severity: Major
Found in django/db/backends/base/operations.py - About 1 day to fix

    File operations.py has 585 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import datetime
    import decimal
    from importlib import import_module
    
    import sqlparse
    Severity: Major
    Found in django/db/backends/base/operations.py - About 1 day to fix

      Function explain_query_prefix has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def explain_query_prefix(self, format=None, **options):
              if not self.connection.features.supports_explaining_query_execution:
                  raise NotSupportedError('This backend does not support explaining query execution.')
              if format:
                  supported_formats = self.connection.features.supported_explain_formats
      Severity: Minor
      Found in django/db/backends/base/operations.py - About 45 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 sql_flush has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def sql_flush(self, style, tables, *, reset_sequences=False, allow_cascade=False):
      Severity: Minor
      Found in django/db/backends/base/operations.py - About 35 mins to fix

        Avoid too many return statements within this function.
        Open

                    return value
        Severity: Major
        Found in django/db/backends/base/operations.py - About 30 mins to fix

          There are no issues that match your filters.

          Category
          Status