class Railroader::RescanReport
Class to make reporting of rescan results simpler to deal with
Attributes
new_results[R]
old_results[R]
Public Class Methods
new(old_results, tracker)
click to toggle source
# File lib/railroader/rescanner.rb, line 403 def initialize old_results, tracker @tracker = tracker @old_results = old_results @all_warnings = nil @diff = nil end
Public Instance Methods
all_warnings()
click to toggle source
Returns an array of all warnings found
# File lib/railroader/rescanner.rb, line 416 def all_warnings @all_warnings ||= @tracker.filtered_warnings end
any_warnings?()
click to toggle source
Returns true if any warnings were found (new or old)
# File lib/railroader/rescanner.rb, line 411 def any_warnings? not all_warnings.empty? end
diff()
click to toggle source
Returns a hash of arrays for :new and :fixed warnings
# File lib/railroader/rescanner.rb, line 438 def diff @diff ||= Railroader::Differ.new(all_warnings, @old_results).diff end
existing_warnings()
click to toggle source
Returns an array of warnings which were in the old report and the new report
# File lib/railroader/rescanner.rb, line 443 def existing_warnings @old ||= all_warnings.select do |w| not new_warnings.include? w end end
fixed_warnings()
click to toggle source
Returns an array of warnings which were in the old report but are not in the new report after rescanning
# File lib/railroader/rescanner.rb, line 422 def fixed_warnings diff[:fixed] end
new_warnings()
click to toggle source
Returns an array of warnings which were in the new report but were not in the old report
# File lib/railroader/rescanner.rb, line 428 def new_warnings diff[:new] end
to_s(verbose = false)
click to toggle source
Output total, fixed, and new warnings
# File lib/railroader/rescanner.rb, line 450 def to_s(verbose = false) Railroader.load_railroader_dependency 'terminal-table' if !verbose <<-OUTPUT Total warnings: #{all_warnings.length} Fixed warnings: #{fixed_warnings.length} New warnings: #{new_warnings.length} OUTPUT else # Eventually move this to different method, or make default to_s out = "" {:fixed => fixed_warnings, :new => new_warnings, :existing => existing_warnings}.each do |warning_type, warnings| if warnings.length > 0 out << "#{warning_type.to_s.titleize} warnings: #{warnings.length}\n" table = Terminal::Table.new(:headings => ["Confidence", "Class", "Method", "Warning Type", "Message"]) do |t| warnings.sort_by { |w| w.confidence}.each do |warning| w = warning.to_row w["Confidence"] = Railroader::Report::TEXT_CONFIDENCE[w["Confidence"]] t << [w["Confidence"], w["Class"], w["Method"], w["Warning Type"], w["Message"]] end end out << truncate_table(table.to_s) end end out end end
warnings_changed?()
click to toggle source
Returns true if there are any new or fixed warnings
# File lib/railroader/rescanner.rb, line 433 def warnings_changed? not (diff[:new].empty? and diff[:fixed].empty?) end