single_cov 1.9.1 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/single_cov/version.rb +1 -1
- data/lib/single_cov.rb +21 -20
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d35277b97cbcabd001c11de169153d1eda320dfcfbd7ad516406ee811e623eb
|
4
|
+
data.tar.gz: c5d9fb7c34b7cb1a67a772a8ce870dbfc40cc6b1ae9ee859a951bbc3cbf93120
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64b8de808afd738fae4817c0701c12905882a4122ac50b53cc3e13694f78a831bcbaa433a7e45115682ef3ea2beefd7b59d2442872ad2ce11a82999007e3c6c7
|
7
|
+
data.tar.gz: 7637465f16cadc6a8beec088abd9fff899a3d9052617dd9c89d786ee24e565cb6fa8a8508a69407d63c013088aa11a3b765ac152198fc395460a490536525295
|
data/lib/single_cov/version.rb
CHANGED
data/lib/single_cov.rb
CHANGED
@@ -40,7 +40,7 @@ module SingleCov
|
|
40
40
|
# ignore lines that are marked as uncovered via comments
|
41
41
|
# TODO: warn when using uncovered but the section is indeed covered
|
42
42
|
content = File.readlines("#{root}/#{file}")
|
43
|
-
uncovered.reject! do |line_start, _, _, _|
|
43
|
+
uncovered.reject! do |line_start, _, _, _, _|
|
44
44
|
content[line_start - 1].match?(UNCOVERED_COMMENT_MARKER)
|
45
45
|
end
|
46
46
|
next if uncovered.size == expected_uncovered
|
@@ -146,18 +146,13 @@ module SingleCov
|
|
146
146
|
def uncovered(coverage)
|
147
147
|
return coverage unless coverage.is_a?(Hash) # just lines
|
148
148
|
|
149
|
-
|
150
|
-
uncovered_lines = coverage.fetch(:lines)
|
151
|
-
.each_with_index
|
152
|
-
.select { |c, _| c == 0 }
|
153
|
-
.map { |_, i| i + 1 }
|
154
|
-
.compact
|
155
|
-
|
149
|
+
uncovered_lines = indexes(coverage.fetch(:lines), 0).map! { |i| i + 1 }
|
156
150
|
uncovered_branches = uncovered_branches(coverage[:branches] || {})
|
157
|
-
uncovered_branches.reject! { |
|
151
|
+
uncovered_branches.reject! { |br| uncovered_lines.include?(br[0]) } # ignore branch when whole line is uncovered
|
158
152
|
|
153
|
+
# combine lines and branches while keeping them sorted
|
159
154
|
all = uncovered_lines.concat uncovered_branches
|
160
|
-
all.sort_by! { |line_start, char_start, _, _| [line_start, char_start || 0] } # branches are unsorted
|
155
|
+
all.sort_by! { |line_start, char_start, _, _, _| [line_start, char_start || 0] } # branches are unsorted
|
161
156
|
all
|
162
157
|
end
|
163
158
|
|
@@ -174,19 +169,21 @@ module SingleCov
|
|
174
169
|
(!defined?(@main_process_pid) || @main_process_pid == Process.pid)
|
175
170
|
end
|
176
171
|
|
172
|
+
# {[branch_id] => {[branch_part] => coverage}} --> uncovered location
|
177
173
|
def uncovered_branches(coverage)
|
178
|
-
|
179
|
-
sum = Hash.new(0)
|
174
|
+
sum = {}
|
180
175
|
coverage.each_value do |branch|
|
181
|
-
branch.
|
182
|
-
|
176
|
+
branch.filter_map do |part, c|
|
177
|
+
location = [part[2], part[3] + 1, part[4], part[5] + 1] # locations can be duplicated
|
178
|
+
type = part[0]
|
179
|
+
info = (sum[location] ||= [0, nil])
|
180
|
+
info[0] += c
|
181
|
+
info[1] = type if type == :else # only else is important to track since it often is not in the code
|
183
182
|
end
|
184
183
|
end
|
185
184
|
|
186
|
-
|
187
|
-
|
188
|
-
found.uniq!
|
189
|
-
found
|
185
|
+
# keep location and type of missing coverage
|
186
|
+
sum.filter_map { |k, v| k + [v[1]] if v[0] == 0 }
|
190
187
|
end
|
191
188
|
|
192
189
|
def default_tests
|
@@ -197,6 +194,10 @@ module SingleCov
|
|
197
194
|
Dir["#{root}/#{pattern}"].map! { |f| f.sub("#{root}/", '') }
|
198
195
|
end
|
199
196
|
|
197
|
+
def indexes(list, find)
|
198
|
+
list.each_with_index.filter_map { |v, i| i if v == find }
|
199
|
+
end
|
200
|
+
|
200
201
|
# do not ask for coverage when SimpleCov already does or it conflicts
|
201
202
|
def coverage_results
|
202
203
|
if defined?(SimpleCov) && (result = SimpleCov.instance_variable_get(:@result))
|
@@ -327,13 +328,13 @@ module SingleCov
|
|
327
328
|
[
|
328
329
|
"#{file} new uncovered lines introduced #{details}",
|
329
330
|
red("Lines missing coverage:"),
|
330
|
-
*uncovered.map do |line_start, char_start, line_end, char_end|
|
331
|
+
*uncovered.map do |line_start, char_start, line_end, char_end, type|
|
331
332
|
if char_start # branch coverage
|
332
333
|
if line_start == line_end
|
333
334
|
"#{file}:#{line_start}:#{char_start}-#{char_end}"
|
334
335
|
else # possibly unreachable since branches always seem to be on the same line
|
335
336
|
"#{file}:#{line_start}:#{char_start}-#{line_end}:#{char_end}"
|
336
|
-
end
|
337
|
+
end + (type ? " # #{type}" : "")
|
337
338
|
else
|
338
339
|
"#{file}:#{line_start}"
|
339
340
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: single_cov
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Grosser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: michael@grosser.it
|