diff --git a/lib/fluent/command/binlog_reader.rb b/lib/fluent/command/binlog_reader.rb index f77c47c4ff..ba7adf430e 100644 --- a/lib/fluent/command/binlog_reader.rb +++ b/lib/fluent/command/binlog_reader.rb @@ -130,7 +130,7 @@ def initialize(argv = ARGV) private def configure_option_parser - @options.merge!(config_params: {}) + @options[:config_params] = {} @opt_parser.banner = "Usage: fluent-binlog-reader #{self.class.to_s.split('::').last.downcase} [options] file" diff --git a/lib/fluent/config/configure_proxy.rb b/lib/fluent/config/configure_proxy.rb index 4db4fd4ef0..ec2ce42040 100644 --- a/lib/fluent/config/configure_proxy.rb +++ b/lib/fluent/config/configure_proxy.rb @@ -201,7 +201,7 @@ def merge_for_finalized(other) def overwrite_defaults(other) # other is owner plugin's corresponding proxy self.defaults = self.defaults.merge(other.defaults) - self.sections.keys.each do |section_key| + self.sections.each_key do |section_key| if other.sections.has_key?(section_key) self.sections[section_key].overwrite_defaults(other.sections[section_key]) end @@ -274,7 +274,7 @@ def parameter_configuration(name, type = nil, **kwargs, &block) option_value_type!(name, opts, :deprecated, String) option_value_type!(name, opts, :obsoleted, String) if type == :enum - if !opts.has_key?(:list) || !opts[:list].is_a?(Array) || opts[:list].empty? || !opts[:list].all?{|v| v.is_a?(Symbol) } + if !opts.has_key?(:list) || !opts[:list].is_a?(Array) || opts[:list].empty? || !opts[:list].all?(Symbol) raise ArgumentError, "#{name}: enum parameter requires :list of Symbols" end end diff --git a/lib/fluent/config/types.rb b/lib/fluent/config/types.rb index 98e7d0d9d8..9c9ba89c8d 100644 --- a/lib/fluent/config/types.rb +++ b/lib/fluent/config/types.rb @@ -123,7 +123,7 @@ def self.enum_value(val, opts = {}, name = nil) s = val.to_sym list = opts[:list] - raise "Plugin BUG: config type 'enum' requires :list of symbols" unless list.is_a?(Array) && list.all?{|v| v.is_a? Symbol } + raise "Plugin BUG: config type 'enum' requires :list of symbols" unless list.is_a?(Array) && list.all?(Symbol) unless list.include?(s) raise ConfigError, "valid options are #{list.join(',')} but got #{val}" end diff --git a/lib/fluent/configurable.rb b/lib/fluent/configurable.rb index aa3ece1752..9131738c11 100644 --- a/lib/fluent/configurable.rb +++ b/lib/fluent/configurable.rb @@ -31,13 +31,13 @@ def initialize super # to simulate implicit 'attr_accessor' by config_param / config_section and its value by config_set_default proxy = self.class.merged_configure_proxy - proxy.params.keys.each do |name| + proxy.params.each_key do |name| next if name.to_s.start_with?('@') if proxy.defaults.has_key?(name) instance_variable_set("@#{name}".to_sym, proxy.defaults[name]) end end - proxy.sections.keys.each do |name| + proxy.sections.each_key do |name| next if name.to_s.start_with?('@') subproxy = proxy.sections[name] if subproxy.multi? diff --git a/lib/fluent/counter/mutex_hash.rb b/lib/fluent/counter/mutex_hash.rb index 9c66286458..22868fcdda 100644 --- a/lib/fluent/counter/mutex_hash.rb +++ b/lib/fluent/counter/mutex_hash.rb @@ -54,7 +54,7 @@ def synchronize(*keys) if mutex.try_lock locks[key] = mutex else - locks.values.each(&:unlock) + locks.each_value(&:unlock) locks = {} # flush locked keys break end diff --git a/lib/fluent/plugin/buf_file.rb b/lib/fluent/plugin/buf_file.rb index d75f789830..7f11478a01 100644 --- a/lib/fluent/plugin/buf_file.rb +++ b/lib/fluent/plugin/buf_file.rb @@ -56,7 +56,7 @@ def configure(conf) @variable_store = Fluent::VariableStore.fetch_or_build(:buf_file) - multi_workers_configured = owner.system_config.workers > 1 ? true : false + multi_workers_configured = owner.system_config.workers > 1 using_plugin_root_dir = false unless @path diff --git a/lib/fluent/plugin_helper/metrics.rb b/lib/fluent/plugin_helper/metrics.rb index 7489732918..452610ab75 100644 --- a/lib/fluent/plugin_helper/metrics.rb +++ b/lib/fluent/plugin_helper/metrics.rb @@ -65,9 +65,9 @@ def metrics_create(namespace: "fluentd", subsystem: "metrics", name:, help_text: metrics.configure(config) # For multi workers environment, cmetrics should be distinguish with static labels. if Fluent::Engine.system_config.workers > 1 - labels.merge!(worker_id: fluentd_worker_id.to_s) + labels[:worker_id] = fluentd_worker_id.to_s end - labels.merge!(plugin: @plugin_type_or_id) + labels[:plugin] = @plugin_type_or_id metrics.create(namespace: namespace, subsystem: subsystem, name: name, help_text: help_text, labels: labels) @_metrics["#{@plugin_type_or_id}_#{namespace}_#{subsystem}_#{name}"] = metrics diff --git a/lib/fluent/test/output_test.rb b/lib/fluent/test/output_test.rb index b7ff3fd37a..bb18884dc2 100644 --- a/lib/fluent/test/output_test.rb +++ b/lib/fluent/test/output_test.rb @@ -139,7 +139,7 @@ def run(&block) assert_equal(@expected_buffer, buffer) end - lines.keys.each do |meta| + lines.each_key do |meta| chunk = @instance.buffer.generate_chunk(meta).staged! chunk.append(lines[meta]) begin