django/django

View on GitHub
django/db/models/deletion.py

Summary

Maintainability
D
3 days
Test Coverage

Function collect has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
Open

    def collect(
        self,
        objs,
        source=None,
        nullable=False,
Severity: Minor
Found in django/db/models/deletion.py - About 1 day 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

File deletion.py has 411 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from collections import Counter, defaultdict
from functools import partial, reduce
from itertools import chain
from operator import attrgetter, or_

Severity: Minor
Found in django/db/models/deletion.py - About 5 hrs to fix

    Function delete has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

        def delete(self):
            # sort instance collections
            for model, instances in self.data.items():
                self.data[model] = sorted(instances, key=attrgetter("pk"))
    
    
    Severity: Minor
    Found in django/db/models/deletion.py - About 5 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 sort has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def sort(self):
            sorted_models = []
            concrete_models = set()
            models = list(self.data)
            while len(sorted_models) < len(models):
    Severity: Minor
    Found in django/db/models/deletion.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 collect has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def collect(
    Severity: Major
    Found in django/db/models/deletion.py - About 1 hr to fix

      Avoid deeply nested control flow statements.
      Open

                              if objs:
                                  key = "'%s.%s'" % (related_model.__name__, field.name)
                                  restricted_objects[key] += objs
                      if restricted_objects:
      Severity: Major
      Found in django/db/models/deletion.py - About 45 mins to fix

        Function can_fast_delete has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def can_fast_delete(self, objs, from_field=None):
                """
                Determine if the objects in the given queryset-like or single object
                can be fast-deleted. This can be done if there are no cascades, no
                parents and no signal listeners for the object class.
        Severity: Minor
        Found in django/db/models/deletion.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 add has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def add(self, objs, source=None, nullable=False, reverse_dependency=False):
                """
                Add 'objs' to the collection of objects to be deleted.  If the call is
                the result of a cascade, 'source' should be the model that caused it,
                and 'nullable' should be set to True if the relation can be null.
        Severity: Minor
        Found in django/db/models/deletion.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