kaspernj/baza

View on GitHub

Showing 177 of 177 total issues

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

  def initialize(db)
    super

    @opts = @db.opts

Severity: Minor
Found in lib/baza/driver/mysql.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 each has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def each
    return unless @result

    @result.each(as: :hash, symbolize_keys: true) do |row|
      next unless row # This sometimes happens when streaming results...
Severity: Minor
Found in lib/baza/driver/mysql2/result.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 jdbc_connect_command has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def jdbc_connect_command
    conn_options = {
      "populateInsertRowWithDefaultValues" => true,
      "zeroDateTimeBehavior" => "round",
      "holdResultsOpenOverStatementClose" => true
Severity: Minor
Found in lib/baza/driver/mysql_java.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 each_table has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def each_table
    if @tables
      tables = @tables
    else
      tables = @db.tables.list
Severity: Minor
Found in lib/baza/dump.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 index has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def index(index_name)
    index_name = index_name.to_s

    if (index = @indexes_list[index_name])
      return index
Severity: Minor
Found in lib/baza/driver/sqlite3/table.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 reconnect has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def reconnect
    require "pg" unless ::Object.const_defined?(:PG)

    close if @conn && !@conn.finished?

Severity: Minor
Found in lib/baza/driver/pg.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 default has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def default
    return nil if (type == :datetime || type == :date) && @data[:Default].to_s.strip.empty?
    return nil if (type == :int || type == :bigint) && @data[:Default].to_s.strip.empty?
    return nil unless @data[:Default]
    @data.fetch(:Default)
Severity: Minor
Found in lib/baza/driver/mysql/column.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 translate_type has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def translate_type(value, type)
    return if value.to_s.empty?

    if type == "datetime"
      return nil if value == "NULL"
Severity: Minor
Found in lib/baza/driver/sqlite3/result.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 columns has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def columns
    @db.columns
    ret = []

    @db.query("PRAGMA table_info(#{@db.quote_table(name)})") do |d_cols|
Severity: Minor
Found in lib/baza/driver/sqlite3/table.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 dump_table has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def dump_table(io, table_obj)
    create_data = table_obj.data.clone
    create_data.delete(:name)
    create_data[:return_sql] = true

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

  def self.drivers
    path = "#{File.dirname(__FILE__)}/driver"
    drivers = []

    Dir.foreach(path) do |file|
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

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

  def [](key)
    raise "No valid key given." unless key
    raise "No data was loaded on the object? Maybe you are trying to call a deleted object?" unless @data

    if @data.key?(key)
Severity: Minor
Found in lib/baza/row.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 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

Similar blocks of code found in 4 locations. Consider refactoring.
Open

  def [](table_name)
    table_name = table_name.to_s
    table = @list[table_name]

    return table if table
Severity: Major
Found in lib/baza/driver/mysql/tables.rb and 3 other locations - About 35 mins to fix
lib/baza/driver/mysql/table.rb on lines 52..62
lib/baza/driver/mysql/table.rb on lines 214..224
lib/baza/driver/sqlite3/tables.rb on lines 14..24

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

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 self.args
    [{
      label: "Host",
      name: "host"
    }, {
Severity: Minor
Found in lib/baza/driver/mysql_java.rb and 1 other location - About 35 mins to fix
lib/baza/mysql_base_driver.rb on lines 2..21

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

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 data
    ret = {
      name: name,
      columns: [],
      indexes: []
Severity: Minor
Found in lib/baza/driver/mysql/table.rb and 1 other location - About 35 mins to fix
lib/baza/driver/sqlite3/table.rb on lines 396..411

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

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

Severity
Category
Status
Source
Language