diff --git a/lib/fluent/log.rb b/lib/fluent/log.rb index d7396ee4be..0e8c647c46 100644 --- a/lib/fluent/log.rb +++ b/lib/fluent/log.rb @@ -565,7 +565,7 @@ def event(level, args) } map.each_pair {|k,v| - if k == "error".freeze && v.is_a?(Exception) && !map.has_key?("error_class") + if k == "error" && v.is_a?(Exception) && !map.has_key?("error_class") message << " error_class=#{v.class.to_s} error=#{v.to_s.inspect}" else message << " #{k}=#{v.inspect}" @@ -600,7 +600,7 @@ def caller_line(type, time, depth, level) worker_id_part = if type == :default && (@process_type == :worker0 || @process_type == :workers) @worker_id_part else - "".freeze + "" end log_msg = "#{format_time(time)} [#{LEVEL_TEXT[level]}]: #{worker_id_part}" if @debug_mode diff --git a/lib/fluent/plugin/formatter_csv.rb b/lib/fluent/plugin/formatter_csv.rb index 6bc33db816..99c823bd38 100644 --- a/lib/fluent/plugin/formatter_csv.rb +++ b/lib/fluent/plugin/formatter_csv.rb @@ -29,7 +29,7 @@ class CsvFormatter < Formatter helpers :record_accessor config_param :delimiter, default: ',' do |val| - ['\t', 'TAB'].include?(val) ? "\t".freeze : val.freeze + ['\t', 'TAB'].include?(val) ? "\t" : val.freeze end config_param :force_quotes, :bool, default: true # "array" looks good for type of :fields, but this implementation removes tailing comma diff --git a/lib/fluent/plugin/formatter_ltsv.rb b/lib/fluent/plugin/formatter_ltsv.rb index 1bf054ecdf..3d5a3ab60e 100644 --- a/lib/fluent/plugin/formatter_ltsv.rb +++ b/lib/fluent/plugin/formatter_ltsv.rb @@ -27,9 +27,9 @@ class LabeledTSVFormatter < Formatter # http://ltsv.org/ - config_param :delimiter, :string, default: "\t".freeze - config_param :label_delimiter, :string, default: ":".freeze - config_param :replacement, :string, default: " ".freeze + config_param :delimiter, :string, default: "\t" + config_param :label_delimiter, :string, default: ":" + config_param :replacement, :string, default: " " config_param :add_newline, :bool, default: true def format(tag, time, record) diff --git a/lib/fluent/plugin/formatter_out_file.rb b/lib/fluent/plugin/formatter_out_file.rb index bb853d5150..aca91e0b02 100644 --- a/lib/fluent/plugin/formatter_out_file.rb +++ b/lib/fluent/plugin/formatter_out_file.rb @@ -31,9 +31,9 @@ class OutFileFormatter < Formatter config_param :output_tag, :bool, default: true config_param :delimiter, default: "\t" do |val| case val - when /SPACE/i then ' '.freeze - when /COMMA/i then ','.freeze - else "\t".freeze + when /SPACE/i then ' ' + when /COMMA/i then ',' + else "\t" end end config_set_default :time_type, :string diff --git a/lib/fluent/plugin/in_http.rb b/lib/fluent/plugin/in_http.rb index 1f72f32b4d..59501cea51 100644 --- a/lib/fluent/plugin/in_http.rb +++ b/lib/fluent/plugin/in_http.rb @@ -195,11 +195,11 @@ def close end RES_TEXT_HEADER = {'Content-Type' => 'text/plain'}.freeze - RESPONSE_200 = ["200 OK".freeze, RES_TEXT_HEADER, "".freeze].freeze - RESPONSE_204 = ["204 No Content".freeze, {}.freeze].freeze - RESPONSE_IMG = ["200 OK".freeze, {'Content-Type'=>'image/gif; charset=utf-8'}.freeze, EMPTY_GIF_IMAGE].freeze - RES_400_STATUS = "400 Bad Request".freeze - RES_500_STATUS = "500 Internal Server Error".freeze + RESPONSE_200 = ["200 OK", RES_TEXT_HEADER, ""].freeze + RESPONSE_204 = ["204 No Content", {}.freeze].freeze + RESPONSE_IMG = ["200 OK", {'Content-Type'=>'image/gif; charset=utf-8'}.freeze, EMPTY_GIF_IMAGE].freeze + RES_400_STATUS = "400 Bad Request" + RES_500_STATUS = "500 Internal Server Error" def on_request(path_info, params) begin @@ -306,7 +306,7 @@ def parse_params_with_parser(params) def add_params_to_record(record, params) if @add_http_headers params.each_pair { |k, v| - if k.start_with?("HTTP_".freeze) + if k.start_with?("HTTP_") record[k] = v end } @@ -314,7 +314,7 @@ def add_params_to_record(record, params) if @add_query_params params.each_pair { |k, v| - if k.start_with?("QUERY_".freeze) + if k.start_with?("QUERY_") record[k] = v end } @@ -422,7 +422,7 @@ def on_headers_complete(headers) end } if expect - if expect == '100-continue'.freeze + if expect == '100-continue' if !size || size < @body_size_limit send_response_nobody("100 Continue", {}) else @@ -444,8 +444,8 @@ def on_body(chunk) @body << chunk end - RES_200_STATUS = "200 OK".freeze - RES_403_STATUS = "403 Forbidden".freeze + RES_200_STATUS = "200 OK" + RES_403_STATUS = "403 Forbidden" # Azure App Service sends GET requests for health checking purpose. # Respond with `200 OK` to accommodate it. @@ -489,11 +489,11 @@ def handle_options_request def on_message_complete return if closing? - if @parser.http_method == 'GET'.freeze + if @parser.http_method == 'GET' return handle_get_request() end - if @parser.http_method == 'OPTIONS'.freeze + if @parser.http_method == 'OPTIONS' return handle_options_request() end @@ -513,9 +513,9 @@ def on_message_complete # Decode payload according to the "Content-Encoding" header. # For now, we only support 'gzip' and 'deflate'. begin - if @content_encoding == 'gzip'.freeze + if @content_encoding == 'gzip' @body = Zlib::GzipReader.new(StringIO.new(@body)).read - elsif @content_encoding == 'deflate'.freeze + elsif @content_encoding == 'deflate' @body = Zlib::Inflate.inflate(@body) end rescue @@ -576,7 +576,7 @@ def on_message_complete end if @keep_alive - header['Connection'] = 'Keep-Alive'.freeze + header['Connection'] = 'Keep-Alive' send_response(code, header, body) else send_response_and_close(code, header, body) @@ -602,13 +602,13 @@ def closing? def send_response(code, header, body) header['Content-Length'] ||= body.bytesize - header['Content-Type'] ||= 'text/plain'.freeze + header['Content-Type'] ||= 'text/plain' data = +"HTTP/1.1 #{code}\r\n" header.each_pair {|k,v| data << "#{k}: #{v}\r\n" } - data << "\r\n".freeze + data << "\r\n" @io.write(data) @io.write(body) @@ -619,7 +619,7 @@ def send_response_nobody(code, header) header.each_pair {|k,v| data << "#{k}: #{v}\r\n" } - data << "\r\n".freeze + data << "\r\n" @io.write(data) end diff --git a/lib/fluent/plugin/in_monitor_agent.rb b/lib/fluent/plugin/in_monitor_agent.rb index 0654f7b7d2..22e9b3ffc0 100644 --- a/lib/fluent/plugin/in_monitor_agent.rb +++ b/lib/fluent/plugin/in_monitor_agent.rb @@ -125,21 +125,21 @@ def render_ltsv(obj, code: 200) def build_object(opts) qs = opts[:query] - if tag = qs['tag'.freeze].first + if tag = qs['tag'].first # ?tag= to search an output plugin by match pattern if obj = @agent.plugin_info_by_tag(tag, opts) list = [obj] else list = [] end - elsif plugin_id = (qs['@id'.freeze].first || qs['id'.freeze].first) + elsif plugin_id = (qs['@id'].first || qs['id'].first) # ?@id= to search a plugin by 'id ' config param if obj = @agent.plugin_info_by_id(plugin_id, opts) list = [obj] else list = [] end - elsif plugin_type = (qs['@type'.freeze].first || qs['type'.freeze].first) + elsif plugin_type = (qs['@type'].first || qs['type'].first) # ?@type= to search plugins by 'type ' config param list = @agent.plugins_info_by_type(plugin_type, opts) else @@ -160,22 +160,22 @@ def build_option(req) # if ?debug=1 is set, set :with_debug_info for get_monitor_info # and :pretty_json for render_json_error opts = { query: qs } - if qs['debug'.freeze].first + if qs['debug'].first opts[:with_debug_info] = true opts[:pretty_json] = true end - if ivars = qs['with_ivars'.freeze].first + if ivars = qs['with_ivars'].first opts[:ivars] = ivars.split(',') end - if with_config = qs['with_config'.freeze].first + if with_config = qs['with_config'].first opts[:with_config] = Fluent::Config.bool_value(with_config) else opts[:with_config] = @agent.include_config end - if with_retry = qs['with_retry'.freeze].first + if with_retry = qs['with_retry'].first opts[:with_retry] = Fluent::Config.bool_value(with_retry) else opts[:with_retry] = @agent.include_retry @@ -388,13 +388,13 @@ def get_retry_info(pe_retry) def plugin_category(pe) case pe when Fluent::Plugin::Input - 'input'.freeze + 'input' when Fluent::Plugin::Output, Fluent::Plugin::MultiOutput, Fluent::Plugin::BareOutput - 'output'.freeze + 'output' when Fluent::Plugin::Filter - 'filter'.freeze + 'filter' else - 'unknown'.freeze + 'unknown' end end diff --git a/lib/fluent/plugin/in_syslog.rb b/lib/fluent/plugin/in_syslog.rb index 133474b4c4..01fb734c7f 100644 --- a/lib/fluent/plugin/in_syslog.rb +++ b/lib/fluent/plugin/in_syslog.rb @@ -83,7 +83,7 @@ class SyslogInput < Input desc 'If true, add source host to event record.' config_param :include_source_host, :bool, default: false, deprecated: 'use "source_hostname_key" or "source_address_key" instead.' desc 'Specify key of source host when include_source_host is true.' - config_param :source_host_key, :string, default: 'source_host'.freeze + config_param :source_host_key, :string, default: 'source_host' desc 'Enable the option to emit unmatched lines.' config_param :emit_unmatched_lines, :bool, default: false diff --git a/test/config/test_configurable.rb b/test/config/test_configurable.rb index 4bd23e027e..0ce404a47e 100644 --- a/test/config/test_configurable.rb +++ b/test/config/test_configurable.rb @@ -535,7 +535,7 @@ class TestConfigurable < ::Test::Unit::TestCase test 'can accept frozen string' do b2 = ConfigurableSpec::Base2.new - assert_instance_of(ConfigurableSpec::Base2, b2.configure(config_element("", "", {"name1" => "t1".freeze, "name5" => "t5", "opt3" => "a"}))) + assert_instance_of(ConfigurableSpec::Base2, b2.configure(config_element("", "", {"name1" => "t1", "name5" => "t5", "opt3" => "a"}))) end test 'raise errors without any specifications for param without defaults' do