django/django

View on GitHub
django/db/backends/postgresql/operations.py

Summary

Maintainability
C
1 day
Test Coverage

DatabaseOperations has 40 functions (exceeds 20 allowed). Consider refactoring.
Open

class DatabaseOperations(BaseDatabaseOperations):
    cast_char_field_without_max_length = "varchar"
    explain_prefix = "EXPLAIN"
    explain_options = frozenset(
        [
Severity: Minor
Found in django/db/backends/postgresql/operations.py - About 5 hrs to fix

    File operations.py has 319 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import json
    from functools import lru_cache, partial
    
    from django.conf import settings
    from django.db.backends.base.operations import BaseDatabaseOperations
    Severity: Minor
    Found in django/db/backends/postgresql/operations.py - About 3 hrs to fix

      Function last_executed_query has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

              def last_executed_query(self, cursor, sql, params):
                  if self.connection.features.uses_server_side_binding:
                      try:
                          return self.compose_sql(sql, params)
                      except errors.DataError:
      Severity: Minor
      Found in django/db/backends/postgresql/operations.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 explain_query_prefix has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def explain_query_prefix(self, format=None, **options):
              extra = {}
              # Normalize options.
              if options:
                  options = {
      Severity: Minor
      Found in django/db/backends/postgresql/operations.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 sql_flush has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def sql_flush(self, style, tables, *, reset_sequences=False, allow_cascade=False):
      Severity: Minor
      Found in django/db/backends/postgresql/operations.py - About 35 mins to fix

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

            def sequence_reset_sql(self, style, model_list):
                from django.db import models
        
                output = []
                qn = self.quote_name
        Severity: Minor
        Found in django/db/backends/postgresql/operations.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