mirror of
https://github.com/inspec/inspec
synced 2024-11-14 00:47:10 +00:00
Minor cleanups for readability.
Signed-off-by: Ryan Davis <zenspider@chef.io>
This commit is contained in:
parent
07dc5e3192
commit
fd7a569d6b
3 changed files with 15 additions and 3 deletions
|
@ -222,16 +222,20 @@ module Inspec
|
|||
|
||||
private
|
||||
|
||||
ALL_OF_OUR_REPORTERS = %w{json json-min json-rspec json-automate junit html yaml documentation progress}.freeze # BUT WHY?!?!
|
||||
|
||||
def suppress_log_output?(opts)
|
||||
return false if opts["reporter"].nil?
|
||||
|
||||
match = %w{json json-min json-rspec json-automate junit html yaml documentation progress} & opts["reporter"].keys
|
||||
match = ALL_OF_OUR_REPORTERS & opts["reporter"].keys
|
||||
|
||||
unless match.empty?
|
||||
match.each do |m|
|
||||
# check to see if we are outputting to stdout
|
||||
return true if opts["reporter"][m]["stdout"] == true
|
||||
end
|
||||
end
|
||||
|
||||
false
|
||||
end
|
||||
|
||||
|
|
|
@ -340,7 +340,15 @@ class Inspec::InspecCLI < Inspec::BaseCLI
|
|||
ui.exit res unless run_type == :ruby_eval
|
||||
|
||||
# No InSpec tests - just print evaluation output.
|
||||
res = (res.respond_to?(:to_json) ? res.to_json : JSON.dump(res)) if o["reporter"]&.keys&.include?("json")
|
||||
reporters = o["reporter"] || {}
|
||||
if reporters.keys.include?("json")
|
||||
res = if res.respond_to?(:to_json)
|
||||
res.to_json
|
||||
else
|
||||
JSON.dump(res)
|
||||
end
|
||||
end
|
||||
|
||||
puts res
|
||||
ui.exit Inspec::UI::EXIT_NORMAL
|
||||
rescue RuntimeError, Train::UserError => e
|
||||
|
|
|
@ -83,7 +83,7 @@ module Inspec
|
|||
return @rspec_exit_code if @formatter.results.empty?
|
||||
|
||||
stats = @formatter.results[:statistics][:controls]
|
||||
skipped = @formatter.results&.fetch(:profiles, nil)&.first&.fetch(:status, nil) == "skipped"
|
||||
skipped = @formatter.results.dig(:profiles, 0, :status) == "skipped"
|
||||
if stats[:failed][:total] == 0 && stats[:skipped][:total] == 0 && !skipped
|
||||
0
|
||||
elsif stats[:failed][:total] > 0
|
||||
|
|
Loading…
Reference in a new issue