class RailsBestPractices::Reviews::CheckSaveReturnValueReview
Check all “save” calls to check the return value is used by a node we have visited.
Track which nodes are used by ‘if’, ‘unless’, ‘&&’ nodes etc. as we pass them by.
Review process:
Implementation:
See the best practice details here rails-bestpractices.com/posts/2012/11/02/check-the-return-value-of-save-otherwise-use-save/
and “create” or use “save!”, “update_attributes!”, or “create!”, respectively.
Review all code to make sure we either check the return value of “save”, “update_attributes”
def model_classnames
def model_classnames @model_classnames ||= models.map(&:to_s) end
def return_value_is_used?(node)
def return_value_is_used?(node) return false unless @used_return_value_of (node == @used_return_value_of) || @used_return_value_of.include?(node) end