Skip to content

Commit c301515

Browse files
committed
Use <<~ (squiggly heredoc) to address warning: literal string will be frozen in the future
This commit addresses the `warning: literal string will be frozen in the future` ```$ ruby -v ruby 3.4.0dev (2024-10-21T16:48:53Z master 5131fb5dbe) +PRISM [x86_64-linux] $ RUBYOPT="--debug-frozen-string-literal" bundle exec rake test TEST=test/test_quiet_assets.rb ``` - Warnings addressed by this commit ```ruby /path/to/sprockets-rails/lib/sprockets/rails/quiet_assets.rb:24: warning: literal string will be frozen in the future /path/to/sprockets-rails/lib/sprockets/rails/quiet_assets.rb:23: info: the string was created here ``` - Sprockets Rails requires Ruby 2.5 that supports `<<~` (squiggly heredoc) introduced since Ruby 2.3. https://www.ruby-lang.org/en/news/2015/12/25/ruby-2-3-0-released/ https://github.com/ruby/ruby/blob/d40ea2afa6ff5a6e5befcf342fb7b6dc58796b20/NEWS?plain=1#L53-L57 ruby/ruby#11893 - `--debug-frozen-string-literal` option has been introduced via ruby/ruby#11893
1 parent 261fede commit c301515

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/sprockets/rails/quiet_assets.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,14 @@ def call(env)
2020

2121
private
2222
def raise_logger_silence_error
23-
error = "You have enabled `config.assets.quiet`, but your `Rails.logger`\n"
24-
error << "does not use the `LoggerSilence` module.\n\n"
25-
error << "Please use a compatible logger such as `ActiveSupport::Logger`\n"
26-
error << "to take advantage of quiet asset logging.\n\n"
23+
error = <<~ERROR
24+
You have enabled `config.assets.quiet`, but your `Rails.logger`
25+
does not use the `LoggerSilence` module.
26+
27+
Please use a compatible logger such as `ActiveSupport::Logger`
28+
to take advantage of quiet asset logging.
29+
30+
ERROR
2731

2832
raise LoggerSilenceError, error
2933
end

0 commit comments

Comments
 (0)