diff options
author | Tim Smith <tsmith84@gmail.com> | 2020-11-06 12:49:30 -0800 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2020-11-06 12:49:30 -0800 |
commit | 00153175b5e9ec7386e57d1d95bd4cd60f91fa5d (patch) | |
tree | cbcd3eb9be9406bce24e8b8712cc1ad7c8207697 | |
parent | 1ad7ec792ecec0bb384415068dbfcf39681e49a9 (diff) | |
download | ohai-00153175b5e9ec7386e57d1d95bd4cd60f91fa5d.tar.gz |
Collapse duplicate branches in case statements
Simpler case statements
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | lib/ohai/plugins/cpu.rb | 4 | ||||
-rw-r--r-- | lib/ohai/plugins/darwin/memory.rb | 4 | ||||
-rw-r--r-- | lib/ohai/runner.rb | 4 |
3 files changed, 3 insertions, 9 deletions
diff --git a/lib/ohai/plugins/cpu.rb b/lib/ohai/plugins/cpu.rb index 9cbb7abb..66aa1260 100644 --- a/lib/ohai/plugins/cpu.rb +++ b/lib/ohai/plugins/cpu.rb @@ -36,11 +36,9 @@ Ohai.plugin(:CPU) do when /CPU:\s+(.+) \(([\d.]+).+\)/ cpuinfo["model_name"] = $1 cpuinfo["mhz"] = $2 - when /Features=.+<(.+)>/ + when /Features=.+<(.+)>/, /Features2=[a-f\dx]+<(.+)>/ cpuinfo["flags"].concat($1.downcase.split(",")) # Features2=0x80000001<SSE3,<b31>> - when /Features2=[a-f\dx]+<(.+)>/ - cpuinfo["flags"].concat($1.downcase.split(",")) else yield(cpuinfo, line) end diff --git a/lib/ohai/plugins/darwin/memory.rb b/lib/ohai/plugins/darwin/memory.rb index d76bd5db..72a6e69f 100644 --- a/lib/ohai/plugins/darwin/memory.rb +++ b/lib/ohai/plugins/darwin/memory.rb @@ -44,9 +44,7 @@ Ohai.plugin(:Memory) do megabyte_val = (pages * page_size) / 1024 / 1024.0 total_consumed += megabyte_val case match - when "wired down" - active += megabyte_val.to_i - when "active" + when "wired down", "active" active += megabyte_val.to_i when "inactive" inactive += megabyte_val.to_i diff --git a/lib/ohai/runner.rb b/lib/ohai/runner.rb index de478895..4f70e952 100644 --- a/lib/ohai/runner.rb +++ b/lib/ohai/runner.rb @@ -58,9 +58,7 @@ module Ohai else raise Ohai::Exceptions::InvalidPlugin, "Invalid plugin version #{plugin.version} for plugin #{plugin}" end - rescue Ohai::Exceptions::Error # rubocop: disable Lint/ShadowedException - raise - rescue SystemExit # abort or exit from plug-in should exit Ohai with failure code + rescue Ohai::Exceptions::Error, SystemExit # SystemExit: abort or exit from plug-in should exit Ohai with failure code raise rescue Exception => e logger.trace("Plugin #{plugin.name} threw exception #{e.inspect} #{e.backtrace.join("\n")}") |