Module: Gitlab::Styles::Rubocop::ModelHelpers

Included in:
Cop::ActiveRecordDependent, Cop::ActiveRecordSerialize, Cop::PolymorphicAssociations
Defined in:
lib/gitlab/styles/rubocop/model_helpers.rb

Instance Method Summary collapse

Instance Method Details

#in_model?(node) ⇒ Boolean

Returns true if the given node originated from the models directory.

Returns:

  • (Boolean)


8
9
10
11
12
13
14
15
# File 'lib/gitlab/styles/rubocop/model_helpers.rb', line 8

def in_model?(node)
  path = node.location.expression.source_buffer.name
  pwd = Dir.pwd
  models_path = File.join(pwd, 'app', 'models')
  ee_models_path = File.join(pwd, 'ee', 'app', 'models')

  path.start_with?(models_path, ee_models_path)
end