lib/undercover/result.rb in undercover-0.4.0 vs lib/undercover/result.rb in undercover-0.4.1

- old
+ new

@@ -37,23 +37,25 @@ end # Method `coverage_f` returns the total coverage of this Undercover::Result # as a % value, taking into account missing branches. Line coverage will be counted # as 0 if any branch is untested. - # rubocop:disable Metrics/AbcSize + # rubocop:disable Metrics/AbcSize, Metrics/MethodLength def coverage_f lines = {} coverage.each do |ln, block_or_line_cov, _, branch_cov| lines[ln] = 1 unless lines.key?(ln) if branch_cov lines[ln] = 0 if branch_cov.zero? elsif block_or_line_cov.zero? lines[ln] = 0 end end + return 1.0 if lines.keys.size.zero? + (lines.values.sum.to_f / lines.keys.size).round(4) end - # rubocop:enable Metrics/AbcSize + # rubocop:enable Metrics/AbcSize, Metrics/MethodLength # TODO: create a formatter interface instead and add some tests. # TODO: re-enable rubocops # rubocop:disable Metrics/MethodLength, Metrics/AbcSize #