diff options
author | Tim Smith <tsmith84@gmail.com> | 2020-11-06 11:26:34 -0800 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2020-11-06 11:28:03 -0800 |
commit | c6fad3888a03eeab41b63df0c9cbdea5a48f7e97 (patch) | |
tree | f08ca91f94580e465b1a468ffbf4ae0419a2a62a /lib | |
parent | a71a65a25b51b52fbb4e2ab4607e584d52cc3b61 (diff) | |
download | chef-c6fad3888a03eeab41b63df0c9cbdea5a48f7e97.tar.gz |
Collapse several duplicate branches down
Write more compact case statements to prevent duplicate branches.
Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/file_access_control/windows.rb | 5 | ||||
-rw-r--r-- | lib/chef/node/attribute_collections.rb | 4 | ||||
-rw-r--r-- | lib/chef/provider/cron.rb | 8 | ||||
-rw-r--r-- | lib/chef/provider/package/snap.rb | 4 | ||||
-rw-r--r-- | lib/chef/resource/plist.rb | 8 | ||||
-rw-r--r-- | lib/chef/util/dsc/lcm_output_parser.rb | 4 | ||||
-rw-r--r-- | lib/chef/util/powershell/cmdlet.rb | 12 |
7 files changed, 10 insertions, 35 deletions
diff --git a/lib/chef/file_access_control/windows.rb b/lib/chef/file_access_control/windows.rb index 9e5f07428c..cc1b96a84d 100644 --- a/lib/chef/file_access_control/windows.rb +++ b/lib/chef/file_access_control/windows.rb @@ -255,10 +255,7 @@ class Chef flags |= CONTAINER_INHERIT_ACE when :objects_only flags |= OBJECT_INHERIT_ACE - when true - flags |= CONTAINER_INHERIT_ACE - flags |= OBJECT_INHERIT_ACE - when nil + when true, nil flags |= CONTAINER_INHERIT_ACE flags |= OBJECT_INHERIT_ACE end diff --git a/lib/chef/node/attribute_collections.rb b/lib/chef/node/attribute_collections.rb index b8fd507336..1b09be7da2 100644 --- a/lib/chef/node/attribute_collections.rb +++ b/lib/chef/node/attribute_collections.rb @@ -73,9 +73,7 @@ class Chef def convert_value(value) case value - when VividMash - value - when AttrArray + when VividMash, AttrArray value when Hash VividMash.new(value, __root__, __node__, __precedence__) diff --git a/lib/chef/provider/cron.rb b/lib/chef/provider/cron.rb index 622f8f5e63..b7aa6dc3fc 100644 --- a/lib/chef/provider/cron.rb +++ b/lib/chef/provider/cron.rb @@ -112,13 +112,7 @@ class Chef when ENV_PATTERN crontab << line unless cron_found next - when SPECIAL_PATTERN - if cron_found - cron_found = false - crontab << newcron - next - end - when CRON_PATTERN + when SPECIAL_PATTERN, CRON_PATTERN if cron_found cron_found = false crontab << newcron diff --git a/lib/chef/provider/package/snap.rb b/lib/chef/provider/package/snap.rb index 57ee1ed6c6..81af09e04d 100644 --- a/lib/chef/provider/package/snap.rb +++ b/lib/chef/provider/package/snap.rb @@ -221,9 +221,7 @@ class Chef case result["result"]["status"] when "Do", "Doing", "Undoing", "Undo" # Continue - when "Abort" - raise result - when "Hold", "Error" + when "Abort", "Hold", "Error" raise result when "Done" waiting = false diff --git a/lib/chef/resource/plist.rb b/lib/chef/resource/plist.rb index f4058520a9..a7cb88ef57 100644 --- a/lib/chef/resource/plist.rb +++ b/lib/chef/resource/plist.rb @@ -151,9 +151,7 @@ class Chef value.to_i when "float" value.to_f - when "string" - value - when "dictionary" + when "string", "dictionary" value when nil "" @@ -168,9 +166,7 @@ class Chef "array" when Integer "integer" - when FalseClass - "bool" - when TrueClass + when FalseClass, TrueClass "bool" when Hash "dict" diff --git a/lib/chef/util/dsc/lcm_output_parser.rb b/lib/chef/util/dsc/lcm_output_parser.rb index 38c202a4bb..509f680bb4 100644 --- a/lib/chef/util/dsc/lcm_output_parser.rb +++ b/lib/chef/util/dsc/lcm_output_parser.rb @@ -89,9 +89,7 @@ class Chef case op_action when "InDesiredState" current_resource[:skipped] = op_value.strip == "True" ? true : false - when "ResourcesInDesiredState" - current_resource[:name] = op_value.strip if op_value - when "ResourcesNotInDesiredState" + when "ResourcesInDesiredState", "ResourcesNotInDesiredState" current_resource[:name] = op_value.strip if op_value when "ReturnValue" current_resource[:context] = nil diff --git a/lib/chef/util/powershell/cmdlet.rb b/lib/chef/util/powershell/cmdlet.rb index ea84798814..1c728fa424 100644 --- a/lib/chef/util/powershell/cmdlet.rb +++ b/lib/chef/util/powershell/cmdlet.rb @@ -31,13 +31,9 @@ class Chef @node = node case output_format - when nil + when nil, :text @json_format = false - when :json - @json_format = true - when :text - @json_format = false - when :object + when :json, :object @json_format = true else raise ArgumentError, "Invalid output format #{output_format} specified" @@ -128,9 +124,7 @@ class Chef switch_present = true case switch_value - when Numeric - switch_argument = switch_value.to_s - when Float + when Numeric, Float switch_argument = switch_value.to_s when FalseClass switch_present = false |