File _functions.py
has 404 lines of code (exceeds 250 allowed). Consider refactoring. Open
"""
Implementations of SQL functions for SQLite.
"""
import functools
Function register
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def register(connection):
create_deterministic_function = functools.partial(
connection.create_function,
deterministic=True,
)
Function _sqlite_datetime_parse
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def _sqlite_datetime_parse(dt, tzname=None, conn_tzname=None):
if dt is None:
return None
try:
dt = typecast_timestamp(dt)
- 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 _sqlite_time_trunc
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _sqlite_time_trunc(lookup_type, dt, tzname, conn_tzname):
if dt is None:
return None
dt_parsed = _sqlite_datetime_parse(dt, tzname, conn_tzname)
if dt_parsed is None:
- 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 _sqlite_datetime_trunc
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _sqlite_datetime_trunc(lookup_type, dt, tzname, conn_tzname):
dt = _sqlite_datetime_parse(dt, tzname, conn_tzname)
if dt is None:
return None
if lookup_type == "year":
- 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 _sqlite_datetime_extract
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _sqlite_datetime_extract(lookup_type, dt, tzname=None, conn_tzname=None):
dt = _sqlite_datetime_parse(dt, tzname, conn_tzname)
if dt is None:
return None
if lookup_type == "week_day":
- 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
Avoid too many return
statements within this function. Open
return f"{dt.year:04d}-{dt.month:02d}-{dt.day:02d}"
Avoid too many return
statements within this function. Open
return ceil(dt.month / 3)
Avoid too many return
statements within this function. Open
return f"{dt.year:04d}-{dt.month:02d}-{dt.day:02d} {dt.hour:02d}:00:00"
Avoid too many return
statements within this function. Open
return dt.isocalendar().year
Avoid too many return
statements within this function. Open
return f"{dt.year:04d}-{dt.month:02d}-{dt.day:02d} 00:00:00"
Avoid too many return
statements within this function. Open
return f"{dt.hour:02d}:{dt.minute:02d}:{dt.second:02d}"
Avoid too many return
statements within this function. Open
return f"{dt.year:04d}-{dt.month:02d}-{dt.day:02d} 00:00:00"
Avoid too many return
statements within this function. Open
return getattr(dt, lookup_type)
Avoid too many return
statements within this function. Open
return (
Avoid too many return
statements within this function. Open
return f"{dt.year:04d}-{dt.month:02d}-{dt.day:02d}"
Function _sqlite_date_trunc
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _sqlite_date_trunc(lookup_type, dt, tzname, conn_tzname):
dt = _sqlite_datetime_parse(dt, tzname, conn_tzname)
if dt is None:
return None
if lookup_type == "year":
- 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"