Showing 145 of 177 total issues
Method copy_to
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
def copy_to(db, args = {})
debug = args[:debug]
raise "No tables given." unless data[:tables]
data[:tables].each do |table|
- Read upRead up
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_multi
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
def insert_multi(tablename, arr_hashes, args = {})
sql = "INSERT INTO `#{tablename}` ("
first = true
if args && args[:keys]
- Read upRead up
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 copy
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
def copy(args = {})
temp_name = "temptable_#{Time.now.to_f.to_s.hash}"
clone(temp_name)
cols_cur = columns
@db.query("DROP TABLE `#{name}`")
- Read upRead up
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 create_indexes
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
def self.create_indexes(index_arr, args = {})
db = args[:db]
if args[:return_sql]
sql = ""
- Read upRead up
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_multi
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
def insert_multi(tablename, arr_hashes, args = {})
sql = "INSERT INTO `#{tablename}` ("
first = true
if args && args[:keys]
- Read upRead up
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
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
def clone(newname, args = {})
raise "Invalid name." if newname.to_s.strip.empty?
sql = "CREATE TABLE #{@db.quote_table(newname)} ("
first = true
- Read upRead up
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
File table.rb
has 342 lines of code (exceeds 250 allowed). Consider refactoring. Open
class Baza::Driver::Sqlite3::Table < Baza::Table # rubocop:disable Metrics/ClassLength
attr_reader :name, :type
def initialize(args)
@db = args.fetch(:db)
Class BaseSqlDriver
has 32 methods (exceeds 20 allowed). Consider refactoring. Open
class Baza::BaseSqlDriver
attr_reader :db, :conn, :sep_database, :sep_table, :sep_col, :sep_val, :sep_index
attr_accessor :tables, :cols, :indexes
SEPARATOR_DATABASE = "`".freeze
Class Db
has 32 methods (exceeds 20 allowed). Consider refactoring. Open
class Baza::Db
include SimpleDelegate
delegate :last_id, :upsert, :upsert_duplicate_key, to: :commands
delegate :current_database, :current_database_name, :with_database, to: :databases
Method create_indexes
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
def create_indexes(index_arr, args = nil)
ret = [] if args && args[:return_sql]
index_arr.each do |index_data|
if index_data.is_a?(String) || index_data.is_a?(Symbol)
- Read upRead up
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
File db.rb
has 312 lines of code (exceeds 250 allowed). Consider refactoring. Open
class Baza::Db
include SimpleDelegate
delegate :last_id, :upsert, :upsert_duplicate_key, to: :commands
delegate :current_database, :current_database_name, :with_database, to: :databases
Method sql
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def sql
sql = ""
first = true
@indexes.each do |index_data|
- Read upRead up
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
File table.rb
has 309 lines of code (exceeds 250 allowed). Consider refactoring. Open
class Baza::Driver::Mysql::Table < Baza::Table
attr_reader :list, :name
def initialize(args)
@db = args.fetch(:db)
Method data_sql
has a Cognitive Complexity of 23 (exceeds 5 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
- Read upRead up
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_with_statement
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def query_with_statement(sql, preload_results)
@mutex.synchronize do
begin
if sql.match?(/^\s*(delete|update|create|drop|insert\s+into|alter|truncate)\s+/i)
return query_no_result_set(sql)
- Read upRead up
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
Class Table
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class Baza::Driver::Sqlite3::Table < Baza::Table # rubocop:disable Metrics/ClassLength
attr_reader :name, :type
def initialize(args)
@db = args.fetch(:db)
Class Select
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class Baza::SqlQueries::Select
def initialize(args)
@db = args.fetch(:db)
@selects = []
@froms = []
Method data_sql
has a Cognitive Complexity of 21 (exceeds 5 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
- Read upRead up
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 change
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def change(data)
if data.key?(:name) && data.fetch(:name).to_s != name
@db.query("#{alter_table_sql} RENAME #{@db.quote_column(name)} TO #{@db.quote_column(data.fetch(:name))}")
@name = data.fetch(:name).to_s
end
- Read upRead up
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 create
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def create(table_name, columns:, indexes: nil, return_sql: false, temp: false)
table_name = table_name.to_s
raise "Invalid table name: #{table_name}" if table_name.strip.empty?
raise "No columns was given for '#{table_name}'." if !columns || columns.empty?
- Read upRead up
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"