simplecov 1.1.1 → 1.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.
Files changed (194) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +148 -5
  3. data/exe/simplecov +0 -3
  4. data/lib/minitest/simplecov_plugin.rb +12 -9
  5. data/lib/simplecov/atomic_file.rb +16 -19
  6. data/lib/simplecov/autostart.rb +5 -7
  7. data/lib/simplecov/baseline/parser.rb +58 -0
  8. data/lib/simplecov/baseline.rb +170 -0
  9. data/lib/simplecov/cli/affected/changed_files.rb +57 -0
  10. data/lib/simplecov/cli/affected/selection.rb +117 -0
  11. data/lib/simplecov/cli/affected.rb +148 -0
  12. data/lib/simplecov/cli/badge/svg.rb +70 -0
  13. data/lib/simplecov/cli/badge.rb +62 -0
  14. data/lib/simplecov/cli/clean.rb +23 -24
  15. data/lib/simplecov/cli/command_helpers.rb +55 -19
  16. data/lib/simplecov/cli/completions/scripts.rb +114 -0
  17. data/lib/simplecov/cli/completions.rb +83 -0
  18. data/lib/simplecov/cli/coverage.rb +25 -28
  19. data/lib/simplecov/cli/coverage_file.rb +58 -14
  20. data/lib/simplecov/cli/dead_code/output.rb +100 -0
  21. data/lib/simplecov/cli/dead_code.rb +139 -0
  22. data/lib/simplecov/cli/diff/output.rb +45 -0
  23. data/lib/simplecov/cli/diff.rb +35 -67
  24. data/lib/simplecov/cli/dotfile.rb +83 -38
  25. data/lib/simplecov/cli/git.rb +41 -0
  26. data/lib/simplecov/cli/history/output.rb +135 -0
  27. data/lib/simplecov/cli/history.rb +67 -0
  28. data/lib/simplecov/cli/merge.rb +34 -39
  29. data/lib/simplecov/cli/open.rb +12 -15
  30. data/lib/simplecov/cli/patch/changed_lines.rb +149 -0
  31. data/lib/simplecov/cli/patch/output.rb +135 -0
  32. data/lib/simplecov/cli/patch.rb +169 -0
  33. data/lib/simplecov/cli/ratchet/output.rb +44 -0
  34. data/lib/simplecov/cli/ratchet.rb +83 -0
  35. data/lib/simplecov/cli/report.rb +18 -24
  36. data/lib/simplecov/cli/run.rb +8 -9
  37. data/lib/simplecov/cli/serve/report_preparer.rb +7 -6
  38. data/lib/simplecov/cli/serve/static_file_handler.rb +62 -56
  39. data/lib/simplecov/cli/serve.rb +27 -24
  40. data/lib/simplecov/cli/show/annotator.rb +87 -0
  41. data/lib/simplecov/cli/show/sweep.rb +36 -0
  42. data/lib/simplecov/cli/show.rb +133 -0
  43. data/lib/simplecov/cli/status/facts.rb +87 -0
  44. data/lib/simplecov/cli/status.rb +93 -0
  45. data/lib/simplecov/cli/tests/redundancy.rb +78 -0
  46. data/lib/simplecov/cli/tests.rb +148 -0
  47. data/lib/simplecov/cli/uncovered/misses.rb +37 -0
  48. data/lib/simplecov/cli/uncovered.rb +70 -32
  49. data/lib/simplecov/cli/usage.rb +152 -0
  50. data/lib/simplecov/cli/watch/live_report.rb +73 -0
  51. data/lib/simplecov/cli/watch/narrator.rb +55 -0
  52. data/lib/simplecov/cli/watch/poller.rb +45 -0
  53. data/lib/simplecov/cli/watch/session.rb +134 -0
  54. data/lib/simplecov/cli/watch/test_plan.rb +43 -0
  55. data/lib/simplecov/cli/watch.rb +85 -0
  56. data/lib/simplecov/cli.rb +43 -92
  57. data/lib/simplecov/color.rb +19 -37
  58. data/lib/simplecov/combine/branches_combiner.rb +7 -31
  59. data/lib/simplecov/combine/coverage_accumulator.rb +49 -142
  60. data/lib/simplecov/combine/identity_interner.rb +10 -13
  61. data/lib/simplecov/combine/interned_counts.rb +7 -9
  62. data/lib/simplecov/combine/lines_combiner.rb +20 -44
  63. data/lib/simplecov/combine/methods_combiner.rb +9 -35
  64. data/lib/simplecov/combine/results_combiner.rb +4 -21
  65. data/lib/simplecov/combine.rb +0 -6
  66. data/lib/simplecov/command_guesser.rb +20 -34
  67. data/lib/simplecov/configuration/baseline.rb +31 -0
  68. data/lib/simplecov/configuration/coverage.rb +91 -79
  69. data/lib/simplecov/configuration/coverage_criteria.rb +43 -54
  70. data/lib/simplecov/configuration/deprecations.rb +21 -0
  71. data/lib/simplecov/configuration/eval_coverage.rb +6 -10
  72. data/lib/simplecov/configuration/filters.rb +40 -73
  73. data/lib/simplecov/configuration/formatting.rb +74 -83
  74. data/lib/simplecov/configuration/groups.rb +19 -13
  75. data/lib/simplecov/configuration/history.rb +44 -0
  76. data/lib/simplecov/configuration/ignored_entries.rb +31 -22
  77. data/lib/simplecov/configuration/merging.rb +94 -62
  78. data/lib/simplecov/configuration/missed_caps.rb +51 -0
  79. data/lib/simplecov/configuration/production.rb +23 -0
  80. data/lib/simplecov/configuration/test_tracking.rb +48 -0
  81. data/lib/simplecov/configuration/thresholds.rb +33 -62
  82. data/lib/simplecov/configuration/view_coverage.rb +38 -0
  83. data/lib/simplecov/configuration.rb +70 -76
  84. data/lib/simplecov/configuration_error.rb +5 -0
  85. data/lib/simplecov/context_map/union.rb +81 -0
  86. data/lib/simplecov/context_map.rb +187 -0
  87. data/lib/simplecov/coverage_json.rb +2 -5
  88. data/lib/simplecov/coverage_statistics.rb +14 -24
  89. data/lib/simplecov/coverage_violations.rb +157 -64
  90. data/lib/simplecov/current_run.rb +61 -0
  91. data/lib/simplecov/defaults.rb +4 -23
  92. data/lib/simplecov/deprecation.rb +45 -27
  93. data/lib/simplecov/directive.rb +46 -62
  94. data/lib/simplecov/exit_codes/baseline_check.rb +46 -0
  95. data/lib/simplecov/exit_codes/check.rb +17 -11
  96. data/lib/simplecov/exit_codes/exit_code_handling.rb +21 -8
  97. data/lib/simplecov/exit_codes/maximum_coverage_drop_check.rb +7 -10
  98. data/lib/simplecov/exit_codes/maximum_missed_check.rb +26 -0
  99. data/lib/simplecov/exit_codes/maximum_missed_per_file_check.rb +34 -0
  100. data/lib/simplecov/exit_codes/maximum_overall_coverage_check.rb +7 -12
  101. data/lib/simplecov/exit_codes/minimum_coverage_by_file_check.rb +11 -10
  102. data/lib/simplecov/exit_codes/minimum_coverage_by_group_check.rb +7 -9
  103. data/lib/simplecov/exit_codes/minimum_overall_coverage_check.rb +16 -17
  104. data/lib/simplecov/exit_codes.rb +16 -10
  105. data/lib/simplecov/exit_handling.rb +94 -59
  106. data/lib/simplecov/file_list.rb +20 -51
  107. data/lib/simplecov/filter.rb +43 -66
  108. data/lib/simplecov/formatter/base.rb +37 -55
  109. data/lib/simplecov/formatter/baseline_formatter.rb +98 -0
  110. data/lib/simplecov/formatter/coverage_json_writer.rb +29 -31
  111. data/lib/simplecov/formatter/html_formatter/public/index.html +15 -9
  112. data/lib/simplecov/formatter/html_formatter/viewer_data_validator.rb +74 -17
  113. data/lib/simplecov/formatter/html_formatter.rb +24 -41
  114. data/lib/simplecov/formatter/json_formatter/errors_formatter.rb +50 -16
  115. data/lib/simplecov/formatter/json_formatter/production_section_formatter.rb +48 -0
  116. data/lib/simplecov/formatter/json_formatter/result_hash_formatter.rb +43 -29
  117. data/lib/simplecov/formatter/json_formatter/source_file_formatter.rb +14 -10
  118. data/lib/simplecov/formatter/json_formatter.rb +7 -13
  119. data/lib/simplecov/formatter/multi_formatter.rb +5 -11
  120. data/lib/simplecov/formatter/simple_formatter.rb +2 -8
  121. data/lib/simplecov/formatter.rb +14 -10
  122. data/lib/simplecov/group_names.rb +13 -12
  123. data/lib/simplecov/history.rb +115 -0
  124. data/lib/simplecov/last_run.rb +6 -9
  125. data/lib/simplecov/lines_classifier.rb +31 -16
  126. data/lib/simplecov/load_global_config.rb +7 -7
  127. data/lib/simplecov/parallel_adapters/base.rb +13 -41
  128. data/lib/simplecov/parallel_adapters/generic.rb +7 -19
  129. data/lib/simplecov/parallel_adapters/parallel_tests.rb +21 -42
  130. data/lib/simplecov/parallel_adapters.rb +24 -55
  131. data/lib/simplecov/parallel_coordination.rb +39 -49
  132. data/lib/simplecov/parallel_result_merger/worker_payload.rb +33 -0
  133. data/lib/simplecov/parallel_result_merger.rb +67 -126
  134. data/lib/simplecov/process.rb +14 -32
  135. data/lib/simplecov/production/error.rb +11 -0
  136. data/lib/simplecov/production/file_sink.rb +130 -0
  137. data/lib/simplecov/production.rb +249 -0
  138. data/lib/simplecov/profiles/rails.rb +1 -12
  139. data/lib/simplecov/profiles/root_filter.rb +0 -4
  140. data/lib/simplecov/profiles/strict.rb +9 -19
  141. data/lib/simplecov/profiles.rb +11 -33
  142. data/lib/simplecov/report_deferral.rb +11 -15
  143. data/lib/simplecov/report_stamp.rb +6 -9
  144. data/lib/simplecov/result/filter_config.rb +19 -0
  145. data/lib/simplecov/result/missing_source_files_reporter.rb +8 -9
  146. data/lib/simplecov/result/serialization.rb +43 -0
  147. data/lib/simplecov/result/source_file_builder.rb +7 -12
  148. data/lib/simplecov/result.rb +68 -117
  149. data/lib/simplecov/result_adapter.rb +56 -68
  150. data/lib/simplecov/result_merger/contexts.rb +22 -0
  151. data/lib/simplecov/result_merger/legacy_format_adapter.rb +4 -8
  152. data/lib/simplecov/result_merger/resultset_file.rb +20 -27
  153. data/lib/simplecov/result_merger/resultset_run_identity.rb +23 -25
  154. data/lib/simplecov/result_merger/resultset_store.rb +23 -14
  155. data/lib/simplecov/result_merger/unloaded_files.rb +24 -32
  156. data/lib/simplecov/result_merger.rb +59 -58
  157. data/lib/simplecov/result_processing.rb +74 -119
  158. data/lib/simplecov/run_identity.rb +16 -18
  159. data/lib/simplecov/simulate_coverage.rb +34 -50
  160. data/lib/simplecov/source_file/branch.rb +8 -33
  161. data/lib/simplecov/source_file/branch_builder.rb +28 -47
  162. data/lib/simplecov/source_file/builder_context.rb +6 -13
  163. data/lib/simplecov/source_file/line.rb +13 -33
  164. data/lib/simplecov/source_file/line_builder.rb +9 -15
  165. data/lib/simplecov/source_file/method.rb +3 -7
  166. data/lib/simplecov/source_file/method_builder.rb +6 -15
  167. data/lib/simplecov/source_file/ruby_data_parser.rb +59 -66
  168. data/lib/simplecov/source_file/skip_chunks.rb +19 -28
  169. data/lib/simplecov/source_file/source_loader.rb +45 -35
  170. data/lib/simplecov/source_file/statistics.rb +10 -9
  171. data/lib/simplecov/source_file.rb +21 -51
  172. data/lib/simplecov/static_coverage_extractor/condition_folding.rb +63 -114
  173. data/lib/simplecov/static_coverage_extractor/location_conventions.rb +76 -121
  174. data/lib/simplecov/static_coverage_extractor/method_collector.rb +11 -24
  175. data/lib/simplecov/static_coverage_extractor/prism_compat.rb +15 -24
  176. data/lib/simplecov/static_coverage_extractor/value_position.rb +25 -38
  177. data/lib/simplecov/static_coverage_extractor/visitor.rb +47 -64
  178. data/lib/simplecov/static_coverage_extractor.rb +46 -62
  179. data/lib/simplecov/test_tracker/accessors.rb +34 -0
  180. data/lib/simplecov/test_tracker/constant_watch.rb +49 -0
  181. data/lib/simplecov/test_tracker/delta.rb +69 -0
  182. data/lib/simplecov/test_tracker/framework_hooks.rb +130 -0
  183. data/lib/simplecov/test_tracker.rb +162 -0
  184. data/lib/simplecov/unloaded_file_injector.rb +18 -31
  185. data/lib/simplecov/useless_results_remover.rb +7 -6
  186. data/lib/simplecov/version.rb +1 -1
  187. data/lib/simplecov/view_coverage/template_compiler.rb +83 -0
  188. data/lib/simplecov/view_coverage.rb +55 -0
  189. data/lib/simplecov-html.rb +1 -0
  190. data/lib/simplecov.rb +57 -113
  191. data/lib/simplecov_json_formatter.rb +1 -0
  192. data/man/simplecov.1 +349 -0
  193. data/sig/simplecov.rbs +523 -595
  194. metadata +72 -5
