django/django

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

Summary

Maintainability
F
3 days
Test Coverage

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

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

    BaseDatabaseOperations has 77 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

      Function window_frame_range_start_end has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def window_frame_range_start_end(self, start=None, end=None):
              if (start is not None and not isinstance(start, int)) or (
                  isinstance(start, int) and start > 0
              ):
                  raise ValueError(
      Severity: Minor
      Found in django/db/backends/base/operations.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 explain_query_prefix has a Cognitive Complexity of 9 (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."
                  )
      Severity: Minor
      Found in django/db/backends/base/operations.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 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