uncov 0.5.0 → 0.6.1

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: 328d5a3a593abb320621afee6841e28c19be46fd4ea1092ae52d6ef513131469
4
- data.tar.gz: ba6658737c8230c2f90dd045a568c478dbee86d782d57c5c75e9f0d9303eb796
3
+ metadata.gz: 2f557524930fea642ca504cc2bfccfc99c7b865b930d42edcbbd76f01ec8013a
4
+ data.tar.gz: 5522f0f4b1c899e48c0b4f5ff7cc78a69005adc36d648f1f554a1778c9045eb4
5
5
  SHA512:
6
- metadata.gz: abba73e5527b9f48108ecd90757036af35f4dd4f9a8b2c2399e7e9c9c804a5d99195bcc0f6d9117583f5f07e9efa2e94db15ccd3b3f3829c09629dcc9bcac57e
7
- data.tar.gz: fdb66c5ff19eb0c3bcacb136147a3d3493ed44400602c071137b91fdc1edacbef6ef6fe13663aa05ae24c9cd68ac773b95080466aed1e4026de6b52a3bcf0a2b
6
+ metadata.gz: 1ea2690f56426f9c50f1d9fa05597cbf86e3c67b3eff3ecbafbcb05b8c1901588b845bfd6e14798dae35355410ff68df2305073883d556cb17c5b6a66f9734c4
7
+ data.tar.gz: 71abb30813bf499aeb08f7126fc19b2d765645df8e7e4704c006083dedcb37f270401d098dee557ef345da5c72aac43494aa65c6a02d95af28c17d5b7b2b7166
data/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## 2025-05-31: [v0.6.1](https://github.com/mpapis/uncov/releases/tag/v0.6.1)
4
+
5
+ ### Patch
6
+
7
+ - [#63](https://github.com/mpapis/uncov/pull/63): Improve filesystem performance, by [@mpapis](https://github.com/mpapis)
8
+
9
+
10
+ ## 2025-05-26: [v0.6.0](https://github.com/mpapis/uncov/releases/tag/v0.6.0)
11
+
12
+ ### Minor
13
+
14
+ - [#47](https://github.com/mpapis/uncov/pull/47): Extensible with plugins, by [@mpapis](https://github.com/mpapis)
15
+ - [#56](https://github.com/mpapis/uncov/pull/56): Add Simplecov and FileSystem filters, by [@mpapis](https://github.com/mpapis)
16
+
17
+ ### Patch
18
+
19
+ - [#59](https://github.com/mpapis/uncov/pull/59): Simplify git rev-parse target, by [@mpapis](https://github.com/mpapis)
20
+
21
+
3
22
  ## 2025-05-12: [v0.5.0](https://github.com/mpapis/uncov/releases/tag/v0.5.0)
4
23
 
5
24
  ### Minor
data/CONTRIBUTING.md CHANGED
@@ -12,7 +12,7 @@ All security vulnerabilities will be promptly addressed.
12
12
 
13
13
  ## Development
14
14
  - `docker-compose build uncov` to (re-)build dev container,
15
- - `docker-compose run uncov` to enter dev container,
15
+ - `docker-compose run --rm uncov` to enter dev container,
16
16
  - `bundle` to install dependencies and uncov,
17
17
  - `rake` to run lint, test and uncov - **precheck** before opening PR,
18
18
  - `uncov` to test manually
data/README.md CHANGED
@@ -13,6 +13,8 @@ Uncov uses `git diff` to detect changes and `simplecov` reports to detect uncove
13
13
  - Identify changed Ruby files
14
14
  - Run tests automatically for (changed) relevant files
15
15
  - Print report of uncovered lines in (changed) files
16
+ - Print report of covered :nocov: lines in (changed) files
17
+ - Extensible with gem plugins
16
18
 
17
19
 
18
20
  ## Installation
@@ -36,8 +38,8 @@ uncov
36
38
  $ uncov -h
37
39
  Usage: uncov [options]
38
40
  -t, --target TARGET Target branch for comparison, default: "HEAD"
39
- -r, --report FILTER Report filter to generate file/line list, one_of: "diff_files", "diff_lines"(default), "git_files", "nocov_lines"
40
- -o, --output-format FORMAT Output format, one_of: "terminal"(default)
41
+ -r, --report FILTER Report filter to generate file/line list, one_of: "DiffFiles", "DiffLines"(default), "FileSystem", "GitFiles", "NocovLines", "Simplecov"
42
+ -o, --output-format FORMAT Output format, one_of: "Terminal"(default)
41
43
  -C, --context LINES_NUMBER Additional lines context in output, default: 1
42
44
  --test-command COMMAND Test command that generates SimpleCov, default: "COVERAGE=true bundle exec rake test"
43
45
  --simplecov-file PATH SimpleCov results file, default: "autodetect"
@@ -49,10 +51,12 @@ Usage: uncov [options]
49
51
  -h, --help Print this help
50
52
 
51
53
  Report FILTERs:
52
- diff_files - Report missing coverage on added/changed files in the git diff
53
- diff_lines - Report missing coverage on added lines in the git diff
54
- git_files - Report missing coverage on files tracked with git
55
- nocov_lines - Report coverage on nocov lines, requires one or both: --nocov-ignore / --nocov-covered
54
+ DiffFiles - Report missing coverage on added/changed files in the git diff
55
+ DiffLines - Report missing coverage on added lines in the git diff
56
+ FileSystem - Report missing coverage on file system
57
+ GitFiles - Report missing coverage on files tracked with git
58
+ NocovLines - Report coverage on nocov lines, requires one or both: --nocov-ignore / --nocov-covered
59
+ Simplecov - Report missing coverage on files tracked with simplecov
56
60
 
57
61
  Report FILTERs take NOTICE:
58
62
  git*/diff* - filters will not consider new files unless added to the git index with `git add`.
@@ -62,7 +66,7 @@ nocov* - filters/flags only work with coverage/.resultset.json SimpleCov fi
62
66
  FN_GLOB: shell filename globing -> https://ruby-doc.org/core-3.1.1/File.html#method-c-fnmatch
63
67
  in bash: `shopt -s extglob dotglob globstar` and test with `ls {app,lib}/**/*.rb`
64
68
 
65
- uncov 0.5.0 by Michal Papis <mpapis@gmail.com>
69
+ uncov 0.6.1 by Michal Papis <mpapis@gmail.com>
66
70
  ```
67
71
 
68
72
 
@@ -79,6 +83,16 @@ COVERAGE=1 rspec
79
83
  ```
80
84
 
81
85
 
86
+ ## Plugins
87
+ Uncov uses [pluginator](https://github.com/rvm/pluginator) to load plugins.
88
+
89
+ See [lib/plugins/uncov](lib/plugins/uncov) for default plugins.
90
+
91
+ To create your own plugin, create a gem with a `lib/plugins/uncov/...` structure - same as uncov has,
92
+ the plugins will be loaded automatically.
93
+
94
+ When you use uncov from a Gemfile then the new gam has to be added there too.
95
+
82
96
  ## Using in CI
83
97
  `uncov` uses itself to check new missing code coverage [.github/workflows/ci.yml](.github/workflows/ci.yml),
84
98
  no need to set minimal, always get better.
@@ -13,15 +13,16 @@ class Uncov::Formatter::Terminal
13
13
  end
14
14
 
15
15
  def output
16
- puts "Found #{report.display_files.size} files with uncovered changes:".yellow
16
+ return puts 'No files to report.'.green if report.files.empty?
17
+ return puts "All changed files(#{report.files.count}) have 100% test coverage!".green unless report.trigger?
18
+
19
+ output_header
17
20
  output_files
18
- puts
19
- puts format(
20
- 'Overall coverage of changes: %<coverage>.2f%% (%<covered_lines>d / %<relevant_lines>d)',
21
- coverage: report.coverage,
22
- covered_lines: report.covered_lines_count,
23
- relevant_lines: report.relevant_lines_count
24
- ).yellow
21
+ output_summary
22
+ end
23
+
24
+ def output_header
25
+ puts "Files with uncovered changes: (#{report.display_files.size} / #{report.files.count})".yellow
25
26
  end
26
27
 
27
28
  def output_files
@@ -70,4 +71,14 @@ class Uncov::Formatter::Terminal
70
71
  def number_length(file_coverage)
71
72
  file_coverage.display_lines.last.number.to_s.length
72
73
  end
74
+
75
+ def output_summary
76
+ puts
77
+ puts format(
78
+ 'Overall coverage of changes: %<coverage>.2f%% (%<covered_lines>d / %<relevant_lines>d)',
79
+ coverage: report.coverage,
80
+ covered_lines: report.covered_lines_count,
81
+ relevant_lines: report.relevant_lines_count
82
+ ).yellow
83
+ end
73
84
  end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ # report only files lines from the diff
4
+ module Uncov::Report::Filters::DiffFiles
5
+ class << self
6
+ def description = 'Report missing coverage on added/changed files in the git diff'
7
+ def simplecov_trigger = :git_diff
8
+
9
+ def files(finder)
10
+ finder.git_diff_files.file_names.map do |file_name|
11
+ Uncov::Report::File.new(
12
+ file_name:,
13
+ git: true,
14
+ lines: lines(finder, file_name)
15
+ )
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ def lines(finder, file_name)
22
+ lines_hash = file_lines(finder, file_name)
23
+ Uncov::Report::Context.add_context(finder, file_name, lines_hash)
24
+ lines_hash.sort.to_h.values
25
+ end
26
+
27
+ def file_lines(finder, file_name)
28
+ finder.file_system_files.lines(file_name).keys.to_h do |line_number|
29
+ [line_number, finder.build_line(file_name, line_number)]
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ # report only files lines from the diff
4
+ module Uncov::Report::Filters::DiffLines
5
+ class << self
6
+ def description = 'Report missing coverage on added lines in the git diff'
7
+ def simplecov_trigger = :git_diff
8
+
9
+ def files(finder)
10
+ finder.git_diff_files.file_names.map do |file_name|
11
+ Uncov::Report::File.new(
12
+ file_name:,
13
+ git: true,
14
+ lines: lines(finder, file_name)
15
+ )
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ def lines(finder, file_name)
22
+ lines_hash = git_diff_files_lines(finder, file_name)
23
+ Uncov::Report::Context.add_context(finder, file_name, lines_hash)
24
+ lines_hash.sort.to_h.values
25
+ end
26
+
27
+ def git_diff_files_lines(finder, file_name)
28
+ finder.git_diff_files.lines(file_name).keys.to_h do |line_number|
29
+ [line_number, finder.build_line(file_name, line_number)]
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ # report all files lines from the file system
4
+ module Uncov::Report::Filters::FileSystem
5
+ class << self
6
+ def description = 'Report missing coverage on file system'
7
+ def simplecov_trigger = :file_system
8
+
9
+ def files(finder)
10
+ finder.file_system_files.file_names.map do |file_name|
11
+ Uncov::Report::File.new(
12
+ file_name:,
13
+ git: finder.git_files.file?(file_name),
14
+ lines: lines(finder, file_name)
15
+ )
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ def lines(finder, file_name)
22
+ lines_hash = file_lines(finder, file_name)
23
+ Uncov::Report::Context.add_context(finder, file_name, lines_hash)
24
+ lines_hash.sort.to_h.values
25
+ end
26
+
27
+ def file_lines(finder, file_name)
28
+ finder.file_system_files.lines(file_name).keys.to_h do |line_number|
29
+ [line_number, finder.build_line(file_name, line_number)]
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ # report only files lines from the diff
4
+ module Uncov::Report::Filters::GitFiles
5
+ class << self
6
+ def description = 'Report missing coverage on files tracked with git'
7
+ def simplecov_trigger = :git
8
+
9
+ def files(finder)
10
+ finder.git_files.file_names.map do |file_name|
11
+ Uncov::Report::File.new(
12
+ file_name:,
13
+ git: true,
14
+ lines: lines(finder, file_name)
15
+ )
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ def lines(finder, file_name)
22
+ lines_hash = file_lines(finder, file_name)
23
+ Uncov::Report::Context.add_context(finder, file_name, lines_hash)
24
+ lines_hash.sort.to_h.values
25
+ end
26
+
27
+ def file_lines(finder, file_name)
28
+ finder.file_system_files.lines(file_name).keys.to_h do |line_number|
29
+ [line_number, finder.build_line(file_name, line_number)]
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ # report only files lines from the diff
4
+ module Uncov::Report::Filters::NocovLines
5
+ class << self
6
+ def description = 'Report coverage on nocov lines, requires one or both: --nocov-ignore / --nocov-covered'
7
+ def simplecov_trigger = :file_system
8
+
9
+ def files(finder)
10
+ finder.nocov_files.file_names.filter_map do |file_name|
11
+ next if finder.nocov_files.lines(file_name).empty?
12
+
13
+ Uncov::Report::File.new(
14
+ file_name:,
15
+ git: finder.git_files.file?(file_name),
16
+ lines: lines(finder, file_name)
17
+ )
18
+ end
19
+ end
20
+
21
+ private
22
+
23
+ def lines(finder, file_name)
24
+ lines_hash = nocov_files_lines(finder, file_name)
25
+ Uncov::Report::Context.add_context(finder, file_name, lines_hash)
26
+ lines_hash.sort.to_h.values
27
+ end
28
+
29
+ def nocov_files_lines(finder, file_name)
30
+ finder.nocov_files.lines(file_name).keys.to_h do |line_number|
31
+ [line_number, finder.build_line(file_name, line_number)]
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ # report only files lines from the simplecov
4
+ module Uncov::Report::Filters::Simplecov
5
+ class << self
6
+ def description = 'Report missing coverage on files tracked with simplecov'
7
+ def simplecov_trigger = :file_system
8
+
9
+ def files(finder)
10
+ finder.simplecov_files.file_names.map do |file_name|
11
+ Uncov::Report::File.new(
12
+ file_name:,
13
+ git: finder.git_files.file?(file_name),
14
+ lines: lines(finder, file_name)
15
+ )
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ def lines(finder, file_name)
22
+ lines_hash = file_lines(finder, file_name)
23
+ Uncov::Report::Context.add_context(finder, file_name, lines_hash)
24
+ lines_hash.sort.to_h.values
25
+ end
26
+
27
+ def file_lines(finder, file_name)
28
+ finder.file_system_files.lines(file_name).keys.to_h do |line_number|
29
+ [line_number, finder.build_line(file_name, line_number)]
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'formatter'
4
- require_relative 'report/generator'
4
+ require_relative 'report/filters'
5
5
 
6
6
  # handle configuration for uncov
7
7
  class Uncov::Configuration
@@ -21,9 +21,9 @@ class Uncov::Configuration
21
21
 
22
22
  option 'target', 'Target branch for comparison', options: ['-t', '--target TARGET'], default: 'HEAD'
23
23
  option 'report', 'Report filter to generate file/line list',
24
- options: ['-r', '--report FILTER'], default: 'diff_lines', allowed_values: -> { Uncov::Report::Generator.filters.keys }
24
+ options: ['-r', '--report FILTER'], default: 'DiffLines', allowed_values: -> { Uncov::Report::Filters.filters.keys }
25
25
  option 'output_format', 'Output format',
26
- options: ['-o', '--output-format FORMAT'], default: 'terminal', allowed_values: -> { Uncov::Formatter.formats }
26
+ options: ['-o', '--output-format FORMAT'], default: 'Terminal', allowed_values: -> { Uncov::Formatter.formatters.keys }
27
27
  option 'context', 'Additional lines context in output',
28
28
  options: ['-C', '--context LINES_NUMBER'], default: 1, value_parse: lambda(&:to_i)
29
29
  option 'test_command', 'Test command that generates SimpleCov',
@@ -101,9 +101,9 @@ class Uncov::Configuration
101
101
  end
102
102
 
103
103
  def footer_extras_types
104
- report_type_length = Uncov::Report::Generator.filters.keys.map(&:length).max
105
- Uncov::Report::Generator.filters.map do |name, config|
106
- "#{name.ljust(report_type_length)} - #{config[:description]}"
104
+ report_type_length = Uncov::Report::Filters.filters.keys.map(&:length).max
105
+ Uncov::Report::Filters.filters.map do |name, filter|
106
+ format("%#{report_type_length}s - %s", name, filter.description)
107
107
  end.join("\n")
108
108
  end
109
109
 
@@ -4,25 +4,33 @@
4
4
  class Uncov::Finder::FileSystem
5
5
  include Uncov::Cache
6
6
 
7
- def files
8
- all_files.to_h do |file_name|
9
- [file_name, lines(file_name)]
7
+ def code_files
8
+ cache(:code_files) do
9
+ list_files(Uncov.configuration.relevant_files).to_h do |file_name|
10
+ [file_name, read_lines(file_name)]
11
+ end
10
12
  end
11
13
  end
12
14
 
15
+ def simplecov_trigger_files
16
+ code_files.keys + test_files
17
+ end
18
+
13
19
  private
14
20
 
15
- def all_files
16
- Dir.glob(Uncov.configuration.relevant_files, Uncov::Configuration::FILE_MATCH_FLAGS).select { |f| File.file?(f) }
21
+ def test_files
22
+ cache(:test_files) do
23
+ list_files(Uncov.configuration.relevant_tests)
24
+ end
17
25
  end
18
26
 
19
- def lines(file_name)
20
- cache(file_name) do
21
- read_lines(file_name)
22
- end
27
+ def list_files(glob)
28
+ Dir.glob(glob, Uncov::Configuration::FILE_MATCH_FLAGS).select { |f| File.file?(f) }
23
29
  end
24
30
 
25
31
  def read_lines(file_name)
26
- File.readlines(file_name).each_with_index.to_h { |line, line_index| [line_index + 1, line.rstrip] }
32
+ lines = {}
33
+ File.foreach(file_name).with_index(1) { |line, idx| lines[idx] = line.chomp }
34
+ lines
27
35
  end
28
36
  end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ # wrap finder results to have the same interface as finder
4
+ class Uncov::Finder::Files
5
+ attr_reader :files
6
+
7
+ def initialize(files)
8
+ @files = files
9
+ end
10
+
11
+ def file?(file_name)
12
+ @files.key?(file_name)
13
+ end
14
+
15
+ def file_names
16
+ @files.keys
17
+ end
18
+
19
+ def lines(file_name)
20
+ @files[file_name] || {}
21
+ end
22
+
23
+ def line(file_name, line_number)
24
+ @files.dig(file_name, line_number)
25
+ end
26
+
27
+ def line?(file_name, line_number)
28
+ lines(file_name)&.key?(line_number)
29
+ end
30
+ end
@@ -14,16 +14,20 @@ class Uncov::Finder::Git
14
14
  end
15
15
  end
16
16
 
17
+ def simplecov_trigger_files
18
+ code_files.keys + test_files
19
+ end
20
+
21
+ private
22
+
17
23
  def test_files
18
24
  cache(:test_files) do
19
- all_file_names.filter_map do |file_name|
20
- [file_name, true] if relevant_test_file?(file_name)
21
- end.to_h
25
+ all_file_names.select do |file_name|
26
+ relevant_test_file?(file_name)
27
+ end
22
28
  end
23
29
  end
24
30
 
25
- private
26
-
27
31
  def all_file_names
28
32
  cache(:all_files) do
29
33
  open_repo.ls_files.keys
@@ -15,16 +15,20 @@ class Uncov::Finder::GitDiff
15
15
  end
16
16
  end
17
17
 
18
+ def simplecov_trigger_files
19
+ code_files.keys + test_files
20
+ end
21
+
22
+ private
23
+
18
24
  def test_files
19
25
  cache(:test_files) do
20
26
  all_files_diff.filter_map do |file_diff|
21
- [file_diff.path, true] if relevant_test_file?(file_diff.path) && File.exist?(file_diff.path)
22
- end.to_h
27
+ file_diff.path if relevant_test_file?(file_diff.path) && File.exist?(file_diff.path)
28
+ end
23
29
  end
24
30
  end
25
31
 
26
- private
27
-
28
32
  def all_files_diff
29
33
  cache(:all_files) do
30
34
  git_diff
@@ -43,15 +47,10 @@ class Uncov::Finder::GitDiff
43
47
 
44
48
  def git_diff
45
49
  repo = open_repo
46
- # TODO: resolve the need for verifying the target with git gem
47
- git_target = repo.lib.send(:command, 'rev-parse', '--verify', target)
50
+ git_target = repo.rev_parse(target)
48
51
  repo.diff(git_target)
49
- rescue Git::FailedError => e
50
- raise Uncov::NotGitObjectError, target if e.result.status.exitstatus == 128 && e.result.stderr.include?('fatal: Needed a single revision')
51
-
52
- # :nocov: when we find a failing example, we can test it
53
- raise
54
- # :nocov:
52
+ rescue Git::FailedError
53
+ raise Uncov::NotGitObjectError, target
55
54
  end
56
55
 
57
56
  def target
@@ -1,24 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # collect nocov information from files
4
- class Uncov::Finder::NoCov
5
- include Uncov::Cache
6
-
4
+ class Uncov::Finder::Nocov
7
5
  def files(all_files)
8
- all_files.to_h do |file_name, lines|
9
- [file_name, nocov_lines(file_name, lines)]
6
+ all_files.files.transform_values do |lines|
7
+ nocov_lines(lines)
10
8
  end
11
9
  end
12
10
 
13
11
  private
14
12
 
15
- def nocov_lines(file_name, lines)
16
- cache(file_name) do
17
- read_nocov(lines)
18
- end
19
- end
20
-
21
- def read_nocov(lines)
13
+ def nocov_lines(lines)
22
14
  nocov = false
23
15
  lines.filter_map do |number, line|
24
16
  line_nocov = line.strip.start_with?('# :nocov:')
@@ -3,7 +3,7 @@
3
3
  require 'json'
4
4
 
5
5
  # collect coverage information, regenerates report if any trigger_files are newer then the report
6
- module Uncov::Finder::SimpleCov
6
+ module Uncov::Finder::Simplecov
7
7
  class << self
8
8
  def files(trigger_files)
9
9
  regenerate_report if requires_regeneration?(trigger_files)
@@ -67,9 +67,9 @@ module Uncov::Finder::SimpleCov
67
67
  def raise_on_missing_coverage_path!
68
68
  return if coverage_path && File.exist?(coverage_path)
69
69
 
70
- raise Uncov::AutodetectSimpleCovPathError if Uncov.configuration.simplecov_file == 'autodetect'
70
+ raise Uncov::AutodetectSimplecovPathError if Uncov.configuration.simplecov_file == 'autodetect'
71
71
 
72
- raise Uncov::MissingSimpleCovReport, coverage_path
72
+ raise Uncov::MissingSimplecovReport, coverage_path
73
73
  end
74
74
  end
75
75
  end
data/lib/uncov/finder.rb CHANGED
@@ -4,94 +4,79 @@
4
4
  class Uncov::Finder
5
5
  include Uncov::Cache
6
6
 
7
- def initialize(simple_cov_trigger) = @simple_cov_trigger = simple_cov_trigger
8
- def git_file?(file_name) = git_files[file_name]
9
- def git_file_names = git_files.keys
10
- def git_diff_file_names = git_diff_files.keys
11
- def git_diff_file_lines(file_name) = git_diff_files[file_name]
12
- def git_diff_file_line?(file_name, line_number) = git_diff_files[file_name]&.key?(line_number)
13
- def file_system_file_names = file_system_files.keys
14
- def file_system_file_line(file_name, line_number) = file_system_files[file_name]&.dig(line_number)
15
- def file_system_file_lines(file_name) = file_system_files[file_name]
16
- def no_cov_file_names = no_cov_files.keys
17
- def no_cov_file_lines(file_name) = no_cov_files[file_name]
18
- def no_cov_file_line?(file_name, line_number) = no_cov_files[file_name]&.dig(line_number)
19
- def simple_cov_file_line?(file_name, line_number) = simple_cov_files.dig(file_name, line_number)
20
-
21
- def debug
22
- {
23
- git_files:,
24
- git_test_files:,
25
- git_diff_files:,
26
- git_diff_test_files:,
27
- file_system_files:,
28
- no_cov_files:,
29
- simple_cov_files:
30
- }
7
+ def initialize(simplecov_trigger)
8
+ @simplecov_trigger = simplecov_trigger
31
9
  end
32
10
 
33
- private
34
-
35
- attr_reader :simple_cov_trigger
36
-
37
- def git_files
38
- git_finder.code_files
11
+ def build_line(file_name, line_number, context: false)
12
+ Uncov::Report::File::Line.new(
13
+ number: line_number,
14
+ content: file_system_files.line(file_name, line_number),
15
+ nocov: nocov_files.line(file_name, line_number),
16
+ simplecov: simplecov_files.line(file_name, line_number),
17
+ git_diff: git_diff_files.line?(file_name, line_number),
18
+ context:
19
+ )
39
20
  end
40
21
 
41
- def git_test_files
42
- git_finder.test_files
22
+ def file_system_files
23
+ Uncov::Finder::Files.new(file_system_finder.code_files)
43
24
  end
44
25
 
45
- def git_finder
46
- cache(:git_finder) do
47
- Uncov::Finder::Git.new
48
- end
26
+ def git_files
27
+ Uncov::Finder::Files.new(git_finder.code_files)
49
28
  end
50
29
 
51
30
  def git_diff_files
52
- git_diff_finder.code_files
31
+ Uncov::Finder::Files.new(git_diff_finder.code_files)
53
32
  end
54
33
 
55
- def git_diff_test_files
56
- git_diff_finder.test_files
34
+ def nocov_files
35
+ cache(:nocov_files) do
36
+ Uncov::Finder::Files.new(Uncov::Finder::Nocov.new.files(file_system_files))
37
+ end
57
38
  end
58
39
 
59
- def git_diff_finder
60
- cache(:git_diff_finder) do
61
- Uncov::Finder::GitDiff.new
40
+ def simplecov_files
41
+ cache(:simplecov_files) do
42
+ Uncov::Finder::Files.new(Uncov::Finder::Simplecov.files(simplecov_trigger_files))
62
43
  end
63
44
  end
64
45
 
65
- def file_system_files
66
- cache(:file_system_files) do
67
- Uncov::Finder::FileSystem.new.files
46
+ private
47
+
48
+ attr_reader :simplecov_trigger
49
+
50
+ def file_system_finder
51
+ cache(:file_system_finder) do
52
+ Uncov::Finder::FileSystem.new
68
53
  end
69
54
  end
70
55
 
71
- def no_cov_files
72
- cache(:no_cov_files) do
73
- Uncov::Finder::NoCov.new.files(file_system_files)
56
+ def git_finder
57
+ cache(:git_finder) do
58
+ Uncov::Finder::Git.new
74
59
  end
75
60
  end
76
61
 
77
- def simple_cov_files
78
- cache(:simple_cov_files) do
79
- Uncov::Finder::SimpleCov.files(simple_cov_trigger_files)
62
+ def git_diff_finder
63
+ cache(:git_diff_finder) do
64
+ Uncov::Finder::GitDiff.new
80
65
  end
81
66
  end
82
67
 
83
- def simple_cov_trigger_files
84
- case simple_cov_trigger
68
+ def simplecov_trigger_files
69
+ case simplecov_trigger
85
70
  when :git
86
- git_file_names + git_test_files.keys
71
+ git_finder
87
72
  when :git_diff
88
- git_diff_file_names + git_diff_test_files.keys
73
+ git_diff_finder
89
74
  when :file_system
90
- file_system_file_names
75
+ file_system_finder
91
76
  else
92
77
  # :nocov:
93
- raise Uncov::UnsupportedSimpleCovTriggerError, simple_cov_trigger
78
+ raise Uncov::UnsupportedSimplecovTriggerError, simplecov_trigger
94
79
  # :nocov:
95
- end
80
+ end.simplecov_trigger_files
96
81
  end
97
82
  end
@@ -3,27 +3,14 @@
3
3
  # chose formater to output the report
4
4
  module Uncov::Formatter
5
5
  class << self
6
- def formats = %w[terminal]
7
-
8
- def output(report)
9
- if report.files.empty?
10
- return puts 'No files to report.'.green
11
- elsif !report.trigger?
12
- return puts "All changed files(#{report.files.count}) have 100% test coverage!".green
13
- end
14
-
15
- output_report(report)
6
+ def formatters
7
+ @formatters ||= Uncov.plugins.plugins_map('formatter')
16
8
  end
17
9
 
18
- private
10
+ def output(report)
11
+ raise Uncov::UnsupportedFormatterError, Uncov.configuration.output_format unless formatters.key?(Uncov.configuration.output_format)
19
12
 
20
- def output_report(report)
21
- case Uncov.configuration.output_format
22
- when 'terminal'
23
- Uncov::Formatter::Terminal.new(report).output
24
- else
25
- raise Uncov::UnsupportedFormatterError, Uncov.configuration.output_format
26
- end
13
+ formatters[Uncov.configuration.output_format].new(report).output
27
14
  end
28
15
  end
29
16
  end
@@ -4,6 +4,20 @@
4
4
  # @return [Integer] only added context lines matching all_line_numbers and not in important_line_numbers
5
5
  module Uncov::Report::Context
6
6
  class << self
7
+ def add_context(finder, file_name, lines_hash)
8
+ return if Uncov.configuration.context.zero?
9
+
10
+ line_numbers =
11
+ lines_hash.filter_map do |line_number, line|
12
+ line_number if line.trigger?
13
+ end
14
+ all_line_numbers = finder.file_system_files.lines(file_name).keys
15
+ context_line_numbers = calculate(all_line_numbers, line_numbers, Uncov.configuration.context)
16
+ context_line_numbers.each do |line_number|
17
+ mark_context_line(finder, file_name, lines_hash, line_number)
18
+ end
19
+ end
20
+
7
21
  def calculate(all_line_numbers, important_line_number, context)
8
22
  context_line_numbers = {}
9
23
  important_line_number.each do |line_number|
@@ -14,5 +28,15 @@ module Uncov::Report::Context
14
28
  end
15
29
  (context_line_numbers.keys.sort & all_line_numbers) - important_line_number
16
30
  end
31
+
32
+ private
33
+
34
+ def mark_context_line(finder, file_name, lines_hash, line_number)
35
+ if lines_hash.key?(line_number)
36
+ lines_hash[line_number].context = true
37
+ else
38
+ lines_hash[line_number] = finder.build_line(file_name, line_number, context: true)
39
+ end
40
+ end
17
41
  end
18
42
  end
@@ -1,28 +1,28 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # represents file line coverage in report
4
- class Uncov::Report::File::Line < Uncov::Struct.new(:number, :content, :simple_cov, :no_cov, :context, :git_diff)
5
- def no_cov
4
+ class Uncov::Report::File::Line < Uncov::Struct.new(:number, :content, :simplecov, :nocov, :context, :git_diff)
5
+ def nocov
6
6
  return false if Uncov.configuration.nocov_ignore
7
7
 
8
- self[:no_cov]
8
+ self[:nocov]
9
9
  end
10
10
 
11
11
  def uncov?
12
- simple_cov == false && !no_cov
12
+ simplecov == false && !nocov
13
13
  end
14
14
 
15
15
  def nocov_covered?
16
16
  # :nocov
17
- Uncov.configuration.nocov_covered && simple_cov == true && self[:no_cov]
17
+ Uncov.configuration.nocov_covered && simplecov == true && self[:nocov]
18
18
  # :nocov
19
19
  end
20
20
 
21
21
  def covered?
22
- return false if Uncov.configuration.nocov_ignore && self[:no_cov]
22
+ return false if Uncov.configuration.nocov_ignore && self[:nocov]
23
23
 
24
- (simple_cov == true && !no_cov) ||
25
- (Uncov.configuration.nocov_covered && simple_cov == false && self[:no_cov])
24
+ (simplecov == true && !nocov) ||
25
+ (Uncov.configuration.nocov_covered && simplecov == false && self[:nocov])
26
26
  end
27
27
 
28
28
  def trigger?
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'pluginator'
4
+ require_relative '../report'
5
+
6
+ # generate report files and lines for the configured report type
7
+ module Uncov::Report::Filters
8
+ class << self
9
+ def filters
10
+ @filters ||= Uncov.plugins.plugins_map('report/filters')
11
+ end
12
+
13
+ def files
14
+ raise Uncov::UnsupportedReportTypeError, Uncov.configuration.report unless filters.key?(Uncov.configuration.report)
15
+
16
+ filter = filters[Uncov.configuration.report]
17
+ filter.files(Uncov::Finder.new(filter.simplecov_trigger))
18
+ end
19
+ end
20
+ end
data/lib/uncov/report.rb CHANGED
@@ -9,7 +9,7 @@ class Uncov::Report < Uncov::Struct.new(:files)
9
9
 
10
10
  class << self
11
11
  def generate
12
- new(files: Uncov::Report::Generator.generate)
12
+ new(files: Uncov::Report::Filters.files)
13
13
  end
14
14
  end
15
15
 
data/lib/uncov/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uncov
4
- VERSION = '0.5.0'
4
+ VERSION = '0.6.1'
5
5
  end
data/lib/uncov.rb CHANGED
@@ -21,6 +21,10 @@ module Uncov
21
21
  def configuration_reset!
22
22
  @configuration = Configuration.new
23
23
  end
24
+
25
+ def plugins
26
+ @plugins ||= Pluginator.find('uncov', extends: ['plugins_map'])
27
+ end
24
28
  end
25
29
 
26
30
  class Error < StandardError
@@ -30,7 +34,7 @@ module Uncov
30
34
  class ConfigurationError < Error; end
31
35
  class GitError < Error; end
32
36
  class FinderError < Error; end
33
- class SimpleCovError < FinderError; end
37
+ class SimplecovError < FinderError; end
34
38
  class FormatterError < Error; end
35
39
  class ReportError < Error; end
36
40
  class OptionValueNotAllowed < ConfigurationError; end
@@ -49,25 +53,25 @@ module Uncov
49
53
  def message = "Git target #{target_branch.inspect} not found locally"
50
54
  end
51
55
 
52
- class UnsupportedSimpleCovTriggerError < FinderError
56
+ class UnsupportedSimplecovTriggerError < FinderError
53
57
  attr_reader :trigger
54
58
 
55
59
  def initialize(trigger) = @trigger = trigger
56
- def message = "#{trigger.inspect} is not a supported simple_cov_trigger type"
60
+ def message = "#{trigger.inspect} is not a supported simplecov_trigger type"
57
61
  end
58
62
 
59
- class FailedToGenerateReport < SimpleCovError
63
+ class FailedToGenerateReport < SimplecovError
60
64
  def message = cause.message
61
65
  end
62
66
 
63
- class MissingSimpleCovReport < SimpleCovError
67
+ class MissingSimplecovReport < SimplecovError
64
68
  attr_reader :coverage_path
65
69
 
66
70
  def initialize(coverage_path) = @coverage_path = coverage_path
67
71
  def message = "SimpleCov results not found at #{coverage_path.inspect}"
68
72
  end
69
73
 
70
- class AutodetectSimpleCovPathError < SimpleCovError
74
+ class AutodetectSimplecovPathError < SimplecovError
71
75
  def message = 'Could not autodetect coverage report path'
72
76
  end
73
77
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uncov
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michał Papis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-05-12 00:00:00.000000000 Z
11
+ date: 2025-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '3.0'
33
+ version: '3.1'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '3.0'
40
+ version: '3.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: git_diff_parser
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pluginator
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.5'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.5'
83
97
  description: uncov compares your current branch with a target branch, identifies changed
84
98
  files, and reports on test coverage for those changes
85
99
  email:
@@ -95,6 +109,13 @@ files:
95
109
  - PHILOSOPHY.md
96
110
  - README.md
97
111
  - bin/uncov
112
+ - lib/plugins/uncov/formatter/terminal.rb
113
+ - lib/plugins/uncov/report/filters/diff_files.rb
114
+ - lib/plugins/uncov/report/filters/diff_lines.rb
115
+ - lib/plugins/uncov/report/filters/file_system.rb
116
+ - lib/plugins/uncov/report/filters/git_files.rb
117
+ - lib/plugins/uncov/report/filters/nocov_lines.rb
118
+ - lib/plugins/uncov/report/filters/simplecov.rb
98
119
  - lib/uncov.rb
99
120
  - lib/uncov/cache.rb
100
121
  - lib/uncov/cli.rb
@@ -102,22 +123,18 @@ files:
102
123
  - lib/uncov/configuration/option.rb
103
124
  - lib/uncov/finder.rb
104
125
  - lib/uncov/finder/file_system.rb
126
+ - lib/uncov/finder/files.rb
105
127
  - lib/uncov/finder/git.rb
106
128
  - lib/uncov/finder/git_base.rb
107
129
  - lib/uncov/finder/git_diff.rb
108
- - lib/uncov/finder/no_cov.rb
109
- - lib/uncov/finder/simple_cov.rb
130
+ - lib/uncov/finder/nocov.rb
131
+ - lib/uncov/finder/simplecov.rb
110
132
  - lib/uncov/formatter.rb
111
- - lib/uncov/formatter/terminal.rb
112
133
  - lib/uncov/report.rb
113
134
  - lib/uncov/report/context.rb
114
135
  - lib/uncov/report/file.rb
115
136
  - lib/uncov/report/file/line.rb
116
- - lib/uncov/report/generator.rb
117
- - lib/uncov/report/generator/diff_files.rb
118
- - lib/uncov/report/generator/diff_lines.rb
119
- - lib/uncov/report/generator/git_files.rb
120
- - lib/uncov/report/generator/nocov_lines.rb
137
+ - lib/uncov/report/filters.rb
121
138
  - lib/uncov/struct.rb
122
139
  - lib/uncov/version.rb
123
140
  homepage: https://github.com/mpapis/uncov
@@ -1,57 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # report only files lines from the diff
4
- module Uncov::Report::Generator::DiffFiles
5
- Uncov::Report::Generator.register(self, :git_diff, 'Report missing coverage on added/changed files in the git diff')
6
-
7
- class << self
8
- def files(finder)
9
- finder.git_diff_file_names.map do |file_name|
10
- Uncov::Report::File.new(
11
- file_name:,
12
- git: true,
13
- lines: lines(finder, file_name)
14
- )
15
- end
16
- end
17
-
18
- private
19
-
20
- def lines(finder, file_name)
21
- lines_hash = file_lines(finder, file_name)
22
- add_context(lines_hash)
23
- lines_hash.sort.to_h.values
24
- end
25
-
26
- def file_lines(finder, file_name)
27
- finder.file_system_file_lines(file_name).to_h do |line_number, content|
28
- [line_number, new_line(finder, file_name, line_number, content)]
29
- end
30
- end
31
-
32
- def add_context(lines_hash)
33
- return if Uncov.configuration.context.zero?
34
-
35
- line_numbers =
36
- lines_hash.filter_map do |line_number, line|
37
- line_number if line.trigger?
38
- end
39
- all_line_numbers = lines_hash.keys
40
- context_line_numbers = Uncov::Report::Context.calculate(all_line_numbers, line_numbers, Uncov.configuration.context)
41
- context_line_numbers.each do |line_number|
42
- lines_hash[line_number].context = true
43
- end
44
- end
45
-
46
- def new_line(finder, file_name, line_number, content)
47
- Uncov::Report::File::Line.new(
48
- number: line_number,
49
- content:,
50
- no_cov: finder.no_cov_file_line?(file_name, line_number),
51
- simple_cov: finder.simple_cov_file_line?(file_name, line_number),
52
- git_diff: finder.git_diff_file_line?(file_name, line_number),
53
- context: false
54
- )
55
- end
56
- end
57
- end
@@ -1,65 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # report only files lines from the diff
4
- module Uncov::Report::Generator::DiffLines
5
- Uncov::Report::Generator.register(self, :git_diff, 'Report missing coverage on added lines in the git diff')
6
-
7
- class << self
8
- def files(finder)
9
- finder.git_diff_file_names.map do |file_name|
10
- Uncov::Report::File.new(
11
- file_name:,
12
- git: true,
13
- lines: lines(finder, file_name)
14
- )
15
- end
16
- end
17
-
18
- private
19
-
20
- def lines(finder, file_name)
21
- lines_hash = git_diff_files_lines(finder, file_name)
22
- add_context(finder, file_name, lines_hash)
23
- lines_hash.sort.to_h.values
24
- end
25
-
26
- def git_diff_files_lines(finder, file_name)
27
- finder.git_diff_file_lines(file_name).keys.to_h do |line_number|
28
- [line_number, new_line(finder, file_name, line_number)]
29
- end
30
- end
31
-
32
- def add_context(finder, file_name, lines_hash)
33
- return if Uncov.configuration.context.zero?
34
-
35
- line_numbers =
36
- lines_hash.filter_map do |line_number, line|
37
- line_number if line.trigger?
38
- end
39
- all_line_numbers = finder.file_system_file_lines(file_name).keys
40
- context_line_numbers = Uncov::Report::Context.calculate(all_line_numbers, line_numbers, Uncov.configuration.context)
41
- context_line_numbers.each do |line_number|
42
- context_line(finder, file_name, lines_hash, line_number)
43
- end
44
- end
45
-
46
- def context_line(finder, file_name, lines_hash, line_number)
47
- if lines_hash.key?(line_number)
48
- lines_hash[line_number].context = true
49
- else
50
- lines_hash[line_number] = new_line(finder, file_name, line_number, context: true)
51
- end
52
- end
53
-
54
- def new_line(finder, file_name, line_number, context: false)
55
- Uncov::Report::File::Line.new(
56
- number: line_number,
57
- content: finder.file_system_file_line(file_name, line_number),
58
- no_cov: finder.no_cov_file_line?(file_name, line_number),
59
- simple_cov: finder.simple_cov_file_line?(file_name, line_number),
60
- git_diff: finder.git_diff_file_line?(file_name, line_number),
61
- context:
62
- )
63
- end
64
- end
65
- end
@@ -1,57 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # report only files lines from the diff
4
- module Uncov::Report::Generator::GitFiles
5
- Uncov::Report::Generator.register(self, :git, 'Report missing coverage on files tracked with git')
6
-
7
- class << self
8
- def files(finder)
9
- finder.git_file_names.map do |file_name|
10
- Uncov::Report::File.new(
11
- file_name:,
12
- git: true,
13
- lines: lines(finder, file_name)
14
- )
15
- end
16
- end
17
-
18
- private
19
-
20
- def lines(finder, file_name)
21
- lines_hash = file_lines(finder, file_name)
22
- add_context(lines_hash)
23
- lines_hash.sort.to_h.values
24
- end
25
-
26
- def file_lines(finder, file_name)
27
- finder.file_system_file_lines(file_name).to_h do |line_number, content|
28
- [line_number, new_line(finder, file_name, line_number, content)]
29
- end
30
- end
31
-
32
- def add_context(lines_hash)
33
- return if Uncov.configuration.context.zero?
34
-
35
- line_numbers =
36
- lines_hash.filter_map do |line_number, line|
37
- line_number if line.trigger?
38
- end
39
- all_line_numbers = lines_hash.keys
40
- context_line_numbers = Uncov::Report::Context.calculate(all_line_numbers, line_numbers, Uncov.configuration.context)
41
- context_line_numbers.each do |line_number|
42
- lines_hash[line_number].context = true
43
- end
44
- end
45
-
46
- def new_line(finder, file_name, line_number, content)
47
- Uncov::Report::File::Line.new(
48
- number: line_number,
49
- content:,
50
- no_cov: finder.no_cov_file_line?(file_name, line_number),
51
- simple_cov: finder.simple_cov_file_line?(file_name, line_number),
52
- git_diff: finder.git_diff_file_line?(file_name, line_number),
53
- context: false
54
- )
55
- end
56
- end
57
- end
@@ -1,67 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # report only files lines from the diff
4
- module Uncov::Report::Generator::NocovLines
5
- Uncov::Report::Generator.register(self, :file_system, 'Report coverage on nocov lines, requires one or both: --nocov-ignore / --nocov-covered')
6
-
7
- class << self
8
- def files(finder)
9
- finder.no_cov_file_names.filter_map do |file_name|
10
- next if finder.no_cov_file_lines(file_name).empty?
11
-
12
- Uncov::Report::File.new(
13
- file_name:,
14
- git: finder.git_file?(file_name),
15
- lines: lines(finder, file_name)
16
- )
17
- end
18
- end
19
-
20
- private
21
-
22
- def lines(finder, file_name)
23
- lines_hash = nocov_files_lines(finder, file_name)
24
- add_context(finder, file_name, lines_hash)
25
- lines_hash.sort.to_h.values
26
- end
27
-
28
- def nocov_files_lines(finder, file_name)
29
- finder.no_cov_file_lines(file_name).keys.to_h do |line_number|
30
- [line_number, new_line(finder, file_name, line_number)]
31
- end
32
- end
33
-
34
- def add_context(finder, file_name, lines_hash)
35
- return if Uncov.configuration.context.zero?
36
-
37
- line_numbers =
38
- lines_hash.filter_map do |line_number, line|
39
- line_number if line.trigger?
40
- end
41
- all_line_numbers = finder.file_system_file_lines(file_name).keys
42
- context_line_numbers = Uncov::Report::Context.calculate(all_line_numbers, line_numbers, Uncov.configuration.context)
43
- context_line_numbers.each do |line_number|
44
- context_line(finder, file_name, lines_hash, line_number)
45
- end
46
- end
47
-
48
- def context_line(finder, file_name, lines_hash, line_number)
49
- if lines_hash.key?(line_number)
50
- lines_hash[line_number].context = true
51
- else
52
- lines_hash[line_number] = new_line(finder, file_name, line_number, context: true)
53
- end
54
- end
55
-
56
- def new_line(finder, file_name, line_number, context: false)
57
- Uncov::Report::File::Line.new(
58
- number: line_number,
59
- content: finder.file_system_file_line(file_name, line_number),
60
- no_cov: finder.no_cov_file_line?(file_name, line_number),
61
- simple_cov: finder.simple_cov_file_line?(file_name, line_number),
62
- git_diff: finder.git_diff_file_line?(file_name, line_number),
63
- context:
64
- )
65
- end
66
- end
67
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../report'
4
-
5
- # generate report files and lines for the configured report type
6
- module Uncov::Report::Generator
7
- class << self
8
- def filters
9
- @filters ||= {}
10
- end
11
-
12
- def register(generator_class, simple_cov_trigger, description)
13
- class_name = generator_class.to_s.split('::').last
14
- generator_name = class_name.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').gsub(/([a-z\d])([A-Z])/, '\1_\2').downcase
15
- filters[generator_name] = { generator_class:, simple_cov_trigger:, description: }
16
- end
17
-
18
- def generate
19
- raise Uncov::UnsupportedReportTypeError, Uncov.configuration.report unless filters.key?(Uncov.configuration.report)
20
-
21
- filters[Uncov.configuration.report] => { generator_class:, simple_cov_trigger: }
22
- generator_class.files(Uncov::Finder.new(simple_cov_trigger))
23
- end
24
- end
25
- end