Skip to content

Commit b392ede

Browse files
committed
Remove redundant freezing on frozen string literals
Signed-off-by: Watson <[email protected]>
1 parent edbc9db commit b392ede

File tree

8 files changed

+40
-40
lines changed

8 files changed

+40
-40
lines changed

lib/fluent/log.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ def event(level, args)
565565
}
566566

567567
map.each_pair {|k,v|
568-
if k == "error".freeze && v.is_a?(Exception) && !map.has_key?("error_class")
568+
if k == "error" && v.is_a?(Exception) && !map.has_key?("error_class")
569569
message << " error_class=#{v.class.to_s} error=#{v.to_s.inspect}"
570570
else
571571
message << " #{k}=#{v.inspect}"
@@ -600,7 +600,7 @@ def caller_line(type, time, depth, level)
600600
worker_id_part = if type == :default && (@process_type == :worker0 || @process_type == :workers)
601601
@worker_id_part
602602
else
603-
"".freeze
603+
""
604604
end
605605
log_msg = "#{format_time(time)} [#{LEVEL_TEXT[level]}]: #{worker_id_part}"
606606
if @debug_mode

lib/fluent/plugin/formatter_csv.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class CsvFormatter < Formatter
2929
helpers :record_accessor
3030

3131
config_param :delimiter, default: ',' do |val|
32-
['\t', 'TAB'].include?(val) ? "\t".freeze : val.freeze
32+
['\t', 'TAB'].include?(val) ? "\t" : val.freeze
3333
end
3434
config_param :force_quotes, :bool, default: true
3535
# "array" looks good for type of :fields, but this implementation removes tailing comma

lib/fluent/plugin/formatter_ltsv.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ class LabeledTSVFormatter < Formatter
2727

2828
# http://ltsv.org/
2929

30-
config_param :delimiter, :string, default: "\t".freeze
31-
config_param :label_delimiter, :string, default: ":".freeze
32-
config_param :replacement, :string, default: " ".freeze
30+
config_param :delimiter, :string, default: "\t"
31+
config_param :label_delimiter, :string, default: ":"
32+
config_param :replacement, :string, default: " "
3333
config_param :add_newline, :bool, default: true
3434

3535
def format(tag, time, record)

lib/fluent/plugin/formatter_out_file.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ class OutFileFormatter < Formatter
3131
config_param :output_tag, :bool, default: true
3232
config_param :delimiter, default: "\t" do |val|
3333
case val
34-
when /SPACE/i then ' '.freeze
35-
when /COMMA/i then ','.freeze
36-
else "\t".freeze
34+
when /SPACE/i then ' '
35+
when /COMMA/i then ','
36+
else "\t"
3737
end
3838
end
3939
config_set_default :time_type, :string

lib/fluent/plugin/in_http.rb

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,11 @@ def close
195195
end
196196

197197
RES_TEXT_HEADER = {'Content-Type' => 'text/plain'}.freeze
198-
RESPONSE_200 = ["200 OK".freeze, RES_TEXT_HEADER, "".freeze].freeze
199-
RESPONSE_204 = ["204 No Content".freeze, {}.freeze].freeze
200-
RESPONSE_IMG = ["200 OK".freeze, {'Content-Type'=>'image/gif; charset=utf-8'}.freeze, EMPTY_GIF_IMAGE].freeze
201-
RES_400_STATUS = "400 Bad Request".freeze
202-
RES_500_STATUS = "500 Internal Server Error".freeze
198+
RESPONSE_200 = ["200 OK", RES_TEXT_HEADER, ""].freeze
199+
RESPONSE_204 = ["204 No Content", {}.freeze].freeze
200+
RESPONSE_IMG = ["200 OK", {'Content-Type'=>'image/gif; charset=utf-8'}.freeze, EMPTY_GIF_IMAGE].freeze
201+
RES_400_STATUS = "400 Bad Request"
202+
RES_500_STATUS = "500 Internal Server Error"
203203

204204
def on_request(path_info, params)
205205
begin
@@ -306,15 +306,15 @@ def parse_params_with_parser(params)
306306
def add_params_to_record(record, params)
307307
if @add_http_headers
308308
params.each_pair { |k, v|
309-
if k.start_with?("HTTP_".freeze)
309+
if k.start_with?("HTTP_")
310310
record[k] = v
311311
end
312312
}
313313
end
314314

315315
if @add_query_params
316316
params.each_pair { |k, v|
317-
if k.start_with?("QUERY_".freeze)
317+
if k.start_with?("QUERY_")
318318
record[k] = v
319319
end
320320
}
@@ -422,7 +422,7 @@ def on_headers_complete(headers)
422422
end
423423
}
424424
if expect
425-
if expect == '100-continue'.freeze
425+
if expect == '100-continue'
426426
if !size || size < @body_size_limit
427427
send_response_nobody("100 Continue", {})
428428
else
@@ -444,8 +444,8 @@ def on_body(chunk)
444444
@body << chunk
445445
end
446446

