django/django

View on GitHub
django/db/models/fields/reverse_related.py

Summary

Maintainability
C
1 day
Test Coverage

File reverse_related.py has 324 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
"Rel objects" for related fields.

"Rel objects" (for lack of a better name) carry information about the relation
modeled by a related field and provide some utility functions. They're stored
Severity: Minor
Found in django/db/models/fields/reverse_related.py - About 3 hrs to fix

    ForeignObjectRel has 30 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class ForeignObjectRel(FieldCacheMixin):
        """
        Used by ForeignObject to store information about the relation.
    
        ``_meta.get_fields()`` returns this class to provide access to the field
    Severity: Minor
    Found in django/db/models/fields/reverse_related.py - About 3 hrs to fix

      Function __init__ has 9 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(
      Severity: Major
      Found in django/db/models/fields/reverse_related.py - About 1 hr to fix

        Function __init__ has 8 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __init__(
        Severity: Major
        Found in django/db/models/fields/reverse_related.py - About 1 hr to fix

          Function __init__ has 8 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def __init__(
          Severity: Major
          Found in django/db/models/fields/reverse_related.py - About 1 hr to fix

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

                def __init__(
            Severity: Major
            Found in django/db/models/fields/reverse_related.py - About 50 mins to fix

              Function get_accessor_name has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  def get_accessor_name(self, model=None):
                      # This method encapsulates the logic that decides what name to give an
                      # accessor descriptor that retrieves related many-to-one or
                      # many-to-many objects. It uses the lowercased object_name + "_set",
                      # but this can be overridden with the "related_name" option. Due to
              Severity: Minor
              Found in django/db/models/fields/reverse_related.py - About 45 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 get_related_field has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def get_related_field(self):
                      """
                      Return the field in the 'to' object to which this relationship is tied.
                      Provided for symmetry with ManyToOneRel.
                      """
              Severity: Minor
              Found in django/db/models/fields/reverse_related.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

              There are no issues that match your filters.

              Category
              Status