Module: Gitlab::Styles::Rubocop::MigrationHelpers

Defined in:
lib/gitlab/styles/rubocop/migration_helpers.rb

Overview

Module containing helper methods for writing migration cops.

Instance Method Summary collapse

Instance Method Details

#in_migration?(node) ⇒ Boolean

Returns true if the given node originated from the db/migrate directory.

Returns:

  • (Boolean)


7
8
9
10
11
# File 'lib/gitlab/styles/rubocop/migration_helpers.rb', line 7

def in_migration?(node)
  dirname = File.dirname(node.location.expression.source_buffer.name)

  dirname.end_with?('db/migrate', 'db/post_migrate')
end