Showing 4 of 4 total issues
Method assert_valid_config!
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def assert_valid_config!(config)
unless config.key?(:readonly) || config.key?(:writable)
raise ArgumentError.new(':readonly or :writable must be specified')
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 handle_generated_connection
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.handle_generated_connection(conn, parent_method, method_name, *args, &block)
switch_point = conn.pool.spec.config[:switch_point]
if switch_point
proxy = ProxyRepository.find(switch_point[:name])
case switch_point[: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 handle_generated_connection
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def self.handle_generated_connection(conn, parent_method, method_name, *args, &block)
Method memorize_switch_point
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def memorize_switch_point(name, mode, pool)
switch_point = { name: name, mode: mode }
if pool.equal?(ActiveRecord::Base.connection_pool)
if mode != :writable
raise Error.new("ActiveRecord::Base's switch_points must be writable, but #{name} is #{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"