undercover 0.7.0 → 0.7.4

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: 440dce283cf6e85e2f59930af7e1c25f40fa1b2f2d67ba881d03435dcd206787
4
- data.tar.gz: 04fc58376332676fb2ba14571510bd55529fa26ca6b5c5377691c0f91032f394
3
+ metadata.gz: fb439eb426932d432434081cf9e17cce9b19b90a85c71b6a4c173d20cceb9392
4
+ data.tar.gz: a2703dd7d19a18f943dd3fdaebc34faf23cc995b1cc94b673756f1b5142cf046
5
5
  SHA512:
6
- metadata.gz: b59a9e99fd2dea093b43a4cba70f64f2c10490c42c7ccf1fe7ed74a943daba3e4f960cbabff9e6fc6da2f97fb863ea75511d2d2335d9cff8d44f9f4217829017
7
- data.tar.gz: 42721ec8490eb12828a2afc31578bc9747a6ae45ed99b90abcefe71bdb652de1331153a0cb24bec5a12cb4615594482052347f6a19547d286ca175fa7fe568e3
6
+ metadata.gz: 034ff6bd2826c4826b06780bd874e28c04c8fbcb0fcde85a5c0a1dd8901e4f5d2ebfe6c149b828c0fcf28fd4064f14ef122f69c763f59170b62d99941281d44b
7
+ data.tar.gz: 114c9a9873fb75c17a3bfe79612bfe8d2891cd2d2b2dd68f8253d49f3529def86bca607d4774d1f113ade2fd8eb2d6d5d55e53d4b47b4a5464c3a6075eb2da3b
@@ -18,11 +18,11 @@ 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
25
- undercover --compare master
25
+ undercover --simplecov coverage/undercover_coverage.json --compare master
26
26
  - uses: actions/upload-artifact@v4
27
27
  with:
