rsim/oracle-enhanced

View on GitHub

Showing 90 of 90 total issues

Consider simplifying this complex logical expression.
Open

          if config[:jndi]
            jndi = config[:jndi].to_s
            ctx = javax.naming.InitialContext.new
            ds = nil

Severity: Critical
Found in lib/active_record/connection_adapters/oracle_enhanced/jdbc_connection.rb - About 2 hrs to fix

    Method visit_Arel_Nodes_SelectStatement has 55 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def visit_Arel_Nodes_SelectStatement(o, collector)
              o = order_hacks(o)
    
              # if need to select first records without ORDER BY and GROUP BY and without DISTINCT
              # then can use simple ROWNUM in WHERE clause
    Severity: Major
    Found in lib/arel/visitors/oracle.rb - About 2 hrs to fix

      Class JDBCConnection has 21 methods (exceeds 20 allowed). Consider refactoring.
      Open

            class JDBCConnection < OracleEnhanced::Connection # :nodoc:
              attr_accessor :active
              alias :active? :active
      
              attr_accessor :auto_retry

        Method table has 54 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

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

          Method type_cast has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

                  def type_cast(value)
                    case value
                    when ActiveModel::Type::Binary::Data
                      lob_value = value == "" ? " " : value
                      bind_type = OCI8::BLOB
          Severity: Minor
          Found in lib/active_record/connection_adapters/oracle_enhanced/oci_quoting.rb - About 2 hrs 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

          Method structure_dump has 48 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  def structure_dump # :nodoc:
                    sequences = select(<<~SQL.squish, "SCHEMA")
                      SELECT
                      sequence_name, min_value, max_value, increment_by, order_flag, cycle_flag
                      FROM all_sequences

            Method visit_Arel_Nodes_HomogeneousIn has a Cognitive Complexity of 15 (exceeds 5 allowed). 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: Minor
            Found in lib/arel/visitors/oracle.rb - 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

            Method _update_record has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                  def _update_record(attribute_names = @attributes.keys)
                    # check if class has custom update method
                    if self.class.custom_update_method
                      # run before/after callbacks defined in model
                      run_callbacks(:update) do
            Severity: Minor
            Found in lib/active_record/connection_adapters/oracle_enhanced/procedures.rb - 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

            Method add_context_index has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                    def add_context_index(table_name, column_name, options = {})
                      column_names = Array(column_name)
                      index_name = options[:name] || index_name(table_name, column: options[:index_column] || column_names,
                        # CONEXT index name max length is 25
                        identifier_max_length: 25)

            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 visit_Arel_Nodes_HomogeneousIn has a Cognitive Complexity of 15 (exceeds 5 allowed). 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: Minor
            Found in lib/arel/visitors/oracle12.rb - 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

            Method add_context_index has 47 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    def add_context_index(table_name, column_name, options = {})
                      column_names = Array(column_name)
                      index_name = options[:name] || index_name(table_name, column: options[:index_column] || column_names,
                        # CONEXT index name max length is 25
                        identifier_max_length: 25)

              Method new_connection has 47 lines of code (exceeds 25 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

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

                          if (column["data_type"] == "NUMBER") && !column["data_precision"].nil?
                            col << "(#{column['data_precision'].to_i}"
                            col << ",#{column['data_scale'].to_i}" if !column["data_scale"].nil?
                            col << ")"
                          elsif column["data_type"].include?("CHAR") || column["data_type"] == "RAW"
                lib/active_record/connection_adapters/oracle_enhanced/structure_dump.rb on lines 81..88

                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 72.

                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

                          if (column["data_type"] == "NUMBER") && !column["data_precision"].nil?
                            col << "(#{column['data_precision'].to_i}"
                            col << ",#{column['data_scale'].to_i}" if !column["data_scale"].nil?
                            col << ")"
                          elsif column["data_type"].include?("CHAR") || column["data_type"] == "RAW"
                lib/active_record/connection_adapters/oracle_enhanced/structure_dump.rb on lines 65..72

                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 72.

                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 structure_dump has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                        def structure_dump # :nodoc:
                          sequences = select(<<~SQL.squish, "SCHEMA")
                            SELECT
                            sequence_name, min_value, max_value, increment_by, order_flag, cycle_flag
                            FROM all_sequences

                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 select has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                        def select(sql, name = nil, return_column_names = false)
                          cursor = @raw_connection.exec(sql)
                          cols = []
                          # Ignore raw_rnum_ which is used to simulate LIMIT and OFFSET
                          cursor.get_col_names.each do |col_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

                Method visit_TableDefinition has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                          def visit_TableDefinition(o)
                            create_sql = +"CREATE#{' GLOBAL TEMPORARY' if o.temporary} TABLE #{quote_table_name(o.name)} "
                            statements = o.columns.map { |c| accept c }
                            statements << accept(o.primary_keys) if o.primary_keys
                
                

                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 add_column_options! has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                          def add_column_options!(sql, options)
                            type = options[:type] || ((column = options[:column]) && column.type)
                            type = type && type.to_sym
                            # handle case of defaults for CLOB/NCLOB columns, which would otherwise get "quoted" incorrectly
                            if options_include_default?(options)

                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 describe has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                          def describe(name)
                            name = name.to_s
                            if name.include?("@")
                              raise ArgumentError "db link is not supported"
                            else
                Severity: Minor
                Found in lib/active_record/connection_adapters/oracle_enhanced/connection.rb - About 1 hr to fix

                  Method get_ruby_value_from_result_set has 43 lines of code (exceeds 25 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?
                    Severity
                    Category
                    Status
                    Source
                    Language