treyhunner/django-simple-history

View on GitHub

Showing 9 of 24 total issues

Function __init__ has 18 arguments (exceeds 7 allowed). Consider refactoring.
Open

    def __init__(
Severity: Major
Found in simple_history/models.py - About 1 hr to fix

    Function copy_fields has a Cognitive Complexity of 14 (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.
            """
    Severity: Minor
    Found in simple_history/models.py - About 1 hr to fix

    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_view has a Cognitive Complexity of 13 (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
    Severity: Minor
    Found in simple_history/admin.py - About 1 hr to fix

    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
    Severity: Minor
    Found in simple_history/admin.py - About 35 mins to fix

    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 9 (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.
    Severity: Minor
    Found in simple_history/management/commands/populate_history.py - About 35 mins to fix

    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 9 (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
    Severity: Minor
    Found in simple_history/management/commands/clean_duplicate_history.py - About 35 mins to fix

    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
    Severity: Minor
    Found in simple_history/management/commands/populate_history.py - About 25 mins to fix

    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 most_recent has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
    Open

        def most_recent(self):
            """
            Returns the most recent copy of the instance available in the history.
            """
            if not self.instance:
    Severity: Minor
    Found in simple_history/manager.py - About 25 mins to fix

    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 8 (exceeds 7 allowed). Consider refactoring.
    Open

    def update_change_reason(instance, reason):
        attrs = {}
        model = type(instance)
        manager = instance if instance.id is not None else model
        for field in instance._meta.fields:
    Severity: Minor
    Found in simple_history/utils.py - About 25 mins to fix

    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

    Severity
    Category
    Status
    Source
    Language