django/django

View on GitHub
django/db/backends/mysql/introspection.py

Summary

Maintainability
D
1 day
Test Coverage

Function get_constraints has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

    def get_constraints(self, cursor, table_name):
        """
        Retrieve any constraints or keys (unique, pk, fk, check, index) across
        one or more columns.
        """
Severity: Minor
Found in django/db/backends/mysql/introspection.py - About 4 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 introspection.py has 324 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from collections import namedtuple

import sqlparse
from MySQLdb.constants import FIELD_TYPE

Severity: Minor
Found in django/db/backends/mysql/introspection.py - About 3 hrs to fix

    Function get_field_type has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_field_type(self, data_type, description):
            field_type = super().get_field_type(data_type, description)
            if "auto_increment" in description.extra:
                if field_type == "IntegerField":
                    return "AutoField"
    Severity: Minor
    Found in django/db/backends/mysql/introspection.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 get_table_description has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_table_description(self, cursor, table_name):
            """
            Return a description of the table with the DB-API cursor.description
            interface."
            """
    Severity: Minor
    Found in django/db/backends/mysql/introspection.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

    Avoid too many return statements within this function.
    Open

                    return "PositiveSmallIntegerField"
    Severity: Major
    Found in django/db/backends/mysql/introspection.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                      return "PositiveIntegerField"
      Severity: Major
      Found in django/db/backends/mysql/introspection.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    return "UUIDField"
        Severity: Major
        Found in django/db/backends/mysql/introspection.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return field_type
          Severity: Major
          Found in django/db/backends/mysql/introspection.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                        return "JSONField"
            Severity: Major
            Found in django/db/backends/mysql/introspection.py - About 30 mins to fix

              There are no issues that match your filters.

              Category
              Status