data/sig/simplecov.rbs CHANGED
@@ -1,20 +1,11 @@
1
- # Code coverage for Ruby. See the README for a full introduction.
2
1
  module SimpleCov
3
- # A coverage criterion that can be enabled, measured, and reported.
4
2
  type criterion = :line | :branch | :method
5
3
  type line_coverage_alternatives = Hash[criterion | :oneshot_line, :line | :oneshot_line]
6
4
 
7
- # Anything accepted by `skip` / `group` (and the deprecated
8
- # `add_filter` / `add_group`): a path-segment substring, a Regexp, a
9
- # prebuilt Filter, a predicate on the SourceFile, or an Array of those.
10
5
  type filter_arg = String | Regexp | Filter[untyped] | ^(SourceFile source_file) -> boolish | Array[filter_arg]
11
6
 
12
- # Anything accepted by `cover`: a shell-glob String, Regexp, Proc,
13
- # prebuilt Filter, or an Array of those.
14
7
  type cover_arg = String | Regexp | ^(SourceFile source_file) -> boolish | Filter[untyped] | Array[cover_arg]
15
8
 
16
- # Raised when a user's configuration is internally inconsistent — e.g.
17
- # every coverage criterion has been disabled.
18
9
  class ConfigurationError < StandardError
19
10
  end
20
11
 
@@ -26,36 +17,40 @@ module SimpleCov
26
17
  def self?.validate!: (Array[String] group_names) -> Array[String]
27
18
  end
28
19
 
29
- # Maps SimpleCov's criterion names to the keys `Coverage.start` expects.
30
20
  CRITERION_TO_RUBY_COVERAGE: Hash[Symbol, Symbol]
31
21
 
32
22
  extend Configuration
23
+ extend SingleForwardable
33
24
 
34
- self.@subprocess_serial: Integer?
35
- self.@forked_subprocess: bool?
25
+ self.@current_run: CurrentRun?
36
26
  self.@autoloading_dot_simplecov: bool?
37
27
  self.@dot_simplecov_start_warned: bool?
38
28
  self.@at_exit_hook_installed: bool?
39
29
  self.@run_id: String?
40
30
  self.@worker_id: String?
41
31
 
32
+ def self.current_run: () -> CurrentRun
33
+
34
+ attr_writer self.current_run: CurrentRun?
35
+
42
36
  attr_accessor self.pid: Integer?
43
37
 
44
- # When this process started tracking coverage.
45
38
  attr_accessor self.process_start_time: Time?
46
39
 
47
40
  def self.run_id: () -> String
48
41
 
49
42
  def self.worker_id: () -> String
50
43
 
51
- # Should something external (e.g. the Minitest plugin) own the
52
- # at_exit behavior instead of SimpleCov's own hook?
44
+ def self.track_test: [T] (String test_id) { () -> T } -> T
45
+
46
+ def self.test_tracker: () -> TestTracker?
47
+
48
+ def self.start_test_tracking: () -> void
49
+
53
50
  attr_accessor self.external_at_exit: bool?
54
51
 
55
52
  def self.external_at_exit?: () -> bool
56
53
 
57
- # A monotonically increasing serial assigned to each forked
58
- # subprocess; the default `at_fork` builds worker command names from it.
59
54
  def self.subprocess_serial: () -> Integer
60
55
 
61
56
  def self.next_subprocess_serial!: () -> Integer
@@ -64,38 +59,20 @@ module SimpleCov
64
59
 
65
60
  def self.mark_forked_subprocess!: () -> void
66
61
 
67
- # `:oneshot_line` stats are folded into the `:line` bucket, so use
68
- # the returned criterion to look up `coverage_statistics`.
69
62
  def self.coverage_statistics_key: ((criterion | :oneshot_line) criterion) -> criterion
70
63
 
71
- # Sets up SimpleCov to run against your project:
72
- #
73
- # SimpleCov.start
74
- # SimpleCov.start 'rails' # using a profile
75
- # SimpleCov.start { skip 'test' } # with a config block
76
- #
77
64
  def self.start: (?(String | Symbol)? profile) ?{ () [self: singleton(SimpleCov)] -> void } -> void
78
65
 
79
66
  def self.with_dot_simplecov_autoload: [T] () { () -> T } -> T
80
67
 
81
68
  def self.warn_about_start_in_dot_simplecov: () -> void
82
69
 
83
- # Install the at_exit hook that formats results and runs exit-code
84
- # checks. Idempotent; `SimpleCov.start` calls this automatically.
85
70
  def self.install_at_exit_hook: () -> void
86
71
 
87
- # Reset at_exit state a forked child inherits from its parent (a
88
- # possibly consumed hook and a Minitest deferral pid-pinned to the
89
- # parent), so the child re-arms a hook that fires at its own exit.
90
- # Called by the fork hook; see issue #1227.
91
72
  def self.reset_inherited_at_exit_state!: () -> void
92
73
 
93
- # Begin coverage tracking without applying configuration. Pairs with
94
- # `SimpleCov.configure { ... }`.
95
74
  def self.start_tracking: () -> void
96
75
 
97
- # Implementation details of `start` / `start_tracking` (private in Ruby;
98
- # RBS cannot mark singleton methods private).
99
76
  def self.start_coverage_measurement: () -> void
100
77
 
101
78
  def self.minitest_autorun_pending?: () -> bool
@@ -105,90 +82,59 @@ module SimpleCov
105
82
  def self.warn_if_jruby_full_trace_disabled: () -> void
106
83
  end
107
84
 
108
- # ----- version -----
109
85
 
110
86
  module SimpleCov
111
87
  VERSION: String
112
88
  end
113
89
 
114
- # ----- result_processing -----
115
90
 
116
- # Result-building façade: turns the raw `Coverage.result` hash into a
117
- # `SimpleCov::Result`, applies filters and groups, drives merging, and
118
- # exposes the `collate` entry point.
119
91
  module SimpleCov
120
92
  self.@result: Result?
121
- self.@collating_result: bool?
122
93
 
123
- # Collate a series of resultset files into a single merged report. By
124
- # default ignores `merge_timeout` so every listed resultset merges;
125
- # pass `ignore_timeout: false` to honor it. `processes:` above 1 fans the
126
- # merge out across that many forked workers, for an identical report;
127
- # anything below 1 is taken as 1.
128
94
  def self.collate: (Array[String] result_filenames, ?(String | Symbol)? profile, ?processes: Integer, ?ignore_timeout: bool) ?{ () [self: singleton(SimpleCov)] -> void } -> void
129
95
 
130
- # The result for the current coverage run, merged across test suites
131
- # when merging is active. nil when no coverage was tracked.
132
96
  def self.result: () -> Result?
133
97
 
134
- # The memoized result, or false/nil when it has not been computed yet.
98
+ def self.merge_own_slice: () -> untyped
99
+
100
+ def self.build_result: (untyped raw, untyped coverage, not_loaded: untyped, tracked: untyped, report: untyped) -> Result
101
+
135
102
  def self.result?: () -> (Result | false | nil)
136
103
 
137
104
  def self.collating_result?: () -> boolish
138
105
 
139
- # Applies the configured filters to the given source files.
140
106
  def self.filtered: ((Array[SourceFile] | FileList) files) -> FileList
141
107
 
142
- # Bin the given source files by group filter. Files matched by no
143
- # group fall into the implicit "Ungrouped" bucket.
144
108
  def self.grouped: ((Array[SourceFile] | FileList) files, ?groups: Hash[String, Filter[untyped]]) -> Hash[String, FileList]
145
109
 
146
- # Applies the profile of the given name to the configuration.
147
110
  def self.load_profile: ((String | Symbol) name) -> void
148
111
 
149
- # Clear the cached result. Primarily useful in testing.
150
112
  def self.clear_result: () -> void
151
113
 
152
114
  def self.write_last_run: (Result result) -> void
153
115
 
154
- # Round coverage down to two decimals.
155
116
  def self.round_coverage: (Numeric coverage) -> Numeric
156
117
 
157
- # Implementation details of `collate` / `result` (private in Ruby;
158
- # RBS cannot mark singleton methods private).
159
118
  def self.initial_setup: ((String | Symbol)? profile) ?{ () [self: singleton(SimpleCov)] -> void } -> void
160
119
 
161
120
  def self.grouped_file_set: (Hash[String, FileList] grouped) -> Set[SourceFile]
162
121
 
163
122
  def self.unloaded_file_discovery_globs: () -> Array[String]
164
123
 
165
- # Every path this process was told to track, whether or not it loaded them.
166
- # Recorded on the result (and from there into the resultset) so that a merge
167
- # in another process can inject the ones nobody loaded without needing this
168
- # process's `cover` / `track_files` configuration.
169
124
  def self.tracked_file_paths: () -> Array[String]
170
125
 
171
- # Add simulated coverage for each of `candidate_paths` the result doesn't
172
- # already carry, and return it with the set of paths added.
173
- #
174
- # @api private — the seam `SimpleCov::ResultMerger` injects through.
175
126
  def self.inject_unloaded_files: (Hash[String, untyped] result, Array[String] candidate_paths, ?synthesize: bool?, ?lines: bool?) -> [Hash[String, untyped], Set[String]]
176
127
 
177
- # Build this process's slice of the coverage result. `standalone` is true
178
- # when no merge step follows, which makes this the final result: it is the
179
- # one that reports dropped source files, and the one that injects unloaded
180
- # files. When a merge does follow, both jobs belong to the merged result.
181
128
  def self.collect_own_coverage: (standalone: bool) -> void
182
129
 
183
130
  def self.process_coverage_result: (report: bool, ?inject_unloaded: bool) -> void
184
131
  end
185
132
 
186
- # ----- configuration -----
187
133
 
188
- # Bundles the configuration options used for SimpleCov. All methods
189
- # defined here are usable from SimpleCov directly.
190
134
  module SimpleCov
191
135
  module Configuration
136
+ def __send__: (Symbol name, *untyped args) -> untyped
137
+
192
138
  @root: String
193
139
  @coverage_dir: String
194
140
  @coverage_dir_explicit: bool?
@@ -200,66 +146,43 @@ module SimpleCov
200
146
  @at_fork: Proc?
201
147
  @project_name: String?
202
148
 
203
- # The root for the project, defaulting to the current working
204
- # directory. Get, or set with `SimpleCov.root('/my/project/path')`.
205
149
  def root: (?String? root) -> String
206
150
 
207
- # The name of the output and cache directory. Defaults to "coverage".
151
+ def root=: (String? root) -> String
152
+
208
153
  def coverage_dir: (?String? dir) -> String
209
154
 
210
- # The full path to the output directory. By default `root` +
211
- # `coverage_dir`; assign an absolute path to pin the destination
212
- # regardless of later `root` / `coverage_dir` changes (see #716).
155
+ def coverage_dir=: (String? dir) -> String
156
+
213
157
  def coverage_path: (?String? path) -> String
214
158
 
215
- # The name of the command (a.k.a. test suite) currently running.
216
- # Auto-detected when not set explicitly.
159
+ def coverage_path=: (String path) -> untyped
160
+
217
161
  def command_name: (?String? name) -> String
218
162
 
219
- # The hash of available profiles.
163
+ def command_name=: (String name) -> String
164
+
220
165
  def profiles: () -> Profiles
221
166
 
222
- # Configure SimpleCov in a block. A zero-argument block runs with the
223
- # configuration target as `self`; a parameterized block keeps its lexical
224
- # `self` and receives the target explicitly:
225
- #
226
- # SimpleCov.configure { skip "test" }
227
- # SimpleCov.configure { |config| config.skip caller_filter }
228
- #
229
167
  def configure: () { () [self: self] -> untyped } -> self
230
168
  | () { (self config) -> untyped } -> self
231
169
 
232
- # Gets or sets the behavior that processes coverage results at
233
- # process exit. The default stores/merges the current result and
234
- # formats only from the final reporting process.
235
170
  def at_exit: () ?{ () -> void } -> Proc
236
171
 
237
- # Whether SimpleCov has anything to do at exit: coverage is being
238
- # tracked, or a result has already been assembled (e.g. by collate).
239
- def active_session?: () -> boolish
172
+ def active_session?: () -> bool
173
+
174
+ def coverage_running?: () -> bool
240
175
 
241
- # Gets or sets the behavior run in a newly forked process. The
242
- # block receives the child pid. The default renames the command
243
- # from the fork serial, silences errors, and restarts SimpleCov.
244
176
  def at_fork: () ?{ (Integer pid) -> void } -> Proc
245
177
 
246
- # The project name — defaults to the last dirname in `root`,
247
- # capitalized, with underscores replaced by spaces.
248
178
  def project_name: (?String? new_name) -> String
249
179
 
250
180
  end
251
181
  end
252
182
 
253
- # ----- configuration/coverage_criteria -----
254
183
 
255
- # Selection and validation of the coverage criteria Ruby's `Coverage`
256
- # library should track: `:line` (default), `:branch`, `:method`, and
257
- # `:oneshot_line`. The standalone `:eval` toggle lives in
258
- # `configuration/eval_coverage.rb`.
259
184
  module SimpleCov
260
185
  module Configuration
261
- # Members are line, branch, method, and oneshot_line (%i[] literals
262
- # infer as Array[Symbol]).
263
186
  SUPPORTED_COVERAGE_CRITERIA: Array[Symbol]
264
187
 
265
188
  DEFAULT_COVERAGE_CRITERION: :line
@@ -272,38 +195,22 @@ module SimpleCov
272
195
  @coverage_criteria: Set[criterion | :oneshot_line]?
273
196
  @coverage_for_eval_enabled: bool?
274
197
 
275
- # Enable one or more coverage criteria. `:eval` is accepted as a
276
- # shorthand for the standalone eval-coverage toggle. `:line` and
277
- # `:oneshot_line` replace each other; the last enabled mode wins.
278
198
  def enable_coverage: (*(criterion | :oneshot_line | :eval) criteria) -> void
279
199
 
