Class: Simplabs::Excellent::Checks::Rails::ValidationsCheck
- Defined in:
- lib/simplabs/excellent/checks/rails/validations_check.rb
Overview
This check reports ActiveRecord models that do not validate anything. Not validating anything in the model is usually not intended and has most likely just been forgotten. For more information on validations and why to use them, see guides.rubyonrails.org/activerecord_validations_callbacks.html#why-use-validations.
Applies to
-
ActiveRecordmodels
Instance Attribute Summary
Attributes inherited from Base
#interesting_files, #interesting_nodes, #warnings
Instance Method Summary collapse
-
#evaluate(context) ⇒ Object
:nodoc:.
-
#initialize ⇒ ValidationsCheck
constructor
:nodoc:.
Methods inherited from Base
#add_warning, #evaluate_node, #warnings_for
Constructor Details
#initialize ⇒ ValidationsCheck
:nodoc:
19 20 21 22 |
# File 'lib/simplabs/excellent/checks/rails/validations_check.rb', line 19 def initialize #:nodoc: super @interesting_nodes = [:class] end |
Instance Method Details
#evaluate(context) ⇒ Object
:nodoc:
24 25 26 |
# File 'lib/simplabs/excellent/checks/rails/validations_check.rb', line 24 def evaluate(context) #:nodoc: add_warning(context, '{{class}} does not validate any attributes.', { :class => context.full_name }) if context.active_record_model? && !context.validating? end |