polyrun 3.2.0-java

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 (225) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +234 -0
  3. data/CODE_OF_CONDUCT.md +26 -0
  4. data/CONTRIBUTING.md +23 -0
  5. data/LICENSE +21 -0
  6. data/README.md +251 -0
  7. data/SECURITY.md +25 -0
  8. data/bin/polyrun +6 -0
  9. data/docs/QUALITY.md +82 -0
  10. data/docs/QUALITY_CONFIGURATION.md +95 -0
  11. data/docs/SETUP_PROFILE.md +139 -0
  12. data/lib/polyrun/benchmark/pressure/cooker.rb +191 -0
  13. data/lib/polyrun/benchmark/pressure/process_sample.rb +127 -0
  14. data/lib/polyrun/benchmark/pressure.rb +144 -0
  15. data/lib/polyrun/benchmark/profile.rb +191 -0
  16. data/lib/polyrun/benchmark/report.rb +87 -0
  17. data/lib/polyrun/cli/benchmark_commands.rb +66 -0
  18. data/lib/polyrun/cli/ci_shard_hooks.rb +129 -0
  19. data/lib/polyrun/cli/ci_shard_run_command.rb +177 -0
  20. data/lib/polyrun/cli/ci_shard_run_parse.rb +68 -0
  21. data/lib/polyrun/cli/config_command.rb +42 -0
  22. data/lib/polyrun/cli/coverage_commands.rb +150 -0
  23. data/lib/polyrun/cli/coverage_merge_io.rb +150 -0
  24. data/lib/polyrun/cli/database_commands.rb +163 -0
  25. data/lib/polyrun/cli/default_run.rb +144 -0
  26. data/lib/polyrun/cli/doctor_command.rb +94 -0
  27. data/lib/polyrun/cli/env_commands.rb +43 -0
  28. data/lib/polyrun/cli/failure_commands.rb +99 -0
  29. data/lib/polyrun/cli/graph_command.rb +68 -0
  30. data/lib/polyrun/cli/help.rb +83 -0
  31. data/lib/polyrun/cli/helpers.rb +162 -0
  32. data/lib/polyrun/cli/hooks_command.rb +97 -0
  33. data/lib/polyrun/cli/init_command.rb +108 -0
  34. data/lib/polyrun/cli/mutation_command.rb +67 -0
  35. data/lib/polyrun/cli/partition_diagnostics.rb +22 -0
  36. data/lib/polyrun/cli/plan_command.rb +184 -0
  37. data/lib/polyrun/cli/prepare_command.rb +70 -0
  38. data/lib/polyrun/cli/prepare_recipe.rb +82 -0
  39. data/lib/polyrun/cli/quality_commands.rb +65 -0
  40. data/lib/polyrun/cli/queue_command.rb +161 -0
  41. data/lib/polyrun/cli/quick_command.rb +13 -0
  42. data/lib/polyrun/cli/report_commands.rb +108 -0
  43. data/lib/polyrun/cli/run_queue_command.rb +127 -0
  44. data/lib/polyrun/cli/run_shards_command.rb +164 -0
  45. data/lib/polyrun/cli/run_shards_parallel_children.rb +112 -0
  46. data/lib/polyrun/cli/run_shards_parallel_wait.rb +252 -0
  47. data/lib/polyrun/cli/run_shards_plan_boot_phases.rb +207 -0
  48. data/lib/polyrun/cli/run_shards_plan_options.rb +74 -0
  49. data/lib/polyrun/cli/run_shards_planning.rb +123 -0
  50. data/lib/polyrun/cli/run_shards_run.rb +171 -0
  51. data/lib/polyrun/cli/run_shards_worker_interrupt.rb +101 -0
  52. data/lib/polyrun/cli/skip_env.rb +34 -0
  53. data/lib/polyrun/cli/spec_quality_commands.rb +149 -0
  54. data/lib/polyrun/cli/start_bootstrap.rb +126 -0
  55. data/lib/polyrun/cli/timing_command.rb +31 -0
  56. data/lib/polyrun/cli/tool_options.rb +48 -0
  57. data/lib/polyrun/cli/validate_command.rb +26 -0
  58. data/lib/polyrun/cli.rb +272 -0
  59. data/lib/polyrun/config/dotted_path.rb +21 -0
  60. data/lib/polyrun/config/effective.rb +82 -0
  61. data/lib/polyrun/config/resolver.rb +114 -0
  62. data/lib/polyrun/config/schema.rb +39 -0
  63. data/lib/polyrun/config/suite.rb +109 -0
  64. data/lib/polyrun/config/tool_defaults.rb +42 -0
  65. data/lib/polyrun/config/tool_validation.rb +79 -0
  66. data/lib/polyrun/config/tools.rb +120 -0
  67. data/lib/polyrun/config.rb +97 -0
  68. data/lib/polyrun/coverage/cobertura_zero_lines.rb +32 -0
  69. data/lib/polyrun/coverage/collector.rb +169 -0
  70. data/lib/polyrun/coverage/collector_blob.rb +53 -0
  71. data/lib/polyrun/coverage/collector_finish.rb +98 -0
  72. data/lib/polyrun/coverage/collector_fragment_meta.rb +57 -0
  73. data/lib/polyrun/coverage/config_resolve.rb +131 -0
  74. data/lib/polyrun/coverage/example_diff.rb +184 -0
  75. data/lib/polyrun/coverage/example_diff_snapshot.rb +44 -0
  76. data/lib/polyrun/coverage/example_diff_track_filter.rb +51 -0
  77. data/lib/polyrun/coverage/file_stats_report.rb +36 -0
  78. data/lib/polyrun/coverage/filter.rb +22 -0
  79. data/lib/polyrun/coverage/formatter.rb +137 -0
  80. data/lib/polyrun/coverage/merge/formatters.rb +188 -0
  81. data/lib/polyrun/coverage/merge/formatters_html.rb +221 -0
  82. data/lib/polyrun/coverage/merge/html/_file_list.html.erb +21 -0
  83. data/lib/polyrun/coverage/merge/html/_file_section.html.erb +26 -0
  84. data/lib/polyrun/coverage/merge/html/_groups_table.html.erb +18 -0
  85. data/lib/polyrun/coverage/merge/html/_overview.html.erb +47 -0
  86. data/lib/polyrun/coverage/merge/html/report.css +147 -0
  87. data/lib/polyrun/coverage/merge/html/report.js +48 -0
  88. data/lib/polyrun/coverage/merge/html/template.html.erb +30 -0
  89. data/lib/polyrun/coverage/merge.rb +160 -0
  90. data/lib/polyrun/coverage/merge_fragment_meta.rb +58 -0
  91. data/lib/polyrun/coverage/merge_merge_two.rb +168 -0
  92. data/lib/polyrun/coverage/merge_native.rb +39 -0
  93. data/lib/polyrun/coverage/rails.rb +126 -0
  94. data/lib/polyrun/coverage/reporting.rb +41 -0
  95. data/lib/polyrun/coverage/result.rb +18 -0
  96. data/lib/polyrun/coverage/track_files.rb +150 -0
  97. data/lib/polyrun/data/cached_fixtures.rb +122 -0
  98. data/lib/polyrun/data/factory_counts.rb +48 -0
  99. data/lib/polyrun/data/factory_instrumentation.rb +50 -0
  100. data/lib/polyrun/data/fixtures.rb +68 -0
  101. data/lib/polyrun/data/parallel_provisioning.rb +93 -0
  102. data/lib/polyrun/data/snapshot.rb +84 -0
  103. data/lib/polyrun/database/clone_shards.rb +106 -0
  104. data/lib/polyrun/database/provision.rb +83 -0
  105. data/lib/polyrun/database/shard.rb +64 -0
  106. data/lib/polyrun/database/url_builder/connection/infer.rb +53 -0
  107. data/lib/polyrun/database/url_builder/connection/url_builders.rb +43 -0
  108. data/lib/polyrun/database/url_builder/connection.rb +191 -0
  109. data/lib/polyrun/database/url_builder/template_prepare.rb +21 -0
  110. data/lib/polyrun/database/url_builder.rb +188 -0
  111. data/lib/polyrun/debug.rb +81 -0
  112. data/lib/polyrun/env/ci.rb +65 -0
  113. data/lib/polyrun/error.rb +3 -0
  114. data/lib/polyrun/export/csv.rb +25 -0
  115. data/lib/polyrun/export/markdown.rb +47 -0
  116. data/lib/polyrun/graph/client.rb +64 -0
  117. data/lib/polyrun/graph/error.rb +13 -0
  118. data/lib/polyrun/graph/index.rb +75 -0
  119. data/lib/polyrun/graph/inspect.rb +58 -0
  120. data/lib/polyrun/graph/plan.rb +134 -0
  121. data/lib/polyrun/graph/planner.rb +117 -0
  122. data/lib/polyrun/graph/syntax.rb +114 -0
  123. data/lib/polyrun/graph/transaction.rb +81 -0
  124. data/lib/polyrun/graph/worker.rb +55 -0
  125. data/lib/polyrun/graph/workspace.rb +117 -0
  126. data/lib/polyrun/hooks/dsl.rb +128 -0
  127. data/lib/polyrun/hooks/shell_runner.rb +33 -0
  128. data/lib/polyrun/hooks/worker_runner.rb +27 -0
  129. data/lib/polyrun/hooks/worker_shell.rb +50 -0
  130. data/lib/polyrun/hooks.rb +190 -0
  131. data/lib/polyrun/log.rb +86 -0
  132. data/lib/polyrun/minitest_support.rb +60 -0
  133. data/lib/polyrun/mutation/candidates.rb +91 -0
  134. data/lib/polyrun/mutation/operators.rb +51 -0
  135. data/lib/polyrun/mutation/runner.rb +133 -0
  136. data/lib/polyrun/mutation/subjects.rb +88 -0
  137. data/lib/polyrun/partition/constraints.rb +80 -0
  138. data/lib/polyrun/partition/hrw.rb +70 -0
  139. data/lib/polyrun/partition/min_heap.rb +64 -0
  140. data/lib/polyrun/partition/paths.rb +175 -0
  141. data/lib/polyrun/partition/paths_build.rb +141 -0
  142. data/lib/polyrun/partition/plan.rb +250 -0
  143. data/lib/polyrun/partition/plan_lpt.rb +91 -0
  144. data/lib/polyrun/partition/plan_sharding.rb +56 -0
  145. data/lib/polyrun/partition/reports.rb +139 -0
  146. data/lib/polyrun/partition/stable_shuffle.rb +18 -0
  147. data/lib/polyrun/partition/suite.rb +120 -0
  148. data/lib/polyrun/partition/timing_diagnostics.rb +138 -0
  149. data/lib/polyrun/partition/timing_keys.rb +86 -0
  150. data/lib/polyrun/prepare/artifacts.rb +40 -0
  151. data/lib/polyrun/prepare/assets.rb +64 -0
  152. data/lib/polyrun/process_stdio.rb +96 -0
  153. data/lib/polyrun/quality/command.rb +84 -0
  154. data/lib/polyrun/quality/measure.rb +38 -0
  155. data/lib/polyrun/quality/observe.rb +53 -0
  156. data/lib/polyrun/quality/observe_hook.rb +103 -0
  157. data/lib/polyrun/quality/sandbox.rb +70 -0
  158. data/lib/polyrun/queue/duration.rb +30 -0
  159. data/lib/polyrun/queue/file_store.rb +413 -0
  160. data/lib/polyrun/queue/file_store_intent.rb +188 -0
  161. data/lib/polyrun/queue/file_store_pending.rb +48 -0
  162. data/lib/polyrun/queue/worker_loop.rb +73 -0
  163. data/lib/polyrun/quick/assertions.rb +32 -0
  164. data/lib/polyrun/quick/config.rb +56 -0
  165. data/lib/polyrun/quick/errors.rb +6 -0
  166. data/lib/polyrun/quick/example_group.rb +111 -0
  167. data/lib/polyrun/quick/example_runner.rb +129 -0
  168. data/lib/polyrun/quick/matchers.rb +159 -0
  169. data/lib/polyrun/quick/matchers_predicates.rb +122 -0
  170. data/lib/polyrun/quick/reporter.rb +76 -0
  171. data/lib/polyrun/quick/runner.rb +224 -0
  172. data/lib/polyrun/quick.rb +1 -0
  173. data/lib/polyrun/railtie.rb +7 -0
  174. data/lib/polyrun/reporting/failure_merge.rb +171 -0
  175. data/lib/polyrun/reporting/junit.rb +126 -0
  176. data/lib/polyrun/reporting/junit_emit.rb +58 -0
  177. data/lib/polyrun/reporting/junit_report.rb +87 -0
  178. data/lib/polyrun/reporting/rspec_failure_fragment_formatter.rb +95 -0
  179. data/lib/polyrun/reporting/rspec_junit.rb +39 -0
  180. data/lib/polyrun/rspec_support/active_record_timeout_recovery.rb +51 -0
  181. data/lib/polyrun/rspec_support/example_debug.rb +167 -0
  182. data/lib/polyrun/rspec_support/example_debug_instrumentation.rb +73 -0
  183. data/lib/polyrun/rspec_support/sharded_formatter_compat.rb +57 -0
  184. data/lib/polyrun/rspec_support.rb +110 -0
  185. data/lib/polyrun/spec_quality/config.rb +139 -0
  186. data/lib/polyrun/spec_quality/fragment.rb +39 -0
  187. data/lib/polyrun/spec_quality/merge.rb +78 -0
  188. data/lib/polyrun/spec_quality/minitest_hook.rb +42 -0
  189. data/lib/polyrun/spec_quality/plan_loader.rb +47 -0
  190. data/lib/polyrun/spec_quality/profile.rb +102 -0
  191. data/lib/polyrun/spec_quality/report.rb +363 -0
  192. data/lib/polyrun/spec_quality/rspec_hook.rb +55 -0
  193. data/lib/polyrun/spec_quality/sql_counter.rb +34 -0
  194. data/lib/polyrun/spec_quality.rb +212 -0
  195. data/lib/polyrun/sus_support.rb +55 -0
  196. data/lib/polyrun/templates/POLYRUN.md +51 -0
  197. data/lib/polyrun/templates/ci_matrix.polyrun.yml +22 -0
  198. data/lib/polyrun/templates/minimal_gem.polyrun.yml +13 -0
  199. data/lib/polyrun/templates/polyrun_hooks_spec_quality.rb +12 -0
  200. data/lib/polyrun/templates/polyrun_spec_quality.yml +20 -0
  201. data/lib/polyrun/templates/rails_prepare.polyrun.yml +51 -0
  202. data/lib/polyrun/templates/rails_prepare_task.rake +16 -0
  203. data/lib/polyrun/timing/merge.rb +36 -0
  204. data/lib/polyrun/timing/rspec_example_formatter.rb +60 -0
  205. data/lib/polyrun/timing/stats.rb +76 -0
  206. data/lib/polyrun/timing/summary.rb +78 -0
  207. data/lib/polyrun/timing/variance_report.rb +51 -0
  208. data/lib/polyrun/version.rb +3 -0
  209. data/lib/polyrun/worker_output.rb +181 -0
  210. data/lib/polyrun/worker_output_forwarders.rb +94 -0
  211. data/lib/polyrun/worker_ping.rb +77 -0
  212. data/lib/polyrun.rb +59 -0
  213. data/polyrun.gemspec +49 -0
  214. data/sig/polyrun/cli.rbs +6 -0
  215. data/sig/polyrun/config.rbs +20 -0
  216. data/sig/polyrun/debug.rbs +12 -0
  217. data/sig/polyrun/log.rbs +12 -0
  218. data/sig/polyrun/minitest_support.rbs +7 -0
  219. data/sig/polyrun/quick.rbs +19 -0
  220. data/sig/polyrun/rspec_support.rbs +21 -0
  221. data/sig/polyrun/sus_support.rbs +7 -0
  222. data/sig/polyrun/worker_output.rbs +11 -0
  223. data/sig/polyrun/worker_ping.rbs +10 -0
  224. data/sig/polyrun.rbs +11 -0
  225. metadata +463 -0
