django/django

View on GitHub
django/db/migrations/utils.py

Summary

Maintainability
B
4 hrs
Test Coverage

Function field_references has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

def field_references(
    model_tuple,
    field,
    reference_model_tuple,
    reference_field_name=None,
Severity: Minor
Found in django/db/migrations/utils.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 resolve_relation has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def resolve_relation(model, app_label=None, model_name=None):
    """
    Turn a model class or model reference string and return a model tuple.

    app_label and model_name are used to resolve the scope of recursive and
Severity: Minor
Found in django/db/migrations/utils.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

Consider simplifying this complex logical expression.
Open

        if (
            reference_field_name is None
            or
            # Unspecified to_field(s).
            to_fields is None
Severity: Major
Found in django/db/migrations/utils.py - About 40 mins to fix

    Function field_references has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def field_references(
    Severity: Minor
    Found in django/db/migrations/utils.py - About 35 mins to fix

      Function get_references has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def get_references(state, model_tuple, field_tuple=()):
          """
          Generator of (model_state, name, field, reference) referencing
          provided context.
      
      
      Severity: Minor
      Found in django/db/migrations/utils.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