280
- # Remove `criterion` from the set of enabled coverage criteria.
281
- # `:eval` turns the standalone eval-coverage toggle back off.
282
- # Disabling every criterion raises at `start_tracking`, not here.
283
200
  def disable_coverage: ((criterion | :oneshot_line | :eval) criterion) -> void
284
201
 
285
- # Gets the report's leading criterion, or sets it. The setter
286
- # validates at runtime that the criterion is enabled; the parameter
287
- # type also rejects unknown criteria statically.
288
202
  def primary_coverage: (?(criterion | :oneshot_line)? criterion) -> (criterion | :oneshot_line)
289
203
 
290
- # The currently enabled criteria. Defaults to `Set[:line]`.
204
+ def primary_coverage=: ((criterion | :oneshot_line) criterion) -> (criterion | :oneshot_line)
205
+
291
206
  def coverage_criteria: () -> Set[criterion | :oneshot_line]
292
207
 
293
- # Any Symbol is accepted: asking whether an unknown criterion is
294
- # enabled is a legitimate question (the answer is false), and the
295
- # private validators rely on it.
296
208
  def coverage_criterion_enabled?: (Symbol criterion) -> bool
297
209
 
298
- # Reset the criteria back to the lazy default (`Set[:line]`).
299
210
  def clear_coverage_criteria: () -> void
300
211
 
301
212
  def validate_coverage_criteria!: () -> void
302
213
 
303
- # Whether this run produces line data at all. The oneshot variant counts:
304
- # `ResultAdapter` turns its executed-line list back into a line array. A
305
- # branch-only or method-only run produces none, and `Coverage.result`
306
- # entries for the files it loaded carry no `"lines"` key.
307
214
  def line_coverage?: () -> bool
308
215
 
309
216
  def branch_coverage?: () -> bool
@@ -314,37 +221,29 @@ module SimpleCov
314
221
 
315
222
  def method_coverage_supported?: () -> bool
316
223
 
317
- # Whether the running Ruby's Coverage library supports the given
318
- # criterion, named in Coverage's own plural vocabulary
319
- # (`:lines`, `:branches`, `:methods`, `:oneshot_lines`, `:eval`).
320
224
  def coverage_criterion_supported?: (Symbol criterion) -> bool
321
225
 
226
+ def load_coverage: () -> untyped
227
+
322
228
  private
323
229
 
324
230
  def add_coverage_criterion: ((criterion | :oneshot_line) criterion) -> void
325
231
 
326
232
  def default_primary_coverage: () -> (criterion | :oneshot_line)
327
233
 
328
- # Validators: any Symbol is accepted at the type level; the whole
329
- # point of these is raising ConfigurationError on bad input.
330
234
  def raise_if_criterion_disabled: (Symbol criterion) -> void
331
235
 
332
236
  def raise_if_criterion_unsupported: (Symbol criterion) -> void
333
237
  end
334
238
  end
335
239
 
336
- # ----- configuration/eval_coverage -----
337
240
 
338
- # The standalone eval-coverage toggle (`enable_coverage :eval`),
339
- # instrumenting `eval`'d code on Rubies that support it. A boolean
340
- # toggle, never a member of the enabled-criteria set.
341
241
  module SimpleCov
342
242
  module Configuration
343
243
  def coverage_for_eval_supported?: () -> bool
344
244
 
345
245
  def coverage_for_eval_enabled?: () -> bool
346
246
 
347
- # DEPRECATED: use `enable_coverage :eval` instead.
348
247
  def enable_coverage_for_eval: () -> void
349
248
 
350
249
  private
@@ -355,97 +254,92 @@ module SimpleCov
355
254
  end
356
255
  end
357
256
 
358
- # ----- configuration/coverage -----
359
-
360
- # The criterion-first `coverage` configuration method: naming a
361
- # criterion enables it, and every threshold is declared with the same
362
- # syntax regardless of criterion.
363
- #
364
- # SimpleCov.start do
365
- # coverage :line do
366
- # minimum 90
367
- # minimum_per_file 80
368
- # minimum_per_file 100, only: "app/mailers/request_mailer.rb"
369
- # maximum_drop 5
370
- # end
371
- #
372
- # coverage :branch, minimum: 80
373
- # end
257
+
258
+ module SimpleCov
259
+ module Configuration
260
+ DEFAULT_VIEW_GLOBS: Array[String]
261
+
262
+ @view_globs: Array[String]?
263
+
264
+ def cover_views: (*(String | Array[String?] | nil) globs) -> Array[String]
265
+
266
+ def view_globs: () -> Array[String]?
267
+
268
+ def view_coverage?: () -> bool
269
+ end
270
+ end
271
+
272
+
374
273
  module SimpleCov
375
274
  module Configuration
376
- # Members are minimum, maximum, exact, maximum_drop, and
377
- # minimum_per_file (%i[] literals infer as Array[Symbol]).
378
275
  COVERAGE_THRESHOLD_OPTIONS: Array[Symbol]
379
276
 
380
- # Configure (and, unless `enabled: false`, enable) a coverage
381
- # criterion. `primary: true` makes it the report's leading
382
- # criterion; `oneshot: true` (only for `:line`) selects
383
- # oneshot-lines mode. Threshold keywords mirror the block verbs
384
- # for one-liner use. Returns the criterion symbol the thresholds
385
- # were stored under.
386
- # The threshold keywords (minimum:, maximum:, exact:, maximum_drop:,
387
- # minimum_per_file:) arrive via **thresholds in the implementation, so
388
- # they are typed as a Numeric kwarg splat. The block runs under
389
- # instance_eval, which also yields the receiver as an optional argument.
390
- def coverage: ((criterion | :eval) criterion, ?primary: bool, ?enabled: bool, ?oneshot: bool, **Numeric thresholds) ?{ (?CoverageCriterion) [self: CoverageCriterion] -> void } -> (criterion | :oneshot_line | :eval)
277
+ def coverage: ((criterion | :eval) criterion, ?primary: bool, ?enabled: bool, ?oneshot: bool, **untyped thresholds) ?{ (?CoverageCriterion) [self: CoverageCriterion] -> void } -> (criterion | :oneshot_line | :eval)
391
278
 
392
279
  private
393
280
 
394
- def apply_threshold_options: (CoverageCriterion configurator, Hash[Symbol, Numeric] options) -> void
281
+ def apply_threshold_options: (CoverageCriterion configurator, Hash[Symbol, untyped] options) -> void
395
282
 
396
283
  def enable_coverage_criterion: ((criterion | :eval) criterion, enabled: bool, oneshot: bool) -> (criterion | :oneshot_line | :eval)
397
284
 
398
285
  def resolve_criterion_variant: ((criterion | :eval) criterion, bool oneshot) -> (criterion | :oneshot_line | :eval)
399
286
 
400
- # Threshold-store writers used by CoverageCriterion via `send`.
401
- # They accept any criterion Symbol; `raise_on_invalid_coverage`
402
- # rejects invalid ones (including `:eval`) at runtime.
403
287
  def store_overall_threshold: (Symbol setting, Symbol criterion, Numeric percent) -> void
404
288
 
405
289
  def store_minimum_per_file: (Symbol criterion, Numeric percent, (String | Regexp)? target) -> void
406
290
 
407
291
  def store_minimum_per_group: (Symbol criterion, Numeric percent, String group_name) -> void
408
292
 
293
+ def store_missed_cap: (Symbol setting, Symbol criterion, Integer count) -> void
294
+
295
+ def store_maximum_missed_per_file: (Symbol criterion, Integer count, (String | Regexp)? target) -> void
296
+
409
297
  public
410
298
 
411
- # Receiver for a `coverage <criterion> do ... end` block. Each verb
412
- # writes a threshold for the single criterion the block configures,
413
- # so values are always plain percentages.
414
299
  class CoverageCriterion
300
+ type per_target = nil | :file | String | Regexp | GroupTarget
301
+
302
+ class GroupTarget
303
+ attr_reader name: String | Symbol
304
+
305
+ def initialize: (name: String | Symbol) -> void
306
+ end
307
+
415
308
  @config: Configuration
416
309
  @criterion: Symbol
417
310
 
418
311
  def initialize: (Configuration config, Symbol criterion) -> void
419
312
 
420
- # Overall (suite-wide) minimum for this criterion.
421
- def minimum: (Numeric percent) -> void
313
+ def minimum: (Numeric percent, ?per: per_target) -> void
422
314
 
423
- # Overall maximum: fails the build if coverage rises above it.
424
315
  def maximum: (Numeric percent) -> void
425
316
 
426
- # Pin coverage to an exact figure (sets both minimum and maximum).
427
317
  def exact: (Numeric percent) -> void
428
318
 
429
- # Maximum allowed drop between runs (0 refuses any drop).
430
319
  def maximum_drop: (Numeric percent) -> void
431
320
 
432
- # Per-file minimum. With no `only:`, the default for every file;
433
- # with `only:` (String path or Regexp), an override for matches.
321
+ def maximum_missed: (Integer count, ?per: per_target) -> void
322
+
323
+ def group: (String | Symbol name) -> GroupTarget
324
+
325
+ def ignore: (*(Symbol | Array[Symbol]) types) -> Array[Symbol]
326
+
434
327
  def minimum_per_file: (Numeric percent, ?only: (String | Regexp)?) -> void
435
328
 
436
- # Per-group minimum for the named group (defined via `group`).
437
329
  def minimum_per_group: (Numeric percent, only: String) -> void
438
330
 
439
- # Make this criterion the report's primary (leading) criterion.
331
+ def maximum_missed_per_file: (Integer count, ?only: (String | Regexp)?) -> void
332
+
440
333
  def primary: () -> void
334
+
335
+ private
336
+
337
+ def raise_invalid_per: (untyped per) -> bot
441
338
  end
442
339
  end
443
340
  end
444
341
 
445
- # ----- configuration/filters -----
446
342
 
447
- # Inclusion / exclusion / grouping methods: `cover`, `skip`, `group`,
448
- # plus the deprecated `track_files` / `add_filter` / `add_group` aliases.
449
343
  module SimpleCov
450
344
  module Configuration
451
345
  attr_writer filters: Array[Filter[untyped]]
@@ -455,56 +349,36 @@ module SimpleCov
455
349
  @cover_filters: Array[Filter[untyped]]?
456
350
  @tracked_files: String?
457
351
 
458
- # Restrict the report to files matching one or more shell globs,
459
- # regexps, or block predicates. Multiple calls union. String globs
460
- # are also expanded on disk so unloaded files appear at 0% coverage.
461
352
  def cover: (*cover_arg args) ?{ (SourceFile source_file) -> boolish } -> Array[Filter[untyped]]
462
353
 
463
- # The configured inclusion filters added via `cover`.
464
354
  def cover_filters: () -> Array[Filter[untyped]]
465
355
 
466
- # The string globs passed to `cover`, driving unloaded-file discovery.
467
356
  def cover_globs: () -> Array[String]
468
357
 
469
- # DEPRECATED: use `cover` instead.
470
358
  def track_files: (String? glob) -> String?
471
359
 
472
360
  def track_files_replacement_hint: (String? glob) -> String
473
361
 
474
- # The glob used to include files that were not explicitly required.
475
362
  def tracked_files: () -> String?
476
363
 
477
- # The configured exclusion filters added via `skip` (or the
478
- # deprecated `add_filter`).
479
364
  def filters: () -> Array[Filter[untyped]]
480
365
 
481
- # Drop matching files from the coverage report. The inverse of
482
- # `cover`. Strings match at path-segment boundaries.
483
366
  def skip: (?filter_arg? filter_argument) ?{ (SourceFile source_file) -> boolish } -> Array[Filter[untyped]]
484
367
 
485
- # DEPRECATED: use `skip` instead (same arguments, same behavior).
486
368
  def add_filter: (?filter_arg? filter_argument) ?{ (SourceFile source_file) -> boolish } -> Array[Filter[untyped]]
487
369
 
488
- # Remove any filters whose `filter_argument` equals the given
489
- # value. Returns true when at least one filter was removed.
490
370
  def remove_filter: (untyped filter_argument) -> bool
491
371
 
492
- # Remove every filter from the chain, including the defaults
493
- # installed by `SimpleCov.start`.
494
372
  def clear_filters: () -> Array[Filter[untyped]]
495
373
 
496
- # The configured groups. Add groups using `group`.
497
374
  def groups: () -> Hash[String, Filter[untyped]]
498
375
 
499
- # Define a display group for files. Same matcher grammar as `skip`,
500
- # but bins matches under `group_name` instead of dropping them.
376
+ def default_groups: () -> Hash[String, Filter[untyped]]
377
+
501
378
  def group: (String group_name, ?filter_arg? filter_argument) ?{ (SourceFile source_file) -> boolish } -> Filter[untyped]
502
379
 
503
- # DEPRECATED: use `group` instead (same arguments, same behavior).
504
380
  def add_group: (String group_name, ?filter_arg? filter_argument) ?{ (SourceFile source_file) -> boolish } -> Filter[untyped]
505
381
 
506
- # Drop every previously installed filter (defaults included) so
507
- # subsequent `skip` calls start from a clean slate.
508
382
  def no_default_skips: () -> Array[Filter[untyped]]
509
383
 
510
384
  private
@@ -517,15 +391,9 @@ module SimpleCov
517
391
  end
518
392
  end
519
393
 
520
- # ----- configuration/formatting -----
521
394
 
522
- # Formatter selection (`formatter` / `formatters`), reporting toggles
523
- # (`print_errors`, `color`, `source_in_json`), and the deprecated
524
- # `# :nocov:` token hook.
525
395
  module SimpleCov
526
396
  module Configuration
527
- # A formatter is a Class whose instances respond to `format(result)`
528
- # (including the anonymous Class built by `MultiFormatter.new`).
529
397
  attr_writer formatter: Class?
530
398
 
531
399
  attr_writer print_error_status: bool
@@ -534,71 +402,64 @@ module SimpleCov
534
402
  @source_in_json: bool
535
403
  @nocov_token: String
536
404
 
