File schema_adapter.rb
has 481 lines of code (exceeds 250 allowed). Consider refactoring. Open
module ForestLiana
class SchemaAdapter
def initialize(model)
@model = model
end
Method add_validations
has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring. Open
def add_validations(column_schema, column)
# NOTICE: Do not consider validations if a before_validation Active Records
# Callback is detected.
if @model._validation_callbacks.map(&:kind).include? :before
return column_schema
- 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_columns
has 114 lines of code (exceeds 25 allowed). Consider refactoring. Open
def add_columns
@model.columns.each do |column|
unless is_sti_column_of_child_model?(column)
field_schema = get_schema_for_column(column)
collection.fields << field_schema unless field_schema.nil?
Method add_validations
has 82 lines of code (exceeds 25 allowed). Consider refactoring. Open
def add_validations(column_schema, column)
# NOTICE: Do not consider validations if a before_validation Active Records
# Callback is detected.
if @model._validation_callbacks.map(&:kind).include? :before
return column_schema
Class SchemaAdapter
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class SchemaAdapter
def initialize(model)
@model = model
end
Method add_columns
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def add_columns
@model.columns.each do |column|
unless is_sti_column_of_child_model?(column)
field_schema = get_schema_for_column(column)
collection.fields << field_schema unless field_schema.nil?
- 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 perform
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
def perform
add_columns
add_associations
collection.fields.sort_by!.with_index { |k, idx| [k[:field].to_s, idx] }
Method add_associations
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Invalid
def add_associations
SchemaUtils.associations(@model).each do |association|
begin
if SchemaUtils.polymorphic?(association) &&
collection.fields << {
Method perform
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def perform
add_columns
add_associations
collection.fields.sort_by!.with_index { |k, idx| [k[:field].to_s, idx] }
- 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_associations
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def add_associations
SchemaUtils.associations(@model).each do |association|
begin
if SchemaUtils.polymorphic?(association) &&
collection.fields << {
- 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"