Showing 177 of 177 total issues
Method clone
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def clone(newname, args = nil)
raise "Invalid name." if newname.to_s.strip.empty?
sql = "CREATE 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
Method query
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def query(str)
str = str.to_s
str = str.force_encoding("UTF-8") if encoding == "utf8" && str.respond_to?(:force_encoding)
tries = 0
- 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
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def query(str)
str = str.to_s
str = str.force_encoding("UTF-8") if @encoding == "utf8" && str.respond_to?(:force_encoding)
tries = 0
- 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 data_sql
has 34 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
Method list
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def list(database: nil, name: nil)
ret = [] unless block_given?
where_args = {}
where_args["TABLE_NAME"] = name if name
Identical blocks of code found in 2 locations. Consider refactoring. Open
def create_foreign_key(args)
fk_name = args[:name]
fk_name ||= "fk_#{table_name}_#{name}"
other_column = args.fetch(:column)
- Read upRead up
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 55.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
def create_foreign_key(args)
fk_name = args[:name]
fk_name ||= "fk_#{table_name}_#{name}"
other_column = args.fetch(:column)
- Read upRead up
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 55.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method tables
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def tables(args = {})
tables_list = [] unless block_given?
where_args = {
table_catalog: 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 insert_multi
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def insert_multi(tablename, arr_hashes, args = {})
return false if arr_hashes.empty?
if @driver.respond_to?(:insert_multi)
if args && args[:return_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 translate_values_with_types
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def translate_values_with_types(values)
values.collect!.with_index do |value, count|
type_sym = types[count]
if type_sym == :int
- 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 foreign_keys
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def foreign_keys(args = {})
sql = "
SELECT
tc.constraint_name,
tc.table_name,
Method create
has 31 lines of code (exceeds 25 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?
Method create
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create(name, columns:, indexes: nil, return_sql: false)
raise "No columns given" if !columns || columns.empty?
sql = "CREATE TABLE `#{name}` ("
Method copy_to
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def copy_to(db, args = {})
debug = args[:debug]
raise "No tables given." unless data[:tables]
data[:tables].each do |table|
Method types
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def types
unless @types
@types = []
@result.fields.length.times do |count|
type_num = @result.ftype(count)
Method from_active_record_connection
has 31 lines of code (exceeds 25 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)
Method referenced_foreign_keys
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def referenced_foreign_keys(args = {})
sql = "
SELECT
tc.constraint_name,
tc.table_name,
Similar blocks of code found in 2 locations. Consider refactoring. Open
def referenced_foreign_keys(args = {})
sql = "
SELECT
tc.constraint_name,
tc.table_name,
- Read upRead up
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 54.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
def foreign_keys(args = {})
sql = "
SELECT
tc.constraint_name,
tc.table_name,
- Read upRead up
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 54.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method clone
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def clone(newname, args = nil)
raise "Invalid name." if newname.to_s.strip.empty?
sql = "CREATE TABLE `#{newname}` ("
first = true