File abstract_mysql_adapter.rb
has 770 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "active_record/connection_adapters/abstract_adapter"
require "active_record/connection_adapters/statement_pool"
require "active_record/connection_adapters/mysql/column"
require "active_record/connection_adapters/mysql/database_statements"
require "active_record/connection_adapters/mysql/explain_pretty_printer"
Class AbstractMysqlAdapter
has 94 methods (exceeds 20 allowed). Consider refactoring. Open
class AbstractMysqlAdapter < AbstractAdapter
include MySQL::DatabaseStatements
include MySQL::Quoting
include MySQL::SchemaStatements
Method build_insert_sql
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def build_insert_sql(insert) # :nodoc:
no_op_column = quote_column_name(insert.keys.first)
# MySQL 8.0.19 replaces `VALUES(<expression>)` clauses with row and column alias names, see https://dev.mysql.com/worklog/task/?id=6312 .
# then MySQL 8.0.20 deprecates the `VALUES(<expression>)` see https://dev.mysql.com/worklog/task/?id=13325 .
- 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 configure_connection
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def configure_connection
super
variables = @config.fetch(:variables, {}).stringify_keys
# Increase timeout so the server doesn't disconnect us.
- 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_exception
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def translate_exception(exception, message:, sql:, binds:)
case error_number(exception)
when nil
if exception.message.match?(/MySQL client is not connected/i)
ConnectionNotEstablished.new(exception, connection_pool: @pool)
Method foreign_keys
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def foreign_keys(table_name)
raise ArgumentError unless table_name.present?
scope = quoted_scope(table_name)
Method build_change_column_definition
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def build_change_column_definition(table_name, column_name, type, **options) # :nodoc:
column = column_for(table_name, column_name)
type ||= column.sql_type
unless options.key?(:default)
- 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 check_constraints
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def check_constraints(table_name)
if supports_check_constraints?
scope = quoted_scope(table_name)
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 configure_connection
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def configure_connection
super
variables = @config.fetch(:variables, {}).stringify_keys
# Increase timeout so the server doesn't disconnect us.
Method build_insert_sql
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def build_insert_sql(insert) # :nodoc:
no_op_column = quote_column_name(insert.keys.first)
# MySQL 8.0.19 replaces `VALUES(<expression>)` clauses with row and column alias names, see https://dev.mysql.com/worklog/task/?id=6312 .
# then MySQL 8.0.20 deprecates the `VALUES(<expression>)` see https://dev.mysql.com/worklog/task/?id=13325 .
Method check_constraints
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def check_constraints(table_name)
if supports_check_constraints?
scope = quoted_scope(table_name)
sql = <<~SQL
Method table_options
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def table_options(table_name) # :nodoc:
create_table_info = create_table_info(table_name)
# strip create_definitions and partition_options
# Be aware that `create_table_info` might not include any table options due to `NO_TABLE_OPTIONS` sql mode.
- 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_exception
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def translate_exception(exception, message:, sql:, binds:)
case error_number(exception)
when nil
if exception.message.match?(/MySQL client is not connected/i)
ConnectionNotEstablished.new(exception, connection_pool: @pool)
- 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 dbconsole
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def dbconsole(config, options = {})
mysql_config = config.configuration_hash
args = {
host: "--host",
- 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 handle_warnings
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def handle_warnings(sql)
return if ActiveRecord.db_warnings_action.nil? || @raw_connection.warning_count == 0
@affected_rows_before_warnings = @raw_connection.affected_rows
warning_count = @raw_connection.warning_count
- 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"