treyhunner/django-simple-history

View on GitHub

Showing 47 of 47 total issues

Merge this if statement with the enclosing one.
Open

            if self.verbosity >= 1:

Merging collapsible if statements increases the code's readability.

Noncompliant Code Example

if condition1:
    if condition2:
        # ...

Compliant Solution

if condition1 and condition2:
    # ...

Function "bulk_update_with_history" has 9 parameters, which is greater than the 7 authorized.
Open

    objs,
    model,
    fields,
    batch_size=None,
    default_user=None,
Severity: Major
Found in simple_history/utils.py by sonar-python

A long parameter list can indicate that a new structure should be created to wrap the numerous parameters or that the function is doing too many things.

Noncompliant Code Example

With a maximum number of 4 parameters:

def do_something(param1, param2, param3, param4, param5):
    ...

Compliant Solution

def do_something(param1, param2, param3, param4):
    ...

Function "bulk_create_with_history" has 8 parameters, which is greater than the 7 authorized.
Open

    objs,
    model,
    batch_size=None,
    ignore_conflicts=False,
    default_user=None,
Severity: Major
Found in simple_history/utils.py by sonar-python

A long parameter list can indicate that a new structure should be created to wrap the numerous parameters or that the function is doing too many things.

Noncompliant Code Example

With a maximum number of 4 parameters:

def do_something(param1, param2, param3, param4, param5):
    ...

Compliant Solution

def do_something(param1, param2, param3, param4):
    ...

Refactor this function to reduce its Cognitive Complexity from 16 to the 15 allowed.
Open

    def _process(self, to_process, date_back=None, dry_run=True):

Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

See

Refactor this function to reduce its Cognitive Complexity from 19 to the 15 allowed.
Open

    def copy_fields(self, model):
Severity: Critical
Found in simple_history/models.py by sonar-python

Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

See

Method "__init__" has 28 parameters, which is greater than the 7 authorized.
Open

        self,
        verbose_name=None,
        verbose_name_plural=None,
        bases=(models.Model,),
        user_related_name="+",
Severity: Major
Found in simple_history/models.py by sonar-python

A long parameter list can indicate that a new structure should be created to wrap the numerous parameters or that the function is doing too many things.

Noncompliant Code Example

With a maximum number of 4 parameters:

def do_something(param1, param2, param3, param4, param5):
    ...

Compliant Solution

def do_something(param1, param2, param3, param4):
    ...

Rename function "HistoryRequestMiddleware" to match the regular expression ^[a-z_][a-z0-9_]{2,}$.
Open

def HistoryRequestMiddleware(get_response):
Severity: Major
Found in simple_history/middleware.py by sonar-python

Shared coding conventions allow teams to collaborate efficiently. This rule checks that all function names match a provided regular expression.

Noncompliant Code Example

With the default provided regular expression: ^[a-z_][a-z0-9_]{2,30}$

def MyFunction(a,b):
    ...

Compliant Solution

def my_function(a,b):
    ...
Severity
Category
Status
Source
Language