single_cov 2.0.0 → 2.1.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 +17 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 03abb741a629409eca737e84185cbd61c34a24a65fdb5b4c381d295f00690eed
|
|
4
|
+
data.tar.gz: fee46d0a03e4812f372c375745ff9a02229292bc1c153e028ee7dc46691edfb0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 52da7209346a1ec927241e0db7390d664ef155a6146642e0895964cbcaa7c6e704ee6dc027591032fcb4727546543de60aa68ddd57f9b7e5f8879b9c98169a73
|
|
7
|
+
data.tar.gz: 3f0ae6f966cb07c608efd71cc8b87787c7506363c8bf2e43c4e334cf88b51122f56d2ad56864afc302b7158339eb4c5f3d8935f8a924c3132e43ab216604f700
|
data/lib/single_cov/version.rb
CHANGED
data/lib/single_cov.rb
CHANGED
|
@@ -4,6 +4,7 @@ module SingleCov
|
|
|
4
4
|
MAX_OUTPUT = Integer(ENV["SINGLE_COV_MAX_OUTPUT"] || "40")
|
|
5
5
|
RAILS_APP_FOLDERS = ["models", "serializers", "helpers", "controllers", "mailers", "views", "jobs", "channels"]
|
|
6
6
|
UNCOVERED_COMMENT_MARKER = /#.*uncovered/
|
|
7
|
+
NOCOV_MARKER = /^\s*#\s*:nocov:/ # see https://github.com/simplecov-ruby/simplecov/blob/00376ea2f29ce7a7355b7c2d7d094b666b57cb9b/lib/simplecov/lines_classifier.rb#L16
|
|
7
8
|
PREFIXES_TO_IGNORE = [] # things to not prefix with lib/ etc
|
|
8
9
|
|
|
9
10
|
class << self
|
|
@@ -40,8 +41,10 @@ module SingleCov
|
|
|
40
41
|
# ignore lines that are marked as uncovered via comments
|
|
41
42
|
# TODO: warn when using uncovered but the section is indeed covered
|
|
42
43
|
content = File.readlines("#{root}/#{file}")
|
|
44
|
+
nocov_lines_nums = nocov_line_numbers(content)
|
|
43
45
|
uncovered.reject! do |line_start, _, _, _, _|
|
|
44
|
-
content[line_start - 1].match?(UNCOVERED_COMMENT_MARKER)
|
|
46
|
+
content[line_start - 1].match?(UNCOVERED_COMMENT_MARKER) ||
|
|
47
|
+
nocov_lines_nums.include?(line_start)
|
|
45
48
|
end
|
|
46
49
|
next if uncovered.size == expected_uncovered
|
|
47
50
|
|
|
@@ -215,6 +218,19 @@ module SingleCov
|
|
|
215
218
|
Dir["#{root}/#{pattern}"].map! { |f| f.sub("#{root}/", '') }
|
|
216
219
|
end
|
|
217
220
|
|
|
221
|
+
# @returns [Integer] 1-based line numbers that are inside :nocov: blocks
|
|
222
|
+
def nocov_line_numbers(content)
|
|
223
|
+
inside = false
|
|
224
|
+
content.each_with_index.filter_map do |line, index|
|
|
225
|
+
if line.match?(NOCOV_MARKER)
|
|
226
|
+
inside = !inside # toggle
|
|
227
|
+
nil # line itself cannot be uncovered since it is only a comment
|
|
228
|
+
elsif inside
|
|
229
|
+
index + 1
|
|
230
|
+
end
|
|
231
|
+
end
|
|
232
|
+
end
|
|
233
|
+
|
|
218
234
|
def indexes(list, find)
|
|
219
235
|
list.each_with_index.filter_map { |v, i| i if v == find }
|
|
220
236
|
end
|