537
- # Gets or sets the configured formatter. Pass `false` (or `nil`) to
538
- # opt out of formatting entirely (see #964).
405
+ BUILT_IN_FORMATS: Hash[Symbol, Symbol]
406
+
407
+ LAZY_FORMAT_REQUIRES: Hash[Symbol, String]
408
+
409
+ def formats: (*untyped names) -> (Array[Class] | Class | nil)
410
+
539
411
  def formatter: (?(Class | false | :__no_arg__)? formatter) -> Class?
540
412
 
541
- # Gets the formatter chain, or sets it. Accepts an Array, a single
542
- # formatter, or nil / `[]` to opt out of formatting entirely.
543
- # Returns the passed value when setting.
544
413
  def formatters: (?(Array[Class] | Class | :__no_arg__)? formatters) -> (Array[Class] | Class | nil)
545
414
 
546
- # Sets the configured formatters (single formatters are wrapped;
547
- # nil / `[]` opts out of formatting entirely).
548
415
  def formatters=: ((Array[Class] | Class)? formatters) -> void
549
416
 
550
- # Whether stderr diagnostics are colorized: `true`, `false`, or
551
- # `:auto` (default — respects TTY, NO_COLOR, and FORCE_COLOR).
552
417
  def color: (?(bool | :auto | :__no_arg__) value) -> (bool | :auto)
553
418
 
554
- # Whether SimpleCov prints its own diagnostic warnings to stderr.
555
- # Defaults to true.
419
+ def color=: (untyped value) -> untyped
420
+
556
421
  def print_errors: (?(bool | :__no_arg__) value) -> bool
557
422
 
558
- # Whether `coverage.json` embeds the full source text of every
559
- # file. Defaults to true.
423
+ def print_errors=: (bool value) -> bool
424
+
560
425
  def source_in_json: (?(bool | :__no_arg__) value) -> bool
561
426
 
562
- # DEPRECATED: use `print_errors` instead (same value).
427
+ def source_in_json=: (bool value) -> bool
428
+
563
429
  def print_error_status: () -> bool
564
430
 
565
- # DEPRECATED: use `# simplecov:disable` / `# simplecov:enable`
566
- # directive comments instead of `# :nocov:` toggles.
567
431
  def nocov_token: (?String? nocov_token) -> String
568
432
 
569
- # DEPRECATED: alias for `nocov_token`.
570
433
  alias skip_token nocov_token
571
434
 
572
435
  def current_nocov_token: (?String? value) -> String
436
+
437
+ private
438
+
439
+ def combined_formatter: (Array[untyped] formatters) -> untyped
440
+
441
+ def resolve_format: (untyped name) -> untyped
442
+
443
+ def require_html_formatter: (untyped name) -> void
573
444
  end
574
445
  end
575
446
 
576
- # ----- configuration/ignored_entries -----
577
447
 
578
- # Coverage-entry filters scoped to branch / method criteria. See
579
- # `ignore_branches` / `ignore_methods` and #1033 / #1046.
580
448
  module SimpleCov
581
449
  module Configuration
582
- # Branch types accepted by `ignore_branches`: implicit_else and
583
- # eval_generated (%i[] literals infer as Array[Symbol]).
584
450
  IGNORABLE_BRANCH_TYPES: Array[Symbol]
585
451
 
586
- # Method types accepted by `ignore_methods`: eval_generated (%i[]
587
- # literals infer as Array[Symbol]).
588
452
  IGNORABLE_METHOD_TYPES: Array[Symbol]
589
453
 
590
454
  @ignored_branches: Array[Symbol]?
591
455
  @ignored_methods: Array[Symbol]?
592
456
 
593
- # Opt out of synthetic branch entries. Variadic; multiple calls
594
- # union. Recorded even when branch coverage is not (yet) enabled.
595
457
  def ignore_branches: (*(:implicit_else | :eval_generated) types) -> Array[Symbol]
596
458
 
597
459
  def ignored_branches: () -> Array[Symbol]
598
460
 
599
461
  def ignored_branch?: (Symbol type) -> bool
600
462
 
601
- # Opt out of synthetic method entries (currently `:eval_generated` only).
602
463
  def ignore_methods: (*:eval_generated types) -> Array[Symbol]
603
464
 
604
465
  def ignored_methods: () -> Array[Symbol]
@@ -607,22 +468,37 @@ module SimpleCov
607
468
 
608
469
  private
609
470
 
471
+ def store_ignored_branches: (Array[Symbol] types) -> Array[Symbol]
472
+
473
+ def store_ignored_methods: (Array[Symbol] types) -> Array[Symbol]
474
+
610
475
  def raise_if_branch_type_unsupported: (Symbol type) -> void
611
476
 
612
477
  def raise_if_method_type_unsupported: (Symbol type) -> void
613
478
  end
614
479
  end
615
480
 
616
- # ----- configuration/merging -----
617
481
 
618
- # Result merging and subprocess / parallel-test coordination:
619
- # `merging`, `merge_subprocesses`, `merge_timeout`, `finalize_merge`,
620
- # `parallel_tests`, `parallel_wait_timeout`.
621
482
  module SimpleCov
622
483
  module Configuration
623
- # `defined?`-guarded module state. Declared non-nil where every
624
- # read is guarded, so readers don't have to refute a nil that
625
- # cannot be observed.
484
+ @track_tests: bool
485
+ @track_tests_granularity: Symbol?
486
+
487
+ TRACK_TESTS_GRANULARITIES: Array[Symbol]
488
+
489
+ def track_tests: (?bool? enabled, ?granularity: Symbol?) -> bool
490
+
491
+ def track_tests_granularity: () -> Symbol
492
+
493
+ def track_tests?: () -> bool
494
+
495
+ def validate_test_tracking!: () -> void
496
+ end
497
+ end
498
+
499
+
500
+ module SimpleCov
501
+ module Configuration
626
502
  @enable_for_subprocesses: bool
627
503
  @parallel_tests: bool?
628
504
  @use_merging: bool
@@ -632,50 +508,42 @@ module SimpleCov
632
508
  @merge_timeout: Integer?
633
509
  @parallel_wait_timeout: Integer?
634
510
 
635
- # Get or set whether SimpleCov hooks `Process._fork` to attach
636
- # itself to subprocesses (e.g. Rails' `parallelize(workers:)`).
637
- # Defaults to false.
638
511
  def merge_subprocesses: (?bool? value) -> bool
639
512
 
513
+ def merge_subprocesses=: (bool? value) -> untyped
514
+
640
515
  def enabled_for_subprocesses?: () -> bool
641
516
 
642
- # Get or set whether SimpleCov auto-requires the `parallel_tests`
643
- # gem when it sees its environment variables. nil (the default)
644
- # means auto-detect. See #1018.
645
517
  def parallel_tests: (?(:__no_arg__ | bool)? value) -> bool?
646
518
 
647
- # DEPRECATED: use `merge_subprocesses` instead (same value).
519
+ def parallel_tests=: (untyped value) -> untyped
520
+
648
521
  def enable_for_subprocesses: (?bool? value) -> bool
649
522
 
650
- # Get or set whether to merge results from multiple test suites
651
- # into a single coverage report. Defaults to true.
652
523
  def merging: (?bool? use) -> bool
653
524
 
654
- # Get or set whether SimpleCov's selected final process owns merge processing:
655
- # waiting for sibling workers, merging, formatting, enforcing
656
- # thresholds, and writing `.last_run.json`. Defaults to true except
657
- # for recognized multi-worker parallel runs writing to a custom
658
- # coverage destination (those likely finalize via an external
659
- # `SimpleCov.collate` step). See #1215.
660
- def finalize_merge: (?(:__no_arg__ | bool) value) -> bool
525
+ def merging=: (bool use) -> bool
526
+
527
+ def finalize_merge: (*bool value) -> bool
528
+
529
+ def finalize_merge=: (bool value) -> bool
661
530
 
662
531
  def finalize_merge?: () -> bool
663
532
 
664
533
  def merge_finalization_owner?: () -> boolish
665
534
 
666
- # DEPRECATED: use `merging` instead (same value, same behavior).
667
- # Returns nil when merging had already been disabled.
668
535
  def use_merging: (?bool? use) -> bool
669
536
 
670
- # The maximum age (in seconds) of a resultset to still be included
671
- # in merged results. Defaults to 600.
672
537
  def merge_timeout: (?Integer? seconds) -> Integer
673
538
 
674
- # How long (in seconds) the reporting process waits for remaining
675
- # parallel-test workers to write their resultsets before it
676
- # proceeds with a partial merge. Defaults to 60. See #1171.
539
+ def merge_timeout=: (untyped seconds) -> untyped
540
+
541
+ def env_merge_timeout: () -> Integer?
542
+
677
543
  def parallel_wait_timeout: (?Integer? seconds) -> Integer
678
544
 
545
+ def parallel_wait_timeout=: (untyped seconds) -> untyped
546
+
679
547
  private
680
548
 
681
549
  def inferred_finalize_merge?: () -> bool
@@ -690,83 +558,70 @@ module SimpleCov
690
558
 
691
559
  def inferred_finalize_merge_warning: () -> String
692
560
 
693
- # Host contract: defined on SimpleCov itself (result_processing.rb).
694
- # This module is only ever extended onto SimpleCov, where both methods
695
- # are available to `merge_finalization_owner?`.
696
561
  def collating_result?: () -> boolish
697
562
 
698
563
  def final_result_process?: () -> boolish
699
564
  end
700
565
  end
701
566
 
702
- # ----- configuration/thresholds -----
703
567
 
704
- # Coverage threshold configuration: `minimum_coverage`,
705
- # `maximum_coverage`, `expected_coverage`, `maximum_coverage_drop`,
706
- # `refuse_coverage_drop`, and the deprecated by-file / by-group forms.
707
568
  module SimpleCov
708
569
  module Configuration
709
- # Thresholds are stored per criterion; a bare Numeric argument is
710
- # normalized to `{primary_coverage => value}`. Keys are criterion
711
- # symbols — Symbol rather than the `criterion` alias because the
712
- # stores also carry `:oneshot_line`, and the validating setters are
713
- # the layer that rejects unknown symbols (with ConfigurationError).
714
570
  type coverage_thresholds = Hash[Symbol, Numeric]
715
571
 
572
+ type missed_caps = Hash[Symbol, Integer]
573
+
716
574
  @minimum_coverage: coverage_thresholds?
717
575
  @maximum_coverage: coverage_thresholds?
718
576
  @maximum_coverage_drop: coverage_thresholds?
577
+ @maximum_missed: missed_caps?
578
+ @maximum_missed_per_file: missed_caps?
579
+ @maximum_missed_per_file_overrides: Hash[String | Regexp, missed_caps]?
719
580
  @minimum_coverage_by_file: coverage_thresholds?
720
581
  @minimum_coverage_by_file_overrides: Hash[String | Regexp, coverage_thresholds]?
721
582
  @minimum_coverage_by_group: Hash[String, coverage_thresholds]?
722
583
 
723
- # The minimum overall coverage required for the suite to pass.
724
- # Default: none (0%, disabled).
725
584
  def minimum_coverage: (?(Numeric | coverage_thresholds)? coverage) -> coverage_thresholds
726
585
 
727
- def raise_on_invalid_coverage: (coverage_thresholds coverage, String coverage_setting) -> void
586
+ def raise_on_invalid_coverage: (coverage_thresholds coverage, (String | Symbol) coverage_setting) -> void
728
587
 
729
- # The maximum overall coverage allowed — an unexpected jump above
730
- # it fails the build. Pair with `minimum_coverage` (or use
731
- # `expected_coverage`) to pin coverage. See #187.
732
588
  def maximum_coverage: (?(Numeric | coverage_thresholds)? coverage) -> coverage_thresholds
733
589
 
734
- # Pin the suite to an exact figure: sets both `minimum_coverage`
735
- # and `maximum_coverage`. See #187.
736
590
  def expected_coverage: (?(Numeric | coverage_thresholds)? coverage) -> coverage_thresholds
737
591
 
738
- # The maximum coverage drop between runs allowed for the suite to
739
- # pass. Default: none (100%, disabled).
740
592
  def maximum_coverage_drop: (?(Numeric | coverage_thresholds)? coverage_drop) -> coverage_thresholds
741
593
 
742
- # DEPRECATED: use `coverage(criterion) { minimum_per_file ... }`.
743
- # Symbol keys declare per-criterion defaults; String / Regexp keys
744
- # declare per-path overrides.
594
+ def maximum_missed: (?(Numeric | missed_caps)? counts) -> missed_caps
595
+
596
+ def maximum_missed_per_file: (?(Numeric | missed_caps)? counts) -> missed_caps
597
+
598
+ def maximum_missed_per_file_overrides: () -> Hash[String | Regexp, missed_caps]
599
+
745
600
  def minimum_coverage_by_file: () -> coverage_thresholds
746
601
  | ((Numeric | Hash[Symbol | String | Regexp, Numeric | coverage_thresholds]) coverage) -> Hash[String | Regexp, coverage_thresholds]
747
602
 
748
- # The per-path overrides set via `minimum_coverage_by_file` (or
749
- # `coverage(criterion) { minimum_per_file N, only: ... }`).
750
603
  def minimum_coverage_by_file_overrides: () -> Hash[String | Regexp, coverage_thresholds]
751
604
 
752
- # DEPRECATED: use `coverage(criterion) { minimum_per_group ... }`.
753
605
  def minimum_coverage_by_group: () -> Hash[String, coverage_thresholds]
754
606
  | (Hash[String, Numeric | coverage_thresholds] coverage) -> Hash[String, coverage_thresholds]
755
607
 
756
- # Refuse any coverage drop for the given criteria (all enabled
757
- # criteria when none are given). Coverage may only increase.
758
608
  def refuse_coverage_drop: (*(criterion | :oneshot_line) criteria) -> coverage_thresholds
759
609
 
760
610
  private
761
611
 
762
- # Shared normalize-and-validate step behind every threshold setter.
763
612
  def normalized_threshold: ((Numeric | coverage_thresholds) coverage, String setting) -> coverage_thresholds
764
613
 
