Class: Undercover::Report
- Inherits:
-
Object
- Object
- Undercover::Report
- Extended by:
- Forwardable
- Defined in:
- lib/undercover.rb
Instance Attribute Summary collapse
-
#changeset ⇒ Object
readonly
Returns the value of attribute changeset.
-
#code_dir ⇒ Object
readonly
Returns the value of attribute code_dir.
-
#lcov ⇒ Object
readonly
Returns the value of attribute lcov.
-
#results ⇒ Object
readonly
Returns the value of attribute results.
Instance Method Summary collapse
-
#all_results ⇒ Object
rubocop:enable Metrics/MethodLength, Metrics/AbcSize.
- #build ⇒ Object
-
#build_warnings ⇒ Object
TODO: this is experimental and might be incorrect! rubocop:disable Metrics/MethodLength, Metrics/AbcSize.
-
#initialize(changeset, opts) ⇒ Report
constructor
Initializes a new Undercover::Report.
- #inspect ⇒ Object (also: #to_s)
Constructor Details
#initialize(changeset, opts) ⇒ Report
Initializes a new Undercover::Report
31 32 33 34 35 36 |
# File 'lib/undercover.rb', line 31 def initialize(changeset, opts) @lcov = LcovParser.parse(File.open(opts.lcov)) @code_dir = opts.path @changeset = changeset.update @results = {} end |
Instance Attribute Details
#changeset ⇒ Object (readonly)
Returns the value of attribute changeset.
22 23 24 |
# File 'lib/undercover.rb', line 22 def changeset @changeset end |
#code_dir ⇒ Object (readonly)
Returns the value of attribute code_dir.
22 23 24 |
# File 'lib/undercover.rb', line 22 def code_dir @code_dir end |
#lcov ⇒ Object (readonly)
Returns the value of attribute lcov.
22 23 24 |
# File 'lib/undercover.rb', line 22 def lcov @lcov end |
#results ⇒ Object (readonly)
Returns the value of attribute results.
22 23 24 |
# File 'lib/undercover.rb', line 22 def results @results end |
Instance Method Details
#all_results ⇒ Object
rubocop:enable Metrics/MethodLength, Metrics/AbcSize
75 76 77 |
# File 'lib/undercover.rb', line 75 def all_results results.values.flatten end |
#build ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/undercover.rb', line 38 def build each_result_arg do |filename, coverage, imagen_node| key = filename.gsub(/^\.\//, '') results[key] ||= [] results[key] << Result.new( imagen_node, coverage, filename ) end self end |
#build_warnings ⇒ Object
TODO: this is experimental and might be incorrect! rubocop:disable Metrics/MethodLength, Metrics/AbcSize
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/undercover.rb', line 51 def build_warnings flagged_results = Set.new changeset.each_changed_line do |filepath, line_no| dist_from_line_no = lambda do |res| return BigDecimal::INFINITY if line_no < res.first_line res_lines = res.first_line..res.last_line return BigDecimal::INFINITY unless res_lines.cover?(line_no) line_no - res.first_line end dist_from_line_no_sorter = lambda do |res1, res2| dist_from_line_no[res1] <=> dist_from_line_no[res2] end next unless results[filepath] res = results[filepath].min(&dist_from_line_no_sorter) flagged_results << res if res&.uncovered?(line_no) end flagged_results end |
#inspect ⇒ Object Also known as: to_s
79 80 81 |
# File 'lib/undercover.rb', line 79 def inspect "#<Undercover::Report:#{object_id} results: #{results.size}>" end |