Skip to content

Commit

Permalink
Resolve Style/RedundantSort warnings
Browse files Browse the repository at this point in the history
Avoid a sort then last and just grab the max.

Signed-off-by: Tim Smith <[email protected]>
  • Loading branch information
tas50 committed Sep 16, 2020
1 parent 40c71d4 commit 1ce3174
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion chef-bin/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Bundler::GemHelper.install_tasks
desc "force install the chef-bin gem"
task "install:force" do
sh "gem build -V chef-bin.gemspec"
built_gem_path = Dir["chef-bin-*.gem"].sort_by { |f| File.mtime(f) }.last
built_gem_path = Dir["chef-bin-*.gem"].max_by { |f| File.mtime(f) }
FileUtils.mkdir_p("pkg") unless Dir.exist?("pkg")
FileUtils.mv(built_gem_path, "pkg")
sh "gem install -f pkg/#{built_gem_path}"
Expand Down
3 changes: 1 addition & 2 deletions lib/chef/mixin/versioned_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ def get_class_for(type)
# in which case we'll just start with the highest version and see what happens
ServerAPIVersions.instance.min_server_version.nil? || (version >= ServerAPIVersions.instance.min_server_version && version <= ServerAPIVersions.instance.send(type))
end
.sort { |a, b| a.send(:minimum_api_version) <=> b.send(:minimum_api_version) }
.last
.max { |a, b| a.send(:minimum_api_version) <=> b.send(:minimum_api_version) }
end

def def_versioned_delegator(method)
Expand Down

0 comments on commit 1ce3174

Please sign in to comment.