prosopite icon indicating copy to clipboard operation
prosopite copied to clipboard

`warning: literal string will be frozen in the future` in ruby 3.4.0-preview2

Open tmimura39 opened this issue 4 months ago • 0 comments

Warning by https://bugs.ruby-lang.org/issues/20205

# rake
/usr/local/bundle/gems/activesupport-6.1.3/lib/active_support/core_ext/class/subclasses.rb:30: warning: method redefined; discarding old subclasses
-- create_table("legs", {force: true})
   -> 0.0014s
-- create_table("chairs", {force: true})
   -> 0.0002s

# Running tests with run options --seed 53168:

../prosopite/lib/prosopite.rb:220: warning: literal string will be frozen in the future
../prosopite/lib/prosopite.rb:220: warning: literal string will be frozen in the future
...../prosopite/lib/prosopite.rb:220: warning: literal string will be frozen in the future
./prosopite/lib/prosopite.rb:220: warning: literal string will be frozen in the future
./prosopite/lib/prosopite.rb:220: warning: literal string will be frozen in the future
../prosopite/lib/prosopite.rb:220: warning: literal string will be frozen in the future
./prosopite/lib/prosopite.rb:220: warning: literal string will be frozen in the future
../prosopite/lib/prosopite.rb:220: warning: literal string will be frozen in the future
..../prosopite/lib/prosopite.rb:220: warning: literal string will be frozen in the future
./prosopite/lib/prosopite.rb:220: warning: literal string will be frozen in the future
../prosopite/lib/prosopite.rb:220: warning: literal string will be frozen in the future
./prosopite/lib/prosopite.rb:220: warning: literal string will be frozen in the future
../prosopite/lib/prosopite.rb:220: warning: literal string will be frozen in the future
............................

Finished tests in 0.578294s, 93.3781 tests/s, 143.5256 assertions/s.


54 tests, 83 assertions, 0 failures, 0 errors, 0 skips

The choices are these

  • Use ''.dup or String.new('') or +''.
diff --git a/lib/prosopite.rb b/lib/prosopite.rb
index 5dee267..16f3a13 100644
--- a/lib/prosopite.rb
+++ b/lib/prosopite.rb
@@ -214,7 +214,7 @@ def send_notifications
       @prosopite_logger ||= false
       @raise ||= false

-      notifications_str = ''
+      notifications_str = +''

       tc[:prosopite_notifications].each do |queries, kaller|
         notifications_str << "N+1 queries detected:\n"
  • Magic comment frozen_string_literal: false like Shopify/httpclient.
  • Ignore warnings until Ruby v3.4 policy is finalized.
  • and other...

tmimura39 avatar Oct 15 '24 13:10 tmimura39