django/django

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

Summary

Maintainability
F
3 days
Test Coverage

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

import datetime
import uuid
from functools import lru_cache

from django.conf import settings
Severity: Major
Found in django/db/backends/oracle/operations.py - About 1 day to fix

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

    class DatabaseOperations(BaseDatabaseOperations):
        # Oracle uses NUMBER(5), NUMBER(11), and NUMBER(19) for integer fields.
        # SmallIntegerField uses NUMBER(11) instead of NUMBER(5), which is used by
        # SmallAutoField, to preserve backward compatibility.
        integer_field_ranges = {
    Severity: Major
    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 in ['JSONField', '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):
              output = []
              query = self._sequence_reset_sql
              for model in model_list:
                  for f in model._meta.local_fields:
      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 sql_flush has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def sql_flush(self, style, tables, *, reset_sequences=False, allow_cascade=False):
              if not tables:
                  return []
      
              truncated_tables = {table.upper() for table in tables}
      Severity: Minor
      Found in django/db/backends/oracle/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 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/oracle/operations.py - About 35 mins to fix

        Function combine_expression has a Cognitive Complexity of 7 (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 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 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 '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 "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 super().combine_expression(connector, 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 "TO_CHAR(%s, 'IYYY')" % field_name
                Severity: Major
                Found in django/db/backends/oracle/operations.py - About 30 mins to fix

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

                      def date_extract_sql(self, lookup_type, field_name):
                          if lookup_type == 'week_day':
                              # TO_CHAR(field, 'D') returns an integer from 1-7, where 1=Sunday.
                              return "TO_CHAR(%s, 'D')" % field_name
                          elif lookup_type == 'iso_week_day':
                  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

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

                      def fetch_returned_insert_columns(self, cursor, returning_params):
                          columns = []
                          for param in returning_params:
                              value = param.get_value()
                              if value is None or value == []:
                  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