File base.py
has 1991 lines of code (exceeds 250 allowed). Consider refactoring. Open
import copy
import inspect
import warnings
from functools import partialmethod
from itertools import chain
Function __new__
has a Cognitive Complexity of 127 (exceeds 5 allowed). Consider refactoring. Open
def __new__(cls, name, bases, attrs, **kwargs):
super_new = super().__new__
# Also ensure initialization is only performed for subclasses of Model
# (excluding Model class itself).
- 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 __init__
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def __init__(self, *args, **kwargs):
# Alias some things as locals to avoid repeat global lookups
cls = self.__class__
opts = self._meta
_setattr = setattr
- 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 _prepare
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def _prepare(cls):
"""Create some methods once self._meta has been populated."""
opts = cls._meta
opts._prepare(cls)
- 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 __new__
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def __new__(cls, name, bases, attrs, **kwargs):
super_new = super().__new__
# Also ensure initialization is only performed for subclasses of Model
# (excluding Model class itself).
Consider simplifying this complex logical expression. Open
if (
not cls._meta.abstract
and cls._meta.pk.auto_created
and
# Inherited PKs are checked in parents models.
Consider simplifying this complex logical expression. Open
if (
not raw
and not force_insert
and self._state.adding
and (
Function _do_update
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def _do_update(self, base_qs, using, pk_val, values, update_fields, forced_update):
Function _save_table
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def _save_table(
Function save
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def save(
Function _do_insert
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _do_insert(self, manager, using, fields, returning_fields, raw):
Function _save_parents
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _save_parents(
Function save_base
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def save_base(
Avoid deeply nested control flow statements. Open
if field.one_to_one:
for parent, parent_link in base_parents.items():
if field == parent_link:
base_parents[parent] = new_field