rsim/oracle-enhanced

View on GitHub

Showing 90 of 90 total issues

Method new_connection has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
Open

        def new_connection(config)
          username = nil

          if config[:jndi]
            jndi = config[:jndi].to_s

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 schema_statements.rb has 544 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "openssl"

module ActiveRecord
  module ConnectionAdapters
    module OracleEnhanced

    Class OracleEnhancedAdapter has 56 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class OracleEnhancedAdapter < AbstractAdapter
          include OracleEnhanced::DatabaseStatements
          include OracleEnhanced::SchemaStatements
          include OracleEnhanced::ContextIndex
          include OracleEnhanced::Quoting
    Severity: Major
    Found in lib/active_record/connection_adapters/oracle_enhanced_adapter.rb - About 1 day to fix

      File oracle_enhanced_adapter.rb has 498 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require "arel/visitors/oracle"
      require "arel/visitors/oracle12"
      require "active_record/connection_adapters"
      require "active_record/connection_adapters/abstract_adapter"
      require "active_record/connection_adapters/statement_pool"
      Severity: Minor
      Found in lib/active_record/connection_adapters/oracle_enhanced_adapter.rb - About 7 hrs to fix

        File jdbc_connection.rb has 440 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        begin
          require "java"
          require "jruby"
        
          # ojdbc7.jar or ojdbc6.jar file should be in application ./lib directory or in load path or in ENV['PATH']

          File oci_connection.rb has 353 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          require "delegate"
          
          begin
            require "oci8"
          rescue LoadError => e

            Method new_connection has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
            Open

                    def self.new_connection(config)
                      # to_s needed if username, password or database is specified as number in database.yml file
                      username = config[:username] && config[:username].to_s
                      password = config[:password] && config[:password].to_s
                      database = config[:database] && config[:database].to_s

            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 structure_dump.rb has 328 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            module ActiveRecord # :nodoc:
              module ConnectionAdapters # :nodoc:
                module OracleEnhanced # :nodoc:
                  module StructureDump # :nodoc:
                    # Statements separator used in structure dump to allow loading of structure dump also with SQL*Plus

              Method table has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
              Open

                        def table(table, stream)
                          columns = @connection.columns(table)
                          begin
                            self.table_name = table
              
              

              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

              Method new_connection has 92 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      def new_connection(config)
                        username = nil
              
                        if config[:jndi]
                          jndi = config[:jndi].to_s

                Method indexes has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                Open

                        def indexes(table_name) # :nodoc:
                          (_owner, table_name) = @raw_connection.describe(table_name)
                          default_tablespace_name = default_tablespace
                
                          result = select_all(<<~SQL.squish, "SCHEMA", [bind_string("table_name", table_name)])

                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

                Identical blocks of code found in 2 locations. Consider refactoring.
                Open

                        def visit_Arel_Nodes_HomogeneousIn(o, collector)
                          in_clause_length = @connection.in_clause_length
                          values = o.casted_values.map { |v| @connection.quote(v) }
                          column_name = quote_table_name(o.table_name) + "." + quote_column_name(o.column_name)
                          operator =
                Severity: Major
                Found in lib/arel/visitors/oracle12.rb and 1 other location - About 3 hrs to fix
                lib/arel/visitors/oracle.rb on lines 96..138

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 109.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Identical blocks of code found in 2 locations. Consider refactoring.
                Open

                        def visit_Arel_Nodes_HomogeneousIn(o, collector)
                          in_clause_length = @connection.in_clause_length
                          values = o.casted_values.map { |v| @connection.quote(v) }
                          column_name = quote_table_name(o.table_name) + "." + quote_column_name(o.column_name)
                          operator =
                Severity: Major
                Found in lib/arel/visitors/oracle.rb and 1 other location - About 3 hrs to fix
                lib/arel/visitors/oracle12.rb on lines 49..91

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 109.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Method get_ruby_value_from_result_set has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                Open

                        def get_ruby_value_from_result_set(rset, i, type_name, get_lob_value = true)
                          case type_name
                          when :NUMBER
                            d = rset.getNUMBER(i)
                            if d.nil?

                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

                Method create_table has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                Open

                        def create_table(table_name, id: :primary_key, primary_key: nil, force: nil, **options)
                          create_sequence = id != false
                          td = create_table_definition(
                            table_name, **options.extract!(:temporary, :options, :as, :comment, :tablespace, :organization)
                          )

                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

                Method _indexes has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                Open

                          def _indexes(table, stream)
                            if (indexes = @connection.indexes(table)).any?
                              add_index_statements = indexes.filter_map do |index|
                                case index.type
                                when nil

                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

                Class OCIConnection has 24 methods (exceeds 20 allowed). Consider refactoring.
                Open

                      class OCIConnection < OracleEnhanced::Connection # :nodoc:
                        def initialize(config)
                          @raw_connection = OCI8EnhancedAutoRecover.new(config, OracleEnhancedOCIFactory)
                          # default schema owner
                          @owner = config[:schema]

                  Method exec_query has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                  Open

                          def exec_query(sql, name = "SQL", binds = [], prepare: false, async: false)
                            sql = transform_query(sql)
                  
                            type_casted_binds = type_casted_binds(binds)
                  
                  

                  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

                  Method exec_insert has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                  Open

                          def exec_insert(sql, name = nil, binds = [], pk = nil, sequence_name = nil)
                            sql, binds = sql_for_insert(sql, pk, binds)
                            type_casted_binds = type_casted_binds(binds)
                  
                            log(sql, name, binds, type_casted_binds) do

                  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

                  Method indexes has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          def indexes(table_name) # :nodoc:
                            (_owner, table_name) = @raw_connection.describe(table_name)
                            default_tablespace_name = default_tablespace
                  
                            result = select_all(<<~SQL.squish, "SCHEMA", [bind_string("table_name", table_name)])
                    Severity
                    Category
                    Status
                    Source
                    Language