app/models/enquiry.rb
Class Enquiry
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class Enquiry < BaseModel
use_database :enquiry
require 'uuidtools'
include Searchable
Method mark_or_unmark_as_reunited
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
def mark_or_unmark_as_reunited(reunited)
without_updating_matches do
Enquiry.skip_callback(:save, :after, :find_matching_children)
self['reunited'] = reunited
save!
- 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 mark_or_unmark_as_reunited
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def mark_or_unmark_as_reunited(reunited)
without_updating_matches do
Enquiry.skip_callback(:save, :after, :find_matching_children)
self['reunited'] = reunited
save!
Method update_from
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
Open
def update_from(properties)
attributes_to_update = {}
properties.each_pair do |name, value|
if value.instance_of?(HashWithIndifferentAccess) || value.instance_of?(ActionController::Parameters)
attributes_to_update[name] = self[name] if attributes_to_update[name].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"