django/django

View on GitHub
django/db/migrations/operations/fields.py

Summary

Maintainability
C
1 day
Test Coverage

File fields.py has 332 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from django.core.exceptions import FieldDoesNotExist
from django.db.models import NOT_PROVIDED
from django.utils.functional import cached_property

from .base import Operation
Severity: Minor
Found in django/db/migrations/operations/fields.py - About 4 hrs to fix

    Function state_forwards has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        def state_forwards(self, app_label, state):
            model_state = state.models[app_label, self.model_name_lower]
            # Rename the field
            fields = model_state.fields
            try:
    Severity: Minor
    Found in django/db/migrations/operations/fields.py - About 3 hrs 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 reduce has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def reduce(self, operation, app_label):
            if isinstance(operation, FieldOperation) and self.is_same_field_operation(operation):
                if isinstance(operation, AlterField):
                    return [
                        AddField(
    Severity: Minor
    Found in django/db/migrations/operations/fields.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

    There are no issues that match your filters.

    Category
    Status