28
28
  name: undercover-${{ matrix.ruby }}-coverage
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,24 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ # [0.7.4] - 2025-07-13
10
+
11
+ ### Fixed
12
+ - Fix `fnmatch` for `FilterSet` to support glob braces (sets) in `--include-files` and `--exclude-files`
13
+
14
+ # [0.7.3] - 2025-07-13
15
+
16
+ ### Fixed
17
+ - Improve Options#parse with glob braces support, strip quotes properly from .undercover config files
18
+ - Fix Result#coverage_f to support ignored branches
19
+ - Fix error parsing JSON coverage with branch coverage disabled ([#231](https://github.com/grodowski/undercover/issues/231))
20
+ - Fixed NoMethodError and Errno::ENOENT that were occurring when coverage report doesn't exist ([#232](https://github.com/grodowski/undercover/issues/232))
21
+
22
+ # [0.7.2] - 2025-07-07
23
+
24
+ ### Fixed
25
+ - Resolved errors when .lcov files doesn't exist using `--lcov` CLI flag and `guess_lcov_path`
26
+
9
27
  # [0.7.0] - 2025-07-03
10
28
 
11
29
  ### Added
@@ -167,7 +185,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
167
185
  ### Added
168
186
  - First release of `undercover` 🎉
169
187
 
170
- [Unreleased]: https://github.com/grodowski/undercover/compare/v0.7.0...HEAD
188
+ [Unreleased]: https://github.com/grodowski/undercover/compare/v0.7.4...HEAD
189
+ [0.7.4]: https://github.com/grodowski/undercover/compare/v0.7.3...v0.7.4
190
+ [0.7.3]: https://github.com/grodowski/undercover/compare/v0.7.2...v0.7.3
191
+ [0.7.2]: https://github.com/grodowski/undercover/compare/v0.7.1...v0.7.2
192
+ [0.7.1]: https://github.com/grodowski/undercover/compare/v0.7.0...v0.7.1
171
193
  [0.7.0]: https://github.com/grodowski/undercover/compare/v0.6.6...v0.7.0
172
194
  [0.6.6]: https://github.com/grodowski/undercover/compare/v0.6.5...0.6.6
173
195
  [0.6.5]: https://github.com/grodowski/undercover/compare/v0.6.4...0.6.5
data/Gemfile CHANGED
@@ -10,8 +10,8 @@ gem 'pry'
10
10
  gem 'rake', '~> 13.0'
11
11
  gem 'rspec', '~> 3.0'
12
12
  gem 'rubocop'
13
+ gem 'ruby-lsp-rspec', require: false
13
14
  gem 'simplecov'
14
15
  gem 'simplecov-html'
15
16
  gem 'simplecov_json_formatter'
16
- gem 'simplecov-lcov'
17
17
  gem 'timecop'
data/README.md CHANGED
@@ -49,8 +49,8 @@ end
49
49
  require 'simplecov'
50
50
  require 'undercover/simplecov_formatter'
51
51
 
52
- # optional, will default to coverage.json
53
- SimpleCov::Formatter::Undercover.output_filename = 'my_project_coverage.json'
52
+ # optional, the filename defaults to `coverage.json` and is automatically recognised by the gem
53
+ # SimpleCov::Formatter::Undercover.output_filename = 'my_project_coverage.json'
54
54
  SimpleCov.formatter = SimpleCov::Formatter::Undercover
55
55
 
56
56
  SimpleCov.start do
@@ -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
@@ -10,7 +10,7 @@ module Undercover
10
10
  end
11
11
 
12
12
  def include?(filepath)
13
- fnmatch = proc { |glob| File.fnmatch(glob, filepath) }
13
+ fnmatch = proc { |glob| File.fnmatch(glob, filepath, File::FNM_EXTGLOB) }
14
14
  allow_filters.any?(fnmatch) && reject_filters.none?(fnmatch)
15
15
  end
16
16
  end
@@ -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
@@ -167,19 +181,20 @@ module Undercover
167
181
 
168
182
  def guess_lcov_path
169
183
  cwd = Pathname.new(File.expand_path(path))
170
- self.lcov = File.join(cwd, 'coverage', 'lcov', "#{cwd.split.last}.lcov")
184
+ try_path = File.join(cwd, 'coverage', 'lcov', "#{cwd.split.last}.lcov")
185
+ self.lcov = try_path if File.exist?(try_path)
171
186
  end
172
187
 
173
188
  def file_filters(parser)
174
189
  desc = 'Include files matching specified glob patterns (comma separated). ' \
175
190
  "Defaults to '#{DEFAULT_FILE_INCLUDE_GLOBS.join(',')}'"
176
191
  parser.on('-f', '--include-files globs', desc) do |comma_separated_globs|
177
- self.glob_allow_filters = comma_separated_globs.strip.split(',')
192
+ self.glob_allow_filters = split_comma_separated_with_braces(comma_separated_globs)
178
193
  end
179
194
 
180
195
  desc = 'Skip files matching specified glob patterns (comma separated). Empty by default.'
181
196
  parser.on('-x', '--exclude-files globs', desc) do |comma_separated_globs|
182
- self.glob_reject_filters = comma_separated_globs.strip.split(',')
197
+ self.glob_reject_filters = split_comma_separated_with_braces(comma_separated_globs)
183
198
  end
184
199
  end
185
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,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Undercover
4
- VERSION = '0.7.0'
4
+ VERSION = '0.7.4'
5
5
  end
data/lib/undercover.rb CHANGED
@@ -39,7 +39,7 @@ module Undercover
39
39
  if opts.simplecov_resultset
40
40
  @simplecov_resultset = SimplecovResultAdapter.parse(File.open(opts.simplecov_resultset), opts)
41
41
  end
42
- @lcov = LcovParser.parse(File.open(opts.lcov), opts)
42
+ @lcov = LcovParser.parse(File.open(opts.lcov), opts) if opts.lcov
43
43
 
44
44
  @code_dir = opts.path
45
45
  @changeset = changeset
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.0
4
+ version: 0.7.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Grodowski
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-07-03 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