summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2021-12-26 19:12:54 -0800
committerTim Smith <tsmith84@gmail.com>2021-12-26 19:14:01 -0800
commit43d45b243d0c54d64b62202710445a70e6d05ac6 (patch)
tree0f2056bd648df0abc5a25c9be3916f74a5cac1fd
parent50a0001bae754c66feb69c84b64cb305a03a34d2 (diff)
downloadchef-43d45b243d0c54d64b62202710445a70e6d05ac6.tar.gz
Resolve Performance/RedundantSortBlock warningsPerformance_RedundantSortBlock
Simplify and speed up the sorts Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--knife/lib/chef/knife/core/generic_presenter.rb2
-rw-r--r--knife/spec/unit/knife/environment_list_spec.rb2
2 files changed, 2 insertions, 2 deletions
diff --git a/knife/lib/chef/knife/core/generic_presenter.rb b/knife/lib/chef/knife/core/generic_presenter.rb
index 850bfa8b3d..214ffd340b 100644
--- a/knife/lib/chef/knife/core/generic_presenter.rb
+++ b/knife/lib/chef/knife/core/generic_presenter.rb
@@ -140,7 +140,7 @@ class Chef
end
def format_list_for_display(list)
- config[:with_uri] ? list : list.keys.sort { |a, b| a <=> b }
+ config[:with_uri] ? list : list.keys.sort
end
def format_for_display(data)
diff --git a/knife/spec/unit/knife/environment_list_spec.rb b/knife/spec/unit/knife/environment_list_spec.rb
index 4f44a93f60..5090596815 100644
--- a/knife/spec/unit/knife/environment_list_spec.rb
+++ b/knife/spec/unit/knife/environment_list_spec.rb
@@ -39,7 +39,7 @@ describe Chef::Knife::EnvironmentList do
end
it "should print the environment names in a sorted list" do
- names = @environments.keys.sort { |a, b| a <=> b }
+ names = @environments.keys.sort
expect(@knife).to receive(:output).with(names)
@knife.run
end