kaspernj/baza

View on GitHub

Showing 145 of 177 total issues

Method default_db has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def self.default_db
    unless @default_db
      config_file = "#{Dir.pwd}/config/baza_database.rb"
      init_file = "#{Dir.pwd}/config/initializers/baza_database.rb"

Severity: Minor
Found in lib/baza.rb - 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

Method reload has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def reload
    data = nil
    @db.query("PRAGMA index_list(#{@db.quote_table(name)})") do |d_indexes|
      next unless d_indexes.fetch(:name) == name
      data = d_indexes
Severity: Minor
Found in lib/baza/driver/sqlite3/index.rb - 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

Method to_sql has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

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

    first = true
    @data.each do |key, value|
Severity: Minor
Found in lib/baza/sql_queries/generic_update.rb - 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

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

  def execute
    return insert_or_handle_duplicate if @terms.empty?

    @db.transaction do
      @db.query(insert_sql)
Severity: Minor
Found in lib/baza/sql_queries/sqlite_upsert_duplicate_key.rb - 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

Method optimize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def optimize(args = nil)
    STDOUT.puts "Beginning optimization of database." if @debug || (args && args[:debug])
    tables.list do |table|
      STDOUT.puts "Optimizing table: '#{table.name}'." if @debug || (args && args[:debug])
      table.optimize
Severity: Minor
Found in lib/baza/db.rb - 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 method.
Open

      return Date.parse(result.string(java_count))
Severity: Major
Found in lib/baza/jdbc_result.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

          return nil
    Severity: Major
    Found in lib/baza/jdbc_result.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

            return result.object(java_count)
      Severity: Major
      Found in lib/baza/jdbc_result.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

              return Date.parse(value)
        Severity: Major
        Found in lib/baza/driver/sqlite3/result.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                return Time.parse(result.string(java_count))
          Severity: Major
          Found in lib/baza/jdbc_result.rb - About 30 mins to fix

            Method foreign_keys has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def foreign_keys(args = {})
                sql = "
                  SELECT
                    tc.constraint_name,
                    tc.table_name,
            Severity: Minor
            Found in lib/baza/driver/pg/table.rb - 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

            Method method_missing has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def method_missing(func_name, *args)
                if (match = func_name.to_s.match(/^(\S+)\?$/)) && @data.key?(match[1].to_sym)
                  if @data.fetch(match[1].to_sym) == "1" || @data.fetch(match[1].to_sym) == "yes"
                    return true
                  elsif @data.fetch(match[1].to_sym) == "0" || @data.fetch(match[1].to_sym) == "no"
            Severity: Minor
            Found in lib/baza/row.rb - 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

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

              def list(args = {})
                where_args = {}
                where_args[:datname] = args.fetch(:name) if args[:name]
            
                database_list = [] unless block_given?
            Severity: Minor
            Found in lib/baza/driver/pg/databases.rb - 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

            Method limit_sql has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def limit_sql
                unless @count
                  if @page
                    @per_page ||= 30
                    sql = "LIMIT #{@db.quote_value(@per_page)} OFFSET #{@per_page * (current_page - 1)}"
            Severity: Minor
            Found in lib/baza/sql_queries/select.rb - 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

            Method fetch has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def fetch
                row = @results[@index += 1]
                return unless row
            
                if @types
            Severity: Minor
            Found in lib/baza/driver/sqlite3/result.rb - 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

            Method foreign_keys has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def foreign_keys(args = {})
                sql = "
                  SELECT
                    TABLE_NAME,
                    COLUMN_NAME,
            Severity: Minor
            Found in lib/baza/driver/mysql/table.rb - 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

            Method quote_value has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.quote_value(val)
                if val.class.name == "Fixnum" || val.is_a?(Integer)
                  val.to_s
                elsif val == nil
                  "NULL"
            Severity: Minor
            Found in lib/baza/base_sql_driver.rb - 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

            Method initialize has a Cognitive Complexity of 6 (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_rhodes.rb - 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

            Method referenced_foreign_keys has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def referenced_foreign_keys(args = {})
                sql = "
                  SELECT
                    TABLE_NAME,
                    COLUMN_NAME,
            Severity: Minor
            Found in lib/baza/driver/mysql/table.rb - 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

            Method quote_value has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def quote_value(val)
                if val.class.name == "Fixnum" || val.is_a?(Integer)
                  val.to_s
                elsif val == nil
                  "NULL"
            Severity: Minor
            Found in lib/baza/base_sql_driver.rb - 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

            Severity
            Category
            Status
            Source
            Language