Class: Ducalis::CallbacksActiverecord
- Inherits:
-
RuboCop::Cop::Cop
- Object
- RuboCop::Cop::Cop
- Ducalis::CallbacksActiverecord
- Includes:
- TypeResolving
- Defined in:
- lib/ducalis/cops/callbacks_activerecord.rb
Constant Summary collapse
- OFFENSE =
<<-MESSAGE.gsub(/^ +\|\s/, '').strip | Please, avoid using of callbacks for models. It's better to keep models small ("dumb") and instead use "builder" classes/services: to construct new objects. MESSAGE
- DETAILS =
<<-MESSAGE.gsub(/^ +\|\s/, '').strip | You can read more [here](https://medium.com/planet-arkency/a61fd75ab2d3). MESSAGE
- METHODS_BLACK_LIST =
%i[ after_commit after_create after_destroy after_find after_initialize after_rollback after_save after_touch after_update after_validation around_create around_destroy around_save around_update before_create before_destroy before_save before_update before_validation ].freeze
Constants included from TypeResolving
TypeResolving::CONTROLLER_SUFFIXES, TypeResolving::MODELS_CLASS_NAMES, TypeResolving::SERVICES_PATH, TypeResolving::WORKERS_SUFFIXES
Instance Method Summary collapse
Methods included from TypeResolving
Instance Method Details
#on_send(node) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/ducalis/cops/callbacks_activerecord.rb', line 40 def on_send(node) return unless in_model? return unless METHODS_BLACK_LIST.include?(node.method_name) add_offense(node, :selector, OFFENSE) end |