614
+ def normalized_missed_caps: ((Numeric | missed_caps) counts, String setting) -> missed_caps
615
+
616
+ def raise_on_invalid_missed_cap: (untyped cap, (String | Symbol) setting) -> void
617
+
618
+ def missed_per_file_replacement: ((Numeric | missed_caps) counts) -> String
619
+
765
620
  def partition_per_file_thresholds: (Hash[Symbol | String | Regexp, Numeric | coverage_thresholds] coverage) -> [coverage_thresholds, Hash[String | Regexp, coverage_thresholds]]
766
621
 
767
622
  def validate_per_file_key: ((Symbol | String | Regexp) key) -> void
768
623
 
769
- def minimum_possible_coverage_exceeded: (String coverage_option) -> void
624
+ def minimum_possible_coverage_exceeded: ((String | Symbol) coverage_option) -> void
770
625
 
771
626
  def per_file_coverage_replacement: (coverage_thresholds defaults, Hash[String | Regexp, coverage_thresholds] overrides) -> String
772
627
 
@@ -776,35 +631,30 @@ module SimpleCov
776
631
  end
777
632
  end
778
633
 
779
- # ----- result -----
780
634
 
781
635
  module SimpleCov
782
- # A coverage result built from the Hash Ruby's Coverage library
783
- # produces: filename => per-criterion coverage data.
784
636
  class Result
785
637
  extend Forwardable
638
+ include Serialization
786
639
 
787
640
  attr_reader original_result: Hash[String, untyped]
788
641
 
789
- # Every path the producing process was told to track, loaded or not.
790
642
  attr_reader tracked_files: Array[String]
791
643
  attr_reader run_id: String?
792
644
  attr_reader worker_id: String?
793
645
  attr_reader files: FileList
794
646
  alias source_files files
795
- # The writers accept the strict types; the ivars stay nilable because
796
- # both default to nil and are lazily backfilled by the readers.
647
+ attr_reader contexts: ContextMap?
797
648
  attr_writer created_at (): Time
798
649
  attr_writer command_name (): String
650
+ attr_writer command_names (): Array[String]
799
651
 
800
652
  @created_at: Time?
801
653
  @command_name: String?
654
+ @command_names: Array[String]?
802
655
  @groups_config: Hash[String, Filter[untyped]]
803
656
  @groups: Hash[String, FileList]?
804
657
 
805
- # Bundles filter and grouping configuration. Every field defaults to
806
- # the SimpleCov singleton's configuration; tests pass a custom
807
- # instance (e.g. `filters: []`) to opt out.
808
658
  class FilterConfig
809
659
  attr_reader filters: Array[Filter[untyped]]
810
660
  attr_reader cover_filters: Array[Filter[untyped]]
@@ -813,22 +663,18 @@ module SimpleCov
813
663
  def initialize: (?filters: Array[Filter[untyped]], ?cover_filters: Array[Filter[untyped]], ?groups: Hash[String, Filter[untyped]]) -> void
814
664
  end
815
665
 
816
- def initialize: (Hash[String, untyped] original_result, ?command_name: String?, ?created_at: Time?, ?not_loaded_files: Set[String], ?tracked_files: _ToA[String], ?run_id: String?, ?worker_id: String?, ?report: bool, ?filter_config: FilterConfig) -> void
666
+ def initialize: (Hash[String, untyped] original_result, ?command_name: String?, ?created_at: Time?, ?not_loaded_files: Set[String], ?tracked_files: _ToA[String]?, ?run_id: String?, ?worker_id: String?, ?contexts: ContextMap?, ?report: bool, ?filter_config: FilterConfig) -> void
817
667
 
818
668
  def filenames: () -> Array[String]
819
- # Accepts an absolute or project-relative path (resolved against SimpleCov.root).
820
669
  def source_file_for: (String path) -> SourceFile?
821
670
  def coverage_for: (String path) -> Hash[criterion, CoverageStatistics]?
822
671
  def groups: () -> Hash[String, FileList]
823
- # Returns nil when formatting is opted out of (`formatter false` /
824
- # `formatters []`); otherwise whatever the configured formatter returns.
825
672
  def format!: () -> untyped
826
673
  def created_at: () -> Time
827
674
  def command_name: () -> String
828
- def to_hash: () -> Hash[String, Hash[String, untyped]]
675
+ def command_names: () -> Array[String]
829
676
  def self.from_hash: (Hash[String, untyped] hash) -> Array[Result]
830
677
 
831
- # Delegated to #files (see FileList).
832
678
  def covered_percent: (?criterion) -> Float?
833
679
  def covered_percentages: () -> Array[Float?]
834
680
  def least_covered_file: () -> String?
@@ -848,20 +694,47 @@ module SimpleCov
848
694
 
849
695
  private
850
696
 
851
- def initialize_coordination_metadata: (_ToA[String] tracked_files, String? run_id, String? worker_id) -> void
852
- def warn_about_missing_source_files: (Array[String] missing, Integer input_size) -> void
853
- def coverage: () -> Hash[String, untyped]
697
+ def initialize_resultset_metadata: (_ToA[String]? tracked_files, String? run_id, String? worker_id, ContextMap? contexts) -> void
698
+ def warn_about_missing_source_files: (Array[String] missing) -> void
854
699
  def apply_filters!: (Array[Filter[untyped]] filters) -> void
855
700
  def apply_cover_filters!: (Array[Filter[untyped]] cover_filters) -> void
856
701
  end
702
+
703
+ class Result
704
+ interface _SerializableResult
705
+ def original_result: () -> Hash[String, untyped]
706
+
707
+ def created_at: () -> Time
708
+
709
+ def command_name: () -> String
710
+
711
+ def run_id: () -> String?
712
+
713
+ def worker_id: () -> String?
714
+
715
+ def tracked_files: () -> Array[String]
716
+
717
+ def contexts: () -> ContextMap?
718
+
719
+ def filenames: () -> Array[String]
720
+ end
721
+
722
+ module Serialization : _SerializableResult
723
+ def to_hash: () -> Hash[String, Hash[String, untyped]]
724
+
725
+ private
726
+
727
+ def append_contexts: (Hash[String, untyped] data) -> void
728
+
729
+ def context_filenames: () -> Set[String]
730
+
731
+ def coverage: () -> Hash[String, untyped]
732
+ end
733
+ end
857
734
  end
858
735
 
859
- # ----- file_list -----
860
736
 
861
737
  module SimpleCov
862
- # An Enumerable of SourceFile instances with aggregate coverage
863
- # helpers. Aggregate readers return nil when the corresponding
864
- # criterion was not enabled for the run.
865
738
  class FileList
866
739
  include Enumerable[SimpleCov::SourceFile]
867
740
  extend Forwardable
@@ -872,7 +745,6 @@ module SimpleCov
872
745
  @coverage_statistics: Hash[criterion, CoverageStatistics]?
873
746
  @coverage_statistics_by_file: Hash[criterion, Array[CoverageStatistics]]?
874
747
 
875
- # Delegated to the underlying Array.
876
748
  def each: () { (SourceFile) -> void } -> void
877
749
  | () -> Enumerator[SourceFile, untyped]
878
750
  def size: () -> Integer
@@ -917,23 +789,16 @@ module SimpleCov
917
789
  end
918
790
  end
919
791
 
920
- # ----- source_file -----
921
792
 
922
793
  module SimpleCov
923
- # A source file with its coverage data, source lines, and helpers to
924
- # interpret that data.
925
794
  class SourceFile
926
795
  include BuilderContext
927
796
 
928
- # Full absolute path to the file.
929
797
  attr_reader filename: String
930
- # Coverage.result-shaped data for this file, e.g.
931
- # {"lines" => [...], "branches" => {...}, "methods" => {...}}.
932
798
  attr_reader coverage_data: Hash[String, untyped]
933
799
 
934
800
  def initialize: (String filename, Hash[String, untyped] coverage_data, ?loaded: bool) -> void
935
801
 
936
- # Memoization backing for the lazy readers below.
937
802
  @loaded: bool
938
803
  @src: Array[String]?
939
804
  @coverage_statistics: Hash[criterion, CoverageStatistics]?
@@ -951,15 +816,10 @@ module SimpleCov
951
816
  @covered_methods: Array[Method]?
952
817
  @missed_methods: Array[Method]?
953
818
 
954
- # Project-relative path with no leading separator (e.g. "lib/foo.rb").
955
819
  def project_filename: () -> String
956
- # Source lines, read lazily.
957
820
  def src: () -> Array[String]
958
821
  alias source src
959
822
 
960
- # With no argument returns a Hash keyed by every supported criterion
961
- # (disabled criteria collapse to 0/0/0); pass a criterion to get that
962
- # one CoverageStatistics.
963
823
  def coverage_statistics: () -> Hash[criterion, CoverageStatistics]
964
824
  | (criterion) -> CoverageStatistics?
965
825
 
@@ -970,7 +830,6 @@ module SimpleCov
970
830
  def never_lines: () -> Array[Line]
971
831
  def skipped_lines: () -> Array[Line]
972
832
  def lines_of_code: () -> Integer
973
- # 1-based line lookup.
974
833
  def line: (Integer number) -> Line?
975
834
  def covered_percent: (?criterion) -> Float?
976
835
  def covered_strength: (?criterion) -> Float?
@@ -979,11 +838,8 @@ module SimpleCov
979
838
 
980
839
  def branches: () -> Array[Branch]
981
840
  def no_branches?: () -> bool
982
- # DEPRECATED: use `covered_percent(:branch)`.
983
841
  def branches_coverage_percent: () -> Float?
984
- # All relevant (covered + missed) branches, not a count.
985
842
  def total_branches: () -> Array[Branch]
986
- # line number => Array of [branch type, hit count] pairs.
987
843
  def branches_report: () -> Hash[Integer, Array[[ Symbol, Integer ]]]
988
844
  def covered_branches: () -> Array[Branch]
989
845
  def missed_branches: () -> Array[Branch]
@@ -993,21 +849,15 @@ module SimpleCov
993
849
  def methods: () -> Array[Method]
994
850
  def covered_methods: () -> Array[Method]
995
851
  def missed_methods: () -> Array[Method]
996
- # DEPRECATED: use `covered_percent(:method)`.
997
852
  def methods_coverage_percent: () -> Float?
998
853
 
999
- # Whether this file was added via `cover` / `track_files` but never
1000
- # loaded during the run.
1001
854
  def not_loaded?: () -> bool
1002
855
  end
1003
856
  end
1004
857
 
1005
- # ----- source_file/line -----
1006
858
 
1007
859
  module SimpleCov
1008
860
  class SourceFile
1009
- # A single source line with its coverage: nil (not relevant, e.g. a
1010
- # comment), 0 (missed), or >= 1 (times executed).
1011
861
  class Line
1012
862
  attr_reader src: String
1013
863
  attr_reader line_number: Integer
@@ -1018,8 +868,6 @@ module SimpleCov
1018
868
  alias line line_number
1019
869
  alias number line_number
1020
870
 
1021
- # Raises ArgumentError unless src is a String, line_number an
1022
- # Integer, and coverage an Integer or nil.
1023
871
  def initialize: (String src, Integer line_number, Integer? coverage) -> void
1024
872
 
1025
873
  def missed?: () -> bool
@@ -1027,22 +875,18 @@ module SimpleCov
1027
875
  def never?: () -> bool
1028
876
  def skipped!: () -> void
1029
877
  def skipped?: () -> bool
1030
- # "covered", "missed", "skipped", or "never" — useful e.g. as a css class.
1031
- def status: () -> String?
878
+ def status: () -> String
1032
879
  end
1033
880
  end
1034
881
  end
1035
882
 
1036
- # ----- source_file/branch -----
1037
883
 
1038
884
  module SimpleCov
1039
885
  class SourceFile
1040
- # A single branch detected in the coverage data.
1041
886
  class Branch
1042
887
  attr_reader start_line: Integer
1043
888
  attr_reader end_line: Integer
1044
889
  attr_reader coverage: Integer
1045
- # Branch arm type as reported by Coverage (:then, :else, :when, ...).
1046
890
  attr_reader type: Symbol
1047
891
 
1048
892
  @inline: bool
@@ -1053,28 +897,21 @@ module SimpleCov
1053
897
  def inline?: () -> bool
1054
898
  def covered?: () -> bool
1055
899
  def missed?: () -> bool
1056
- # The line the branch is reported on: its own start line when
1057
- # inline, otherwise the line above (the if/else itself).
1058
900
  def report_line: () -> Integer
1059
901
  def skipped!: () -> void
1060
902
  def skipped?: () -> bool
1061
903
  def overlaps_with?: (Range[Integer] line_range) -> bool
1062
- # [branch type, hit count]
1063
904
  def report: () -> [ Symbol, Integer ]
1064
905
  end
1065
906
  end
1066
907
  end
1067
908
 
1068
- # ----- source_file/method -----
1069
909
 
1070
910
  module SimpleCov
1071
911
  class SourceFile
1072
- # A single method detected in the coverage data.
1073
912
  class Method
1074
913
  attr_reader source_file: SourceFile
1075
914
  attr_reader coverage: Integer
1076
- # A Module when the data comes straight from Coverage, a String
1077
- # after a JSON round-trip through a resultset.
1078
915
  attr_reader class_name: Module | String
1079
916
  attr_reader method_name: Symbol | String
1080
917
  attr_reader start_line: Integer?
@@ -1085,15 +922,12 @@ module SimpleCov
1085
922
  @skipped: bool
1086
923
  @lines: Array[Line]?
1087
924
 
1088
- # info is the Coverage method key minus its class entry:
1089
- # [class_name, method_name, start_line, start_col, end_line, end_col].
1090
925
  def initialize: (SourceFile source_file, [ Module | String, Symbol | String, Integer?, Integer?, Integer?, Integer? ] info, Integer coverage) -> void
1091
926
 
1092
927
  def covered?: () -> bool
1093
928
  def skipped?: () -> bool
1094
929
  def skipped!: () -> void
1095
930
  def missed?: () -> bool
1096
- # The source lines spanned by this method ([] when the location is unknown).
1097
931
  def lines: () -> Array[Line]
