django/django

View on GitHub
django/core/management/commands/inspectdb.py

Summary

Maintainability
D
2 days
Test Coverage

Function handle_inspection has a Cognitive Complexity of 69 (exceeds 5 allowed). Consider refactoring.
Open

    def handle_inspection(self, options):
        connection = connections[options['database']]
        # 'table_name_filter' is a stealth option
        table_name_filter = options.get('table_name_filter')

Severity: Minor
Found in django/core/management/commands/inspectdb.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

Function normalize_col_name has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    def normalize_col_name(self, col_name, used_column_names, is_relation):
        """
        Modify the column name to make it Python-compatible as a field name
        """
        field_params = {}
Severity: Minor
Found in django/core/management/commands/inspectdb.py - About 2 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 get_meta has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def get_meta(self, table_name, constraints, column_to_field_name, is_view, is_partition):
        """
        Return a sequence comprising the lines of code necessary
        to construct the inner Meta class for the model corresponding
        to the given database table name.
Severity: Minor
Found in django/core/management/commands/inspectdb.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_field_type has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def get_field_type(self, connection, table_name, row):
        """
        Given the database connection, the table name, and the cursor row
        description, this routine will return the given field type name, as
        well as any additional keyword parameters and notes for the field.
Severity: Minor
Found in django/core/management/commands/inspectdb.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

Avoid deeply nested control flow statements.
Open

                        if field_type == 'AutoField(':
                            continue
                        elif field_type == connection.features.introspected_field_types['AutoField'] + '(':
                            comment_notes.append('AutoField?')

Severity: Major
Found in django/core/management/commands/inspectdb.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if not field_desc.endswith('('):
                                field_desc += ', '
                            field_desc += ', '.join('%s=%r' % (k, v) for k, v in extra_params.items())
    Severity: Major
    Found in django/core/management/commands/inspectdb.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if extra_params.pop('unique', False) or extra_params.get('primary_key'):
                                  rel_type = 'OneToOneField'
                              else:
                                  rel_type = 'ForeignKey'
                              rel_to = (
      Severity: Major
      Found in django/core/management/commands/inspectdb.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if rel_to in known_models:
                                    field_type = '%s(%s' % (rel_type, rel_to)
                                else:
                                    field_type = "%s('%s'" % (rel_type, rel_to)
                            else:
        Severity: Major
        Found in django/core/management/commands/inspectdb.py - About 45 mins to fix

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

              def get_meta(self, table_name, constraints, column_to_field_name, is_view, is_partition):
          Severity: Minor
          Found in django/core/management/commands/inspectdb.py - About 35 mins to fix

            There are no issues that match your filters.

            Category
            Status