Skip to content

Commit

Permalink
rubocop: Use find instead of select.first
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Menges <[email protected]>
  • Loading branch information
Garfield96 committed Jun 14, 2023
1 parent ae2a1d5 commit 980987d
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/fluent/plugin/in_forward.rb
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ def check_ping(message, remote_addr, user_auth_salt, nonce)
end
_ping, hostname, shared_key_salt, shared_key_hexdigest, username, password_digest = message

node = @nodes.select{|n| n[:address].include?(remote_addr) rescue false }.first
node = @nodes.find{|n| n[:address].include?(remote_addr) rescue false }
if !node && !@security.allow_anonymous_source
log.warn "Anonymous client disallowed", address: remote_addr, hostname: hostname
return false, "anonymous source host '#{remote_addr}' denied", nil
Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/plugin/in_sample.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def initialize
def configure(conf)
super
@sample_index = 0
config = conf.elements.select{|e| e.name == 'storage' }.first
config = conf.elements.find{|e| e.name == 'storage' }
@storage = storage_create(usage: 'suspend', conf: config, default_type: DEFAULT_STORAGE_TYPE)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/plugin/out_exec_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def start
@rr = 0

exit_callback = ->(status){
c = @children.select{|child| child.pid == status.pid }.first
c = @children.find{|child| child.pid == status.pid }
if c
unless self.stopped?
log.warn "child process exits with error code", code: status.to_i, status: status.exitstatus, signal: status.termsig
Expand Down
4 changes: 2 additions & 2 deletions lib/fluent/plugin_helper/thread.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ def thread_exist?(title)
end

def thread_started?(title)
t = @_threads.values.select{|thread| title == thread[:_fluentd_plugin_helper_thread_title] }.first
t = @_threads.values.find{|thread| title == thread[:_fluentd_plugin_helper_thread_title] }
t && t[:_fluentd_plugin_helper_thread_started]
end

def thread_running?(title)
t = @_threads.values.select{|thread| title == thread[:_fluentd_plugin_helper_thread_title] }.first
t = @_threads.values.find{|thread| title == thread[:_fluentd_plugin_helper_thread_title] }
t && t[:_fluentd_plugin_helper_thread_running]
end

Expand Down
2 changes: 1 addition & 1 deletion test/plugin/test_output_as_buffered_retries.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def dummy_event_stream
end
def get_log_time(msg, logs)
log_time = nil
log = logs.select{|l| l.include?(msg) }.first
log = logs.find{|l| l.include?(msg) }
if log && /^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} [-+]\d{4}) \[error\]/ =~ log
log_time = Time.parse($1)
end
Expand Down
2 changes: 1 addition & 1 deletion test/plugin_helper/test_child_process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ def configure(conf)
m.lock
pid = pids.first
# 16357 sleeeeeeeeeper -e sleep 10; puts "hello"
assert{ proc_lines.select{|line| line =~ /^\s*#{pid}\s/ }.first.strip.split(/\s+/)[1] == "sleeeeeeeeeper" }
assert{ proc_lines.find{|line| line =~ /^\s*#{pid}\s/ }.strip.split(/\s+/)[1] == "sleeeeeeeeeper" }
@d.stop; @d.shutdown; @d.close; @d.terminate
end
end
Expand Down

0 comments on commit 980987d

Please sign in to comment.