1098
932
  def overlaps_with?: (Range[Integer] line_range) -> bool
1099
933
  def to_s: () -> String
@@ -1101,12 +935,9 @@ module SimpleCov
1101
935
  end
1102
936
  end
1103
937
 
1104
- # ----- source_file/statistics -----
1105
938
 
1106
939
  module SimpleCov
1107
940
  class SourceFile
1108
- # Builds the CoverageStatistics triple (:line/:branch/:method) for a
1109
- # SourceFile; disabled or empty criteria collapse to 0/0/0.
1110
941
  class Statistics
1111
942
  @source_file: SourceFile
1112
943
 
@@ -1127,49 +958,28 @@ module SimpleCov
1127
958
  end
1128
959
  end
1129
960
 
1130
- # ----- source_file/builder_context -----
1131
961
 
1132
962
  module SimpleCov
1133
963
  class SourceFile
1134
- # Helpers shared by the per-criterion builders (LineBuilder /
1135
- # BranchBuilder / MethodBuilder). Mixed into SourceFile so each
1136
- # builder can ask the file for its skip-chunk ranges and Prism-derived
1137
- # real source positions without duplicating the memoization.
1138
964
  module BuilderContext
1139
- # Positions extracted from the parsed source: branch start lines,
1140
- # and [method name, line] pairs. Method names are Symbols from
1141
- # runtime data and Strings after a JSON round-trip.
1142
965
  type real_positions = { branches: Set[Integer], methods: Set[[untyped, Integer]] }
1143
966
 
1144
967
  @skip_chunks: SkipChunks?
1145
968
  @real_source_positions: real_positions?
1146
969
 
1147
- # Skip-chunk lookup for the named criterion (`:line`, `:branch`,
1148
- # `:method`).
1149
970
  def skip_chunks_for: (criterion) -> Array[Range[Integer]]
1150
971
 
1151
- # Memoized set of real source positions extracted via Prism. Returns
1152
- # nil when Prism is unavailable or parsing fails, signaling callers
1153
- # to keep every Coverage entry (no false drops). The `defined?`
1154
- # guard preserves a nil memoization across calls.
1155
972
  def real_source_positions: () -> real_positions?
1156
973
 
1157
- # Provided by the including class (SourceFile).
1158
974
  def filename: () -> String
1159
975
  def src: () -> Array[String]
1160
976
  end
1161
977
  end
1162
978
  end
1163
979
 
1164
- # ----- coverage_statistics -----
1165
980
 
1166
981
  module SimpleCov
1167
- # Uniform per-criterion coverage statistics. Counts are Integers;
1168
- # percent and strength are Floats. `percent` is 100.0 whenever nothing
1169
- # was missed, including the 0-of-0 case; `strength` is 0.0 when there
1170
- # is nothing to cover.
1171
982
  class CoverageStatistics
1172
- # Seed for the reduce in .from: covered, missed, omitted, strength.
1173
983
  ZERO_STATS: [Integer, Integer, Integer, Float]
1174
984
 
1175
985
  attr_reader total: Integer
@@ -1181,8 +991,6 @@ module SimpleCov
1181
991
 
1182
992
  def self.from: (Array[CoverageStatistics] coverage_statistics) -> CoverageStatistics
1183
993
 
1184
- # `percent:` overrides the computed percentage (used to report 0%
1185
- # for tracked-but-never-loaded files).
1186
994
  def initialize: (covered: Integer, missed: Integer, ?omitted: Integer, ?total_strength: Integer | Float, ?percent: Float?) -> void
1187
995
 
1188
996
  private
@@ -1192,16 +1000,11 @@ module SimpleCov
1192
1000
  end
1193
1001
  end
1194
1002
 
1195
- # ----- last_run -----
1196
1003
 
1197
1004
  module SimpleCov
1198
- # Reads and writes coverage/.last_run.json — the previous run's
1199
- # coverage percentages used by MaximumCoverageDropCheck.
1200
1005
  module LastRun
1201
1006
  def self.last_run_path: () -> String
1202
1007
 
1203
- # nil when the file does not exist, is blank, or does not hold a
1204
- # JSON object. Keys are symbolized.
1205
1008
  def self.read: () -> Hash[Symbol, untyped]?
1206
1009
 
1207
1010
  def self.write: (Hash[Symbol, untyped] json) -> void
@@ -1210,41 +1013,29 @@ module SimpleCov
1210
1013
  end
1211
1014
  end
1212
1015
 
1213
- # ----- filter -----
1214
1016
 
1215
1017
  module SimpleCov
1216
- # Base filter class. Inherit and override `matches?` to create custom
1217
- # filters. `T` is the type of the configured filter argument.
1218
1018
  class Filter[T]
1219
1019
  attr_reader filter_argument: T
1220
1020
 
1221
1021
  def initialize: (T filter_argument) -> void
1222
1022
 
1223
- # The base implementation raises NotImplementedError.
1224
1023
  def matches?: (SourceFile source_file) -> boolish
1225
1024
 
1226
- # Whether the verdict depends only on the path, so it can be decided
1227
- # before the file has any coverage.
1228
1025
  def path_only?: () -> bool
1229
1026
 
1230
1027
  def self.build_filter: (filter_arg filter_argument, ?string_filter: singleton(Filter)) -> Filter[untyped]
1231
1028
 
1232
1029
  def self.class_for_argument: (filter_arg filter_argument) -> singleton(Filter)
1233
1030
 
1234
- # Maps raw filter-argument classes (String, Regexp, Array, Proc) to
1235
- # the Filter subclass that handles them. Private class method.
1236
1031
  self.@filter_classes_by_argument_type: Hash[Class, singleton(Filter)]?
1237
1032
 
1238
1033
  def self.filter_classes_by_argument_type: () -> Hash[Class, singleton(Filter)]
1239
1034
  end
1240
1035
 
1241
- # Matches when the project path contains the configured string at a
1242
- # path-segment boundary ("lib" matches "lib/foo.rb" but not "library/").
1243
1036
  class StringFilter < Filter[String]
1244
1037
  def matches?: (SourceFile source_file) -> bool
1245
1038
 
1246
- # Whether the verdict depends only on the path, so it can be decided
1247
- # before the file has any coverage.
1248
1039
  def path_only?: () -> bool
1249
1040
 
1250
1041
  private
@@ -1256,122 +1047,81 @@ module SimpleCov
1256
1047
  def compute_segment_pattern: () -> Regexp
1257
1048
  end
1258
1049
 
1259
- # Matches when the project path matches the configured Regexp.
1260
1050
  class RegexFilter < Filter[Regexp]
1261
1051
  def matches?: (SourceFile source_file) -> bool
1262
1052
 
1263
- # Whether the verdict depends only on the path, so it can be decided
1264
- # before the file has any coverage.
1265
1053
  def path_only?: () -> bool
1266
1054
  end
1267
1055
 
1268
- # Matches when the configured block returns truthy for the source file.
1269
1056
  class BlockFilter < Filter[^(SourceFile) -> boolish]
1270
1057
  def matches?: (SourceFile source_file) -> boolish
1271
1058
 
1272
- # Whether the verdict depends only on the path, so it can be decided
1273
- # before the file has any coverage.
1274
1059
  def path_only?: () -> bool
1275
1060
  end
1276
1061
 
1277
- # Matches when the project path matches the configured shell glob
1278
- # (e.g. "lib/**/*.rb").
1279
1062
  class GlobFilter < Filter[String]
1280
1063
  def matches?: (SourceFile source_file) -> bool
1281
1064
 
1282
- # Whether the verdict depends only on the path, so it can be decided
1283
- # before the file has any coverage.
1284
1065
  def path_only?: () -> bool
1285
1066
  end
1286
1067
 
1287
- # Matches when any of the component filters built from the array's
1288
- # elements match. Note: `filter_argument` holds the built Filter
1289
- # objects, not the raw array passed to `new`.
1290
1068
  class ArrayFilter < Filter[Array[Filter[untyped]]]
1291
1069
  def initialize: (Array[filter_arg] filter_argument) -> void
1292
1070
 
1293
1071
  def matches?: (SourceFile source_file) -> boolish
1294
1072
 
1295
- # Whether the verdict depends only on the path, so it can be decided
1296
- # before the file has any coverage.
1297
1073
  def path_only?: () -> bool
1298
1074
  end
1299
1075
  end
1300
1076
 
1301
- # ----- formatter -----
1302
1077
 
1303
1078
  module SimpleCov
1304
- # Namespace for result formatters. A formatter is any class whose
1305
- # instances respond to `#format(result)` and that can be instantiated
1306
- # with no arguments, or a ready-built instance responding to
1307
- # `#format(result)`; wire one up via `SimpleCov.formatter=` or
1308
- # `SimpleCov.formatters=`.
1309
1079
  module Formatter
1310
- # Structural interface for custom formatter instances.
1311
1080
  interface _Formatter
1312
1081
  def format: (SimpleCov::Result result) -> untyped
1313
1082
  end
1314
1083
 
1315
- # Normalizes a configured formatter — class or ready-built
1316
- # instance — into an instance. See #1240.
1317
1084
  def self.instance_for: (untyped formatter) -> untyped
1318
1085
 
1319
- # Instantiates a formatter class when necessary and dispatches the result.
1086
+ def self.instantiable?: (untyped formatter) -> bool
1087
+
1320
1088
  def self.format: (untyped formatter, SimpleCov::Result result) -> untyped
1321
1089
  end
1322
1090
  end
1323
1091
 
1324
- # ----- formatter/base -----
1325
1092
 
1326
1093
  module SimpleCov
1327
1094
  module Formatter
1328
- # @api private — shared scaffolding for formatters that write a
1329
- # report to an output directory and emit the "Coverage report
1330
- # generated for X to Y" status line on stderr. Subclasses implement
1331
- # `format`.
1332
1095
  class Base
1333
1096
  @silent: bool
1334
1097
  @output_dir: String?
1335
1098
 
1336
- # `output_dir` defaults to `SimpleCov.coverage_path` when nil.
1337
1099
  def initialize: (?silent: bool, ?output_dir: String?) -> void
1338
1100
 
1339
1101
  private
1340
1102
 
1341
- # Subclasses prepend a marker (e.g. "JSON ") to the summary line.
1342
1103
  def message_prefix: () -> String
1343
1104
 
1344
1105
  def output_path: () -> String
1345
1106
 
1346
- # Directory (relative to cwd when inside it) plus the subclass's
1347
- # `entry_point_filename`, for the status line. See issue #197.
1348
1107
  def displayable_output_path: () -> String
1349
1108
 
1350
1109
  def relative_or_absolute_output_path: () -> String
1351
1110
 
1352
- # Subclasses name the report's entry-point file (`index.html`,
1353
- # `coverage.json`); nil leaves the bare directory in the status line.
1354
1111
  def entry_point_filename: () -> String?
1355
1112
 
1356
- # Prints `output_message` to stderr unless silent; the one home of
1357
- # the "status lines go to stderr, not through warn" decision (#1225).
1358
- def emit_status: (SimpleCov::Result result) -> void
1113
+ def emit_status: (untyped result) -> void
1359
1114
 
1360
- def output_message: (SimpleCov::Result result) -> String
1115
+ def output_message: (untyped result) -> String
1361
1116
 
1362
- # nil for branch/method criteria with nothing to measure, so the
1363
- # summary doesn't print "Branch coverage: 0 / 0 (100.00%)" noise.
1364
1117
  def stats_line: (Symbol criterion, SimpleCov::CoverageStatistics stat) -> String?
1365
1118
  end
1366
1119
  end
1367
1120
  end
1368
1121
 
1369
- # ----- formatter/simple_formatter -----
1370
1122
 
1371
1123
  module SimpleCov
1372
1124
  module Formatter
1373
- # Renders the result as a plain-text string, one section per group.
1374
- # Returns the string; does not write anything to disk.
1375
1125
  class SimpleFormatter
1376
1126
  def format: (SimpleCov::Result result) -> String
1377
1127
 
@@ -1382,52 +1132,31 @@ module SimpleCov
1382
1132
  end
1383
1133
  end
1384
1134
 
1385
- # ----- formatter/multi_formatter -----
1386
1135
 
1387
1136
  module SimpleCov
1388
1137
  module Formatter
1389
- # Wraps multiple formatters so one configured formatter can drive
1390
- # several output formats (HTML + JSON, etc.) in a single run.
1391
1138
  class MultiFormatter
1392
- # Shared `#format` implementation, included into the anonymous
1393
- # classes that `MultiFormatter.new` builds. Formatter errors are
1394
- # rescued and mapped to nil, so the result array can hold nils.
1395
1139
  module InstanceMethods
1396
1140
  def format: (SimpleCov::Result result) -> Array[untyped]
1397
1141
 
1398
- # Defined via `define_method` on each class `MultiFormatter.new`
1399
- # builds; declared here so users of those classes type-check.
1400
1142
  def formatters: () -> Array[untyped]
1401
1143
  end
1402
1144
 
1403
- # Returns a newly built Class (not a MultiFormatter instance) whose
1404
- # instances respond to `#format` and `#formatters`. The argument is
1405
- # normalized with `Array()`: a single formatter, an array of
1406
- # formatters, or nil are all accepted.
1407
1145
  def self.new: (?untyped formatters) -> Class
1408
1146
  end
1409
1147
  end
1410
1148
  end
1411
1149
 
1412
- # ----- formatter/html_formatter -----
1413
1150
 
1414
1151
  module SimpleCov
1415
1152
  module Formatter
1416
- # Writes the HTML report as a single self-contained index.html (the
1417
- # compiled template with the coverage JSON substituted at the data
1418
- # marker), and coverage.json as a side artifact (shared serialization
1419
- # via JSONFormatter.build_hash).
1420
1153
  class HTMLFormatter < Base
1421
1154
  DATA_MARKER: "<!-- SIMPLECOV_COVERAGE_DATA -->"
1422
1155
 
