Showing 5 of 7 total issues
Method calculate_save_order
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
Open
def calculate_save_order
constraints, klasses = Set.new, Set.new
traverse do |current_hash|
klasses.add(current_hash['klass']) unless klasses.include?(current_hash['klass'])
- 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
Class Builder
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class Builder
def initialize(serialized_hash)
@hash_origin = serialized_hash
@hash_copy = JSON.parse(serialized_hash.to_json) # a way to do deep clone
@save_order = calculate_save_order
Method calculate_save_order
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def calculate_save_order
constraints, klasses = Set.new, Set.new
traverse do |current_hash|
klasses.add(current_hash['klass']) unless klasses.include?(current_hash['klass'])
Method sanitize_copy_param
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
def sanitize_copy_param(name, param)
return [] if param.nil?
unless param.is_a?(Array)
raise "#{name} param must be an array"
- 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 copy_dependencies_for_join_type
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
self_class,
association_class,
join_table_class,
self_key_on_join_table,
association_key_on_join_table