summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2020-09-16 16:31:27 -0700
committerGitHub <noreply@github.com>2020-09-16 16:31:27 -0700
commitf28f61545a9c5859c9b9063bd594f4b8ce3cef6d (patch)
treec6455a618f451a4fb788be25f6830cdc2125e2bd
parent40c71d4e8702894600276f11ce615a9d6334496b (diff)
parente3179ff2c94e3ed59d5d3b78243dd564d4b127f7 (diff)
downloadchef-f28f61545a9c5859c9b9063bd594f4b8ce3cef6d.tar.gz
Merge pull request #10439 from chef/RedundantSort
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--chef-bin/Rakefile2
-rw-r--r--lib/chef/mixin/versioned_api.rb3
2 files changed, 2 insertions, 3 deletions
diff --git a/chef-bin/Rakefile b/chef-bin/Rakefile
index 5e5c9bbf5f..7fe4f1e9d4 100644
--- a/chef-bin/Rakefile
+++ b/chef-bin/Rakefile
@@ -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}"
diff --git a/lib/chef/mixin/versioned_api.rb b/lib/chef/mixin/versioned_api.rb
index eab2ea8228..b627e0210c 100644
--- a/lib/chef/mixin/versioned_api.rb
+++ b/lib/chef/mixin/versioned_api.rb
@@ -50,8 +50,7 @@ class Chef
# 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_by { |a| a.send(:minimum_api_version) }
end
def def_versioned_delegator(method)