Sha256: 468941aeaf03e97b63d43b28d72286c0430c36cded3555063cc34804a27c0a08

Contents?: true

Size: 541 Bytes

Versions: 4

Compression:

Stored size: 541 Bytes

Contents

# frozen_string_literal: true

module Gitlab
  module Styles
    module Rubocop
      module Gitlab::Styles::Rubocop::ModelHelpers
        # Returns true if the given node originated from the models directory.
        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
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gitlab-styles-9.2.0 lib/gitlab/styles/rubocop/model_helpers.rb
gitlab-styles-9.1.0 lib/gitlab/styles/rubocop/model_helpers.rb
gitlab-styles-9.0.0 lib/gitlab/styles/rubocop/model_helpers.rb
gitlab-styles-8.0.0 lib/gitlab/styles/rubocop/model_helpers.rb