undercover 0.7.2 → 0.7.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7f341b6d38bd4e04ea3c1a24d16b3bc579687aa56346324a84bcc371f457bf89
4
- data.tar.gz: 28e44ac1b1ff7238a27d4cadfcca432a17435dffcf64ddb885123260050e2788
3
+ metadata.gz: b415f8a7947dbd35f4e15bb97a14f54c5384a89a2362d5bd26767ea233505ad6
4
+ data.tar.gz: b196b2c82dec2a3914d8ba6255b488b7dcd5c26ccf82a9672ff63c61ee4dbcca
5
5
  SHA512:
6
- metadata.gz: dc3018cc8b775516dd88f54ce3b01a1fb74e0ba0f45603ec95a73bab8ff5d927ad75db135ed9bedc5739c352fc1d3012568a1fb96ccb21b3d0feede37202a025
7
- data.tar.gz: 2533bf76c0d0492ca6478912e1050789e83444566c29c0e6e3907c2506189a5b528f92bac77f86874d81a44eac82a8d6d7a8a22982a144a0347050e2450959ce
6
+ metadata.gz: a9641af92eec955168c06ee73fcba81525a443e7eabdc44304dc6b17e25d98f469461ddc80db4c325d469ef45a4ce3387954863161dff4faa7963b0c3f8da40c
7
+ data.tar.gz: fe32c17ed7508581e96dc908eb50579e692f95f1956cd68d72c2c20a961047f12eccaafabae9892a9f1506dd5847218e90d15971696d2e3d9879c104fc105dd7
@@ -18,7 +18,7 @@ jobs:
18
18
  run: |
19
19
  gem install bundler undercover --no-doc
20
20
  bundle install --jobs 4 --retry 3
21
- bundle exec rake
21
+ rake
22
22
  - name: undercover (local)
23
23
  run: |
24
24
  git fetch --update-head-ok origin master:master
data/.tool-versions CHANGED
@@ -1,2 +1,2 @@
1
1
  ruby 3.4.2
