class RuboCop::ResultCache

def remove_oldest_files(files, dirs, cache_root, verbose)

def remove_oldest_files(files, dirs, cache_root, verbose)
  # Add 1 to half the number of files, so that we remove the file if
  # there's only 1 left.
  remove_count = 1 + files.length / 2
  if verbose
    puts "Removing the #{remove_count} oldest files from #{cache_root}"
  end
  sorted = files.sort_by { |path| File.mtime(path) }
  remove_files(sorted, dirs, remove_count)
rescue Errno::ENOENT
  # This can happen if parallel RuboCop invocations try to remove the
  # same files. No problem.
  puts $ERROR_INFO if verbose
end