lib/spontaneous/data_mapper/content_model/associations.rb
Method belongs_to_content
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def belongs_to_content(name, opts = {})
opts[:association] = :many_to_one
opts[:dataset_method] = "#{name}_dataset"
opts[:add_method] = "#{name}="
opts[:load_method] = "load_#{opts[:association]}_association".to_sym
Method has_many_content
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def has_many_content(name, opts = {})
opts[:association] = :one_to_many
opts[:dataset_method] = "#{name}_dataset"
opts[:load_ps_method] = "load_#{name}_association_prepared_statement".to_sym
opts[:ps_method] = "#{name}_prepared_statement".to_sym
Method belongs_to_content
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
Open
def belongs_to_content(name, opts = {})
opts[:association] = :many_to_one
opts[:dataset_method] = "#{name}_dataset"
opts[:add_method] = "#{name}="
opts[:load_method] = "load_#{opts[:association]}_association".to_sym
- 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 define_proxy_association
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def define_proxy_association(association, proxy_methods, name, opts = {}, &block)