2
- nodejs 20.12.2
2
+ nodejs v24.4.0
data/CHANGELOG.md CHANGED
@@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ # [0.7.3] - 2025-07-13
10
+
11
+ ### Fixed
12
+ - Improve Options#parse with glob braces support, strip quotes properly from .undercover config files
13
+ - Fix Result#coverage_f to support ignored branches
14
+ - Fix error parsing JSON coverage with branch coverage disabled ([#231](https://github.com/grodowski/undercover/issues/231))
15
+ - Fixed NoMethodError and Errno::ENOENT that were occurring when coverage report doesn't exist ([#232](https://github.com/grodowski/undercover/issues/232))
16
+
9
17
  # [0.7.2] - 2025-07-07
10
18
 
11
19
  ### Fixed
@@ -172,7 +180,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
172
180
  ### Added
173
181
  - First release of `undercover` 🎉
174
182
 
175
- [Unreleased]: https://github.com/grodowski/undercover/compare/v0.7.2...HEAD
183
+ [Unreleased]: https://github.com/grodowski/undercover/compare/v0.7.3...HEAD
184
+ [0.7.3]: https://github.com/grodowski/undercover/compare/v0.7.2...v0.7.3
176
185
  [0.7.2]: https://github.com/grodowski/undercover/compare/v0.7.1...v0.7.2
177
186
  [0.7.1]: https://github.com/grodowski/undercover/compare/v0.7.0...v0.7.1
178
187
  [0.7.0]: https://github.com/grodowski/undercover/compare/v0.6.6...v0.7.0
data/README.md CHANGED
@@ -73,8 +73,6 @@ If you're upgrading from an older version of undercover that used LCOV, you can
73
73
  ```ruby
74
74
  # Gemfile
75
75
  group :test do
76
- gem 'simplecov'
77
- gem 'simplecov_json_formatter'
78
76
  gem 'undercover'
79
77
  end
80
78
 
@@ -22,9 +22,29 @@ module Undercover
22
22
  end
23
23
 
24
24
  def self.run_report(opts)
25
+ coverage_path = opts.simplecov_resultset || opts.lcov
26
+ return handle_missing_coverage_path(opts) if coverage_path.nil?
27
+ return handle_missing_file(coverage_path) unless File.exist?(coverage_path)
28
+
25
29
  report = Undercover::Report.new(changeset(opts), opts).build
30
+ handle_report_validation(report, coverage_path)
31
+ end
32
+
33
+ def self.handle_missing_coverage_path(opts)
34
+ puts Rainbow('❌ ERROR: No coverage report found. Checked default paths:').red
35
+ puts Rainbow(' - ./coverage/coverage.json (SimpleCov)').red
36
+ puts Rainbow(" - ./coverage/lcov/#{Pathname.new(File.expand_path(opts.path)).split.last}.lcov (LCOV)").red
37
+ puts Rainbow('Set a custom path with --lcov or --simplecov option').red
38
+ 1
39
+ end
40
+
41
+ def self.handle_missing_file(coverage_path)
42
+ puts Rainbow("❌ ERROR: Coverage report not found at: #{coverage_path}").red
43
+ 1
44
+ end
26
45
 
27
- error = report.validate(opts.simplecov_resultset || opts.lcov)
46
+ def self.handle_report_validation(report, coverage_path)
47
+ error = report.validate(coverage_path)
28
48
  if error
29
49
  puts(WARNINGS_TO_S[error])
30
50
  return 0 if error == :no_changes
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'optparse'
4
4
  require 'pathname'
5
+ require 'shellwords'
5
6
 
6
7
  module Undercover
7
8
  class Options # rubocop:disable Metrics/ClassLength
@@ -104,13 +105,26 @@ module Undercover
104
105
  def args_from_options_file(path)
105
106
  return [] unless File.exist?(path)
106
107
 
107
- File.read(path).split('\n').flat_map(&:split)
108
+ File.read(path).split("\n").flat_map { parse_line(_1) }
108
109
  end
109
110
 
110
111
  def project_options_file
111
112
  './.undercover'
112
113
  end
113
114
 
115
+ def parse_line(line)
116
+ line = line.strip
117
+ return [] if line.empty? || line.start_with?('#')
118
+
119
+ Shellwords.split(line)
120
+ end
121
+
122
+ def split_comma_separated_with_braces(input)
123
+ return [] if input.empty?
124
+
125
+ input.split(/,(?![^{]*})/).map(&:strip) # split on commas that are not inside braces
126
+ end
127
+
114
128
  def lcov_path_option(parser)
115
129
  parser.on('-l', '--lcov path', 'LCOV report file path') do |path|
116
130
  self.lcov = path
@@ -175,12 +189,12 @@ module Undercover
175
189
  desc = 'Include files matching specified glob patterns (comma separated). ' \
176
190
  "Defaults to '#{DEFAULT_FILE_INCLUDE_GLOBS.join(',')}'"
177
191
  parser.on('-f', '--include-files globs', desc) do |comma_separated_globs|
178
- self.glob_allow_filters = comma_separated_globs.strip.split(',')
192
+ self.glob_allow_filters = split_comma_separated_with_braces(comma_separated_globs)
179
193
  end
180
194
 
181
195
  desc = 'Skip files matching specified glob patterns (comma separated). Empty by default.'
182
196
  parser.on('-x', '--exclude-files globs', desc) do |comma_separated_globs|
183
- self.glob_reject_filters = comma_separated_globs.strip.split(',')
197
+ self.glob_reject_filters = split_comma_separated_with_braces(comma_separated_globs)
184
198
  end
185
199
  end
186
200
  end
@@ -67,7 +67,7 @@ module Undercover
67
67
 
68
68
  lines[ln] = 1 unless lines.key?(ln)
69
69
  if branch_cov
70
- lines[ln] = 0 if branch_cov.zero?
70
+ lines[ln] = 0 if branch_cov != 'ignored' && branch_cov.zero?
71
71
  elsif block_or_line_cov.zero?
72
72
  lines[ln] = 0
73
73
  end
@@ -35,6 +35,8 @@ module Undercover
35
35
  lines = source_file['lines'].map.with_index do |line_coverage, idx|
36
36
  [idx + 1, line_coverage] if line_coverage
37
37
  end.compact
38
+ return lines unless source_file['branches']
39
+
38
40
  branch_idx = 0
39
41
  branches = source_file['branches'].map do |branch|
40
42
  branch_idx += 1
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Undercover
4
- VERSION = '0.7.2'
4
+ # :nocov:
5
+ VERSION = '0.7.3'
6
+ # :nocov:
5
7
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: undercover
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Grodowski
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-07-07 00:00:00.000000000 Z
10
+ date: 2025-07-13 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: base64