diff options
author | blackst0ne <blackst0ne.ru@gmail.com> | 2017-06-13 14:44:13 +0300 |
---|---|---|
committer | blackst0ne <blackst0ne.ru@gmail.com> | 2017-06-13 14:44:13 +0300 |
commit | bc00806a4eec785068671f2c995febe01682c2d0 (patch) | |
tree | a44f9408df37e2f6ee8c07d8f081b5a2a82684e4 /rubocop/cop/migration/add_timestamps.rb | |
parent | de20057ccbd3b8c94d64ff5d8deb14cab232d08a (diff) |
Add database helpers 'add_timestamps_with_timezone' and 'timestamps_with_timezone'
Diffstat (limited to 'rubocop/cop/migration/add_timestamps.rb')
-rw-r--r-- | rubocop/cop/migration/add_timestamps.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/rubocop/cop/migration/add_timestamps.rb b/rubocop/cop/migration/add_timestamps.rb new file mode 100644 index 00000000000..08ddd91e54d --- /dev/null +++ b/rubocop/cop/migration/add_timestamps.rb @@ -0,0 +1,25 @@ +require_relative '../../migration_helpers' + +module RuboCop + module Cop + module Migration + # Cop that checks if 'add_timestamps' method is called with timezone information. + class AddTimestamps < RuboCop::Cop::Cop + include MigrationHelpers + + MSG = 'Do not use `add_timestamps`, use `add_timestamps_with_timezone` instead'.freeze + + # Check methods. + def on_send(node) + return unless in_migration?(node) + + add_offense(node, :selector) if method_name(node) == :add_timestamps + end + + def method_name(node) + node.children[1] + end + end + end + end +end |