@@ -0,0 +1,221 @@
1
+ # rubocop:disable Polyrun/FileLength -- HTML merge formatter + helpers in one file
2
+ require "cgi"
3
+ require "digest/sha1"
4
+ require "erb"
5
+ require "pathname"
6
+
7
+ module Polyrun
8
+ module Coverage
9
+ module Merge
10
+ module_function
11
+
12
+ # Standalone HTML report with summary, file table, and per-file source details.
13
+ # rubocop:disable Metrics/AbcSize -- linear assembly of overview, file table, sections, asset reads
14
+ def emit_html(coverage_blob, title: "Polyrun coverage", root: nil, groups: nil, generated_at: Time.now)
15
+ files = coverage_blob.keys.sort.map { |path| html_file_payload(path, coverage_blob[path], root) }
16
+ summary = html_summary(files)
17
+ groups_html = render_html_partial("groups_table", group_rows_html: html_group_rows(groups).join("\n"))
18
+ overview_html = render_html_partial(
19
+ "overview",
20
+ summary: summary,
21
+ summary_badge_class: html_badge_class(summary[:line_percent]),
22
+ groups_html: groups_html
23
+ )
24
+ file_list_html = render_html_partial("file_list", file_rows_html: files.map { |file| html_file_list_row(file) }.join("\n"))
25
+ file_sections_html = files.map { |file| render_html_partial("file_section", file: file) }.join("\n")
26
+ html_root_template_erb.result_with_hash(
27
+ title: CGI.escapeHTML(title.to_s),
28
+ generated_label: html_generated_label(generated_at),
29
+ overview_html: overview_html,
30
+ file_list_html: file_list_html,
31
+ file_sections_html: file_sections_html,
32
+ stylesheet: File.read(html_stylesheet_path, encoding: Encoding::UTF_8),
33
+ javascript: File.read(html_javascript_path, encoding: Encoding::UTF_8)
34
+ )
35
+ end
36
+ # rubocop:enable Metrics/AbcSize
37
+
38
+ def html_asset_dir
39
+ File.join(__dir__, "html")
40
+ end
41
+
42
+ def html_template_path
43
+ File.join(html_asset_dir, "template.html.erb")
44
+ end
45
+
46
+ def html_stylesheet_path
47
+ File.join(html_asset_dir, "report.css")
48
+ end
49
+
50
+ def html_javascript_path
51
+ File.join(html_asset_dir, "report.js")
52
+ end
53
+
54
+ def html_partial_path(name)
55
+ File.join(html_asset_dir, "_#{name}.html.erb")
56
+ end
57
+
58
+ def render_html_partial(name, locals = {})
59
+ html_partial_erb(name).result_with_hash(locals)
60
+ end
61
+
62
+ # rubocop:disable ThreadSafety/ClassInstanceVariable -- template cache keyed by partial name; process-local
63
+ def html_partial_erb(name)
64
+ @html_partial_erbs ||= {}
65
+ @html_partial_erbs[name] ||= ERB.new(
66
+ File.read(html_partial_path(name), encoding: Encoding::UTF_8),
67
+ trim_mode: "-"
68
+ )
69
+ end
70
+
71
+ def html_root_template_erb
72
+ @html_root_template_erb ||= ERB.new(
73
+ File.read(html_template_path, encoding: Encoding::UTF_8),
74
+ trim_mode: "-"
75
+ )
76
+ end
77
+ # rubocop:enable ThreadSafety/ClassInstanceVariable
78
+ private_class_method :html_partial_erb, :html_root_template_erb
79
+
80
+ def html_file_payload(path, file, root)
81
+ line_arr = line_array_from_file_entry(file) || []
82
+ source_lines = html_source_lines(path, line_arr.length)
83
+ counts = line_counts(file)
84
+ relevant = counts[:relevant]
85
+ covered = counts[:covered]
86
+ total_hits = line_arr.sum { |hit| html_numeric_hit(hit) || 0 }
87
+ pct = relevant.positive? ? (100.0 * covered / relevant) : 0.0
88
+ {
89
+ id: "file-#{Digest::SHA1.hexdigest(path.to_s)}",
90
+ path: path.to_s,
91
+ display_path: html_display_path(path, root),
92
+ badge_class: html_badge_class(pct),
93
+ total_lines: [source_lines.length, line_arr.length].max,
94
+ relevant: relevant,
95
+ covered: covered,
96
+ missed: relevant - covered,
97
+ avg_hits: relevant.positive? ? (total_hits.to_f / relevant) : 0.0,
98
+ line_percent: pct,
99
+ source_rows: html_source_rows(source_lines, line_arr)
100
+ }
101
+ end
102
+
103
+ def html_summary(files)
104
+ relevant = files.sum { |file| file[:relevant] }
105
+ covered = files.sum { |file| file[:covered] }
106
+ total_hits = files.sum { |file| file[:avg_hits] * file[:relevant] }
107
+ {
108
+ files: files.length,
109
+ lines_relevant: relevant,
110
+ lines_covered: covered,
111
+ lines_missed: relevant - covered,
112
+ line_percent: relevant.positive? ? (100.0 * covered / relevant) : 0.0,
113
+ avg_hits: relevant.positive? ? (total_hits.to_f / relevant) : 0.0
114
+ }
115
+ end
116
+
117
+ def html_group_rows(groups)
118
+ return [] unless groups.is_a?(Hash) && !groups.empty?
119
+
120
+ groups.map do |name, data|
121
+ pct = html_group_percent(data)
122
+ <<~ROW.strip
123
+ <tr>
124
+ <td>#{CGI.escapeHTML(name.to_s)}</td>
125
+ <td class="cell--number"><span class="badge #{html_badge_class(pct)}">#{format("%.2f", pct)}%</span></td>
126
+ </tr>
127
+ ROW
128
+ end
129
+ end
130
+
131
+ def html_group_percent(data)
132
+ return 0.0 unless data.is_a?(Hash)
133
+
134
+ lines = data["lines"] || data[:lines]
135
+ pct = lines.is_a?(Hash) ? (lines["covered_percent"] || lines[:covered_percent]) : nil
136
+ pct.to_f
137
+ end
138
+
139
+ def html_file_list_row(file)
140
+ <<~ROW.strip
141
+ <tr class="t-file">
142
+ <td class="strong t-file__name"><a href="##{file[:id]}" class="src_link" title="#{CGI.escapeHTML(file[:display_path])}">#{CGI.escapeHTML(file[:display_path])}</a></td>
143
+ <td class="cell--number"><span class="badge #{html_badge_class(file[:line_percent])}">#{format("%.2f", file[:line_percent])}%</span></td>
144
+ <td class="cell--number">#{file[:total_lines]}</td>
145
+ <td class="cell--number">#{file[:relevant]}</td>
146
+ <td class="cell--number">#{file[:covered]}</td>
147
+ <td class="cell--number">#{file[:missed]}</td>
148
+ <td class="cell--number">#{format("%.2f", file[:avg_hits])}</td>
149
+ </tr>
150
+ ROW
151
+ end
152
+
153
+ def html_source_rows(source_lines, line_arr)
154
+ max_len = [source_lines.length, line_arr.length].max
155
+ Array.new(max_len) do |idx|
156
+ source = source_lines[idx] || ""
157
+ hit = line_arr[idx]
158
+ css = html_line_class(hit)
159
+ hits_label = html_hit_label(hit)
160
+ <<~ROW.strip
161
+ <tr class="#{css}">
162
+ <td class="line-num">#{idx + 1}</td>
163
+ <td class="line-hits">#{hits_label}</td>
164
+ <td class="line-source"><code>#{source.empty? ? "&nbsp;" : CGI.escapeHTML(source)}</code></td>
165
+ </tr>
166
+ ROW
167
+ end
168
+ end
169
+
170
+ def html_source_lines(path, fallback_length)
171
+ return Array.new(fallback_length, "") unless File.file?(path.to_s)
172
+
173
+ File.readlines(path.to_s, chomp: true, encoding: Encoding::UTF_8)
174
+ rescue Errno::ENOENT, Errno::EACCES, ArgumentError
175
+ Array.new(fallback_length, "")
176
+ end
177
+
178
+ def html_display_path(path, root)
179
+ p = File.expand_path(path.to_s)
180
+ return p if root.nil? || root.to_s.empty?
181
+
182
+ Pathname.new(p).relative_path_from(Pathname.new(File.expand_path(root.to_s))).to_s
183
+ rescue ArgumentError
184
+ p
185
+ end
186
+
187
+ def html_generated_label(generated_at)
188
+ t = generated_at.is_a?(Time) ? generated_at : Time.now
189
+ t.utc.strftime("%Y-%m-%d %H:%M:%S UTC")
190
+ end
191
+
192
+ def html_badge_class(percent)
193
+ return "green" if percent >= 90.0
194
+ return "yellow" if percent >= 80.0
195
+
196
+ "red"
197
+ end
198
+
199
+ def html_numeric_hit(hit)
200
+ return nil if hit.nil? || hit == "ignored"
201
+
202
+ hit.to_i
203
+ end
204
+
205
+ def html_hit_label(hit)
206
+ return "" if hit.nil?
207
+ return "ignored" if hit == "ignored"
208
+
209
+ hit.to_i.to_s
210
+ end
211
+
212
+ def html_line_class(hit)
213
+ return "line-none" if hit.nil?
214
+ return "line-ignored" if hit == "ignored"
215
+
216
+ hit.to_i.positive? ? "line-covered" : "line-missed"
217
+ end
218
+ end
219
+ end
220
+ end
221
+ # rubocop:enable Polyrun/FileLength
@@ -0,0 +1,21 @@
1
+ <div class="panel file_list_container" id="file-list">
2
+ <h2>Files</h2>
3
+ <div class="file_list--responsive">
4
+ <table class="file_list" data-sortable="true">
5
+ <thead>
6
+ <tr>
7
+ <th>File</th>
8
+ <th class="cell--number">% covered</th>
9
+ <th class="cell--number">Lines</th>
10
+ <th class="cell--number">Relevant Lines</th>
11
+ <th class="cell--number">Lines covered</th>
12
+ <th class="cell--number">Lines missed</th>
13
+ <th class="cell--number">Avg. Hits / Line</th>
14
+ </tr>
15
+ </thead>
16
+ <tbody>
17
+ <%= file_rows_html %>
18
+ </tbody>
19
+ </table>
20
+ </div>
21
+ </div>
@@ -0,0 +1,26 @@
1
+ <div class="panel file-section source_file" id="<%= file[:id] %>">
2
+ <div class="file-heading">
3
+ <h2><%= CGI.escapeHTML(file[:display_path]) %></h2>
4
+ <a href="#overview">Back to summary</a>
5
+ </div>
6
+ <div class="file-meta">
7
+ <span class="badge <%= file[:badge_class] %>"><%= format("%.2f", file[:line_percent]) %>%</span>
8
+ <%= file[:covered] %> / <%= file[:relevant] %> relevant lines covered,
9
+ <%= file[:missed] %> missed,
10
+ <%= format("%.2f", file[:avg_hits]) %> avg. hits / line
11
+ </div>
12
+ <div class="file_list--responsive">
13
+ <table class="source_table">
14
+ <thead>
15
+ <tr>
16
+ <th class="line-num">Line</th>
17
+ <th class="line-hits">Hits</th>
18
+ <th class="line-source">Source</th>
19
+ </tr>
20
+ </thead>
21
+ <tbody>
22
+ <%= file[:source_rows].join("\n") %>
23
+ </tbody>
24
+ </table>
25
+ </div>
26
+ </div>
@@ -0,0 +1,18 @@
1
+ <% unless group_rows_html.empty? %>
2
+ <div class="group-summary">
3
+ <h3>Groups</h3>
4
+ <div class="file_list--responsive">
5
+ <table class="group-table" data-sortable="true">
6
+ <thead>
7
+ <tr>
8
+ <th>Group</th>
9
+ <th class="cell--number">% covered</th>
10
+ </tr>
11
+ </thead>
12
+ <tbody>
13
+ <%= group_rows_html %>
14
+ </tbody>
15
+ </table>
16
+ </div>
17
+ </div>
18
+ <% end %>
@@ -0,0 +1,47 @@
1
+ <div class="panel file_list_container" id="overview">
2
+ <h2>
3
+ <span class="group_name">All Files</span>
4
+ (<span class="covered_percent"><span class="<%= summary_badge_class %>"><%= format("%.2f", summary[:line_percent]) %>%</span></span>
5
+ covered at
6
+ <span class="covered_strength"><span class="<%= summary_badge_class %>"><%= format("%.2f", summary[:avg_hits]) %></span></span>
7
+ hits/line)
8
+ </h2>
9
+
10
+ <div><b><%= summary[:files] %></b> files in total.</div>
11
+ <div class="t-line-summary">
12
+ <b><%= summary[:lines_relevant] %></b> relevant lines,
13
+ <span class="green"><b><%= summary[:lines_covered] %></b> lines covered</span> and
14
+ <span class="red"><b><%= summary[:lines_missed] %></b> lines missed</span>
15
+ (<span class="<%= summary_badge_class %>"><%= format("%.2f", summary[:line_percent]) %>%</span>)
16
+ </div>
17
+
18
+ <div class="metrics">
19
+ <div class="metric">
20
+ <div class="metric-label">Coverage</div>
21
+ <div class="metric-value"><%= format("%.2f", summary[:line_percent]) %>%</div>
22
+ </div>
23
+ <div class="metric">
24
+ <div class="metric-label">Relevant Lines</div>
25
+ <div class="metric-value"><%= summary[:lines_relevant] %></div>
26
+ </div>
27
+ <div class="metric">
28
+ <div class="metric-label">Lines Covered</div>
29
+ <div class="metric-value"><%= summary[:lines_covered] %></div>
30
+ </div>
31
+ <div class="metric">
32
+ <div class="metric-label">Lines Missed</div>
33
+ <div class="metric-value"><%= summary[:lines_missed] %></div>
34
+ </div>
35
+ <div class="metric">
36
+ <div class="metric-label">Avg. Hits / Line</div>
37
+ <div class="metric-value"><%= format("%.2f", summary[:avg_hits]) %></div>
38
+ </div>
39
+ </div>
40
+
41
+ <%= groups_html %>
42
+
43
+ <div class="nav-links">
44
+ <a href="#file-list">File List</a>
45
+ <a href="#source-files">Source Files</a>
46
+ </div>
47
+ </div>
@@ -0,0 +1,147 @@
1
+ :root {
2
+ color-scheme: light;
3
+ --bg: #f5f7fb;
4
+ --surface: #ffffff;
5
+ --border: #d7ddea;
6
+ --text: #1f2937;
7
+ --muted: #6b7280;
8
+ --green: #0f766e;
9
+ --green-bg: #ecfdf5;
10
+ --yellow: #b45309;
11
+ --yellow-bg: #fffbeb;
12
+ --red: #b91c1c;
13
+ --red-bg: #fef2f2;
14
+ --gray-bg: #f8fafc;
15
+ }
16
+
17
+ * { box-sizing: border-box; }
18
+
19
+ html {
20
+ scroll-behavior: smooth;
21
+ }
22
+
23
+ body {
24
+ margin: 0;
25
+ font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
26
+ background: var(--bg);
27
+ color: var(--text);
28
+ line-height: 1.45;
29
+ }
30
+
31
+ a { color: #1d4ed8; text-decoration: none; }
32
+ a:hover { text-decoration: underline; }
33
+
34
+ #wrapper { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }
35
+
36
+ .topbar {
37
+ display: flex;
38
+ justify-content: space-between;
39
+ gap: 1rem;
40
+ align-items: baseline;
41
+ margin-bottom: 1rem;
42
+ }
43
+
44
+ .timestamp { color: var(--muted); font-size: 0.9rem; }
45
+
46
+ .panel {
47
+ background: var(--surface);
48
+ border: 1px solid var(--border);
49
+ border-radius: 12px;
50
+ padding: 1rem 1.25rem;
51
+ margin-bottom: 1rem;
52
+ box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
53
+ }
54
+
55
+ .metrics {
56
+ display: grid;
57
+ grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
58
+ gap: 0.75rem;
59
+ margin-top: 1rem;
60
+ }
61
+
62
+ .metric {
63
+ border: 1px solid var(--border);
64
+ border-radius: 10px;
65
+ padding: 0.85rem 1rem;
66
+ background: var(--gray-bg);
67
+ }
68
+
69
+ .metric-label { color: var(--muted); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.03em; }
70
+ .metric-value { font-size: 1.4rem; font-weight: 700; margin-top: 0.2rem; }
71
+ .summary-line, .t-line-summary { margin-top: 0.75rem; color: var(--muted); }
72
+ .group-summary { margin-top: 1rem; }
73
+
74
+ table { width: 100%; border-collapse: collapse; }
75
+
76
+ th, td { padding: 0.55rem 0.7rem; border-top: 1px solid var(--border); vertical-align: top; }
77
+
78
+ thead th {
79
+ background: var(--gray-bg);
80
+ color: var(--muted);
81
+ font-size: 0.82rem;
82
+ text-transform: uppercase;
83
+ letter-spacing: 0.03em;
84
+ border-top: none;
85
+ position: sticky;
86
+ top: 0;
87
+ }
88
+
89
+ th[data-sortable-column="true"] {
90
+ cursor: pointer;
91
+ user-select: none;
92
+ }
93
+
94
+ th[data-sort-direction="asc"]::after { content: " ↑"; }
95
+ th[data-sort-direction="desc"]::after { content: " ↓"; }
96
+
97
+ .cell--number { text-align: right; white-space: nowrap; }
98
+
99
+ .badge {
100
+ display: inline-block;
101
+ min-width: 72px;
102
+ text-align: center;
103
+ border-radius: 999px;
104
+ padding: 0.15rem 0.55rem;
105
+ font-weight: 700;
106
+ }
107
+
108
+ .green { color: var(--green); }
109
+ .yellow { color: var(--yellow); }
110
+ .red { color: var(--red); }
111
+ .badge.green { background: var(--green-bg); }
112
+ .badge.yellow { background: var(--yellow-bg); }
113
+ .badge.red { background: var(--red-bg); }
114
+
115
+ .file_list--responsive { overflow-x: auto; }
116
+ .file-section { margin-top: 1rem; }
117
+
118
+ .file-heading {
119
+ display: flex;
120
+ justify-content: space-between;
121
+ gap: 1rem;
122
+ align-items: baseline;
123
+ flex-wrap: wrap;
124
+ }
125
+
126
+ .file-meta { color: var(--muted); font-size: 0.95rem; }
127
+
128
+ .source_table td {
129
+ font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
130
+ font-size: 0.83rem;
131
+ white-space: pre-wrap;
132
+ word-break: break-word;
133
+ }
134
+
135
+ .line-num, .line-hits {
136
+ width: 5rem;
137
+ color: var(--muted);
138
+ text-align: right;
139
+ white-space: nowrap;
140
+ }
141
+
142
+ .line-source { width: auto; }
143
+ .line-covered { background: rgba(16, 185, 129, 0.10); }
144
+ .line-missed { background: rgba(239, 68, 68, 0.10); }
145
+ .line-ignored, .line-none { background: transparent; }
146
+ .nav-links { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 0.75rem; }
147
+ .group-table td:first-child, .file_list td:first-child { width: 100%; }
@@ -0,0 +1,48 @@
1
+ (() => {
2
+ function cellValue(row, index) {
3
+ const cell = row.children[index];
4
+ return cell ? cell.textContent.trim() : "";
5
+ }
6
+
7
+ function sortableValue(text) {
8
+ const numeric = Number.parseFloat(text.replace(/[% ,]/g, ""));
9
+ return Number.isNaN(numeric) ? text.toLowerCase() : numeric;
10
+ }
11
+
12
+ function sortTable(table, index, direction) {
13
+ const body = table.tBodies[0];
14
+ if (!body) return;
15
+
16
+ const rows = Array.from(body.rows);
17
+ rows.sort((left, right) => {
18
+ const a = sortableValue(cellValue(left, index));
19
+ const b = sortableValue(cellValue(right, index));
20
+ if (a < b) return direction === "asc" ? -1 : 1;
21
+ if (a > b) return direction === "asc" ? 1 : -1;
22
+ return 0;
23
+ });
24
+
25
+ rows.forEach((row) => body.appendChild(row));
26
+ }
27
+
28
+ function installSortableTables() {
29
+ document.querySelectorAll("table[data-sortable='true']").forEach((table) => {
30
+ const headers = Array.from(table.tHead ? table.tHead.rows[0].cells : []);
31
+ headers.forEach((header, index) => {
32
+ header.dataset.sortableColumn = "true";
33
+ header.addEventListener("click", () => {
34
+ const nextDirection = header.dataset.sortDirection === "asc" ? "desc" : "asc";
35
+ headers.forEach((cell) => delete cell.dataset.sortDirection);
36
+ header.dataset.sortDirection = nextDirection;
37
+ sortTable(table, index, nextDirection);
38
+ });
39
+ });
40
+ });
41
+ }
42
+
43
+ if (document.readyState === "loading") {
44
+ document.addEventListener("DOMContentLoaded", installSortableTables);
45
+ } else {
46
+ installSortableTables();
47
+ }
48
+ })();
@@ -0,0 +1,30 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8"/>
5
+ <title><%= title %></title>
6
+ <style>
7
+ <%= stylesheet %>
8
+ </style>
9
+ </head>
10
+ <body>
11
+ <div id="wrapper">
12
+ <div class="topbar">
13
+ <h1><%= title %></h1>
14
+ <div class="timestamp">Generated <%= generated_label %></div>
15
+ </div>
16
+
17
+ <%= overview_html %>
18
+
19
+ <%= file_list_html %>
20
+
21
+ <div id="source-files">
22
+ <%= file_sections_html %>
23
+ </div>
24
+ </div>
25
+
26
+ <script>
27
+ <%= javascript %>
28
+ </script>
29
+ </body>
30
+ </html>