From ed8047fdcddbfadbd9385fb730d3a340f7a5362b Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Tue, 16 Aug 2016 14:29:04 -0700 Subject: [PATCH] Resolve cookstyle warnings Signed-off-by: Tim Smith --- libraries/collector_classes.rb | 6 +++--- libraries/helper.rb | 2 +- libraries/profile.rb | 4 ++-- libraries/report.rb | 2 +- recipes/default.rb | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libraries/collector_classes.rb b/libraries/collector_classes.rb index 04b3d4de..f70a376e 100644 --- a/libraries/collector_classes.rb +++ b/libraries/collector_classes.rb @@ -6,7 +6,7 @@ class Collector # # Used to send inspec reports to Chef Visibility via the data_collector service # - class ChefVisibility # rubocop:disable Metrics/ClassLength + class ChefVisibility @entity_uuid = nil @run_id = nil @blob = [] @@ -111,7 +111,7 @@ def count_controls(profiles) end # Return a json string containing the inspec report to be sent to the data_collector - def enriched_report # rubocop:disable Metrics/AbcSize + def enriched_report return nil unless @blob.is_a?(Hash) && @blob[:reports].is_a?(Hash) final_report = {} node_name = @blob[:node] # ~FC001, ~FC019, ~FC039 @@ -152,7 +152,7 @@ def enriched_report # rubocop:disable Metrics/AbcSize end # Method used in order to send the inspec report to the data_collector server - def send_report # rubocop:disable PerceivedComplexity, Metrics/CyclomaticComplexity + def send_report unless @entity_uuid && @run_id Chef::Log.warn "entity_uuid(#{@entity_uuid}) or run_id(#{@run_id}) can't be nil, not sending report..." return false diff --git a/libraries/helper.rb b/libraries/helper.rb index 23bb3fd4..43ae3244 100644 --- a/libraries/helper.rb +++ b/libraries/helper.rb @@ -32,7 +32,7 @@ def handle_http_error_code(code) end msg = "Received HTTP error #{code}. Please verify the authentication (e.g. token) is set properly." Chef::Log.error msg - fail msg if @raise_if_unreachable + raise msg if @raise_if_unreachable end #rubocop:disable all diff --git a/libraries/profile.rb b/libraries/profile.rb index f705b406..a50016ba 100644 --- a/libraries/profile.rb +++ b/libraries/profile.rb @@ -6,7 +6,7 @@ # `compliance_profile` custom resource to collect and run Chef Compliance # profiles -class ComplianceProfile < Chef::Resource # rubocop:disable Metrics/ClassLength +class ComplianceProfile < Chef::Resource include ComplianceHelpers use_automatic_resource_name @@ -133,7 +133,7 @@ class ComplianceProfile < Chef::Resource # rubocop:disable Metrics/ClassLength supported_schemes = %w{http https supermarket compliance chefserver} if !supported_schemes.include?(URI(path).scheme) && !::File.exist?(path) Chef::Log.warn "No such path! Skipping: #{path}" - fail "Aborting since profile is not present here: #{path}" if run_context.node['audit']['fail_if_not_present'] + raise "Aborting since profile is not present here: #{path}" if run_context.node['audit']['fail_if_not_present'] return end diff --git a/libraries/report.rb b/libraries/report.rb index eefa7d4a..d0e013a8 100644 --- a/libraries/report.rb +++ b/libraries/report.rb @@ -64,7 +64,7 @@ class ComplianceReport < Chef::Resource Chef::Log.warn "#{collector} is not a supported inspec report collector" end - fail "#{total_failed} audits have failed. Aborting chef-client run." if total_failed > 0 && node['audit']['fail_if_any_audits_failed'] + raise "#{total_failed} audits have failed. Aborting chef-client run." if total_failed > 0 && node['audit']['fail_if_any_audits_failed'] end end diff --git a/recipes/default.rb b/recipes/default.rb index d1c1d813..730378f6 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -48,7 +48,7 @@ else next if value == false end - fail "Invalid profile name '#{owner_profile}'. "\ + raise "Invalid profile name '#{owner_profile}'. "\ "Must contain /, e.g. 'john/ssh'" if owner_profile !~ %r{\/} o, p = owner_profile.split('/').last(2)