From bc00806a4eec785068671f2c995febe01682c2d0 Mon Sep 17 00:00:00 2001 From: blackst0ne Date: Tue, 13 Jun 2017 22:44:13 +1100 Subject: Add database helpers 'add_timestamps_with_timezone' and 'timestamps_with_timezone' --- rubocop/cop/migration/add_timestamps.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 rubocop/cop/migration/add_timestamps.rb (limited to 'rubocop/cop/migration/add_timestamps.rb') 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 -- cgit v1.2.1