class Inspec::Reporters::CLI::Control
def anonymous?
def anonymous? id.start_with?("(generated from ") end
def failure_count
def failure_count results.select { |r| r[:status] == "failed" }.size end
def id
def id data[:id] end
def impact
def impact data[:impact] end
def impact_string
def impact_string if anonymous? nil elsif impact.nil? "unknown" elsif results&.find { |r| r[:status] == "skipped" } "skipped" elsif results.nil? || results.empty? || results.all? { |r| r[:status] == "passed" } "passed" else "failed" end end
def impact_string_for_enhanced_outcomes
def impact_string_for_enhanced_outcomes if impact.nil? "unknown" else status end end
def impact_string_for_result(result)
def impact_string_for_result(result) if result[:status] == "skipped" "skipped" elsif result[:status] == "passed" "passed" elsif impact.nil? "unknown" else "failed" end end
def initialize(control_hash)
def initialize(control_hash) @data = control_hash end
def results
def results data[:results] end
def skipped_count
def skipped_count results.select { |r| r[:status] == "skipped" }.size end
def source_location
def source_location data[:source_location] end
def status
def status data[:status] end
def title
def title data[:title] end
def title_for_report
def title_for_report # if this is an anonymous control, just grab the resource title from any result entry return results.first[:resource_title] if anonymous? title_for_report = "#{id}: #{title || results.first[:resource_title]}" # we will not add any additional data to the title if there's only # zero or one test for this control. return title_for_report if results.nil? || results.size <= 1 # append a failure summary if appropriate. title_for_report += " (#{failure_count} failed)" if failure_count > 0 title_for_report += " (#{skipped_count} skipped)" if skipped_count > 0 title_for_report end