diff options
author | Tim Smith <tsmith84@gmail.com> | 2020-09-16 08:58:36 -0700 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2020-09-16 13:15:38 -0700 |
commit | d3670722ec82783b77d1c3d388e5d493f30c9bc2 (patch) | |
tree | 722eea75366c73b3a9863e318f57bc0ea0400925 | |
parent | 321cda9a730ecb561ffa536eb47bc3397d378104 (diff) | |
download | chef-d3670722ec82783b77d1c3d388e5d493f30c9bc2.tar.gz |
Resolve Style/RedundantCondition cop
We have some extra conditionals that aren't getting us anything
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | lib/chef/cookbook_site_streaming_uploader.rb | 6 | ||||
-rw-r--r-- | lib/chef/knife/bootstrap/chef_vault_handler.rb | 2 | ||||
-rw-r--r-- | lib/chef/provider/launchd.rb | 2 | ||||
-rw-r--r-- | lib/chef/provider/package/zypper.rb | 2 | ||||
-rw-r--r-- | lib/chef/provider/route.rb | 6 | ||||
-rw-r--r-- | lib/chef/provider/service/macosx.rb | 2 | ||||
-rw-r--r-- | lib/chef/provider/template_finder.rb | 12 | ||||
-rw-r--r-- | lib/chef/provider_resolver.rb | 2 | ||||
-rw-r--r-- | lib/chef/recipe.rb | 2 | ||||
-rw-r--r-- | lib/chef/resource/execute.rb | 2 |
10 files changed, 11 insertions, 27 deletions
diff --git a/lib/chef/cookbook_site_streaming_uploader.rb b/lib/chef/cookbook_site_streaming_uploader.rb index 9f2efd3d8a..65b27fed1d 100644 --- a/lib/chef/cookbook_site_streaming_uploader.rb +++ b/lib/chef/cookbook_site_streaming_uploader.rb @@ -231,11 +231,7 @@ class Chef @part_no += 1 @part_offset = 0 next_part = read(how_much_next_part) - result = current_part + if next_part - next_part - else - "" - end + result = current_part + (next_part || "") else @part_offset += how_much_current_part result = current_part diff --git a/lib/chef/knife/bootstrap/chef_vault_handler.rb b/lib/chef/knife/bootstrap/chef_vault_handler.rb index b36c178d8e..20759d6fdf 100644 --- a/lib/chef/knife/bootstrap/chef_vault_handler.rb +++ b/lib/chef/knife/bootstrap/chef_vault_handler.rb @@ -112,7 +112,7 @@ class Chef if bootstrap_vault_item bootstrap_vault_item else - json = bootstrap_vault_json ? bootstrap_vault_json : File.read(bootstrap_vault_file) + json = bootstrap_vault_json || File.read(bootstrap_vault_file) Chef::JSONCompat.from_json(json) end end diff --git a/lib/chef/provider/launchd.rb b/lib/chef/provider/launchd.rb index 37c73924f8..1045d4294f 100644 --- a/lib/chef/provider/launchd.rb +++ b/lib/chef/provider/launchd.rb @@ -209,7 +209,7 @@ class Chef # @api private def path - @path ||= new_resource.path ? new_resource.path : gen_path_from_type + @path ||= new_resource.path || gen_path_from_type end end end diff --git a/lib/chef/provider/package/zypper.rb b/lib/chef/provider/package/zypper.rb index 1096dcd044..da6bf0efbf 100644 --- a/lib/chef/provider/package/zypper.rb +++ b/lib/chef/provider/package/zypper.rb @@ -158,7 +158,7 @@ class Chef end def global_options - new_resource.global_options if new_resource.global_options + new_resource.global_options end end end diff --git a/lib/chef/provider/route.rb b/lib/chef/provider/route.rb index 3eac41aef0..8a304a7e45 100644 --- a/lib/chef/provider/route.rb +++ b/lib/chef/provider/route.rb @@ -169,11 +169,7 @@ class Chef next unless resource.is_a? Chef::Resource::Route # default to eth0 - dev = if resource.device - resource.device - else - "eth0" - end + dev = resource.device || "eth0" conf[dev] = "" if conf[dev].nil? case @action diff --git a/lib/chef/provider/service/macosx.rb b/lib/chef/provider/service/macosx.rb index ae04c7bfdd..2152789a6e 100644 --- a/lib/chef/provider/service/macosx.rb +++ b/lib/chef/provider/service/macosx.rb @@ -47,7 +47,7 @@ class Chef @current_resource = Chef::Resource::MacosxService.new(@new_resource.name) @current_resource.service_name(@new_resource.service_name) @plist_size = 0 - @plist = @new_resource.plist ? @new_resource.plist : find_service_plist + @plist = @new_resource.plist || find_service_plist @service_label = find_service_label # LaunchAgents should be loaded as the console user. @console_user = @plist ? @plist.include?("LaunchAgents") : false diff --git a/lib/chef/provider/template_finder.rb b/lib/chef/provider/template_finder.rb index fdc5eaeda9..fa120a1624 100644 --- a/lib/chef/provider/template_finder.rb +++ b/lib/chef/provider/template_finder.rb @@ -43,19 +43,11 @@ class Chef protected def template_source_name(name, options) - if options[:source] - options[:source] - else - name - end + options[:source] || name end def find_cookbook_name(options) - if options[:cookbook] - options[:cookbook] - else - @cookbook_name - end + options[:cookbook] || @cookbook_name end end end diff --git a/lib/chef/provider_resolver.rb b/lib/chef/provider_resolver.rb index b0dd0d9376..94727a1043 100644 --- a/lib/chef/provider_resolver.rb +++ b/lib/chef/provider_resolver.rb @@ -113,7 +113,7 @@ class Chef # if resource.provider is set, just return one of those objects def maybe_explicit_provider(resource) - resource.provider if resource.provider + resource.provider end # try dynamically finding a provider based on querying the providers to see what they support diff --git a/lib/chef/recipe.rb b/lib/chef/recipe.rb index 4009677936..972edf9649 100644 --- a/lib/chef/recipe.rb +++ b/lib/chef/recipe.rb @@ -122,7 +122,7 @@ class Chef end def to_s - "cookbook: #{cookbook_name ? cookbook_name : "(none)"}, recipe: #{recipe_name ? recipe_name : "(none)"} " + "cookbook: #{cookbook_name || "(none)"}, recipe: #{recipe_name || "(none)"} " end def inspect diff --git a/lib/chef/resource/execute.rb b/lib/chef/resource/execute.rb index 93bf689dd9..11d1c2fc40 100644 --- a/lib/chef/resource/execute.rb +++ b/lib/chef/resource/execute.rb @@ -587,7 +587,7 @@ class Chef ancestor_attributes = superclass.guard_inherited_attributes end - ancestor_attributes.concat(@class_inherited_attributes ? @class_inherited_attributes : []).uniq + ancestor_attributes.concat(@class_inherited_attributes || []).uniq end # post resource creation validation |