single_cov 2.1.0 → 2.2.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 -6
- 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: 12be958e8135fecd7c8e8dc446b97cae5dd0a7d1397c33ea851cffdeb7389ee0
|
|
4
|
+
data.tar.gz: 315153f27ef5c680a52584c95e28d96904b10c3c9a094d5e19b06ebac66dbfc1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e3c97161e9ef85134dd6456b5e4ee75c0c9f0c5fe238f64bb5fbf9b9551e3773833f00ace1f567e4071e33f95d0b85fb79d0841765e1b2ddac83cd9a70ada3a9
|
|
7
|
+
data.tar.gz: 3bbf1d85f580c4affb6672c5d8b5ac4523b896379b282146484d7199ff9fb79263c96b692b22edd47b5bdd32269a3ac547ea67e4b48d38d32e5ff4956519406b
|
data/lib/single_cov/version.rb
CHANGED
data/lib/single_cov.rb
CHANGED
|
@@ -5,6 +5,9 @@ module SingleCov
|
|
|
5
5
|
RAILS_APP_FOLDERS = ["models", "serializers", "helpers", "controllers", "mailers", "views", "jobs", "channels"]
|
|
6
6
|
UNCOVERED_COMMENT_MARKER = /#.*uncovered/
|
|
7
7
|
NOCOV_MARKER = /^\s*#\s*:nocov:/ # see https://github.com/simplecov-ruby/simplecov/blob/00376ea2f29ce7a7355b7c2d7d094b666b57cb9b/lib/simplecov/lines_classifier.rb#L16
|
|
8
|
+
SIMPLECOV_DISABLE_MARKER = /#\s*simplecov:disable\b/ # see https://github.com/simplecov-ruby/simplecov/blob/main/docs/Configuration.md#ignoringskipping-code
|
|
9
|
+
SIMPLECOV_DISABLE_BLOCK_MARKER = /^\s*#\s*simplecov:disable\b/
|
|
10
|
+
SIMPLECOV_ENABLE_BLOCK_MARKER = /^\s*#\s*simplecov:enable\b/
|
|
8
11
|
PREFIXES_TO_IGNORE = [] # things to not prefix with lib/ etc
|
|
9
12
|
|
|
10
13
|
class << self
|
|
@@ -43,7 +46,9 @@ module SingleCov
|
|
|
43
46
|
content = File.readlines("#{root}/#{file}")
|
|
44
47
|
nocov_lines_nums = nocov_line_numbers(content)
|
|
45
48
|
uncovered.reject! do |line_start, _, _, _, _|
|
|
46
|
-
content[line_start - 1]
|
|
49
|
+
line = content[line_start - 1]
|
|
50
|
+
line.match?(UNCOVERED_COMMENT_MARKER) ||
|
|
51
|
+
line.match?(SIMPLECOV_DISABLE_MARKER) || # inline, block markers are comments and never uncovered
|
|
47
52
|
nocov_lines_nums.include?(line_start)
|
|
48
53
|
end
|
|
49
54
|
next if uncovered.size == expected_uncovered
|
|
@@ -218,14 +223,24 @@ module SingleCov
|
|
|
218
223
|
Dir["#{root}/#{pattern}"].map! { |f| f.sub("#{root}/", '') }
|
|
219
224
|
end
|
|
220
225
|
|
|
221
|
-
# @returns [Integer] 1-based line numbers that are inside :nocov: blocks
|
|
226
|
+
# @returns [Integer] 1-based line numbers that are inside :nocov: or simplecov:disable blocks
|
|
227
|
+
# categories (line/branch/method) are ignored, every disable ignores lines and branches
|
|
228
|
+
# unclosed simplecov:disable runs until end of file, like simplecov
|
|
222
229
|
def nocov_line_numbers(content)
|
|
223
|
-
|
|
230
|
+
nocov = false
|
|
231
|
+
disabled = false
|
|
224
232
|
content.each_with_index.filter_map do |line, index|
|
|
233
|
+
# marker lines themselves cannot be uncovered since they are only comments
|
|
225
234
|
if line.match?(NOCOV_MARKER)
|
|
226
|
-
|
|
227
|
-
nil
|
|
228
|
-
elsif
|
|
235
|
+
nocov = !nocov # toggle
|
|
236
|
+
nil
|
|
237
|
+
elsif line.match?(SIMPLECOV_DISABLE_BLOCK_MARKER)
|
|
238
|
+
disabled = true
|
|
239
|
+
nil
|
|
240
|
+
elsif line.match?(SIMPLECOV_ENABLE_BLOCK_MARKER)
|
|
241
|
+
disabled = false
|
|
242
|
+
nil
|
|
243
|
+
elsif nocov || disabled
|
|
229
244
|
index + 1
|
|
230
245
|
end
|
|
231
246
|
end
|