kaspernj/baza

View on GitHub

Showing 145 of 177 total issues

Method sql_make_where has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def sql_make_where(arr_terms, _driver = nil)
    sql = ""

    first = true
    arr_terms.each do |key, value|
Severity: Minor
Found in lib/baza/base_sql_driver.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_sql has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def update_sql
    sql = "UPDATE OR IGNORE #{@db.quote_table(@table_name)} SET "

    first = true
    @updates.each do |key, value|
Severity: Minor
Found in lib/baza/sql_queries/sqlite_upsert_duplicate_key.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 where_sql has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def where_sql
    return if @wheres.empty?

    sql = " WHERE"

Severity: Minor
Found in lib/baza/sql_queries/select.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 clone_insert_from_original_table has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def clone_insert_from_original_table(newname, columns_list)
    sql_clone = "INSERT INTO #{@db.quote_table(newname)} ("

    first = true
    columns_list.each do |column_data|
Severity: Minor
Found in lib/baza/driver/pg/table.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 insert_sql has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def insert_sql
    sql = "INSERT OR IGNORE INTO #{@db.quote_table(@table_name)} ("

    combined_data = @updates.merge(@terms)

Severity: Minor
Found in lib/baza/sql_queries/sqlite_upsert_duplicate_key.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 query has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def query(string, args = nil, &block)
    if @debug
      print "SQL: #{string}\n"

      if @debug.class.name == "Fixnum" && @debug >= 2
Severity: Minor
Found in lib/baza/db.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 columns has a Cognitive Complexity of 10 (exceeds 5 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

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

  def insert_sql
    sql = "INSERT INTO #{@db.quote_table(@table_name)} ("

    combined_data = @updates.merge(@terms)

Severity: Minor
Found in lib/baza/sql_queries/postgres_upsert_duplicate_key.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 reconnect has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def reconnect
    @mutex.synchronize do
      require "mysql2" unless ::Object.const_defined?(:Mysql2)

      args = {
Severity: Minor
Found in lib/baza/driver/mysql2.rb - About 1 hr to fix

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

      def flush_real(db = nil)
        return nil if @queries_count <= 0
        db = @db if db == nil
    
        @lock.synchronize do
    Severity: Minor
    Found in lib/baza/query_buffer.rb - About 1 hr to fix

      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

              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

              Severity
              Category
              Status
              Source
              Language