1423
- # The sibling files a 1.0.0 through 1.0.3 report wrote next to
1424
- # index.html, removed by format when an earlier version left them.
1425
1156
  LEGACY_REPORT_FILES: Array[String]
1426
1157
 
1427
1158
  def format: (SimpleCov::Result result) -> void
1428
1159
 
1429
- # Generate HTML from a pre-existing coverage.json file without a
1430
- # live SimpleCov::Result or a running test suite.
1431
1160
  def format_from_json: (String json_path, String output_dir) -> void
1432
1161
 
1433
1162
  private
@@ -1436,11 +1165,8 @@ module SimpleCov
1436
1165
 
1437
1166
  def source_less_hash: (Hash[Symbol, untyped] hash) -> Hash[Symbol, untyped]
1438
1167
 
1439
- # Write coverage.json and index.html, then clear any legacy
1440
- # sibling files an earlier version left in the output directory.
1441
1168
  def write_report_files: (Hash[untyped, untyped] json_hash, Hash[untyped, untyped] viewer_hash, SimpleCov::Result result) -> void
1442
1169
 
1443
- # Substitute the coverage JSON into the compiled template.
1444
1170
  def render_report: (String json) -> String
1445
1171
 
1446
1172
  def public_dir: () -> String
@@ -1448,13 +1174,40 @@ module SimpleCov
1448
1174
  end
1449
1175
  end
1450
1176
 
1451
- # ----- formatter/coverage_json_writer -----
1452
1177
 
1453
1178
  module SimpleCov
1454
1179
  module Formatter
1455
- # Shared writer for the coverage.json artifact (JSONFormatter's
1456
- # report and HTMLFormatter's side file): one pretty-printed binary
1457
- # write plus the issue-#1171 concurrent-overwrite warning.
1180
+ class BaselineFormatter < Base
1181
+ def format: (SimpleCov::Result result) -> void
1182
+
1183
+ private
1184
+
1185
+ def ratchet: (SimpleCov::Result result) -> String
1186
+
1187
+ def generate: (Baseline::current_floors current) -> String
1188
+
1189
+ def summary: (Baseline::Outcome outcome, bool changed) -> String
1190
+
1191
+ def below_floors: (Array[String] regressed) -> String
1192
+
1193
+ def current_floors: (SimpleCov::Result result) -> Baseline::current_floors
1194
+
1195
+ def measured_criteria: () -> Array[Symbol]
1196
+
1197
+ def floor_of: (untyped file, Symbol criterion) -> { percent: Numeric, missed: Integer }
1198
+
1199
+ def write: (Baseline baseline) -> void
1200
+
1201
+ def output_path: () -> String
1202
+
1203
+ def output_message: (untyped message) -> String
1204
+ end
1205
+ end
1206
+ end
1207
+
1208
+
1209
+ module SimpleCov
1210
+ module Formatter
1458
1211
  module CoverageJSONWriter
1459
1212
  FILENAME: "coverage.json"
1460
1213
 
@@ -1462,20 +1215,14 @@ module SimpleCov
1462
1215
 
1463
1216
  def self?.write: (untyped output_path, Hash[Symbol, untyped] hash, SimpleCov::Result result) -> String
1464
1217
 
1465
- # Warns when an existing coverage.json is newer than this process's
1466
- # start time (a concurrent sibling writer). See issue #1171.
1467
1218
  def self?.warn_if_concurrent_overwrite: (String path, SimpleCov::Result result) -> void
1468
1219
 
1469
- # timestamp stays untyped (not Time) so the comparison sites don't
1470
- # require the stdlib `time` extension sigs; the value is produced by
1471
- # Time.iso8601 at runtime.
1472
1220
  def self?.existing_meta: (String path) -> ({ timestamp: untyped, command_name: untyped })?
1473
1221
 
1222
+ def self?.parse_time: (untyped value) -> untyped
1223
+
1474
1224
  def self?.parse_meta: (String path) -> Hash[Symbol, untyped]?
1475
1225
 
1476
- # Bounded head read that parses just the flat meta object of files
1477
- # this module wrote; nil on any miss so parse_meta falls back to a
1478
- # full parse.
1479
1226
  def self?.parse_meta_head: (String path) -> Hash[Symbol, untyped]?
1480
1227
 
1481
1228
  def self?.parse_meta_full: (String path) -> Hash[Symbol, untyped]?
@@ -1483,18 +1230,12 @@ module SimpleCov
1483
1230
  end
1484
1231
  end
1485
1232
 
1486
- # ----- formatter/json_formatter -----
1487
1233
 
1488
1234
  module SimpleCov
1489
1235
  module Formatter
1490
- # Writes coverage results as JSON to coverage/coverage.json.
1491
1236
  class JSONFormatter < Base
1492
1237
  FILENAME: "coverage.json"
1493
1238
 
1494
- # The hash serialized to coverage.json ($schema, meta, total,
1495
- # coverage, groups, errors). `include_source:` defaults to
1496
- # `SimpleCov.source_in_json`; pass true to force the per-file
1497
- # source arrays regardless of the global setting.
1498
1239
  def self.build_hash: (SimpleCov::Result result, ?include_source: bool) -> Hash[Symbol, untyped]
1499
1240
 
1500
1241
  def format: (SimpleCov::Result result) -> void
@@ -1508,10 +1249,8 @@ module SimpleCov
1508
1249
  end
1509
1250
  end
1510
1251
 
1511
- # ----- exit_codes -----
1512
1252
 
1513
1253
  module SimpleCov
1514
- # Exit codes SimpleCov uses when a coverage check fails.
1515
1254
  module ExitCodes
1516
1255
  SUCCESS: 0
1517
1256
 
@@ -1523,20 +1262,15 @@ module SimpleCov
1523
1262
 
1524
1263
  MAXIMUM_COVERAGE: 4
1525
1264
 
1526
- # Threshold-violation reports and exit-status notices: enforcement
1527
- # output on stderr, deliberately not routed through Kernel#warn.
1265
+ UNITS: Hash[Symbol, String]
1266
+
1528
1267
  def self.print_error: (String message) -> void
1529
1268
  end
1530
1269
  end
1531
1270
 
1532
- # ----- exit_codes/exit_code_handling -----
1533
1271
 
1534
1272
  module SimpleCov
1535
1273
  module ExitCodes
1536
- # The threshold-limit readers ExitCodeHandling consults. Satisfied by
1537
- # SimpleCov's own configuration, or by any object exposing the same
1538
- # readers (see the dogfood check in spec/helper.rb for an example
1539
- # built from a plain Data class).
1540
1274
  interface _CoverageLimits
1541
1275
  def minimum_coverage: () -> Hash[Symbol, Numeric]
1542
1276
 
@@ -1549,66 +1283,313 @@ module SimpleCov
1549
1283
  def maximum_coverage: () -> Hash[Symbol, Numeric]
1550
1284
 
1551
1285
  def maximum_coverage_drop: () -> Hash[Symbol, Numeric]
1286
+
1287
+ def maximum_missed: () -> Hash[Symbol, Integer]
1288
+
1289
+ def maximum_missed_per_file: () -> Hash[Symbol, Integer]
1290
+
1291
+ def maximum_missed_per_file_overrides: () -> untyped
1292
+
1293
+ def baseline: () -> Baseline?
1552
1294
  end
1553
1295
 
1554
- # Runs every coverage check against the result and returns the exit
1555
- # code of the first failing one, or SUCCESS when all pass.
1556
1296
  module ExitCodeHandling
1557
1297
  def self?.call: (SimpleCov::Result result, coverage_limits: _CoverageLimits) -> Integer
1558
1298
 
1559
1299
  def self?.coverage_checks: (SimpleCov::Result result, _CoverageLimits coverage_limits) -> Array[untyped]
1300
+
1301
+ def self?.minimum_by_file_check: (SimpleCov::Result result, _CoverageLimits coverage_limits) -> untyped
1302
+
1303
+ def self?.maximum_missed_per_file_check: (SimpleCov::Result result, _CoverageLimits coverage_limits) -> untyped
1560
1304
  end
1561
1305
  end
1562
1306
  end
1563
1307
 
1564
- # ----- profiles -----
1565
1308
 
1566
1309
  module SimpleCov
1567
- # Registry of named configuration procs, loadable via
1568
- # `SimpleCov.start :rails` and definable via
1569
- # `SimpleCov.profiles.define(:foo) { ... }`. The stored blocks are
1570
- # evaluated through `SimpleCov.configure`, so they self-bind to the
1571
- # configuration DSL.
1572
- # A stored profile block. The self-type is untyped because the block
1573
- # is written against the configuration DSL but stored as a plain Proc;
1574
- # it self-binds when SimpleCov.configure evaluates it.
1310
+ module History
1311
+ ENVELOPE: String
1312
+
1313
+ FORMAT_VERSION: Integer
1314
+
1315
+ type entry = Hash[String, untyped]
1316
+
1317
+ def self.history_path: () -> String
1318
+
1319
+ def self.record: (SimpleCov::Result result) -> void
1320
+
1321
+ def self.read: () -> Array[entry]
1322
+
1323
+ def self.entries_with: (SimpleCov::Result result) -> Array[entry]
1324
+
1325
+ def self.git_info: () -> [String?, String?]
1326
+
1327
+ private
1328
+
1329
+ def self.entry_for: (SimpleCov::Result result) -> entry
1330
+
1331
+ def self.measured_percents: (untyped stats_source) -> Hash[String, Numeric]
1332
+
1333
+ def self.files_percents: (SimpleCov::Result result) -> Hash[String, Hash[String, Numeric]]
1334
+
1335
+ def self.write: (Array[entry] entries) -> void
1336
+
1337
+ def self.invalid_history: () -> Array[entry]
1338
+
1339
+ def self.git: (*String args) -> String?
1340
+ end
1341
+ end
1342
+
1343
+
1344
+ module SimpleCov
1345
+ module Configuration
1346
+ DROP_BASELINES: Array[Symbol]
1347
+
1348
+ @history_limit: Integer?
1349
+
1350
+ @drop_baseline: Symbol?
1351
+
1352
+ def history_limit: (?Integer? limit) -> Integer
1353
+
1354
+ def history_limit=: (Integer limit) -> Integer
1355
+
1356
+ def drop_baseline: (?Symbol? mode) -> Symbol
1357
+ end
1358
+ end
1359
+
1360
+
1361
+ module SimpleCov
1362
+ module Configuration
1363
+ @production_coverage: String?
1364
+
1365
+ def production_coverage: (?String? path) -> String?
1366
+
1367
+ def production_coverage=: (String path) -> String
1368
+ end
1369
+ end
1370
+
1371
+
1372
+ module SimpleCov
1373
+ module Production
1374
+ class Error < StandardError
1375
+ end
1376
+
1377
+ interface _Sink
1378
+ def store: (Hash[String, Array[Integer]] coverage) -> untyped
1379
+ end
1380
+
1381
+ self.@running: bool?
1382
+ self.@pid: Integer?
1383
+ self.@started_coverage: bool?
1384
+ self.@root_prefix: String
1385
+ self.@sink: _Sink
1386
+ self.@flush_interval: Float | Integer
1387
+ self.@flush_jitter: Float | Integer
1388
+ self.@sample_rate: Float | Integer
1389
+ self.@max_buffered_lines: Integer
1390
+ self.@pending: Hash[String, Set[Integer]]
1391
+ self.@measuring: bool
1392
+ self.@mutex: Mutex
1393
+ self.@waiter: ConditionVariable
1394
+ self.@thread: Thread?
1395
+ self.@at_exit_installed: bool?
1396
+
1397
+ def self.start: (?root: String, ?sink: _Sink?, ?flush_interval: (Float | Integer),
1398
+ ?flush_jitter: (Float | Integer)?, ?sample_rate: (Float | Integer),
1399
+ ?max_buffered_lines: Integer) -> bool
1400
+
1401
+ def self.running?: () -> bool
1402
+
1403
+ def self.flush: () -> bool
1404
+
1405
+ def self.stop: () -> bool
1406
+
1407
+ def self.reset!: () -> void
1408
+
1409
+ private
1410
+
1411
+ def self.validate!: ((Float | Integer) flush_interval, (Float | Integer)? flush_jitter,
1412
+ (Float | Integer) sample_rate, Integer max_buffered_lines) -> void
1413
+
1414
+ def self.validate_jitter!: ((Float | Integer)? flush_jitter) -> void
1415
+
1416
+ def self.claim_coverage: () -> boolish
1417
+
1418
+ def self.oneshot_supported?: () -> bool
1419
+
1420
+ def self.configure: (String root, _Sink? sink, flush_interval: (Float | Integer),
1421
+ flush_jitter: (Float | Integer)?, sample_rate: (Float | Integer),
1422
+ max_buffered_lines: Integer) -> void
1423
+
1424
+ def self.default_sink: (String root) -> FileSink
1425
+
1426
+ def self.spawn_flush_thread: () -> void
1427
+
1428
+ def self.flush_loop: () -> void
1429
+
1430
+ def self.interval_with_jitter: () -> (Float | Integer)
1431
+
1432
+ def self.wake_flush_thread: () -> void
1433
+
1434
+ def self.cycle: () -> void
1435
+
1436
+ def self.resample: () -> void
1437
+
1438
+ def self.pull_pending: () -> void
1439
+
1440
+ def self.push_pending: () -> bool
1441
+
1442
+ def self.enforce_ceiling: () -> void
1443
+
1444
+ def self.relativize: (String path) -> String?
1445
+
1446
+ def self.warn_decline: (String reason) -> false
1447
+
1448
+ def self.install_at_exit: () -> void
1449
+
1450
+ end
1451
+ end
1452
+
1453
+
1454
+ module SimpleCov
1455
+ module Production
1456
+ class FileSink
1457
+ ENVELOPE: String
1458
+
1459
+ FORMAT_VERSION: Integer
1460
+
1461
+ attr_reader path: String
1462
+
1463
+ def initialize: (path: String) -> void
1464
+
1465
+ def store: (Hash[String, Array[Integer]] coverage) -> true
1466
+
1467
+ def self.read: (String path) -> Hash[String, untyped]
1468
+
1469
+ def self.parse: (String content, String path) -> Hash[String, untyped]
1470
+
1471
+ def self.envelope_of: (untyped document, String path) -> Hash[String, untyped]
1472
+
1473
+ private
1474
+
1475
+ def with_exclusive_lock: [T] () { (File file) -> T } -> T
1476
+
1477
+ def open_file: [T] (String name, Integer mode, Integer perm) { (File file) -> T } -> T
1478
+
1479
+ def rewrite: (File file, Hash[String, untyped] payload) -> void
1480
+
1481
+ def merge: (Hash[String, untyped] existing, Hash[String, Array[Integer]] incoming) -> Hash[String, untyped]
1482
+
1483
+ def envelope: (Hash[String, untyped] existing, Hash[String, Array[Integer]] incoming) -> Hash[String, untyped]
1484
+ end
1485
+ end
1486
+ end
1487
+
1488
+
1489
+ module SimpleCov
1490
+ class Baseline
1491
+ DEFAULT_FILENAME: String
1492
+
1493
+ class Floor
1494
+ attr_reader percent: Numeric
1495
+ attr_reader missed: Integer?
1496
+
1497
+ def initialize: (percent: Numeric, missed: Integer?) -> void
1498
+ end
1499
+
1500
+ class Outcome
1501
+ attr_reader baseline: Baseline
1502
+ attr_reader tightened: Array[String]
1503
+ attr_reader pruned: Array[String]
1504
+ attr_reader regressed: Array[String]
1505
+ attr_reader unchanged: Array[String]
1506
+
1507
+ def initialize: (baseline: Baseline, tightened: Array[String], pruned: Array[String],
1508
+ regressed: Array[String], unchanged: Array[String]) -> void
1509
+ end
1510
+
1511
+ type current_floors = Hash[String, Hash[Symbol, {percent: Numeric, missed: Integer}]]
1512
+
1513
+ def self.read_if_exists: (String path) -> Baseline?
1514
+
1515
+ def self.read: (String path) -> Baseline?
1516
+
1517
+ def self.generate: (current_floors current) -> Baseline
1518
+
1519
+ attr_reader entries: Hash[String, Hash[Symbol, Floor]]
1520
+
1521
+ def initialize: (Hash[String, Hash[Symbol, Floor]] entries) -> void
1522
+
1523
+ def entry_for: (String project_filename) -> Hash[Symbol, Floor]?
1524
+
1525
+ def floor_for: (String project_filename, Symbol criterion) -> Floor?
1526
+
1527
+ def covers?: (String project_filename, Symbol criterion) -> bool
1528
+
1529
+ def ratchet: (current_floors current) -> Outcome
1530
+
1531
+ def to_yaml: () -> String
1532
+
1533
+ private
1534
+
1535
+ def ratchet_entry: (Hash[Symbol, Floor] entry, Hash[Symbol, {percent: Numeric, missed: Integer}]? current_entry) -> {bucket: Symbol, ?entry: Hash[Symbol, Floor]}
1536
+
1537
+ def bucket_for: (Hash[Symbol, Floor] entry, Hash[Symbol, Floor] merged, Hash[Symbol, {percent: Numeric, missed: Integer}] current_entry) -> Symbol
1538
+
1539
+ def tighten: (Floor? floor, {percent: Numeric, missed: Integer}? current) -> Floor
1540
+
1541
+ def dump_floor: (Floor floor) -> Hash[String, untyped]
1542
+ end
1543
+ end
1544
+
1545
+
1546
+ module SimpleCov
1547
+ module Configuration
1548
+ DEPRECATION_MODES: Array[Symbol]
1549
+
1550
+ @deprecations: Symbol?
1551
+
1552
+ def deprecations: (?Symbol? mode) -> Symbol
1553
+ end
1554
+ end
1555
+
1556
+
1557
+ module SimpleCov
1558
+ module Configuration
1559
+ @baseline_file: String?
1560
+
1561
+ @baseline: Baseline?
1562
+
1563
+ @baseline_path: String?
1564
+
1565
+ def baseline_file: (?String? path) -> String
1566
+
1567
+ def baseline_file=: (String path) -> String
1568
+
1569
+ def baseline: () -> Baseline?
1570
+ end
1571
+ end
1572
+
1573
+
1574
+ module SimpleCov
1575
1575
  type profile_proc = ^() [self: untyped] -> void
