Class: RuboCop::Cop::Code0::ZeroTrack::Migration::Timestamps
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Code0::ZeroTrack::Migration::Timestamps
- Extended by:
- AutoCorrector
- Includes:
- RuboCop::Code0::ZeroTrack::FileHelpers
- Defined in:
- lib/rubocop/cop/code0/zero_track/migration/timestamps.rb
Overview
Cop that checks if ‘timestamps’ method is called with timezone information.
Constant Summary collapse
- MSG =
'Do not use `timestamps`, use `timestamps_with_timezone` instead'
Instance Method Summary collapse
- #method_name(node) ⇒ Object
-
#on_def(node) ⇒ Object
Check methods in table creation.
Methods included from RuboCop::Code0::ZeroTrack::FileHelpers
#basename, #dirname, #filepath, #in_migration?
Instance Method Details
#method_name(node) ⇒ Object
30 31 32 |
# File 'lib/rubocop/cop/code0/zero_track/migration/timestamps.rb', line 30 def method_name(node) node.children[1] end |
#on_def(node) ⇒ Object
Check methods in table creation.
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rubocop/cop/code0/zero_track/migration/timestamps.rb', line 18 def on_def(node) return unless in_migration?(node) node.each_descendant(:send) do |send_node| next unless method_name(send_node) == :timestamps add_offense(send_node.loc.selector) do |corrector| corrector.replace(send_node.loc.selector, 'timestamps_with_timezone') end end end |