kaspernj/baza

View on GitHub

Showing 177 of 177 total issues

Method create_column_programmatic has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def create_column_programmatic(col_data)
    temp_name = "temptable_#{Time.now.to_f.to_s.hash}"
    clone(temp_name)
    cols_cur = columns
    @db.query("DROP TABLE `#{name}`")
Severity: Minor
Found in lib/baza/driver/sqlite3/table.rb - About 1 hr to fix

    Method fetch has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def fetch
        if @enum
          begin
            ret = @enum.next
          rescue StopIteration
    Severity: Minor
    Found in lib/baza/driver/mysql/unbuffered_result.rb - About 1 hr to fix

      Method data_sql has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def data_sql(data)
          data.each_key do |key|
            raise "Invalid key: '#{key}' (#{key.class.name})." unless DATA_SQL_ALLOWED_KEYS.include?(key)
          end
      
      
      Severity: Minor
      Found in lib/baza/driver/sqlite3/columns.rb - About 1 hr to fix

        Method columns has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def columns(args = nil)
            @db.columns
            ret = []
            sql = "SHOW FULL COLUMNS FROM #{@db.quote_table(name)}"
            sql << " WHERE `Field` = '#{@db.esc(args.fetch(:name))}'" if args && args.key?(:name)
        Severity: Minor
        Found in lib/baza/driver/mysql/table.rb - About 1 hr to fix

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

              rescue => e
                if tries <= 3
                  if e.message == "MySQL server has gone away" || e.message == "closed MySQL connection" || e.message == "Can't connect to local MySQL server through socket"
                    sleep 0.5
                    reconnect
          Severity: Major
          Found in lib/baza/driver/mysql.rb and 1 other location - About 1 hr to fix
          lib/baza/driver/mysql2.rb on lines 103..116

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

          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

              rescue => e
                if tries <= 3
                  if e.message == "MySQL server has gone away" || e.message == "closed MySQL connection" || e.message == "Can't connect to local MySQL server through socket"
                    sleep 0.5
                    reconnect
          Severity: Major
          Found in lib/baza/driver/mysql2.rb and 1 other location - About 1 hr to fix
          lib/baza/driver/mysql.rb on lines 62..75

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

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

            def type
              unless @type
                if (match = @data.fetch(:Type).match(/^([A-z]+)$/))
                  @maxlength = false
                  @type = match[0].to_sym
          Severity: Minor
          Found in lib/baza/driver/mysql/column.rb - 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

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

            def indexes(args = {})
              where_args = {
                tablename: name
              }
          
          
          Severity: Minor
          Found in lib/baza/driver/pg/table.rb - 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

          Method insert_and_register_conflict has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def insert_and_register_conflict
              @db.query(insert_sql)
              @db.last_id if @return_id
            rescue => e
              if (match = e.message.match(/Key \((.+)\)=\((.+)\) already exists/))
          Severity: Minor
          Found in lib/baza/sql_queries/postgres_upsert_duplicate_key.rb - 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

          Method execute has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def execute
              # Give 'cloned_ubuf' argument to 'q'-method.
              if @args
                @args_q = {cloned_ubuf: true} if @args[:cloned_ubuf]
                @args_q = {unbuffered: true} if @args[:unbuffered]
          Severity: Minor
          Found in lib/baza/commands/select.rb - 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

          Method initialize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def initialize(args)
              args = {time: args} if args.is_a?(String)
          
              raise "Invalid arguments given: #{args}" unless args.is_a?(Hash)
              raise "No time given." unless args[:time]
          Severity: Minor
          Found in lib/baza/dbtime.rb - 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

          Method register_thread has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def register_thread
              raise "Baza-object is not in threadding mode" unless @conns
          
              thread_cur = Thread.current
              tid = __id__
          Severity: Minor
          Found in lib/baza/db.rb - 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

          Method read_row has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def read_row
              return false unless @result_set
          
              unless @result_set.next
                destroy
          Severity: Minor
          Found in lib/baza/jdbc_result.rb - 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

          Method initialize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def initialize(db)
              super
          
              @path = @db.opts[:path] if @db.opts[:path]
              @mutex_statement_reader = Mutex.new
          Severity: Minor
          Found in lib/baza/driver/sqlite3.rb - 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

          Method list has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def list(args = {})
              tables_list = [] unless block_given?
          
              where_args = {
                table_catalog: @db.opts[:db],
          Severity: Minor
          Found in lib/baza/driver/pg/tables.rb - 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

          Method from_active_record_connection has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.from_active_record_connection(connection)
              if connection.class.name.include?("Mysql2Adapter")
                connection = connection.instance_variable_get(:@connection)
          
                config = connection.instance_variable_get(:@query_options)
          Severity: Minor
          Found in lib/baza/cloner.rb - 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

          Method add_select_sql has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def add_select_sql
              # Set up IDQuery-stuff if that is given in arguments.
              if @args && @args[:idquery]
                if @args.fetch(:idquery) == true
                  select_sql = "#{@db.quote_column(:id)}"
          Severity: Minor
          Found in lib/baza/commands/select.rb - 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

          Method translate_type has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def translate_type(result, count)
              java_count = count + 1
          
              return result.string(java_count) if @type_translation == :string
          
          
          Severity: Minor
          Found in lib/baza/jdbc_result.rb - 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

          Method insert_with_multi has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def insert_with_multi(table, data, sort: false)
              data_key = ""
          
              if sort
                data = data.sort_by { |element| element[0].to_s }
          Severity: Minor
          Found in lib/baza/query_buffer.rb - 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

          Method add_limit_sql has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def add_limit_sql
              return if @args.nil?
          
              @sql << " LIMIT #{@args[:limit]}" if @args[:limit]
          
          
          Severity: Minor
          Found in lib/baza/commands/select.rb - 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

          Severity
          Category
          Status
          Source
          Language