django/django

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

Summary

Maintainability
D
3 days
Test Coverage

Function _parse_column_or_constraint_definition has a Cognitive Complexity of 77 (exceeds 5 allowed). Consider refactoring.
Open

    def _parse_column_or_constraint_definition(self, tokens, columns):
        token = None
        is_constraint_definition = None
        field_name = None
        constraint_name = None
Severity: Minor
Found in django/db/backends/sqlite3/introspection.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

File introspection.py has 372 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from collections import namedtuple

import sqlparse

from django.db import DatabaseError
Severity: Minor
Found in django/db/backends/sqlite3/introspection.py - About 4 hrs to fix

    Function _parse_table_constraints has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        def _parse_table_constraints(self, sql, columns):
            # Check constraint parsing is based of SQLite syntax diagram.
            # https://www.sqlite.org/syntaxdiagrams.html#table-constraint
            statement = sqlparse.parse(sql)[0]
            constraints = {}
    Severity: Minor
    Found in django/db/backends/sqlite3/introspection.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_constraints has a Cognitive Complexity of 17 (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/sqlite3/introspection.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_column_collations has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def _get_column_collations(self, cursor, table_name):
            row = cursor.execute(
                """
                SELECT sql
                FROM sqlite_master
    Severity: Minor
    Found in django/db/backends/sqlite3/introspection.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

    Avoid deeply nested control flow statements.
    Open

                            if unique_columns:
                                # Stop constraint parsing.
                                unique = False
                            continue
    Severity: Major
    Found in django/db/backends/sqlite3/introspection.py - About 45 mins to fix

      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/sqlite3/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

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

          def _get_index_columns_orders(self, sql):
              tokens = sqlparse.parse(sql)[0]
              for token in tokens:
                  if isinstance(token, sqlparse.sql.Parenthesis):
                      columns = str(token).strip("()").split(", ")
      Severity: Minor
      Found in django/db/backends/sqlite3/introspection.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