gitlab-org--gitlab-foss/rubocop/migration_helpers.rb
Rémy Coutable 187e6c8d7c New Migration/UpdateColumnInBatches cop
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-05-29 11:28:23 +02:00

11 lines
363 B
Ruby

module RuboCop
# Module containing helper methods for writing migration cops.
module MigrationHelpers
# Returns true if the given node originated from the db/migrate directory.
def in_migration?(node)
dirname = File.dirname(node.location.expression.source_buffer.name)
dirname.end_with?('db/migrate', 'db/post_migrate')
end
end
end