Showing 19 of 49 total issues
File models.py
has 995 lines of code (exceeds 500 allowed). Consider refactoring. Open
import copy
import importlib
import uuid
import warnings
from dataclasses import dataclass
HistoricalRecords
has 28 functions (exceeds 20 allowed). Consider refactoring. Open
class HistoricalRecords:
DEFAULT_MODEL_NAME_PREFIX = "Historical"
thread = context = LocalContext() # retain thread for backwards compatibility
m2m_models = {}
Function __init__
has 27 arguments (exceeds 7 allowed). Consider refactoring. Open
def __init__(
Function copy_fields
has a Cognitive Complexity of 19 (exceeds 7 allowed). Consider refactoring. Open
def copy_fields(self, model):
"""
Creates copies of the model's original fields, returning
a dictionary mapping field name to copied field object.
"""
- 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
SimpleHistoryAdmin
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
class SimpleHistoryAdmin(admin.ModelAdmin):
history_list_display = []
object_history_template = "simple_history/object_history.html"
object_history_list_template = "simple_history/object_history_list.html"
Function _get_m2m_field_changes_for_diff
has a Cognitive Complexity of 18 (exceeds 7 allowed). Consider refactoring. Open
def _get_m2m_field_changes_for_diff(
self,
old_history: "HistoricalChanges",
m2m_fields: Iterable[str],
foreign_keys_are_objs: bool,
- 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 _get_field_changes_for_diff
has a Cognitive Complexity of 17 (exceeds 7 allowed). Consider refactoring. Open
def _get_field_changes_for_diff(
self,
old_history: "HistoricalChanges",
fields: Iterable[str],
foreign_keys_are_objs: bool,
- 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 _process
has a Cognitive Complexity of 16 (exceeds 7 allowed). Consider refactoring. Open
def _process(self, to_process, date_back=None, dry_run=True):
if date_back:
stop_date = timezone.now() - timezone.timedelta(minutes=date_back)
else:
stop_date = 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 __init__
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def __init__(
self,
verbose_name=None,
verbose_name_plural=None,
bases=(models.Model,),
Function history_view
has a Cognitive Complexity of 12 (exceeds 7 allowed). Consider refactoring. Open
def history_view(self, request, object_id, extra_context=None):
"""The 'history' admin view for this model."""
request.current_app = self.admin_site.name
model = self.model
opts = model._meta
- 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 bulk_create_with_history
has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring. Open
def bulk_create_with_history(
objs,
model,
batch_size=None,
ignore_conflicts=False,
- 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 update_change_reason
has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring. Open
def update_change_reason(instance, reason):
attrs = {}
model = type(instance)
manager = instance if instance.pk is not None else model
history = get_history_manager_for_model(manager)
- 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 bulk_update_with_history
has 9 arguments (exceeds 7 allowed). Consider refactoring. Open
def bulk_update_with_history(
Function bulk_create_with_history
has 8 arguments (exceeds 7 allowed). Consider refactoring. Open
def bulk_create_with_history(
Function finalize
has a Cognitive Complexity of 9 (exceeds 7 allowed). Consider refactoring. Open
def finalize(self, sender, **kwargs):
inherited = False
if self.cls is not sender: # set in concrete
inherited = self.inherit and issubclass(sender, self.cls)
if not inherited:
- 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 transform_field
has a Cognitive Complexity of 9 (exceeds 7 allowed). Consider refactoring. Open
def transform_field(field):
"""Customize field appropriately for use in historical model"""
field.name = field.attname
if isinstance(field, models.BigAutoField):
field.__class__ = models.BigIntegerField
- 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 history_form_view
has a Cognitive Complexity of 9 (exceeds 7 allowed). Consider refactoring. Open
def history_form_view(self, request, object_id, version_id, extra_context=None):
request.current_app = self.admin_site.name
original_opts = self.model._meta
model = getattr(
self.model, self.model._meta.simple_history_manager_attribute
- 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 _bulk_history_create
has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring. Open
def _bulk_history_create(self, model, batch_size):
"""Save a copy of all instances to the historical model.
:param model: Model you want to bulk create
:param batch_size: number of models to create at once.
- 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 handle
has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring. Open
def handle(self, *args, **options):
self.verbosity = options["verbosity"]
to_process = set()
model_strings = options.get("models", []) or args
- 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"