Skip to content

Commit ab12aba

Browse files
committed
Address warning: literal string will be frozen in the future warnings
This commit addresses the `warning: literal string will be frozen in the future` warnings appeared at Rails CI https://buildkite.com/rails/rails-nightly/builds/1122#019263a3-2200-4e62-a6a8-028cffa60aaf Here are the warnings appeared: ``` /usr/local/lib/ruby/gems/3.4.0+0/bundler/gems/httpclient-d57cc6d5ffee/lib/httpclient.rb:1256: warning: literal string will be frozen in the future /usr/local/lib/ruby/gems/3.4.0+0/bundler/gems/httpclient-d57cc6d5ffee/lib/httpclient/http.rb:580: warning: literal string will be frozen in the future /usr/local/lib/ruby/gems/3.4.0+0/bundler/gems/httpclient-d57cc6d5ffee/lib/httpclient/session.rb:954: warning: literal string will be frozen in the future /usr/local/lib/ruby/gems/3.4.0+0/bundler/gems/httpclient-d57cc6d5ffee/lib/httpclient/util.rb:71: warning: literal string will be frozen in the future ``` There should be some warnings remained because Rails CI does not use all of httpclient code. I'll open some pull requests later to address remaining ones. Ref: https://bugs.ruby-lang.org/issues/20205
1 parent f4ee330 commit ab12aba

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

lib/httpclient.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1240,7 +1240,7 @@ def do_get_block(req, proxy, conn, &block)
12401240
conn.push(res)
12411241
return res
12421242
end
1243-
content = block ? nil : ''
1243+
content = block ? nil : ''.dup
12441244
res = HTTP::Message.new_response(content, req.header)
12451245
@debug_dev << "= Request\n\n" if @debug_dev
12461246
sess = @session_manager.query(req, proxy)

lib/httpclient/http.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ def reset_pos(io)
574574
end
575575

576576
def dump_file(io, dev, sz)
577-
buf = ''
577+
buf = ''.dup
578578
rest = sz
579579
while rest > 0
580580
n = io.read([rest, @chunk_size].min, buf)

lib/httpclient/session.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -950,7 +950,7 @@ def read_body_rest
950950
end
951951

952952
def empty_bin_str
953-
str = ''
953+
str = ''.dup
954954
str.force_encoding('BINARY') if str.respond_to?(:force_encoding)
955955
str
956956
end

lib/httpclient/util.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class AddressableURI < Addressable::URI
6464
# Overwrites the original definition just for one line...
6565
def authority
6666
self.host && @authority ||= (begin
67-
authority = ""
67+
authority = "".dup
6868
if self.userinfo != nil
6969
authority << "#{self.userinfo}@"
7070
end

0 commit comments

Comments
 (0)