diff options
author | Tim Smith <tsmith@chef.io> | 2018-06-28 21:17:34 -0700 |
---|---|---|
committer | Tim Smith <tsmith@chef.io> | 2018-07-02 09:21:23 -0700 |
commit | 896ecc78d7cb85b98f9611c73acd25c3d8728995 (patch) | |
tree | c586c8c3f0e7210502ab8a9fd00804e646bfa26e /lib | |
parent | cb90ed45d4e8afa4e5899222a78b201e1d967a53 (diff) | |
download | ohai-896ecc78d7cb85b98f9611c73acd25c3d8728995.tar.gz |
Resolve 2 unneeded sort warnings
We're trying to get the min so use min vs. sort then first.
Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ohai/plugins/linux/network.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/ohai/plugins/linux/network.rb b/lib/ohai/plugins/linux/network.rb index 1616d8a7..73a922d5 100644 --- a/lib/ohai/plugins/linux/network.rb +++ b/lib/ohai/plugins/linux/network.rb @@ -388,9 +388,9 @@ Ohai.plugin(:Network) do def choose_default_route(routes) routes.select do |r| r[:destination] == "default" - end.sort do |x, y| + end.min do |x, y| (x[:metric].nil? ? 0 : x[:metric].to_i) <=> (y[:metric].nil? ? 0 : y[:metric].to_i) - end.first + end end def interface_has_no_addresses_in_family?(iface, family) @@ -447,7 +447,7 @@ Ohai.plugin(:Network) do iface[r[:dev]][:state] == "up" && route_is_valid_default_route?(r, default_route) end - end.sort_by do |r| + end.min_by do |r| # sorting the selected routes: # - getting default routes first # - then sort by metric @@ -463,7 +463,7 @@ Ohai.plugin(:Network) do 0 end, ] - end.first + end end # Both the network plugin and this plugin (linux/network) are run on linux. This plugin runs first. |