Showing 177 of 177 total issues
Method create_indexes
has 30 lines of code (exceeds 25 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)
Similar blocks of code found in 2 locations. Consider refactoring. Open
def referenced_foreign_keys(args = {})
sql = "
SELECT
TABLE_NAME,
COLUMN_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 53.
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
TABLE_NAME,
COLUMN_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 53.
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 sql
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def sql
sql = ""
first = true
@indexes.each do |index_data|
Method sql
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def sql
sql = "CREATE"
sql << " TEMPORARY" if @temporary
sql << " TABLE #{Baza::Driver::Mysql.quote_table(@name)} ("
Method indexes
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def indexes
@db.indexes
ret = [] unless block_given?
@db.query("PRAGMA index_list(#{@db.quote_table(name)})") do |d_indexes|
Method initialize
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(args)
@args = args
@db = args.fetch(:db)
@queries = []
@inserts = {}
Method list
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def list(args = {})
ret = [] unless block_given?
@list_mutex.synchronize do
tables_args = {type: "table"}
Method foreign_keys
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def foreign_keys(args = {})
sql = "
SELECT
TABLE_NAME,
COLUMN_NAME,
Method referenced_foreign_keys
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def referenced_foreign_keys(args = {})
sql = "
SELECT
TABLE_NAME,
COLUMN_NAME,
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|
- 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 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|
- 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 where_sql
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def where_sql
return if @wheres.empty?
sql = " WHERE"
- 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_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|
- 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_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)
- 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 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
- 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 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)
- 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_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)
- 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 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 = {
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