1576
1576
 
1577
1577
  class Profiles < Hash[Symbol, profile_proc]
1578
- # Raises SimpleCov::ConfigurationError when the name is taken.
1579
- # The block runs via instance_exec against the SimpleCov module itself
1580
- # (which extends Configuration), not a Configuration instance.
1581
1578
  def define: (Symbol | String name) { () [self: singleton(SimpleCov)] -> void } -> profile_proc
1582
1579
 
1583
- # Applies the named profile via SimpleCov.configure.
1584
1580
  def load: (Symbol | String name) -> void
1585
1581
 
1586
- # Returns the proc for the given profile name, autoloading bundled
1587
- # ("simplecov/profiles/<name>") or plugin-gem
1588
- # ("simplecov-profile-<name>") profiles on first lookup. Raises
1589
- # SimpleCov::ConfigurationError when none is found.
1590
1582
  def fetch_proc: (Symbol | String name) -> profile_proc
1591
1583
 
1592
1584
  private
1593
1585
 
1594
- # Tries `require "simplecov/profiles/<name>"`, then
1595
- # `require "simplecov-profile-<name>"`; swallows LoadError so
1596
- # fetch_proc raises the user-facing error.
1597
1586
  def autoload_profile: (Symbol name) -> void
1598
1587
  end
1599
1588
  end
1600
1589
 
1601
- # ----- parallel_adapters -----
1602
1590
 
1603
1591
  module SimpleCov
1604
- # Registry + selection for parallel-test-runner adapters. An adapter is
1605
- # a class (used as a singleton, never instantiated) answering the
1606
- # `_Adapter` contract; subclass `ParallelAdapters::Base` to inherit
1607
- # no-op defaults. Register custom adapters via
1608
- # `SimpleCov::ParallelAdapters.register MyRunnerAdapter`.
1609
1592
  module ParallelAdapters
1610
- # The class-level contract an adapter must answer. `singleton(Base)`
1611
- # and its subclasses satisfy this structurally.
1612
1593
  interface _Adapter
1613
1594
  def active?: () -> boolish
1614
1595
 
@@ -1621,93 +1602,51 @@ module SimpleCov
1621
1602
  def expected_worker_count: () -> Integer
1622
1603
  end
1623
1604
 
1624
- # Registry state. Declared on both the instance and singleton sides
1625
- # because `module_function` bodies type-check as instance methods
1626
- # while runtime state lives on the module itself.
1627
1605
  @adapters: Array[_Adapter]?
1628
1606
 
1629
1607
  self.@adapters: Array[_Adapter]?
1630
1608
 
1631
- # Memoized current adapter. Distinguishes "not yet computed" (ivar
1632
- # undefined) from "computed, no adapter active" (nil), hence the
1633
- # `defined?` guard in the implementation.
1634
1609
  @current: _Adapter?
1635
1610
 
1636
1611
  self.@current: _Adapter?
1637
1612
 
1638
- # Adapters in selection order: user-registered adapters first, then
1639
- # ParallelTestsAdapter, then GenericAdapter.
1640
1613
  def self?.adapters: () -> Array[_Adapter]
1641
1614
 
1642
- # Registers a custom adapter at the front of the selection list and
1643
- # returns it. Clears the memoized `current` selection.
1644
1615
  def self?.register: (_Adapter adapter) -> _Adapter
1645
1616
 
1646
- # The first registered adapter whose `active?` returns true, or nil
1647
- # when no recognized parallel runner is active (single-worker run).
1648
1617
  def self?.current: () -> _Adapter?
1649
1618
 
1650
- # Clears the memoized `current` selection (primarily for tests that
1651
- # mutate env vars between examples).
1652
1619
  def self?.reset_current!: () -> void
1653
1620
  end
1654
1621
  end
1655
1622
 
1656
- # ----- parallel_adapters/base -----
1657
1623
 
1658
1624
  module SimpleCov
1659
1625
  module ParallelAdapters
1660
- # No-op defaults for a parallel-test-runner adapter: behave like a
1661
- # single-process run. Real adapters subclass and override what they
1662
- # need. The contract methods are class methods; adapters are never
1663
- # instantiated.
1664
1626
  class Base
1665
- # Should this adapter be selected for the current process? The
1666
- # first registered adapter whose `active?` returns truthy wins.
1667
1627
  def self.active?: () -> boolish
1668
1628
 
1669
- # Should THIS worker do the final-result work (wait for siblings,
1670
- # merge resultsets, run threshold checks, format the report)?
1671
- # Defaults to true for the single-process case.
1672
1629
  def self.first_worker?: () -> bool
1673
1630
 
1674
- # Optional: block until sibling workers have finished writing
1675
- # their resultsets. The no-op default leaves synchronization to
1676
- # SimpleCov's resultset polling fallback.
1677
1631
  def self.wait_for_siblings: () -> void
1678
1632
 
1679
- # Does `wait_for_siblings` block until every sibling process has
1680
- # exited? When true, a settled resultset count below
1681
- # `expected_worker_count` is accepted as final.
1682
1633
  def self.native_wait?: () -> boolish
1683
1634
 
1684
- # How many parallel workers participate in this run. Defaults to 1.
1685
1635
  def self.expected_worker_count: () -> Integer
1686
1636
 
1687
- # The user's explicit `SimpleCov.parallel_tests false` opt-out.
1688
1637
  def self.forced_off?: () -> bool
1689
1638
 
1690
- # Shared PARALLEL_TEST_GROUPS parsing; 1 for unset, empty,
1691
- # non-numeric, or non-positive values.
1692
1639
  def self.parallel_test_groups_count: () -> Integer
1693
1640
  end
1694
1641
  end
1695
1642
  end
1696
1643
 
1697
- # ----- parallel_adapters/generic -----
1698
1644
 
1699
1645
  module SimpleCov
1700
1646
  module ParallelAdapters
1701
- # Catch-all adapter for runners that follow the `TEST_ENV_NUMBER` /
1702
- # `PARALLEL_TEST_GROUPS` env-var convention without shipping a Ruby
1703
- # API (parallel_rspec, knapsack-style splitters, custom CI sharding).
1704
- # Activates when `TEST_ENV_NUMBER` is set, unless
1705
- # `SimpleCov.parallel_tests false` opted out.
1706
1647
  class GenericAdapter < Base
1707
1648
  def self.active?: () -> bool
1708
1649
 
1709
- # First worker is TEST_ENV_NUMBER "" (parallel_tests convention)
1710
- # or "1" (runners that number from 1).
1711
1650
  def self.first_worker?: () -> bool
1712
1651
 
1713
1652
  def self.expected_worker_count: () -> Integer
@@ -1715,32 +1654,20 @@ module SimpleCov
1715
1654
  end
1716
1655
  end
1717
1656
 
1718
- # ----- parallel_adapters/parallel_tests -----
1719
1657
 
1720
1658
  module SimpleCov
1721
1659
  module ParallelAdapters
1722
- # Adapter for grosser/parallel_tests. Requires the full native
1723
- # coordination contract (ParallelTests constant loaded,
1724
- # TEST_ENV_NUMBER and PARALLEL_PID_FILE set); env-var-only setups
1725
- # fall through to GenericAdapter.
1726
1660
  class ParallelTestsAdapter < Base
1727
1661
  def self.active?: () -> bool
1728
1662
 
1729
- # Delegates to ParallelTests.first_process? (the first started
1730
- # process does the final-result work; see issue #922).
1731
1663
  def self.first_worker?: () -> bool
1732
1664
 
1733
- # Uses ParallelTests.wait_for_other_processes_to_finish when the
1734
- # pid-file contract is present.
1735
1665
  def self.wait_for_siblings: () -> void
1736
1666
 
1737
1667
  def self.native_wait?: () -> bool
1738
1668
 
1739
1669
  def self.expected_worker_count: () -> Integer
1740
1670
 
1741
- # Auto-requires parallel_tests when installed and the env vars it
1742
- # sets are present; a missing gem is treated as "not using
1743
- # parallel_tests" (see issue #1018).
1744
1671
  def self.ensure_loaded: () -> void
1745
1672
 
1746
1673
  def self.env_suggests_parallel_tests?: () -> bool
@@ -1750,28 +1677,29 @@ module SimpleCov
1750
1677
  end
1751
1678
  end
1752
1679
 
1753
- # ----- deprecation -----
1754
1680
 
1755
1681
  module SimpleCov
1756
- # Emits legacy-API deprecation warnings, deduplicated by the source
1757
- # location that triggered them (see issue #1204).
1758
1682
  module Deprecation
1759
- # Warns about a deprecated API at most once per call-site location.
1760
- # `message` is the notice without the `[DEPRECATION]` tag or location
1761
- # prefix; `location` defaults to the caller of the deprecated method.
1683
+ MODES: Array[Symbol]
1684
+
1685
+ def self?.mode: () -> Symbol
1686
+
1687
+ def self?.mode=: (Symbol mode) -> Symbol
1688
+
1762
1689
  def self?.warn: (String message, ?location: String?) -> void
1763
1690
 
1764
- # Dedup keys (locations, or messages when no backtrace is available)
1765
- # already emitted by this process. Declared on both the instance and
1766
- # singleton sides because `module_function` bodies type-check as
1767
- # instance methods while runtime state lives on the module itself.
1691
+ def self?.caller_location: () -> String?
1692
+
1768
1693
  @emitted: Set[String]?
1769
1694
 
1770
1695
  self.@emitted: Set[String]?
1771
1696
 
1697
+ @mode: Symbol?
1698
+
1699
+ self.@mode: Symbol?
1700
+
1772
1701
  def self?.emitted: () -> Set[String]
1773
1702
 
1774
- # @api private — reset emitted state between tests.
1775
1703
  def self?.reset!: () -> void
1776
1704
  end
1777
1705
  end