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.
-
#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(lcov_report_path, code_dir, git_dir: '.git', compare: nil) ⇒ Report
constructor
TODO: pass merge base as cli argument add dependecy on “options” for all opts (dirs, git_dir, etc).
- #inspect ⇒ Object (also: #to_s)
Constructor Details
#initialize(lcov_report_path, code_dir, git_dir: '.git', compare: nil) ⇒ Report
TODO: pass merge base as cli argument add dependecy on “options” for all opts (dirs, git_dir, etc)
28 29 30 31 32 |
# File 'lib/undercover.rb', line 28 def initialize(lcov_report_path, code_dir, git_dir: '.git', compare: nil) @lcov = LcovParser.parse(File.open(lcov_report_path)) @changeset = Changeset.new(File.join(code_dir, git_dir), compare).update @results = Hash.new { |hsh, key| hsh[key] = [] } 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 |
#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
61 62 63 |
# File 'lib/undercover.rb', line 61 def all_results results.values.flatten end |
#build ⇒ Object
34 35 36 37 38 39 |
# File 'lib/undercover.rb', line 34 def build each_result_arg do |filename, coverage, imagen_node| results[filename] << 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
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/undercover.rb', line 43 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 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 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
65 66 67 |
# File 'lib/undercover.rb', line 65 def inspect "#<Undercover::Report:#{object_id} results: #{results.size}>" end |