File expressions.py
has 1628 lines of code (exceeds 250 allowed). Consider refactoring. Open
import copy
import datetime
import functools
import inspect
from collections import defaultdict
BaseExpression
has 33 functions (exceeds 20 allowed). Consider refactoring. Open
class BaseExpression:
"""Base class for all query expressions."""
empty_result_set_value = NotImplemented
# aggregate specific fields
Combinable
has 26 functions (exceeds 20 allowed). Consider refactoring. Open
class Combinable:
"""
Provide the ability to combine one or two objects with
some connector. For example F('foo') + F('bar').
"""
Function convert_value
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def convert_value(self):
"""
Expressions provide their own converters because users have the option
of manually specifying the output_field which may be a different type
from the one the database returns.
- 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 resolve_expression
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def resolve_expression(
self, query=None, allow_joins=True, reuse=None, summarize=False, for_save=False
):
lhs = self.lhs.resolve_expression(
query, allow_joins, reuse, summarize, for_save
- 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 identity
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def identity(self):
args, kwargs = self._constructor_args
signature = self._constructor_signature.bind_partial(self, *args, **kwargs)
signature.apply_defaults()
arguments = iter(signature.arguments.items())
- 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 as_sql
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def as_sql(
Function resolve_expression
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def resolve_expression(
Function as_sql
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def as_sql(
Function resolve_expression
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def resolve_expression(
Function resolve_expression
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def resolve_expression(
Function resolve_expression
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def resolve_expression(
Function resolve_expression
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def resolve_expression(
Function resolve_expression
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def resolve_expression(
Function resolve_expression
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def resolve_expression(
Function __init__
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(
Function resolve_expression
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def resolve_expression(
Function resolve_expression
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def resolve_expression(
Function resolve_expression
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def resolve_expression(
Function resolve_expression
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def resolve_expression(
Function as_sql
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def as_sql(self, compiler, connection, template=None, **extra_context):
Function __init__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, *cases, default=None, output_field=None, **extra):
Function as_sql
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def as_sql(self, compiler, connection, template=None, **extra_context):
Function as_sql
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def as_sql(self, compiler, connection, template=None, **extra_context):
Function __init__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, expression, descending=False, nulls_first=None, nulls_last=None):
Function as_sqlite
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def as_sqlite(self, compiler, connection, **extra_context):
sql, params = self.as_sql(compiler, connection, **extra_context)
if self.connector in {Combinable.MUL, Combinable.DIV}:
try:
lhs_type = self.lhs.output_field.get_internal_type()
- 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 flatten
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def flatten(self):
"""
Recursively yield this expression and all subexpressions, in
depth-first order.
"""
- 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 _resolve_output_field
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _resolve_output_field(self):
"""
Attempt to infer the output type of the expression.
As a guess, if the output fields of all source fields match then simply
- 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"