Class: RuboCop::Cop::RailsDeprecation::ToFormattedS
- Extended by:
- AutoCorrector
- Defined in:
- lib/rubocop/cop/rails_deprecation/to_formatted_s.rb
Overview
This cop identifies passing a format to ‘#to_s`.
Constant Summary collapse
- MSG =
'Use `to_fs(...)` instead of `to_s(...)`.'
Constants inherited from Base
Base::DEFAULT_MAXIMUM_TARGET_RAILS_VERSION, Base::DEFAULT_MINIMUM_TARGET_RAILS_VERSION
Instance Method Summary collapse
- #on_send(node) ⇒ Object (also: #on_csend)
Methods inherited from Base
Instance Method Details
#on_send(node) ⇒ Object Also known as: on_csend
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rubocop/cop/rails_deprecation/to_formatted_s.rb', line 36 def on_send(node) return unless to_s_with_any_argument?(node) add_offense(node) do |rewriter| rewriter.replace( node.loc.selector, 'to_fs' ) end end |