Method: RuboCop::Server::Cache.require_data

Defined in:
lib/rubocop/server/cache.rb

.require_data(yaml) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/rubocop/server/cache.rb', line 177

def require_data(yaml)
  return '' unless (require_paths = yaml['require'])

  Array(require_paths).map do |path|
    # NOTE: This targets only relative or absolute path specifications.
    # For example, specifications like `require: rubocop-performance`,
    # which can be loaded from `$LOAD_PATH`, are ignored.
    next unless path.start_with?('.', '/')

    # NOTE: `.so` files are not typically specified, so only `.rb` files are targeted.
    path = "#{path}.rb" unless path.end_with?('.rb')
    path = Pathname(path)

    path.exist? ? path.read : ''
  end.join
end