Method indexes
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def indexes(table_name)
scope = quoted_scope(table_name)
result = query(<<-SQL, "SCHEMA")
SELECT distinct i.relname, d.indisunique, d.indkey, pg_get_indexdef(d.indexrelid), t.oid,
- 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 indexes
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
def indexes(table_name)
scope = quoted_scope(table_name)
result = query(<<-SQL, "SCHEMA")
SELECT distinct i.relname, d.indisunique, d.indkey, pg_get_indexdef(d.indexrelid), t.oid,
Method index_exists?
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def index_exists?(table_name, column_name, options = {})
column_names = Array.wrap(column_name)
index_name = options.key?(:name) ? options[:name].to_s : index_name(table_name, column: column_names)
# Always compare the index 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 split_expression
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def split_expression(expression)
result = []
parens = 0
buffer = ""
- 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 index_name
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def index_name(table_name, options) #:nodoc:
if Hash === options # legacy support
if options[:column]
column_names = Array.wrap(options[:column]).map {|c| expression_index_name(c)}
"index_#{table_name}_on_#{column_names * '_and_'}"
- 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_index
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def add_index(table_name, column_name, options = {})
creation_method = options.delete(:concurrently) ? 'CONCURRENTLY' : nil
# Whether to skip the quoting of columns. Used only for expressions like JSON indexes in which
# the column is difficult to target for quoting.
- 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"