django/django

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

Summary

Maintainability
C
1 day
Test Coverage

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

class DatabaseOperations(BaseDatabaseOperations):
    cast_char_field_without_max_length = 'text'
    cast_data_types = {
        'DateField': 'TEXT',
        'DateTimeField': 'TEXT',
Severity: Minor
Found in django/db/backends/sqlite3/operations.py - About 4 hrs to fix

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

    import datetime
    import decimal
    import uuid
    from functools import lru_cache
    from itertools import chain
    Severity: Minor
    Found in django/db/backends/sqlite3/operations.py - About 2 hrs to fix

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

          def check_expression_support(self, expression):
              bad_fields = (fields.DateField, fields.DateTimeField, fields.TimeField)
              bad_aggregates = (aggregates.Sum, aggregates.Avg, aggregates.Variance, aggregates.StdDev)
              if isinstance(expression, bad_aggregates):
                  for expr in expression.get_source_expressions():
      Severity: Minor
      Found in django/db/backends/sqlite3/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 get_decimalfield_converter has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_decimalfield_converter(self, expression):
              # SQLite stores only 15 significant digits. Digits coming from
              # float inaccuracy must be removed.
              create_decimal = decimal.Context(prec=15).create_decimal_from_float
              if isinstance(expression, Col):
      Severity: Minor
      Found in django/db/backends/sqlite3/operations.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

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

          def adapt_datetimefield_value(self, value):
              if value is None:
                  return None
      
              # Expression values are adapted by the database.
      Severity: Minor
      Found in django/db/backends/sqlite3/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

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

          def get_db_converters(self, expression):
              converters = super().get_db_converters(expression)
              internal_type = expression.output_field.get_internal_type()
              if internal_type == 'DateTimeField':
                  converters.append(self.convert_datetimefield_value)
      Severity: Minor
      Found in django/db/backends/sqlite3/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