django/db/backends/base/operations.py
File operations.py
has 684 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import datetime
import decimal
import json
import warnings
from importlib import import_module
BaseDatabaseOperations
has 77 functions (exceeds 20 allowed). Consider refactoring. Open
Open
class BaseDatabaseOperations:
"""
Encapsulate backend-specific differences, such as the way a backend
performs ordering or calculates the ID of a recently-inserted row.
"""
Function window_frame_range_start_end
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
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(
- Read upRead up
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
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."
)
- Read upRead up
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
Open
def sql_flush(self, style, tables, *, reset_sequences=False, allow_cascade=False):
Avoid too many return
statements within this function. Open
Open
return value