Skip to content

Commit

Permalink
Resolve cookstyle warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Smith <tsmith@chef.io>
  • Loading branch information
tas50 committed Aug 16, 2016
1 parent f2638ab commit ed8047f
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions libraries/collector_classes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion libraries/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions libraries/profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion libraries/report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit ed8047f

Please sign in to comment.