django/django

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

Summary

Maintainability
D
2 days
Test Coverage

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

    def collect(self, objs, source=None, nullable=False, collect_related=True,
                source_attr=None, reverse_dependency=False, keep_parents=False,
                fail_on_restricted=True):
        """
        Add 'objs' to the collection of objects to be deleted as well as all
Severity: Minor
Found in django/db/models/deletion.py - About 7 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 delete has a Cognitive Complexity of 27 (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 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

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

import operator
from collections import Counter, defaultdict
from functools import partial, reduce
from itertools import chain
from operator import attrgetter
Severity: Minor
Found in django/db/models/deletion.py - About 3 hrs to fix

    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(self, objs, source=None, nullable=False, collect_related=True,
    Severity: Major
    Found in django/db/models/deletion.py - About 1 hr 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