Skip to content

Commit

Permalink
(CONT-517) Fix undefined method reverse
Browse files Browse the repository at this point in the history
Prior to this commit `items.find_all.last` had been repaced by `items.reverse.find`.

The change was introduced due to a Rubocop suggestion. However, it was
incorrect due to the datatype of `items`.

This commit reverts the change.
  • Loading branch information
chelnak committed Jan 25, 2023
1 parent 8b97092 commit 1c06f6d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/puppetlabs_spec_helper/tasks/fixtures.rb
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,9 @@ def download_items(items)
end
else
# the last thread started should be the longest wait
item, item_opts = items.reverse.find { |_i, o| o.key?(:thread) }
# Rubocop seems to push towards using select here.. however the implementation today relies on the result being
# an array. Select returns a hash which makes it unsuitable so we need to use find_all.last.
item, item_opts = items.find_all { |_i, o| o.key?(:thread) }.last # rubocop:disable Performance/Detect, Style/CollectionMethods
logger.debug "Waiting on #{item}"
item_opts[:thread].join # wait for the thread to finish
# now that we waited lets try again
Expand Down

0 comments on commit 1c06f6d

Please sign in to comment.