When faced with large numbers of warnings from Rubocop related to its
FrozenStringLiteralComment rule, from a newly-linted project or perhaps due to large numbers of auto-generated files, there’s an easy fix to avoid correcting each file manually.
The default autocorrect will not work for this rule, so warnings like the following will remain intact:
app/controllers/application_controller.rb:1:1: C: Missing frozen string literal comment. class ApplicationController < ActionController::Base
The solution is found in this command option (executed with Bundler):
$ bundle exec rubocop --auto-correct --only FrozenStringLiteralComment .
Here a single rule is executed, and applied to all files, so there’s no need to modify affected files individually.