single_cov 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d9013c1ed2b97cce637e61b99eaa10065168043c
4
- data.tar.gz: e38fa0e5148d10bf3e597365f127c214f68aa48a
3
+ metadata.gz: c0559494539f0d0ca9209b84bde674198d89a56e
4
+ data.tar.gz: 2ce03aecd293040fea661925982345c06a11fa4d
5
5
  SHA512:
6
- metadata.gz: e47ba2fa0586dbee6b63a7a1deb0d810e7fbfb722b42cee290750507de9bf441b95f21f0dd53b58d38a8715b9320fa79387561ad93ac0fb3e50f0c3aaa0b75e9
7
- data.tar.gz: 181ff29f4d94703556fee5eaf2fcb6eacb0fdb590296684f00580ca74be7239fda452451e1e726cc2745068a0154bde54f60a19a3fd73d731d85a135d24852c7
6
+ metadata.gz: 37e9d7ad51bf85e3e405fb6f0f8f614eeb917a3f5a9a23b5a202bba56d70792853dd9571747327d29a1c841aae80a2da38768f6959da593965281971d0ac9988
7
+ data.tar.gz: ff595bc8c38abc1562624b63ba413dbf60041c52f5c76fedae08d5b17f3bdf721503461a33ccb128c3fc219406989681b8de0dc640e6fbd71b88b6496004dd15
@@ -1,3 +1,3 @@
1
1
  module SingleCov
2
- VERSION = "0.8.1"
2
+ VERSION = "0.8.2"
3
3
  end
data/lib/single_cov.rb CHANGED
@@ -20,15 +20,17 @@ module SingleCov
20
20
  def all_covered?(result)
21
21
  errors = COVERAGES.map do |file, expected_uncovered|
22
22
  if coverage = result["#{root}/#{file}"]
23
- lines = (coverage.is_a?(Hash) ? coverage.fetch(:lines) : coverage)
24
- uncovered_lines = line_coverage(file, lines)
23
+ line_coverage = (coverage.is_a?(Hash) ? coverage.fetch(:lines) : coverage)
24
+ uncovered_lines = line_coverage.each_with_index.map { |c, i| i + 1 if c == 0 }.compact
25
25
 
26
- if branches = (coverage.is_a?(Hash) && coverage[:branches])
27
- uncovered_lines += branch_coverage(file, branches)
26
+ uncovered = uncovered_lines.map { |l| "#{file}:#{l}" }
27
+
28
+ if branch_coverage = (coverage.is_a?(Hash) && coverage[:branches])
29
+ uncovered += uncovered_branches(file, branch_coverage, uncovered_lines)
28
30
  end
29
31
 
30
- next if uncovered_lines.size == expected_uncovered
31
- warn_about_bad_coverage(file, expected_uncovered, uncovered_lines)
32
+ next if uncovered.size == expected_uncovered
33
+ warn_about_bad_coverage(file, expected_uncovered, uncovered)
32
34
  else
33
35
  warn_about_no_coverage(file)
34
36
  end
@@ -101,13 +103,11 @@ module SingleCov
101
103
 
102
104
  private
103
105
 
104
- def line_coverage(file, coverage)
105
- coverage.each_with_index.map { |c, i| "#{file}:#{i + 1}" if c == 0 }.compact
106
- end
107
-
108
- def branch_coverage(file, coverage)
106
+ def uncovered_branches(file, coverage, uncovered_lines)
109
107
  coverage.each_value.flat_map do |branch_part|
110
- branch_part.select { |_k, v| v == 0 }.map { |k, _| "#{file}:#{k[2]}:#{k[3]+1}-#{k[4]}:#{k[5]+1}" }
108
+ branch_part.
109
+ select { |k, v| v.zero? && !uncovered_lines.include?(k[2]) }.
110
+ map { |k, _| "#{file}:#{k[2]}:#{k[3]+1}-#{k[4]}:#{k[5]+1}" }
111
111
  end
112
112
  end
113
113
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: single_cov
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser