Showing 4 of 4 total issues
Method foreign_keys
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def foreign_keys(table_name)
fk_info = select_all %{
SELECT t2.relname AS to_table
, a1.attname AS column
, a2.attname AS primary_key
- 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 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def foreign_keys(table_name)
fk_info = select_all %{
SELECT t2.relname AS to_table
, a1.attname AS column
, a2.attname AS primary_key
Method tables_with_foreign_keys
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def tables_with_foreign_keys(stream)
tables_without_foreign_keys(stream)
# Ensure Foreigner to be initialized before running foreign_keys.
# This is required since schema::load is not initializing the environment
# anymore in Rails 4.1.9 (https://github.com/rails/rails/commit/5d6bb89f)
- 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 add_foreign_key_sql
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def add_foreign_key_sql(from_table, to_table, options = {})
column = options[:column] || "#{to_table.to_s.singularize}_id"
foreign_key_name = options.key?(:name) ? options[:name].to_s : foreign_key_name(from_table, column)
primary_key = options[:primary_key] || "id"
dependency = dependency_sql(options[:dependent])
- 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"