447-
RES_200_STATUS = "200 OK".freeze
448-
RES_403_STATUS = "403 Forbidden".freeze
447+
RES_200_STATUS = "200 OK"
448+
RES_403_STATUS = "403 Forbidden"
449449

450450
# Azure App Service sends GET requests for health checking purpose.
451451
# Respond with `200 OK` to accommodate it.
@@ -489,11 +489,11 @@ def handle_options_request
489489
def on_message_complete
490490
return if closing?
491491

492-
if @parser.http_method == 'GET'.freeze
492+
if @parser.http_method == 'GET'
493493
return handle_get_request()
494494
end
495495

496-
if @parser.http_method == 'OPTIONS'.freeze
496+
if @parser.http_method == 'OPTIONS'
497497
return handle_options_request()
498498
end
499499

@@ -513,9 +513,9 @@ def on_message_complete
513513
# Decode payload according to the "Content-Encoding" header.
514514
# For now, we only support 'gzip' and 'deflate'.
515515
begin
516-
if @content_encoding == 'gzip'.freeze
516+
if @content_encoding == 'gzip'
517517
@body = Zlib::GzipReader.new(StringIO.new(@body)).read
518-
elsif @content_encoding == 'deflate'.freeze
518+
elsif @content_encoding == 'deflate'
519519
@body = Zlib::Inflate.inflate(@body)
520520
end
521521
rescue
@@ -576,7 +576,7 @@ def on_message_complete
576576
end
577577

578578
if @keep_alive
579-
header['Connection'] = 'Keep-Alive'.freeze
579+
header['Connection'] = 'Keep-Alive'
580580
send_response(code, header, body)
581581
else
582582
send_response_and_close(code, header, body)
@@ -602,13 +602,13 @@ def closing?
602602

603603
def send_response(code, header, body)
604604
header['Content-Length'] ||= body.bytesize
605-
header['Content-Type'] ||= 'text/plain'.freeze
605+
header['Content-Type'] ||= 'text/plain'
606606

607607
data = +"HTTP/1.1 #{code}\r\n"
608608
header.each_pair {|k,v|
609609
data << "#{k}: #{v}\r\n"
610610
}
611-
data << "\r\n".freeze
611+
data << "\r\n"
612612
@io.write(data)
613613

614614
@io.write(body)
@@ -619,7 +619,7 @@ def send_response_nobody(code, header)
619619
header.each_pair {|k,v|
620620
data << "#{k}: #{v}\r\n"
621621
}
622-
data << "\r\n".freeze
622+
data << "\r\n"
623623
@io.write(data)
624624
end
625625

lib/fluent/plugin/in_monitor_agent.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -125,21 +125,21 @@ def render_ltsv(obj, code: 200)
125125

