Skip to content

Commit bbd85d1

Browse files
committed
Suppress 'warning: literal string will be frozen in the future'
Signed-off-by: Watson <watson1978@gmail.com>
1 parent c8c6040 commit bbd85d1

File tree

100 files changed

+347
-148
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+347
-148
lines changed

lib/fluent/command/ctl.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
#
24
# Fluentd
35
#
@@ -67,7 +69,7 @@ def initialize(argv = ARGV)
6769
end
6870

6971
def help_text
70-
text = "\n"
72+
text = +"\n"
7173
if Fluent.windows?
7274
text << "Usage: #{$PROGRAM_NAME} COMMAND [PID_OR_SVCNAME]\n"
7375
else

lib/fluent/command/plugin_config_formatter.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
#
24
# Fluentd
35
#
@@ -79,7 +81,7 @@ def call
7981
private
8082

8183
def dump_txt(dumped_config)
82-
dumped = ""
84+
dumped = +""
8385
plugin_helpers = dumped_config.delete(:plugin_helpers)
8486
if plugin_helpers && !plugin_helpers.empty?
8587
dumped << "helpers: #{plugin_helpers.join(',')}\n"
@@ -101,7 +103,7 @@ def dump_txt(dumped_config)
101103
end
102104

103105
def dump_section_txt(base_section, level = 0)
104-
dumped = ""
106+
dumped = +""
105107
indent = " " * level
106108
if base_section[:section]
107109
sections = []
@@ -135,10 +137,10 @@ def dump_section_txt(base_section, level = 0)
135137
end
136138

137139
def dump_markdown(dumped_config)
138-
dumped = ""
140+
dumped = +""
139141
plugin_helpers = dumped_config.delete(:plugin_helpers)
140142
if plugin_helpers && !plugin_helpers.empty?
141-
dumped = "## Plugin helpers\n\n"
143+
dumped = +"## Plugin helpers\n\n"
142144
plugin_helpers.each do |plugin_helper|
143145
dumped << "* #{plugin_helper_markdown_link(plugin_helper)}\n"
144146
end
@@ -156,7 +158,7 @@ def dump_markdown(dumped_config)
156158
end
157159

158160
def dump_section_markdown(base_section, level = 0)
159-
dumped = ""
161+
dumped = +""
160162
if base_section[:section]
161163
sections = []
162164
params = base_section

lib/fluent/compat/formatter_utils.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
#
24
# Fluentd
35
#

lib/fluent/compat/output.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
#
24
# Fluentd
35
#

lib/fluent/compat/record_filter_mixin.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
#
24
# Fluentd
35
#
@@ -21,7 +23,7 @@ def filter_record(tag, time, record)
2123
end
2224

2325
def format_stream(tag, es)
24-
out = ''
26+
out = +''
2527
es.each {|time,record|
2628
tag_temp = tag.dup
2729
filter_record(tag_temp, time, record)

lib/fluent/config/element.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
#
24
# Fluentd
35
#
@@ -141,7 +143,7 @@ def check_not_fetched(&block)
141143
def to_s(nest = 0)
142144
indent = " " * nest
143145
nindent = " " * (nest + 1)
144-
out = ""
146+
out = +""
145147
if @arg.nil? || @arg.empty?
146148
out << "#{indent}<#{@name}>\n"
147149
else
@@ -230,7 +232,7 @@ def dump_value(k, v, nindent)
230232
end
231233

232234
def self.unescape_parameter(v)
233-
result = ''
235+
result = +''
234236
v.each_char { |c| result << LiteralParser.unescape_char(c) }
235237
result
236238
end

lib/fluent/config/literal_parser.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
#
24
# Fluentd
35
#
@@ -228,8 +230,8 @@ def scan_json(is_array)
228230
# Yajl does not raise ParseError for incomplete json string, like '[1', '{"h"', '{"h":' or '{"h1":1'
229231
# This is the reason to use JSON module.
230232

231-
buffer = (is_array ? "[" : "{")
232-
line_buffer = ""
233+
buffer = +(is_array ? "[" : "{")
234+
line_buffer = +""
233235

234236
until result
235237
char = getch
@@ -252,7 +254,7 @@ def scan_json(is_array)
252254
# ignore comment char
253255
end
254256
buffer << line_buffer + "\n"
255-
line_buffer = ""
257+
line_buffer = +""
256258
else
257259
# '#' is a char in json string
258260
line_buffer << char
@@ -263,7 +265,7 @@ def scan_json(is_array)
263265

264266
if char == "\n"
265267
buffer << line_buffer + "\n"
266-
line_buffer = ""
268+
line_buffer = +""
267269
next
268270
end
269271

lib/fluent/config/types.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def self.enum_value(val, opts = {}, name = nil)
183183
value
184184
else
185185
case type
186-
when :string then value.to_s.force_encoding(Encoding::UTF_8)
186+
when :string then (+(value.to_s)).force_encoding(Encoding::UTF_8)
187187
when :integer then INTEGER_TYPE.call(value, opts, name)
188188
when :float then FLOAT_TYPE.call(value, opts, name)
189189
when :size then Config.size_value(value, opts, name)

lib/fluent/config/yaml_parser/fluent_value.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
#
24
# Fluentd
35
#
@@ -30,7 +32,7 @@ def to_element
3032

3133
StringValue = Struct.new(:val, :context) do
3234
def to_s
33-
context.instance_eval("\"#{val}\"")
35+
context.instance_eval("\"#{val}\"").freeze
3436
rescue Fluent::SetNil => _
3537
''
3638
rescue Fluent::SetDefault => _

lib/fluent/log.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
#
24
# Fluentd
35
#
@@ -205,7 +207,7 @@ def format=(fmt)
205207
@format = :text
206208
@formatter = Proc.new { |type, time, level, msg|
207209
r = caller_line(type, time, @depth_offset, level)
208-
r << msg
210+
r += msg
209211
r
210212
}
211213
when :json
@@ -550,7 +552,7 @@ def get_worker_id(type)
550552

551553
def event(level, args)
552554
time = Time.now
553-
message = @optional_header ? @optional_header.dup : ''
555+
message = @optional_header ? @optional_header.dup : +''
554556
map = @optional_attrs ? @optional_attrs.dup : {}
555557
args.each {|a|
556558
if a.is_a?(Hash)

0 commit comments

Comments
 (0)