django/django

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

Summary

Maintainability
D
2 days
Test Coverage

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

class DatabaseOperations(BaseDatabaseOperations):
    # Oracle uses NUMBER(11) and NUMBER(19) for integer fields.
    integer_field_ranges = {
        'SmallIntegerField': (-99999999999, 99999999999),
        'IntegerField': (-99999999999, 99999999999),
Severity: Major
Found in django/db/backends/oracle/operations.py - About 7 hrs to fix

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

    import datetime
    import re
    import uuid
    from functools import lru_cache
    
    
    Severity: Minor
    Found in django/db/backends/oracle/operations.py - About 7 hrs to fix

      Function get_db_converters has a Cognitive Complexity of 12 (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 == 'TextField':
                  converters.append(self.convert_textfield_value)
      Severity: Minor
      Found in django/db/backends/oracle/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 sequence_reset_sql has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def sequence_reset_sql(self, style, model_list):
              from django.db import models
              output = []
              query = self._sequence_reset_sql
              for model in model_list:
      Severity: Minor
      Found in django/db/backends/oracle/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 a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def sql_flush(self, style, tables, sequences, allow_cascade=False):
              if tables:
                  truncated_tables = {table.upper() for table in tables}
                  constraints = set()
                  # Oracle's TRUNCATE CASCADE only works with ON DELETE CASCADE
      Severity: Minor
      Found in django/db/backends/oracle/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 bulk_insert_sql has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def bulk_insert_sql(self, fields, placeholder_rows):
              query = []
              for row in placeholder_rows:
                  select = []
                  for i, placeholder in enumerate(row):
      Severity: Minor
      Found in django/db/backends/oracle/operations.py - About 55 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 datetime_trunc_sql has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def datetime_trunc_sql(self, lookup_type, field_name, tzname):
              field_name = self._convert_field_to_tz(field_name, tzname)
              # https://docs.oracle.com/en/database/oracle/oracle-database/18/sqlrf/ROUND-and-TRUNC-Date-Functions.html
              if lookup_type in ('year', 'month'):
                  sql = "TRUNC(%s, '%s')" % (field_name, lookup_type.upper())
      Severity: Minor
      Found in django/db/backends/oracle/operations.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 'FLOOR(%(lhs)s / POWER(2, %(rhs)s))' % {'lhs': lhs, 'rhs': rhs}
      Severity: Major
      Found in django/db/backends/oracle/operations.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    return "EXTRACT(%s FROM %s)" % (lookup_type.upper(), field_name)
        Severity: Major
        Found in django/db/backends/oracle/operations.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return 'POWER(%s)' % ','.join(sub_expressions)
          Severity: Major
          Found in django/db/backends/oracle/operations.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return super().combine_expression(connector, sub_expressions)
            Severity: Major
            Found in django/db/backends/oracle/operations.py - About 30 mins to fix

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

                  def combine_expression(self, connector, sub_expressions):
                      lhs, rhs = sub_expressions
                      if connector == '%%':
                          return 'MOD(%s)' % ','.join(sub_expressions)
                      elif connector == '&':
              Severity: Minor
              Found in django/db/backends/oracle/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 adapt_datetimefield_value has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def adapt_datetimefield_value(self, value):
                      """
                      Transform a datetime value to an object compatible with what is expected
                      by the backend driver for datetime columns.
              
              
              Severity: Minor
              Found in django/db/backends/oracle/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 last_executed_query has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def last_executed_query(self, cursor, sql, params):
                      # https://cx-oracle.readthedocs.io/en/latest/cursor.html#Cursor.statement
                      # The DB API definition does not define this attribute.
                      statement = cursor.statement
                      # Unlike Psycopg's `query` and MySQLdb`'s `_executed`, cx_Oracle's
              Severity: Minor
              Found in django/db/backends/oracle/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