126126
def build_object(opts)
127127
qs = opts[:query]
128-
if tag = qs['tag'.freeze].first
128+
if tag = qs['tag'].first
129129
# ?tag= to search an output plugin by match pattern
130130
if obj = @agent.plugin_info_by_tag(tag, opts)
131131
list = [obj]
132132
else
133133
list = []
134134
end
135-
elsif plugin_id = (qs['@id'.freeze].first || qs['id'.freeze].first)
135+
elsif plugin_id = (qs['@id'].first || qs['id'].first)
136136
# ?@id= to search a plugin by 'id <plugin_id>' config param
137137
if obj = @agent.plugin_info_by_id(plugin_id, opts)
138138
list = [obj]
139139
else
140140
list = []
141141
end
142-
elsif plugin_type = (qs['@type'.freeze].first || qs['type'.freeze].first)
142+
elsif plugin_type = (qs['@type'].first || qs['type'].first)
143143
# ?@type= to search plugins by 'type <type>' config param
144144
list = @agent.plugins_info_by_type(plugin_type, opts)
145145
else
@@ -160,22 +160,22 @@ def build_option(req)
160160
# if ?debug=1 is set, set :with_debug_info for get_monitor_info
161161
# and :pretty_json for render_json_error
162162
opts = { query: qs }
163-
if qs['debug'.freeze].first
163+
if qs['debug'].first
164164
opts[:with_debug_info] = true
165165
opts[:pretty_json] = true
166166
end
167167

168-
if ivars = qs['with_ivars'.freeze].first
168+
if ivars = qs['with_ivars'].first
169169
opts[:ivars] = ivars.split(',')
170170
end
171171

172-
if with_config = qs['with_config'.freeze].first
172+
if with_config = qs['with_config'].first
173173
opts[:with_config] = Fluent::Config.bool_value(with_config)
174174
else
175175
opts[:with_config] = @agent.include_config
176176
end
177177

178-
if with_retry = qs['with_retry'.freeze].first
178+
if with_retry = qs['with_retry'].first
179179
opts[:with_retry] = Fluent::Config.bool_value(with_retry)
180180
else
181181
opts[:with_retry] = @agent.include_retry
@@ -388,13 +388,13 @@ def get_retry_info(pe_retry)
388388
def plugin_category(pe)
389389
case pe
390390
when Fluent::Plugin::Input
391-
'input'.freeze
391+
'input'
392392
when Fluent::Plugin::Output, Fluent::Plugin::MultiOutput, Fluent::Plugin::BareOutput
393-
'output'.freeze
393+
'output'
394394
when Fluent::Plugin::Filter
395-
'filter'.freeze
395+
'filter'
396396
else
397-
'unknown'.freeze
397+
'unknown'
398398
end
399399
end
400400

lib/fluent/plugin/in_syslog.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class SyslogInput < Input
8383
desc 'If true, add source host to event record.'
8484
config_param :include_source_host, :bool, default: false, deprecated: 'use "source_hostname_key" or "source_address_key" instead.'
8585
desc 'Specify key of source host when include_source_host is true.'
86-
config_param :source_host_key, :string, default: 'source_host'.freeze
86+
config_param :source_host_key, :string, default: 'source_host'
8787
desc 'Enable the option to emit unmatched lines.'
8888
config_param :emit_unmatched_lines, :bool, default: false
8989

test/config/test_configurable.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ class TestConfigurable < ::Test::Unit::TestCase
535535

536536
test 'can accept frozen string' do
537537
b2 = ConfigurableSpec::Base2.new
538-
assert_instance_of(ConfigurableSpec::Base2, b2.configure(config_element("", "", {"name1" => "t1".freeze, "name5" => "t5", "opt3" => "a"})))
538+
assert_instance_of(ConfigurableSpec::Base2, b2.configure(config_element("", "", {"name1" => "t1", "name5" => "t5", "opt3" => "a"})))
539539
end
540540

541541
test 'raise errors without any specifications for param without defaults' do

0 commit comments

Comments
 (0)