summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2020-09-16 15:14:34 -0700
committerTim Smith <tsmith84@gmail.com>2020-09-16 15:32:58 -0700
commit1ce3174538126c8e3642bf005382f1ee396b5542 (patch)
tree91cea9acb1701d971c14a92f50b17be569222b76
parent40c71d4e8702894600276f11ce615a9d6334496b (diff)
downloadchef-1ce3174538126c8e3642bf005382f1ee396b5542.tar.gz
Resolve Style/RedundantSort warnings
Avoid a sort then last and just grab the max. 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..9333a39101 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 { |a, b| a.send(:minimum_api_version) <=> b.send(:minimum_api_version) }
end
def def_versioned_delegator(method)