Sha256: e4b7a46bf2187945d0623d3260e740dc914ee2c6df7c4a68e04f8504c59ce9fd

Contents?: true

Size: 516 Bytes

Versions: 15

Compression:

Stored size: 516 Bytes

Contents

# frozen_string_literal: true

module Gitlab
  module Styles
    module Rubocop
      module 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

15 entries across 15 versions & 1 rubygems

Version Path
gitlab-styles-7.1.0 lib/gitlab/styles/rubocop/model_helpers.rb
gitlab-styles-7.0.0 lib/gitlab/styles/rubocop/model_helpers.rb
gitlab-styles-6.6.0 lib/gitlab/styles/rubocop/model_helpers.rb
gitlab-styles-6.5.0 lib/gitlab/styles/rubocop/model_helpers.rb
gitlab-styles-6.4.0 lib/gitlab/styles/rubocop/model_helpers.rb
gitlab-styles-6.3.0 lib/gitlab/styles/rubocop/model_helpers.rb
gitlab-styles-6.2.1 lib/gitlab/styles/rubocop/model_helpers.rb
gitlab-styles-6.2.0 lib/gitlab/styles/rubocop/model_helpers.rb
gitlab-styles-6.1.0 lib/gitlab/styles/rubocop/model_helpers.rb
gitlab-styles-6.0.0 lib/gitlab/styles/rubocop/model_helpers.rb
gitlab-styles-5.4.0 lib/gitlab/styles/rubocop/model_helpers.rb
gitlab-styles-5.3.0 lib/gitlab/styles/rubocop/model_helpers.rb
gitlab-styles-5.2.0 lib/gitlab/styles/rubocop/model_helpers.rb
gitlab-styles-5.1.0 lib/gitlab/styles/rubocop/model_helpers.rb
gitlab-styles-5.0.0 lib/gitlab/styles/rubocop/model_helpers.rb