Method included
has 107 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.included(base)
base.class_eval do
# to build joins over to meta_terms from a media resource
has_many :meta_data_meta_terms,
Method set_meta_data
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def set_meta_data meta_data_hash
if meta_data_attributes = meta_data_hash.symbolize_keys[:meta_data_attributes]
meta_data_attributes.map{|k,v|[k,v.symbolize_keys]}.each do |k,meta_datum_hash|
# TODO deprecate meta_key_label
meta_key_id = (meta_datum_hash[:meta_key_id] or meta_datum_hash[:meta_key_label])
- 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 get
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def get(key, build_if_not_found = true)
key_id = if key.is_a? MetaKey
key.id
else
MetaKey.find_by_id(key).try(&:id)
- 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 for_context
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def for_context(context = Context.find("core"), build_if_not_exists = true)
meta_keys = context.meta_keys
meta_key_ids = context.meta_key_ids
mds = where(:meta_key_id => meta_key_ids).eager_load(:meta_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"