@hublo/sentinel 1.7.0-alpha.34 → 1.7.0-alpha.36

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.
@@ -134,8 +134,9 @@ import {
134
134
  TARGET as TARGET3,
135
135
  defaults as defaults3,
136
136
  defineSql,
137
- squawkRules
138
- } from "./chunk-53HYHJTD.js";
137
+ squawkRules,
138
+ withDefaults
139
+ } from "./chunk-5KNSTZ7F.js";
139
140
  import {
140
141
  CODE_CHURN_CONFIG_FILE,
141
142
  REPORT_DIR as REPORT_DIR2,
@@ -2368,13 +2369,13 @@ function treeAtCommit(workspaceRoot, sha) {
2368
2369
  for (const path2 of wanted) {
2369
2370
  const end = batch.out.indexOf(10, at);
2370
2371
  if (end === -1) break;
2371
- const header2 = batch.out.subarray(at, end).toString("utf8").split(" ");
2372
- if (header2[1] !== "blob") {
2372
+ const header3 = batch.out.subarray(at, end).toString("utf8").split(" ");
2373
+ if (header3[1] !== "blob") {
2373
2374
  texts.set(path2, void 0);
2374
2375
  at = end + 1;
2375
2376
  continue;
2376
2377
  }
2377
- const size = Number(header2[2]);
2378
+ const size = Number(header3[2]);
2378
2379
  texts.set(path2, batch.out.subarray(end + 1, end + 1 + size).toString("utf8"));
2379
2380
  at = end + 1 + size + 1;
2380
2381
  }
@@ -2537,16 +2538,16 @@ function analyseModule(options) {
2537
2538
  const members = entry.members !== void 0 && entry.members.length > 0 ? entry.members : [];
2538
2539
  const all2 = members.length > 0 ? members : entry.allNames.length > 0 ? entry.allNames : ["*"];
2539
2540
  const values = new Set(members.length > 0 ? members : entry.names);
2540
- const byFile3 = /* @__PURE__ */ new Map();
2541
+ const byFile = /* @__PURE__ */ new Map();
2541
2542
  const fileOfName = /* @__PURE__ */ new Map();
2542
2543
  for (const name of all2) {
2543
2544
  const file = definingFile(resolution.path, name);
2544
- const typeOnly = (byFile3.get(file) ?? true) && !values.has(name);
2545
- byFile3.set(file, typeOnly);
2545
+ const typeOnly = (byFile.get(file) ?? true) && !values.has(name);
2546
+ byFile.set(file, typeOnly);
2546
2547
  fileOfName.set(name, file);
2547
2548
  }
2548
2549
  const targets4 = /* @__PURE__ */ new Map();
2549
- for (const [workspacePath, typeOnly] of byFile3) {
2550
+ for (const [workspacePath, typeOnly] of byFile) {
2550
2551
  const target = targetFile(workspacePath, typeOnly);
2551
2552
  if (target !== void 0) targets4.set(workspacePath, target);
2552
2553
  }
@@ -3157,7 +3158,7 @@ function byFamily(rows) {
3157
3158
  const orphans = rows.filter((row) => familyOf(row.metric) === void 0);
3158
3159
  return orphans.length > 0 ? [...grouped2, { label: "Other", rows: orphans }] : grouped2;
3159
3160
  }
3160
- function figureBlock(row, places2 = "") {
3161
+ function figureBlock(row, places = "") {
3161
3162
  const help = helpFor(row.metric);
3162
3163
  const label = help?.label ?? row.metric;
3163
3164
  const mark = row.status === void 0 ? "" : `<span class="mark s-${row.status}">${escape(VERDICT[row.status] ?? row.status)}</span>`;
@@ -3172,7 +3173,7 @@ function figureBlock(row, places2 = "") {
3172
3173
  <span class="val">${escape(figure(row))}${mark}${unit}</span>
3173
3174
  </div>${action}
3174
3175
  ${detail}
3175
- ${places2}
3176
+ ${places}
3176
3177
  </div>`;
3177
3178
  }
3178
3179
  function helpDetails(help, withoutReference) {
@@ -3327,16 +3328,16 @@ function renderJson(report) {
3327
3328
  }
3328
3329
  function renderMarkdown(report) {
3329
3330
  const version = report.settings.find((setting) => setting.key === "sentinel")?.value;
3330
- const places2 = /* @__PURE__ */ new Map();
3331
+ const places = /* @__PURE__ */ new Map();
3331
3332
  for (const finding3 of report.findings) {
3332
- places2.set(finding3.metric, (places2.get(finding3.metric) ?? 0) + 1);
3333
+ places.set(finding3.metric, (places.get(finding3.metric) ?? 0) + 1);
3333
3334
  }
3334
3335
  const figureLine = (row) => {
3335
3336
  const help = helpFor(row.metric);
3336
3337
  const label = help?.label ?? row.metric;
3337
3338
  const mark = row.status === void 0 ? "" : ` **${VERDICT[row.status] ?? row.status}**`;
3338
3339
  const unit = row.unit === "" ? "" : `${row.unit.startsWith("%") ? "" : " "}${row.unit}`;
3339
- const count = places2.get(row.metric) ?? 0;
3340
+ const count = places.get(row.metric) ?? 0;
3340
3341
  const found = count === 0 ? "" : ` \xB7 ${count} ${count === 1 ? "place" : "places"}`;
3341
3342
  const line = `**${label}** \xB7 ${figure(row)}${mark}${unit}${found}`;
3342
3343
  return help?.fix === void 0 ? [line, ""] : [line, `> **What to do.** ${help.fix}`, ""];
@@ -3568,9 +3569,9 @@ function findingsPanel(report) {
3568
3569
  if (findings.length === 0) {
3569
3570
  return ` <p class="read">This run produced no finding to list.</p>`;
3570
3571
  }
3571
- const counts2 = /* @__PURE__ */ new Map();
3572
- for (const finding3 of findings) counts2.set(finding3.metric, (counts2.get(finding3.metric) ?? 0) + 1);
3573
- const chips = [...counts2.entries()].map(
3572
+ const counts = /* @__PURE__ */ new Map();
3573
+ for (const finding3 of findings) counts.set(finding3.metric, (counts.get(finding3.metric) ?? 0) + 1);
3574
+ const chips = [...counts.entries()].map(
3574
3575
  ([metric, count]) => `<button type="button" class="fchip" data-kind="${escape(kindOf(metric))}">${escape(kindOf(metric))} <span>${grouped(count)}</span></button>`
3575
3576
  ).join("\n ");
3576
3577
  return ` <div class="ftools">
@@ -4082,7 +4083,7 @@ function renderHtml(report) {
4082
4083
  ).join("\n");
4083
4084
  const shown = new Set(report.rows.map((row) => row.metric));
4084
4085
  const orphansByFamily = /* @__PURE__ */ new Map();
4085
- for (const [metric, places2] of placesByMetric) {
4086
+ for (const [metric, places] of placesByMetric) {
4086
4087
  if (shown.has(metric)) continue;
4087
4088
  const orphanHelp = helpFor(metric);
4088
4089
  const orphanAction = orphanHelp?.fix === void 0 ? "" : `
@@ -4090,7 +4091,7 @@ function renderHtml(report) {
4090
4091
  const block = ` <div class="figure">
4091
4092
  <div class="head"><span class="name">${escape(orphanHelp?.label ?? metric)}</span></div>${orphanAction}
4092
4093
  ${orphanHelp === void 0 ? "" : helpDetails(orphanHelp, true)}
4093
- ${places2}
4094
+ ${places}
4094
4095
  </div>`;
4095
4096
  const family = familyOf(metric) ?? "Other";
4096
4097
  orphansByFamily.set(family, [...orphansByFamily.get(family) ?? [], block]);
@@ -4218,14 +4219,14 @@ function buildReport(input) {
4218
4219
  };
4219
4220
  }
4220
4221
  function ruleLine(rule, colors) {
4221
- const counts2 = `${rule.added.length} new, ${rule.known} known`;
4222
+ const counts = `${rule.added.length} new, ${rule.known} known`;
4222
4223
  const comment = rule.comment === void 0 ? "" : ` ${rule.comment}`;
4223
4224
  if (rule.severity === "off") return ` ${colors.dim(`- ${rule.name} off in this module`)}`;
4224
4225
  if (rule.added.length === 0)
4225
- return ` ${colors.ok("\u2713")} ${rule.name}${colors.dim(comment)} ${colors.dim(counts2)}`;
4226
+ return ` ${colors.ok("\u2713")} ${rule.name}${colors.dim(comment)} ${colors.dim(counts)}`;
4226
4227
  const mark = rule.severity === "error" ? colors.fail("\u2717") : colors.warn("\u26A0");
4227
4228
  const level = rule.severity === "warn" ? " (warn" + (rule.levelFrom === "module" ? ", this module" : "") + ")" : "";
4228
- return ` ${mark} ${rule.name}${comment} ${counts2}${colors.dim(level)}`;
4229
+ return ` ${mark} ${rule.name}${comment} ${counts}${colors.dim(level)}`;
4229
4230
  }
4230
4231
  function rolesLine(roles) {
4231
4232
  const listed = Object.entries(roles).sort(([left], [right]) => left.localeCompare(right)).map(([role, count]) => `${role} ${count}`);
@@ -6131,9 +6132,9 @@ function sidePath(raw, prefix) {
6131
6132
  return path2.startsWith(prefix) ? path2.slice(prefix.length) : path2;
6132
6133
  }
6133
6134
  function samePath(rest) {
6134
- const header2 = rest.trim();
6135
- const quoted = /^("(?:[^"\\]|\\.)*") ("(?:[^"\\]|\\.)*")$/.exec(header2);
6136
- const [left, right] = quoted ? [unquote(quoted[1] ?? ""), unquote(quoted[2] ?? "")] : header2.length % 2 === 1 ? [header2.slice(0, (header2.length - 1) / 2), header2.slice((header2.length + 1) / 2)] : ["", ""];
6135
+ const header3 = rest.trim();
6136
+ const quoted = /^("(?:[^"\\]|\\.)*") ("(?:[^"\\]|\\.)*")$/.exec(header3);
6137
+ const [left, right] = quoted ? [unquote(quoted[1] ?? ""), unquote(quoted[2] ?? "")] : header3.length % 2 === 1 ? [header3.slice(0, (header3.length - 1) / 2), header3.slice((header3.length + 1) / 2)] : ["", ""];
6137
6138
  if (!left.startsWith("a/") || !right.startsWith("b/") || left.slice(2) !== right.slice(2)) {
6138
6139
  return null;
6139
6140
  }
@@ -6843,6 +6844,269 @@ var percent = (rate) => rate === null ? "no figure" : `${rate}%`;
6843
6844
  import { existsSync as existsSync14, mkdirSync as mkdirSync3, unlinkSync, writeFileSync as writeFileSync6 } from "node:fs";
6844
6845
  import { join as join19 } from "node:path";
6845
6846
 
6847
+ // src/shared/html-report-styles.ts
6848
+ var REPORT_STYLES = `
6849
+ :root {
6850
+ color-scheme: light dark;
6851
+ --page: #faf7f1; --surface: #ffffff; --ink: #23091c; --ink-soft: #4a3344; --label: #6f5a67;
6852
+ --rule: #e1dcd0; --brand: #491b3c; --brand-bg: #f3e9ee; --moved: #a3341f; --over: #a3341f;
6853
+ --ok: #2f6b4f; --note: #fdf6ee; --fix: #8a6a12; --shade: rgba(35, 9, 28, 0.22); --radius: 10px;
6854
+ }
6855
+ @media (prefers-color-scheme: dark) {
6856
+ :root {
6857
+ --page: #23091c; --surface: #2f1128; --ink: #faf7f1; --ink-soft: #d8c6d1; --label: #b298ab;
6858
+ --rule: #45253d; --brand: #ffab93; --brand-bg: #3a1830; --moved: #ef8f78; --over: #ef8f78;
6859
+ --ok: #7ed3a5; --note: #2f1128; --fix: #9cc3f0; --shade: rgba(250, 247, 241, 0.25);
6860
+ }
6861
+ }
6862
+ * { box-sizing: border-box; }
6863
+ body { margin: 0; padding: 2.5rem 1rem 4rem; background: var(--page); color: var(--ink);
6864
+ font: 15px/1.6 'Brand Sans', Inter, ui-sans-serif, system-ui, sans-serif; }
6865
+ main { max-width: 78rem; margin: 0 auto; }
6866
+ code { font: 0.86em ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink-soft); }
6867
+ header { border-left: 3px solid var(--brand); padding-left: 0.9rem; margin-bottom: 1.6rem; }
6868
+ header .top { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem; margin: 0;
6869
+ color: var(--label); font-size: 0.8rem; }
6870
+ h1 { font-size: 1.4rem; font-weight: 600; margin: 0.3rem 0 0.4rem; overflow-wrap: anywhere; }
6871
+ .lead { margin: 0 0 1rem; max-width: 60rem; font-size: 1rem; color: var(--ink-soft); }
6872
+ .summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 0.8rem; }
6873
+ .kpi { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 0.8rem 1rem; }
6874
+ .kpi p { margin: 0.2rem 0; font-size: 0.88rem; }
6875
+ .kpi .label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--label); font-weight: 600; }
6876
+ .kpi .big { font-size: 1.7rem; font-weight: 650; line-height: 1.2; margin: 0.2rem 0 0.4rem; }
6877
+ .kpi .small { font-size: 0.85rem; font-weight: 400; color: var(--label); }
6878
+ .kpi.band-watch, .kpi.band-above { border-color: var(--over); }
6879
+ .bar { display: flex; height: 0.6rem; border-radius: 999px; overflow: hidden; background: var(--rule); margin: 0.3rem 0; }
6880
+ .seg { display: block; height: 100%; }
6881
+ .seg-feat { background: var(--brand); }
6882
+ .seg-fix { background: var(--fix); }
6883
+ .seg-refactor { background: var(--ok); }
6884
+ .seg-other { background: var(--label); }
6885
+ .legend { display: flex; flex-wrap: wrap; gap: 0.2rem 0.8rem; }
6886
+ .legend > span { white-space: nowrap; }
6887
+ .dot { display: inline-block; width: 0.55rem; height: 0.55rem; border-radius: 50%; margin-right: 0.3rem; }
6888
+ .unit, .small-note { font-size: 0.78rem !important; }
6889
+ .pop .read { color: var(--ink-soft); }
6890
+ .partner { font: 0.8rem ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 600; overflow-wrap: anywhere; }
6891
+ td.partners { min-width: 17rem; }
6892
+ .more-partners summary { cursor: pointer; color: var(--brand); font-size: 0.78rem; margin-top: 0.2rem; }
6893
+ .more-partners ol { margin: 0.3rem 0 0; padding-left: 1.1rem; font-size: 0.8rem; }
6894
+ .more-partners li { margin: 0.15rem 0; }
6895
+ .pill { white-space: nowrap; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
6896
+ padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--brand-bg); color: var(--brand); font-weight: 600; }
6897
+ .band-above .pill, .band-watch .pill { background: var(--over); color: var(--surface); }
6898
+ .kind { font: 0.76rem ui-monospace, SFMono-Regular, Menlo, monospace; padding: 0.05rem 0.4rem;
6899
+ border-radius: 4px; background: var(--brand-bg); color: var(--brand); white-space: nowrap; }
6900
+ /* Neutral on purpose: a fix is often the healthy outcome, and red would read as danger. */
6901
+ .kind-other { background: transparent; color: var(--label); border: 1px solid var(--rule); }
6902
+ .tabs > input { position: absolute; opacity: 0; pointer-events: none; }
6903
+ .tabs > label { display: inline-block; padding: 0.55rem 1rem; margin-right: 0.2rem; border: 1px solid transparent;
6904
+ border-bottom: none; border-radius: 8px 8px 0 0; cursor: pointer; color: var(--label); }
6905
+ .tabs > label span { color: var(--label); font-size: 0.78rem; }
6906
+ .tabs > input:checked + label { color: var(--ink); background: var(--surface); border-color: var(--rule); font-weight: 600; }
6907
+ .tabs > input:focus-visible + label { outline: 2px solid var(--brand); }
6908
+ .panel { display: none; border-top: 1px solid var(--rule); padding-top: 1.2rem; }
6909
+ #tab-files:checked ~ #panel-files, #tab-settings:checked ~ #panel-settings { display: block; }
6910
+ .top-right { display: inline-flex; align-items: center; gap: 0.6rem; }
6911
+ .help-button { padding: 0.3rem 0.9rem; border-radius: 999px; border: 1px solid var(--brand); background: var(--brand);
6912
+ color: var(--surface); font: inherit; font-size: 0.82rem; font-weight: 600; cursor: pointer; }
6913
+ .help-button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
6914
+ /* The help opens at the TOP of the screen, under the banner it is called from, and scrolls on its own. */
6915
+ .pop.help-dialog { position: fixed; inset: 1.5rem 0 auto 0; margin: 0 auto; width: min(52rem, calc(100vw - 2rem));
6916
+ max-width: none; max-height: calc(100vh - 3rem); overflow-y: auto; padding: 1.2rem 1.6rem; }
6917
+ .help-dialog::backdrop { background: rgba(35, 9, 28, 0.35); }
6918
+ .help-head { display: flex; justify-content: space-between; align-items: center; font-size: 1.05rem; }
6919
+ .help-dialog h3 { font-size: 0.95rem; margin: 1.3rem 0 0.3rem; color: var(--brand); }
6920
+ .help-dialog p, .help-dialog dd { max-width: 46rem; }
6921
+ .help-dialog pre { background: var(--page); padding: 0.6rem 0.8rem; border-radius: 6px; overflow-x: auto; }
6922
+ .example { background: var(--note); border-left: 3px solid var(--brand); padding: 0.4rem 0.7rem; border-radius: 4px; }
6923
+ .close { width: 1.6rem; height: 1.6rem; font-size: 1rem; }
6924
+ .tools { display: flex; gap: 0.6rem; align-items: center; }
6925
+ .tools input { flex: 1; padding: 0.6rem 0.8rem; border: 1px solid var(--rule); border-radius: var(--radius);
6926
+ background: var(--surface); color: var(--ink); font: inherit; }
6927
+ .guide { padding: 0.55rem 0.9rem; border-radius: var(--radius); border: 1px solid var(--brand);
6928
+ background: var(--surface); color: var(--brand); font: inherit; font-size: 0.86rem; cursor: pointer; white-space: nowrap; }
6929
+ .chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.8rem 0; }
6930
+ .chip { padding: 0.25rem 0.7rem; border-radius: 999px; border: 1px solid var(--rule); background: var(--surface);
6931
+ color: var(--ink); font: inherit; font-size: 0.82rem; cursor: pointer; }
6932
+ .chip span { color: var(--label); }
6933
+ .chip.on { background: var(--brand); border-color: var(--brand); color: var(--surface); }
6934
+ .chip.on span { color: var(--surface); }
6935
+ /*
6936
+ * A table wider than the page must SAY so: with the last visible column ending exactly at the
6937
+ * edge, a reader took the table for complete (found in review). Shadows that scroll with the
6938
+ * content show on the side where columns are hidden, the file column stays in place, and the
6939
+ * script writes a line above the table while it overflows.
6940
+ */
6941
+ .scroll { overflow-x: auto; border: 1px solid var(--rule); border-radius: var(--radius);
6942
+ background:
6943
+ linear-gradient(to right, var(--surface) 40%, transparent) left / 2.5rem 100% no-repeat local,
6944
+ linear-gradient(to left, var(--surface) 40%, transparent) right / 2.5rem 100% no-repeat local,
6945
+ radial-gradient(farthest-side at 0 50%, var(--shade), transparent) left / 1rem 100% no-repeat scroll,
6946
+ radial-gradient(farthest-side at 100% 50%, var(--shade), transparent) right / 1rem 100% no-repeat scroll,
6947
+ var(--surface); }
6948
+ table.ctable thead th:first-child, table.ctable tbody th { position: sticky; left: 0; z-index: 1;
6949
+ background: var(--surface); box-shadow: 1px 0 0 var(--rule); }
6950
+ .overflow-hint { margin: 0 0 0.4rem; color: var(--label); font-size: 0.8rem; text-align: right; }
6951
+ table { width: 100%; border-collapse: collapse; }
6952
+ th, td { text-align: left; padding: 0.5rem 0.45rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
6953
+ thead th { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--label);
6954
+ font-weight: 600; white-space: nowrap; cursor: pointer; user-select: none; }
6955
+ thead th:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
6956
+ thead th[aria-sort='descending'] .th::after { content: ' \u2193'; }
6957
+ thead th[aria-sort='ascending'] .th::after { content: ' \u2191'; }
6958
+ .n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
6959
+ tbody th { font: 0.82rem ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 400; min-width: 13rem; max-width: 26rem; overflow-wrap: anywhere; }
6960
+ tbody th .dir { color: var(--label); }
6961
+ tbody th b { font-weight: 600; color: var(--ink); }
6962
+ tr[hidden] { display: none; }
6963
+ .gone { font: 0.7rem 'Brand Sans', Inter, sans-serif; color: var(--label); border: 1px solid var(--rule); border-radius: 4px; padding: 0 0.3rem; }
6964
+ .none { color: var(--label); font-size: 0.78rem; }
6965
+ /* At most 55% of the warning colour: the text on the darkest tint keeps WCAG AA, 6.95:1 light, 5.15:1 dark (70% gave 3.81 in dark). */
6966
+ .score { display: inline-block; min-width: 2.6rem; padding: 0 0.3rem; border-radius: 4px;
6967
+ background: color-mix(in srgb, var(--over) calc(var(--s) * 55%), transparent); }
6968
+ .q { margin-left: 0.15rem; width: 1.1rem; height: 1.1rem; border-radius: 50%; border: 1px solid var(--label);
6969
+ background: transparent; color: var(--label); font-size: 0.68rem; line-height: 1; cursor: pointer; padding: 0; }
6970
+ .q:hover, .q:focus-visible { border-color: var(--brand); color: var(--brand); }
6971
+ .pop { max-width: 26rem; padding: 0.9rem 1rem; border: 1px solid var(--rule); border-radius: var(--radius);
6972
+ background: var(--surface); color: var(--ink); box-shadow: 0 8px 28px rgba(35, 9, 28, 0.18); font-size: 0.9rem; }
6973
+ .pop.wide { max-width: 38rem; }
6974
+ .pop p { margin: 0.4rem 0 0; }
6975
+ .pager { display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center; margin: 0.8rem 0; color: var(--label); font-size: 0.85rem; }
6976
+ .pager span:first-child { margin-right: 0.6rem; }
6977
+ .pager button { min-width: 2rem; padding: 0.2rem 0.5rem; border: 1px solid var(--rule); border-radius: 6px;
6978
+ background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; }
6979
+ .pager button.on { background: var(--brand); border-color: var(--brand); color: var(--surface); }
6980
+ .pager button:disabled:not(.on) { opacity: 0.4; cursor: default; }
6981
+ .warn { color: var(--over); font-size: 0.9rem; }
6982
+ .empty, .quiet { color: var(--label); }
6983
+ h2 { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--label); margin: 2rem 0 0.6rem; font-weight: 600; }
6984
+ .card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 0.4rem 1.1rem; }
6985
+ .card p { max-width: 62rem; }
6986
+ table.settings { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); border-collapse: separate; border-spacing: 0; overflow: hidden; }
6987
+ table.settings thead th, table.plain thead th { cursor: default; }
6988
+ table.settings td code { overflow-wrap: anywhere; }
6989
+ table.plain tbody th, table.settings tbody th { font: inherit; font-weight: 600; min-width: 0; white-space: nowrap; }
6990
+ table.settings td:last-child { white-space: nowrap; }
6991
+ dl { margin: 0.6rem 0; }
6992
+ dt { font-weight: 600; margin-top: 0.8rem; }
6993
+ dd { margin: 0.2rem 0 0; color: var(--ink-soft); max-width: 62rem; }
6994
+ .moved { color: var(--moved); font-weight: 500; }
6995
+ footer { margin-top: 2.5rem; color: var(--label); font-size: 0.8rem; }
6996
+ a { color: var(--brand); }
6997
+ `;
6998
+
6999
+ // src/shared/html-table-script.ts
7000
+ function tableScript(pageSize, unit, single) {
7001
+ const count = single === void 0 ? `' ${unit}'` : `' ' + (list.length === 1 ? ${JSON.stringify(single)} : ${JSON.stringify(unit)})`;
7002
+ return `
7003
+ (function () {
7004
+ var SIZE = ${pageSize}
7005
+ document.querySelectorAll('table.ctable').forEach(function (table) {
7006
+ var id = table.id
7007
+ var body = table.tBodies[0]
7008
+ var rows = [].slice.call(body.rows)
7009
+ var box = document.querySelector('input[data-table="' + id + '"]')
7010
+ var chips = [].slice.call(document.querySelectorAll('.chips[data-table="' + id + '"] .chip'))
7011
+ var nav = document.querySelector('.pager[data-table="' + id + '"]')
7012
+ var tag = ''
7013
+ var page = 0
7014
+ function shown() {
7015
+ var text = box ? box.value.trim().toLowerCase() : ''
7016
+ return rows.filter(function (row) {
7017
+ var tags = ' ' + row.getAttribute('data-tags') + ' '
7018
+ return (tag === '' || tags.indexOf(' ' + tag + ' ') !== -1) &&
7019
+ (text === '' || row.getAttribute('data-find').indexOf(text) !== -1)
7020
+ })
7021
+ }
7022
+ function draw() {
7023
+ var list = shown()
7024
+ var pages = Math.max(1, Math.ceil(list.length / SIZE))
7025
+ if (page >= pages) page = pages - 1
7026
+ rows.forEach(function (row) { row.hidden = true })
7027
+ list.slice(page * SIZE, page * SIZE + SIZE).forEach(function (row) { row.hidden = false })
7028
+ if (!nav) return
7029
+ nav.textContent = ''
7030
+ var from = list.length === 0 ? 0 : page * SIZE + 1
7031
+ var to = Math.min(list.length, page * SIZE + SIZE)
7032
+ var label = document.createElement('span')
7033
+ label.textContent = from + '\u2013' + to + ' of ' + list.length + ${count}
7034
+ nav.appendChild(label)
7035
+ if (pages < 2) return
7036
+ function button(text, target, current) {
7037
+ var b = document.createElement('button')
7038
+ b.type = 'button'
7039
+ b.textContent = text
7040
+ b.disabled = target < 0 || target >= pages || current
7041
+ if (current) b.className = 'on'
7042
+ b.addEventListener('click', function () { page = target; draw(); table.scrollIntoView({ block: 'start' }) })
7043
+ nav.appendChild(b)
7044
+ }
7045
+ button('\u2039', page - 1, false)
7046
+ for (var p = 0; p < pages; p++) {
7047
+ if (p === 0 || p === pages - 1 || Math.abs(p - page) <= 2) button(String(p + 1), p, p === page)
7048
+ else if (Math.abs(p - page) === 3) { var gap = document.createElement('span'); gap.textContent = '\u2026'; nav.appendChild(gap) }
7049
+ }
7050
+ button('\u203A', page + 1, false)
7051
+ }
7052
+ if (box) box.addEventListener('input', function () { page = 0; draw() })
7053
+ chips.forEach(function (chip) {
7054
+ chip.addEventListener('click', function () {
7055
+ tag = chip.getAttribute('data-tag')
7056
+ chips.forEach(function (other) { other.classList.toggle('on', other === chip) })
7057
+ page = 0
7058
+ draw()
7059
+ })
7060
+ })
7061
+ var heads = [].slice.call(table.tHead.rows[0].cells)
7062
+ heads.forEach(function (head, column) {
7063
+ var order = 0
7064
+ // Reachable from the keyboard: Tab to a column title, Enter or Space to sort by it.
7065
+ head.tabIndex = 0
7066
+ head.addEventListener('keydown', function (event) {
7067
+ if (event.target !== head || (event.key !== 'Enter' && event.key !== ' ')) return
7068
+ event.preventDefault()
7069
+ head.click()
7070
+ })
7071
+ head.addEventListener('click', function (event) {
7072
+ if (event.target.closest('button')) return
7073
+ var numeric = head.getAttribute('data-sort') === 'num'
7074
+ order = order === 0 ? (numeric ? -1 : 1) : -order
7075
+ var key = function (row) { return row.cells[column].getAttribute('data-v') || '' }
7076
+ rows.sort(function (a, b) {
7077
+ return numeric ? (Number(key(a)) - Number(key(b))) * order : key(a).localeCompare(key(b)) * order
7078
+ })
7079
+ rows.forEach(function (row) { body.appendChild(row) })
7080
+ heads.forEach(function (other) { other.removeAttribute('aria-sort') })
7081
+ head.setAttribute('aria-sort', order === 1 ? 'ascending' : 'descending')
7082
+ page = 0
7083
+ draw()
7084
+ })
7085
+ })
7086
+ draw()
7087
+ // Say when the table is wider than the page, and keep saying it as the window resizes.
7088
+ var frame = table.parentElement
7089
+ var hint = document.createElement('p')
7090
+ hint.className = 'overflow-hint'
7091
+ hint.textContent = '\u2190 \u2192 more columns: scroll the table sideways'
7092
+ frame.parentElement.insertBefore(hint, frame)
7093
+ function overflow() { hint.hidden = frame.scrollWidth <= frame.clientWidth + 1 }
7094
+ overflow()
7095
+ window.addEventListener('resize', overflow)
7096
+ document.querySelectorAll('.tabs > input').forEach(function (tab) { tab.addEventListener('change', overflow) })
7097
+ })
7098
+ // "/" focuses the search box of the tab on screen, as on the static analysis page.
7099
+ document.addEventListener('keydown', function (event) {
7100
+ if (event.key !== '/' || event.target !== document.body) return
7101
+ var box = [].slice.call(document.querySelectorAll('input[type=search]')).filter(function (one) {
7102
+ return one.offsetParent !== null
7103
+ })[0]
7104
+ if (box) { event.preventDefault(); box.focus() }
7105
+ })
7106
+ })()
7107
+ `;
7108
+ }
7109
+
6846
7110
  // src/roles/code-churn/report/help.ts
6847
7111
  var churnHelp = {
6848
7112
  label: "Code churn",
@@ -6972,15 +7236,15 @@ function day(iso) {
6972
7236
  });
6973
7237
  }
6974
7238
  var shareOf = (count, total) => total === 0 ? 0 : Math.round(count / total * 100);
6975
- function kindBar(counts2, unit, noun) {
6976
- const total = CHANGE_KINDS.reduce((sum, kind) => sum + counts2[kind], 0);
7239
+ function kindBar(counts, unit, noun) {
7240
+ const total = CHANGE_KINDS.reduce((sum, kind) => sum + counts[kind], 0);
6977
7241
  if (total === 0) return "";
6978
- const parts = CHANGE_KINDS.filter((kind) => counts2[kind] > 0);
6979
- return `<div class="bar" role="img" aria-label="${escape(parts.map((kind) => `${counts2[kind]} ${KIND_WORDS[kind]}`).join(", "))}">${parts.map(
6980
- (kind) => `<span class="seg seg-${kind}" style="width:${counts2[kind] / total * 100}%"></span>`
7242
+ const parts = CHANGE_KINDS.filter((kind) => counts[kind] > 0);
7243
+ return `<div class="bar" role="img" aria-label="${escape(parts.map((kind) => `${counts[kind]} ${KIND_WORDS[kind]}`).join(", "))}">${parts.map(
7244
+ (kind) => `<span class="seg seg-${kind}" style="width:${counts[kind] / total * 100}%"></span>`
6981
7245
  ).join("")}</div>
6982
7246
  <p class="legend">${parts.map(
6983
- (kind) => `<span><i class="dot seg-${kind}"></i>${grouped(counts2[kind])} ${escape(noun)}${escape(KIND_WORDS[kind])} <span class="quiet">(${shareOf(counts2[kind], total)}%)</span></span>`
7247
+ (kind) => `<span><i class="dot seg-${kind}"></i>${grouped(counts[kind])} ${escape(noun)}${escape(KIND_WORDS[kind])} <span class="quiet">(${shareOf(counts[kind], total)}%)</span></span>`
6984
7248
  ).join(" ")}</p>
6985
7249
  <p class="quiet unit">${escape(unit)}</p>`;
6986
7250
  }
@@ -7043,10 +7307,10 @@ function pathCell(row) {
7043
7307
  const name = cut === -1 ? row.path : row.path.slice(cut + 1);
7044
7308
  return `<th scope="row" data-v="${escape(row.path)}"><span class="dir">${escape(dir)}</span><b>${escape(name)}</b>${row.deleted ? ' <span class="gone" title="This file no longer exists: it was deleted after these changes. Its figures are those it had.">deleted since</span>' : ""}</th>`;
7045
7309
  }
7046
- function toolbar(table, chips, total, guide) {
7310
+ function toolbar(table, chips, total, guide2) {
7047
7311
  return `<div class="tools">
7048
7312
  <input type="search" data-table="${table}" placeholder="Search a file&hellip;" aria-label="Search a file" autocomplete="off">
7049
- <button type="button" class="guide" popovertarget="${guide}">How to read this table</button>
7313
+ <button type="button" class="guide" popovertarget="${guide2}">How to read this table</button>
7050
7314
  </div>
7051
7315
  <div class="chips" data-table="${table}">
7052
7316
  <button type="button" class="chip on" data-tag="">All <span>${grouped(total)}</span></button>
@@ -7126,331 +7390,77 @@ function settingsPanel(report) {
7126
7390
  return `<h2>Settings this run used</h2>
7127
7391
  <table class="settings"><thead><tr><th scope="col">Setting</th><th scope="col">Value</th><th scope="col">From</th></tr></thead><tbody>
7128
7392
  ${settings}
7129
- </tbody></table>
7130
- <p class="quiet">A module moves a setting in <code>code-churn.config.mjs</code>; the report then marks it, because two modules measured differently no longer compare.${report.status.moved ? ' <span class="moved">This module set its own levels.</span>' : ""}</p>
7131
- <h2>Bands</h2>
7132
- ${bandsTable(report)}`;
7133
- }
7134
- function bandsTable(report) {
7135
- const { levels } = report.status;
7136
- return `<table class="plain"><thead><tr><th scope="col">Band</th><th scope="col">When</th></tr></thead><tbody>
7137
- <tr><th scope="row">${BAND_LABEL.quiet}</th><td>fewer than ${grouped(levels.minimumAdded)} lines added in the period: no percentage is given, it would be noise</td></tr>
7138
- <tr><th scope="row">${BAND_LABEL.low}</th><td>under ${levels.low}%</td></tr>
7139
- <tr><th scope="row">${BAND_LABEL.usual}</th><td>${levels.low} to ${levels.above}%</td></tr>
7140
- <tr><th scope="row">${BAND_LABEL.above}</th><td>over ${levels.above}%</td></tr>
7141
- <tr><th scope="row">${BAND_LABEL.watch}</th><td>over ${levels.watch}%</td></tr>
7142
- </tbody></table>`;
7143
- }
7144
- function helpDialog(report) {
7145
- const live = report.rows.filter((row) => !row.deleted);
7146
- const reworked = live.find((row) => row.rewritten > 0 && row.added >= 20);
7147
- const coupled = [...live].filter((row) => row.changesWith !== null).sort((a, b) => (b.changesWith?.count ?? 0) - (a.changesWith?.count ?? 0))[0];
7148
- const hot = [...live].sort((a, b) => (b.hotspot ?? -1) - (a.hotspot ?? -1))[0];
7149
- const example = (text) => `<p class="example"><b>In this module.</b> ${text}</p>`;
7150
- const code = (path2) => `<code>${escape(nameOf3(path2))}</code>`;
7151
- const kindsOf2 = (row) => CHANGE_KINDS.filter((kind) => row.kinds[kind] > 0).map((kind) => `${row.kinds[kind]} ${kind}`).join(", ");
7152
- const { figures } = report;
7153
- const links = [
7154
- ...churnHelp.links ?? [],
7155
- ...kindsHelp.links ?? [],
7156
- ...correlationHelp.links ?? []
7157
- ].map((link) => `<a href="${escape(link.url)}">${escape(link.label)}</a>`).join(" \xB7 ");
7158
- return `<div popover id="help" class="pop help-dialog">
7159
- <div class="help-head"><b>How to read this page</b><button type="button" class="q close" popovertarget="help" popovertargetaction="hide" aria-label="Close the help">&times;</button></div>
7160
-
7161
- <h3>What code churn is</h3>
7162
- <p>${escape(churnHelp.what)} A line rewritten days after it was written is work done twice.</p>
7163
- ${figures.rate === null ? "" : example(`${grouped(figures.rewritten)} of the ${grouped(figures.added)} lines added from ${escape(day(report.period.from))} to ${escape(day(report.period.to))} were rewritten or deleted within ${report.reworkDays} days: ${escape(percent(figures.rate))}.`)}
7164
-
7165
- <h3>Why it matters</h3>
7166
- <p>Code churn is a symptom. Code rewritten soon after it is written points at a design that is still being found, or at a requirement that is still moving. It is rarely spread evenly: a few files carry most of it, and those are where to look. It never says the code is bad, and it never judges the people who wrote it.</p>
7167
-
7168
- <h3>The band</h3>
7169
- <p>${escape(report.status.text)} The bands place the figure among the hublo/monorepo modules; they say where it stands, never whether the code is good. A module compares best with itself over time.</p>
7170
- ${bandsTable(report)}
7171
-
7172
- <h3>Why the code changed</h3>
7173
- <p>${escape(kindsHelp.what)}</p>
7174
- <p>${escape(kindsHelp.read)}</p>
7175
- ${reworked === void 0 ? "" : example(`${code(reworked.path)} gained ${grouped(reworked.added)} lines, ${grouped(reworked.rewritten)} of them rewritten within ${report.reworkDays} days (${escape(percent(reworked.rate))}), over ${grouped(reworked.modifications)} change(s): ${escape(kindsOf2(reworked))}.`)}
7176
- <p class="quiet">${escape(kindsHelp.caveat)}</p>
7177
-
7178
- <h3>Each column</h3>
7179
- <dl>${Object.values(COLUMN_HELP).map(
7180
- (help) => `<dt>${escape(help.title)}</dt><dd>${escape(help.what)} ${escape(help.read)}</dd>`
7181
- ).join("")}</dl>
7182
- ${hot?.hotspot == null ? "" : example(`${code(hot.path)} has the highest hotspot score, ${hot.hotspot.toFixed(2)}: ${grouped(hot.modifications)} change(s) and a complexity of ${hot.complexity ?? "not measured"}${(hot.complexity ?? 0) > 10 ? ", over 10: a test or a split pays off before the next change" : ", at most 10: high only next to the simpler files of this module"}.`)}
7183
- ${coupled?.changesWith == null ? "" : example(`${code(coupled.path)} changed with ${code(coupled.changesWith.path)} in ${grouped(coupled.changesWith.count)} of its ${grouped(coupled.modifications)} changes. When you change one, look at the other.`)}
7184
-
7185
- <h3>Going further: the code itself</h3>
7186
- <p>This page reads how the code changed. Static analysis reads what the code is today: complexity of every function, duplication, dead code, import cycles and coupling. Put the two side by side: a file that is rewritten often here and complex or duplicated there is the first one to test and split.</p>
7187
- <pre><code>${escape(STATIC_ANALYSIS_COMMAND)}</code></pre>
7188
- <p class="quiet">It writes <code>static-analysis-report/static-analysis.html</code> in the module.</p>
7189
-
7190
- <h3>What these figures do not say</h3>
7191
- <p>${escape(churnHelp.caveat)}</p>
7192
-
7193
- <h3>Sources</h3>
7194
- <p class="quiet">${escape(churnHelp.source)} ${escape(kindsHelp.source)}</p>
7195
- <p>${links}</p>
7196
- </div>`;
7197
- }
7198
- var TABLE_SCRIPT = `
7199
- (function () {
7200
- var SIZE = ${PAGE_SIZE}
7201
- document.querySelectorAll('table.ctable').forEach(function (table) {
7202
- var id = table.id
7203
- var body = table.tBodies[0]
7204
- var rows = [].slice.call(body.rows)
7205
- var box = document.querySelector('input[data-table="' + id + '"]')
7206
- var chips = [].slice.call(document.querySelectorAll('.chips[data-table="' + id + '"] .chip'))
7207
- var nav = document.querySelector('.pager[data-table="' + id + '"]')
7208
- var tag = ''
7209
- var page = 0
7210
- function shown() {
7211
- var text = box ? box.value.trim().toLowerCase() : ''
7212
- return rows.filter(function (row) {
7213
- var tags = ' ' + row.getAttribute('data-tags') + ' '
7214
- return (tag === '' || tags.indexOf(' ' + tag + ' ') !== -1) &&
7215
- (text === '' || row.getAttribute('data-find').indexOf(text) !== -1)
7216
- })
7217
- }
7218
- function draw() {
7219
- var list = shown()
7220
- var pages = Math.max(1, Math.ceil(list.length / SIZE))
7221
- if (page >= pages) page = pages - 1
7222
- rows.forEach(function (row) { row.hidden = true })
7223
- list.slice(page * SIZE, page * SIZE + SIZE).forEach(function (row) { row.hidden = false })
7224
- if (!nav) return
7225
- nav.textContent = ''
7226
- var from = list.length === 0 ? 0 : page * SIZE + 1
7227
- var to = Math.min(list.length, page * SIZE + SIZE)
7228
- var label = document.createElement('span')
7229
- label.textContent = from + '\u2013' + to + ' of ' + list.length + ' file(s)'
7230
- nav.appendChild(label)
7231
- if (pages < 2) return
7232
- function button(text, target, current) {
7233
- var b = document.createElement('button')
7234
- b.type = 'button'
7235
- b.textContent = text
7236
- b.disabled = target < 0 || target >= pages || current
7237
- if (current) b.className = 'on'
7238
- b.addEventListener('click', function () { page = target; draw(); table.scrollIntoView({ block: 'start' }) })
7239
- nav.appendChild(b)
7240
- }
7241
- button('\u2039', page - 1, false)
7242
- for (var p = 0; p < pages; p++) {
7243
- if (p === 0 || p === pages - 1 || Math.abs(p - page) <= 2) button(String(p + 1), p, p === page)
7244
- else if (Math.abs(p - page) === 3) { var gap = document.createElement('span'); gap.textContent = '\u2026'; nav.appendChild(gap) }
7245
- }
7246
- button('\u203A', page + 1, false)
7247
- }
7248
- if (box) box.addEventListener('input', function () { page = 0; draw() })
7249
- chips.forEach(function (chip) {
7250
- chip.addEventListener('click', function () {
7251
- tag = chip.getAttribute('data-tag')
7252
- chips.forEach(function (other) { other.classList.toggle('on', other === chip) })
7253
- page = 0
7254
- draw()
7255
- })
7256
- })
7257
- var heads = [].slice.call(table.tHead.rows[0].cells)
7258
- heads.forEach(function (head, column) {
7259
- var order = 0
7260
- // Reachable from the keyboard: Tab to a column title, Enter or Space to sort by it.
7261
- head.tabIndex = 0
7262
- head.addEventListener('keydown', function (event) {
7263
- if (event.target !== head || (event.key !== 'Enter' && event.key !== ' ')) return
7264
- event.preventDefault()
7265
- head.click()
7266
- })
7267
- head.addEventListener('click', function (event) {
7268
- if (event.target.closest('button')) return
7269
- var numeric = head.getAttribute('data-sort') === 'num'
7270
- order = order === 0 ? (numeric ? -1 : 1) : -order
7271
- var key = function (row) { return row.cells[column].getAttribute('data-v') || '' }
7272
- rows.sort(function (a, b) {
7273
- return numeric ? (Number(key(a)) - Number(key(b))) * order : key(a).localeCompare(key(b)) * order
7274
- })
7275
- rows.forEach(function (row) { body.appendChild(row) })
7276
- heads.forEach(function (other) { other.removeAttribute('aria-sort') })
7277
- head.setAttribute('aria-sort', order === 1 ? 'ascending' : 'descending')
7278
- page = 0
7279
- draw()
7280
- })
7281
- })
7282
- draw()
7283
- // Say when the table is wider than the page, and keep saying it as the window resizes.
7284
- var frame = table.parentElement
7285
- var hint = document.createElement('p')
7286
- hint.className = 'overflow-hint'
7287
- hint.textContent = '\u2190 \u2192 more columns: scroll the table sideways'
7288
- frame.parentElement.insertBefore(hint, frame)
7289
- function overflow() { hint.hidden = frame.scrollWidth <= frame.clientWidth + 1 }
7290
- overflow()
7291
- window.addEventListener('resize', overflow)
7292
- document.querySelectorAll('.tabs > input').forEach(function (tab) { tab.addEventListener('change', overflow) })
7293
- })
7294
- // "/" focuses the search box of the tab on screen, as on the static analysis page.
7295
- document.addEventListener('keydown', function (event) {
7296
- if (event.key !== '/' || event.target !== document.body) return
7297
- var box = [].slice.call(document.querySelectorAll('input[type=search]')).filter(function (one) {
7298
- return one.offsetParent !== null
7299
- })[0]
7300
- if (box) { event.preventDefault(); box.focus() }
7301
- })
7302
- })()
7303
- `;
7304
- var STYLES3 = `
7305
- :root {
7306
- color-scheme: light dark;
7307
- --page: #faf7f1; --surface: #ffffff; --ink: #23091c; --ink-soft: #4a3344; --label: #6f5a67;
7308
- --rule: #e1dcd0; --brand: #491b3c; --brand-bg: #f3e9ee; --moved: #a3341f; --over: #a3341f;
7309
- --ok: #2f6b4f; --note: #fdf6ee; --fix: #8a6a12; --shade: rgba(35, 9, 28, 0.22); --radius: 10px;
7310
- }
7311
- @media (prefers-color-scheme: dark) {
7312
- :root {
7313
- --page: #23091c; --surface: #2f1128; --ink: #faf7f1; --ink-soft: #d8c6d1; --label: #b298ab;
7314
- --rule: #45253d; --brand: #ffab93; --brand-bg: #3a1830; --moved: #ef8f78; --over: #ef8f78;
7315
- --ok: #7ed3a5; --note: #2f1128; --fix: #9cc3f0; --shade: rgba(250, 247, 241, 0.25);
7316
- }
7317
- }
7318
- * { box-sizing: border-box; }
7319
- body { margin: 0; padding: 2.5rem 1rem 4rem; background: var(--page); color: var(--ink);
7320
- font: 15px/1.6 'Brand Sans', Inter, ui-sans-serif, system-ui, sans-serif; }
7321
- main { max-width: 78rem; margin: 0 auto; }
7322
- code { font: 0.86em ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink-soft); }
7323
- header { border-left: 3px solid var(--brand); padding-left: 0.9rem; margin-bottom: 1.6rem; }
7324
- header .top { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem; margin: 0;
7325
- color: var(--label); font-size: 0.8rem; }
7326
- h1 { font-size: 1.4rem; font-weight: 600; margin: 0.3rem 0 0.4rem; overflow-wrap: anywhere; }
7327
- .lead { margin: 0 0 1rem; max-width: 60rem; font-size: 1rem; color: var(--ink-soft); }
7328
- .summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 0.8rem; }
7329
- .kpi { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 0.8rem 1rem; }
7330
- .kpi p { margin: 0.2rem 0; font-size: 0.88rem; }
7331
- .kpi .label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--label); font-weight: 600; }
7332
- .kpi .big { font-size: 1.7rem; font-weight: 650; line-height: 1.2; margin: 0.2rem 0 0.4rem; }
7333
- .kpi .small { font-size: 0.85rem; font-weight: 400; color: var(--label); }
7334
- .kpi.band-watch, .kpi.band-above { border-color: var(--over); }
7335
- .bar { display: flex; height: 0.6rem; border-radius: 999px; overflow: hidden; background: var(--rule); margin: 0.3rem 0; }
7336
- .seg { display: block; height: 100%; }
7337
- .seg-feat { background: var(--brand); }
7338
- .seg-fix { background: var(--fix); }
7339
- .seg-refactor { background: var(--ok); }
7340
- .seg-other { background: var(--label); }
7341
- .legend { display: flex; flex-wrap: wrap; gap: 0.2rem 0.8rem; }
7342
- .legend > span { white-space: nowrap; }
7343
- .dot { display: inline-block; width: 0.55rem; height: 0.55rem; border-radius: 50%; margin-right: 0.3rem; }
7344
- .unit, .small-note { font-size: 0.78rem !important; }
7345
- .pop .read { color: var(--ink-soft); }
7346
- .partner { font: 0.8rem ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 600; overflow-wrap: anywhere; }
7347
- td.partners { min-width: 17rem; }
7348
- .more-partners summary { cursor: pointer; color: var(--brand); font-size: 0.78rem; margin-top: 0.2rem; }
7349
- .more-partners ol { margin: 0.3rem 0 0; padding-left: 1.1rem; font-size: 0.8rem; }
7350
- .more-partners li { margin: 0.15rem 0; }
7351
- .pill { white-space: nowrap; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
7352
- padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--brand-bg); color: var(--brand); font-weight: 600; }
7353
- .band-above .pill, .band-watch .pill { background: var(--over); color: var(--surface); }
7354
- .kind { font: 0.76rem ui-monospace, SFMono-Regular, Menlo, monospace; padding: 0.05rem 0.4rem;
7355
- border-radius: 4px; background: var(--brand-bg); color: var(--brand); white-space: nowrap; }
7356
- /* Neutral on purpose: a fix is often the healthy outcome, and red would read as danger. */
7357
- .kind-other { background: transparent; color: var(--label); border: 1px solid var(--rule); }
7358
- .tabs > input { position: absolute; opacity: 0; pointer-events: none; }
7359
- .tabs > label { display: inline-block; padding: 0.55rem 1rem; margin-right: 0.2rem; border: 1px solid transparent;
7360
- border-bottom: none; border-radius: 8px 8px 0 0; cursor: pointer; color: var(--label); }
7361
- .tabs > label span { color: var(--label); font-size: 0.78rem; }
7362
- .tabs > input:checked + label { color: var(--ink); background: var(--surface); border-color: var(--rule); font-weight: 600; }
7363
- .tabs > input:focus-visible + label { outline: 2px solid var(--brand); }
7364
- .panel { display: none; border-top: 1px solid var(--rule); padding-top: 1.2rem; }
7365
- #tab-files:checked ~ #panel-files, #tab-settings:checked ~ #panel-settings { display: block; }
7366
- .top-right { display: inline-flex; align-items: center; gap: 0.6rem; }
7367
- .help-button { padding: 0.3rem 0.9rem; border-radius: 999px; border: 1px solid var(--brand); background: var(--brand);
7368
- color: var(--surface); font: inherit; font-size: 0.82rem; font-weight: 600; cursor: pointer; }
7369
- .help-button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
7370
- /* The help opens at the TOP of the screen, under the banner it is called from, and scrolls on its own. */
7371
- .pop.help-dialog { position: fixed; inset: 1.5rem 0 auto 0; margin: 0 auto; width: min(52rem, calc(100vw - 2rem));
7372
- max-width: none; max-height: calc(100vh - 3rem); overflow-y: auto; padding: 1.2rem 1.6rem; }
7373
- .help-dialog::backdrop { background: rgba(35, 9, 28, 0.35); }
7374
- .help-head { display: flex; justify-content: space-between; align-items: center; font-size: 1.05rem; }
7375
- .help-dialog h3 { font-size: 0.95rem; margin: 1.3rem 0 0.3rem; color: var(--brand); }
7376
- .help-dialog p, .help-dialog dd { max-width: 46rem; }
7377
- .help-dialog pre { background: var(--page); padding: 0.6rem 0.8rem; border-radius: 6px; overflow-x: auto; }
7378
- .example { background: var(--note); border-left: 3px solid var(--brand); padding: 0.4rem 0.7rem; border-radius: 4px; }
7379
- .close { width: 1.6rem; height: 1.6rem; font-size: 1rem; }
7380
- .tools { display: flex; gap: 0.6rem; align-items: center; }
7381
- .tools input { flex: 1; padding: 0.6rem 0.8rem; border: 1px solid var(--rule); border-radius: var(--radius);
7382
- background: var(--surface); color: var(--ink); font: inherit; }
7383
- .guide { padding: 0.55rem 0.9rem; border-radius: var(--radius); border: 1px solid var(--brand);
7384
- background: var(--surface); color: var(--brand); font: inherit; font-size: 0.86rem; cursor: pointer; white-space: nowrap; }
7385
- .chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.8rem 0; }
7386
- .chip { padding: 0.25rem 0.7rem; border-radius: 999px; border: 1px solid var(--rule); background: var(--surface);
7387
- color: var(--ink); font: inherit; font-size: 0.82rem; cursor: pointer; }
7388
- .chip span { color: var(--label); }
7389
- .chip.on { background: var(--brand); border-color: var(--brand); color: var(--surface); }
7390
- .chip.on span { color: var(--surface); }
7391
- /*
7392
- * A table wider than the page must SAY so: with the last visible column ending exactly at the
7393
- * edge, a reader took the table for complete (found in review). Shadows that scroll with the
7394
- * content show on the side where columns are hidden, the file column stays in place, and the
7395
- * script writes a line above the table while it overflows.
7396
- */
7397
- .scroll { overflow-x: auto; border: 1px solid var(--rule); border-radius: var(--radius);
7398
- background:
7399
- linear-gradient(to right, var(--surface) 40%, transparent) left / 2.5rem 100% no-repeat local,
7400
- linear-gradient(to left, var(--surface) 40%, transparent) right / 2.5rem 100% no-repeat local,
7401
- radial-gradient(farthest-side at 0 50%, var(--shade), transparent) left / 1rem 100% no-repeat scroll,
7402
- radial-gradient(farthest-side at 100% 50%, var(--shade), transparent) right / 1rem 100% no-repeat scroll,
7403
- var(--surface); }
7404
- table.ctable thead th:first-child, table.ctable tbody th { position: sticky; left: 0; z-index: 1;
7405
- background: var(--surface); box-shadow: 1px 0 0 var(--rule); }
7406
- .overflow-hint { margin: 0 0 0.4rem; color: var(--label); font-size: 0.8rem; text-align: right; }
7407
- table { width: 100%; border-collapse: collapse; }
7408
- th, td { text-align: left; padding: 0.5rem 0.45rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
7409
- thead th { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--label);
7410
- font-weight: 600; white-space: nowrap; cursor: pointer; user-select: none; }
7411
- thead th:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
7412
- thead th[aria-sort='descending'] .th::after { content: ' \u2193'; }
7413
- thead th[aria-sort='ascending'] .th::after { content: ' \u2191'; }
7414
- .n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
7415
- tbody th { font: 0.82rem ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 400; min-width: 13rem; max-width: 26rem; overflow-wrap: anywhere; }
7416
- tbody th .dir { color: var(--label); }
7417
- tbody th b { font-weight: 600; color: var(--ink); }
7418
- tr[hidden] { display: none; }
7419
- .gone { font: 0.7rem 'Brand Sans', Inter, sans-serif; color: var(--label); border: 1px solid var(--rule); border-radius: 4px; padding: 0 0.3rem; }
7420
- .none { color: var(--label); font-size: 0.78rem; }
7421
- /* At most 55% of the warning colour: the text on the darkest tint keeps WCAG AA, 6.95:1 light, 5.15:1 dark (70% gave 3.81 in dark). */
7422
- .score { display: inline-block; min-width: 2.6rem; padding: 0 0.3rem; border-radius: 4px;
7423
- background: color-mix(in srgb, var(--over) calc(var(--s) * 55%), transparent); }
7424
- .q { margin-left: 0.15rem; width: 1.1rem; height: 1.1rem; border-radius: 50%; border: 1px solid var(--label);
7425
- background: transparent; color: var(--label); font-size: 0.68rem; line-height: 1; cursor: pointer; padding: 0; }
7426
- .q:hover, .q:focus-visible { border-color: var(--brand); color: var(--brand); }
7427
- .pop { max-width: 26rem; padding: 0.9rem 1rem; border: 1px solid var(--rule); border-radius: var(--radius);
7428
- background: var(--surface); color: var(--ink); box-shadow: 0 8px 28px rgba(35, 9, 28, 0.18); font-size: 0.9rem; }
7429
- .pop.wide { max-width: 38rem; }
7430
- .pop p { margin: 0.4rem 0 0; }
7431
- .pager { display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center; margin: 0.8rem 0; color: var(--label); font-size: 0.85rem; }
7432
- .pager span:first-child { margin-right: 0.6rem; }
7433
- .pager button { min-width: 2rem; padding: 0.2rem 0.5rem; border: 1px solid var(--rule); border-radius: 6px;
7434
- background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; }
7435
- .pager button.on { background: var(--brand); border-color: var(--brand); color: var(--surface); }
7436
- .pager button:disabled:not(.on) { opacity: 0.4; cursor: default; }
7437
- .warn { color: var(--over); font-size: 0.9rem; }
7438
- .empty, .quiet { color: var(--label); }
7439
- h2 { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--label); margin: 2rem 0 0.6rem; font-weight: 600; }
7440
- .card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 0.4rem 1.1rem; }
7441
- .card p { max-width: 62rem; }
7442
- table.settings { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); border-collapse: separate; border-spacing: 0; overflow: hidden; }
7443
- table.settings thead th, table.plain thead th { cursor: default; }
7444
- table.settings td code { overflow-wrap: anywhere; }
7445
- table.plain tbody th, table.settings tbody th { font: inherit; font-weight: 600; min-width: 0; white-space: nowrap; }
7446
- table.settings td:last-child { white-space: nowrap; }
7447
- dl { margin: 0.6rem 0; }
7448
- dt { font-weight: 600; margin-top: 0.8rem; }
7449
- dd { margin: 0.2rem 0 0; color: var(--ink-soft); max-width: 62rem; }
7450
- .moved { color: var(--moved); font-weight: 500; }
7451
- footer { margin-top: 2.5rem; color: var(--label); font-size: 0.8rem; }
7452
- a { color: var(--brand); }
7453
- `;
7393
+ </tbody></table>
7394
+ <p class="quiet">A module moves a setting in <code>code-churn.config.mjs</code>; the report then marks it, because two modules measured differently no longer compare.${report.status.moved ? ' <span class="moved">This module set its own levels.</span>' : ""}</p>
7395
+ <h2>Bands</h2>
7396
+ ${bandsTable(report)}`;
7397
+ }
7398
+ function bandsTable(report) {
7399
+ const { levels } = report.status;
7400
+ return `<table class="plain"><thead><tr><th scope="col">Band</th><th scope="col">When</th></tr></thead><tbody>
7401
+ <tr><th scope="row">${BAND_LABEL.quiet}</th><td>fewer than ${grouped(levels.minimumAdded)} lines added in the period: no percentage is given, it would be noise</td></tr>
7402
+ <tr><th scope="row">${BAND_LABEL.low}</th><td>under ${levels.low}%</td></tr>
7403
+ <tr><th scope="row">${BAND_LABEL.usual}</th><td>${levels.low} to ${levels.above}%</td></tr>
7404
+ <tr><th scope="row">${BAND_LABEL.above}</th><td>over ${levels.above}%</td></tr>
7405
+ <tr><th scope="row">${BAND_LABEL.watch}</th><td>over ${levels.watch}%</td></tr>
7406
+ </tbody></table>`;
7407
+ }
7408
+ function helpDialog(report) {
7409
+ const live = report.rows.filter((row) => !row.deleted);
7410
+ const reworked = live.find((row) => row.rewritten > 0 && row.added >= 20);
7411
+ const coupled = [...live].filter((row) => row.changesWith !== null).sort((a, b) => (b.changesWith?.count ?? 0) - (a.changesWith?.count ?? 0))[0];
7412
+ const hot = [...live].sort((a, b) => (b.hotspot ?? -1) - (a.hotspot ?? -1))[0];
7413
+ const example = (text) => `<p class="example"><b>In this module.</b> ${text}</p>`;
7414
+ const code = (path2) => `<code>${escape(nameOf3(path2))}</code>`;
7415
+ const kindsOf2 = (row) => CHANGE_KINDS.filter((kind) => row.kinds[kind] > 0).map((kind) => `${row.kinds[kind]} ${kind}`).join(", ");
7416
+ const { figures } = report;
7417
+ const links = [
7418
+ ...churnHelp.links ?? [],
7419
+ ...kindsHelp.links ?? [],
7420
+ ...correlationHelp.links ?? []
7421
+ ].map((link) => `<a href="${escape(link.url)}">${escape(link.label)}</a>`).join(" \xB7 ");
7422
+ return `<div popover id="help" class="pop help-dialog">
7423
+ <div class="help-head"><b>How to read this page</b><button type="button" class="q close" popovertarget="help" popovertargetaction="hide" aria-label="Close the help">&times;</button></div>
7424
+
7425
+ <h3>What code churn is</h3>
7426
+ <p>${escape(churnHelp.what)} A line rewritten days after it was written is work done twice.</p>
7427
+ ${figures.rate === null ? "" : example(`${grouped(figures.rewritten)} of the ${grouped(figures.added)} lines added from ${escape(day(report.period.from))} to ${escape(day(report.period.to))} were rewritten or deleted within ${report.reworkDays} days: ${escape(percent(figures.rate))}.`)}
7428
+
7429
+ <h3>Why it matters</h3>
7430
+ <p>Code churn is a symptom. Code rewritten soon after it is written points at a design that is still being found, or at a requirement that is still moving. It is rarely spread evenly: a few files carry most of it, and those are where to look. It never says the code is bad, and it never judges the people who wrote it.</p>
7431
+
7432
+ <h3>The band</h3>
7433
+ <p>${escape(report.status.text)} The bands place the figure among the hublo/monorepo modules; they say where it stands, never whether the code is good. A module compares best with itself over time.</p>
7434
+ ${bandsTable(report)}
7435
+
7436
+ <h3>Why the code changed</h3>
7437
+ <p>${escape(kindsHelp.what)}</p>
7438
+ <p>${escape(kindsHelp.read)}</p>
7439
+ ${reworked === void 0 ? "" : example(`${code(reworked.path)} gained ${grouped(reworked.added)} lines, ${grouped(reworked.rewritten)} of them rewritten within ${report.reworkDays} days (${escape(percent(reworked.rate))}), over ${grouped(reworked.modifications)} change(s): ${escape(kindsOf2(reworked))}.`)}
7440
+ <p class="quiet">${escape(kindsHelp.caveat)}</p>
7441
+
7442
+ <h3>Each column</h3>
7443
+ <dl>${Object.values(COLUMN_HELP).map(
7444
+ (help) => `<dt>${escape(help.title)}</dt><dd>${escape(help.what)} ${escape(help.read)}</dd>`
7445
+ ).join("")}</dl>
7446
+ ${hot?.hotspot == null ? "" : example(`${code(hot.path)} has the highest hotspot score, ${hot.hotspot.toFixed(2)}: ${grouped(hot.modifications)} change(s) and a complexity of ${hot.complexity ?? "not measured"}${(hot.complexity ?? 0) > 10 ? ", over 10: a test or a split pays off before the next change" : ", at most 10: high only next to the simpler files of this module"}.`)}
7447
+ ${coupled?.changesWith == null ? "" : example(`${code(coupled.path)} changed with ${code(coupled.changesWith.path)} in ${grouped(coupled.changesWith.count)} of its ${grouped(coupled.modifications)} changes. When you change one, look at the other.`)}
7448
+
7449
+ <h3>Going further: the code itself</h3>
7450
+ <p>This page reads how the code changed. Static analysis reads what the code is today: complexity of every function, duplication, dead code, import cycles and coupling. Put the two side by side: a file that is rewritten often here and complex or duplicated there is the first one to test and split.</p>
7451
+ <pre><code>${escape(STATIC_ANALYSIS_COMMAND)}</code></pre>
7452
+ <p class="quiet">It writes <code>static-analysis-report/static-analysis.html</code> in the module.</p>
7453
+
7454
+ <h3>What these figures do not say</h3>
7455
+ <p>${escape(churnHelp.caveat)}</p>
7456
+
7457
+ <h3>Sources</h3>
7458
+ <p class="quiet">${escape(churnHelp.source)} ${escape(kindsHelp.source)}</p>
7459
+ <p>${links}</p>
7460
+ </div>`;
7461
+ }
7462
+ var TABLE_SCRIPT = tableScript(PAGE_SIZE, "file(s)");
7463
+ var STYLES3 = REPORT_STYLES;
7454
7464
 
7455
7465
  // src/roles/code-churn/report/render-json.ts
7456
7466
  var JSON_SCHEMA_VERSION2 = 1;
@@ -7508,7 +7518,7 @@ function codeCell(path2) {
7508
7518
  }
7509
7519
  function kindsLine(report) {
7510
7520
  const { changes, rewritten } = report.figures.kinds;
7511
- const list = (counts2) => CHANGE_KINDS.map((kind) => `${counts2[kind]} ${kind}`).join(" \xB7 ");
7521
+ const list = (counts) => CHANGE_KINDS.map((kind) => `${counts[kind]} ${kind}`).join(" \xB7 ");
7512
7522
  const total = CHANGE_KINDS.reduce((sum, kind) => sum + rewritten[kind], 0);
7513
7523
  return `Why it changed: ${list(changes)}` + (total > 0 ? `. Rewritten lines, by the change that rewrote them: ${list(rewritten)}.` : ".");
7514
7524
  }
@@ -7907,7 +7917,7 @@ function fileRows(figures, measured) {
7907
7917
  });
7908
7918
  }
7909
7919
  function describeKinds(kinds) {
7910
- const list = (counts2) => CHANGE_KINDS.map((kind) => `${counts2[kind]} ${kind}`).join(", ");
7920
+ const list = (counts) => CHANGE_KINDS.map((kind) => `${counts[kind]} ${kind}`).join(", ");
7911
7921
  const changes = CHANGE_KINDS.reduce((total, kind) => total + kinds.changes[kind], 0);
7912
7922
  const rewritten = CHANGE_KINDS.reduce((total, kind) => total + kinds.rewritten[kind], 0);
7913
7923
  return `why it changed: ${changes} change(s) in the period (${list(kinds.changes)})` + (rewritten > 0 ? `; the ${rewritten} rewritten line(s), by the change that rewrote them: ${list(kinds.rewritten)}.` : ".");
@@ -8522,8 +8532,8 @@ function codeFindings(view, settings, contracts) {
8522
8532
  optional: [...derived.optional.keys()].sort(),
8523
8533
  contracts: contracts.map(({ path: path2, parsed: parsed2 }) => ({ path: path2, keys: parsed2.keys.length }))
8524
8534
  };
8525
- const counts2 = { required: derived.required.size, optional: derived.optional.size };
8526
- if (contracts.length === 0) return { findings: [], inventory, counts: counts2, compared: false };
8535
+ const counts = { required: derived.required.size, optional: derived.optional.size };
8536
+ if (contracts.length === 0) return { findings: [], inventory, counts, compared: false };
8527
8537
  const declaredAt = /* @__PURE__ */ new Map();
8528
8538
  for (const { path: path2, parsed: parsed2 } of contracts) {
8529
8539
  for (const entry of parsed2.entries) {
@@ -8563,7 +8573,7 @@ function codeFindings(view, settings, contracts) {
8563
8573
  return finding("optional-var-undeclared", { name, file: site?.path, line: site?.line });
8564
8574
  })
8565
8575
  ];
8566
- return { findings, inventory, counts: counts2, compared: true };
8576
+ return { findings, inventory, counts, compared: true };
8567
8577
  }
8568
8578
  function dockerFindings(view, settings) {
8569
8579
  const excluded2 = (path2) => settings.docker.excludePaths.some((prefix) => path2.startsWith(prefix));
@@ -8800,8 +8810,8 @@ function verdictOf(report) {
8800
8810
  return report.level === "error" ? `${counted}: failing` : `${counted}: reported, not failing`;
8801
8811
  }
8802
8812
  function headline2(report) {
8803
- const { counts: counts2 } = report;
8804
- return `${counts2.envFiles} env file(s), ${counts2.contracts} contract(s), ${counts2.required} required and ${counts2.optional} optional variable(s) read, ${counts2.dockerfiles} Dockerfile(s)` + (report.nodeVersion ? `, node ${report.nodeVersion}` : "");
8813
+ const { counts } = report;
8814
+ return `${counts.envFiles} env file(s), ${counts.contracts} contract(s), ${counts.required} required and ${counts.optional} optional variable(s) read, ${counts.dockerfiles} Dockerfile(s)` + (report.nodeVersion ? `, node ${report.nodeVersion}` : "");
8805
8815
  }
8806
8816
  function renderConsole3(report, palette2) {
8807
8817
  const lines = [];
@@ -10034,16 +10044,16 @@ function parseOxlintDiagnostics(stdout) {
10034
10044
  return out;
10035
10045
  }
10036
10046
  function errorCountsByConfigRule(stdout) {
10037
- const counts2 = /* @__PURE__ */ new Map();
10047
+ const counts = /* @__PURE__ */ new Map();
10038
10048
  for (const entry of rawDiagnostics(stdout)) {
10039
10049
  if (entry.severity !== "error") continue;
10040
10050
  const code = typeof entry.code === "string" ? entry.code : "";
10041
10051
  if (code === TSCONFIG_ERROR_CODE) continue;
10042
10052
  const id = configRuleId(code);
10043
10053
  if (!id) continue;
10044
- counts2.set(id, (counts2.get(id) ?? 0) + 1);
10054
+ counts.set(id, (counts.get(id) ?? 0) + 1);
10045
10055
  }
10046
- return counts2;
10056
+ return counts;
10047
10057
  }
10048
10058
  function tsconfigErrors(stdout) {
10049
10059
  return rawDiagnostics(stdout).filter((entry) => entry.code === TSCONFIG_ERROR_CODE).map(
@@ -10364,12 +10374,12 @@ var DEFAULT_IGNORE_PATTERNS = [
10364
10374
 
10365
10375
  // src/roles/lint/adapters/oxlint/plan.ts
10366
10376
  function summariseByPlugin(rules) {
10367
- const counts2 = /* @__PURE__ */ new Map();
10377
+ const counts = /* @__PURE__ */ new Map();
10368
10378
  for (const name of deferredRuleNames(rules)) {
10369
10379
  const plugin = name.includes("/") ? name.split("/")[0] ?? name : "core";
10370
- counts2.set(plugin, (counts2.get(plugin) ?? 0) + 1);
10380
+ counts.set(plugin, (counts.get(plugin) ?? 0) + 1);
10371
10381
  }
10372
- return [...counts2.entries()].sort((left, right) => right[1] - left[1]).map(([plugin, count]) => `${count} ${plugin}`).join(", ");
10382
+ return [...counts.entries()].sort((left, right) => right[1] - left[1]).map(([plugin, count]) => `${count} ${plugin}`).join(", ");
10373
10383
  }
10374
10384
  function plan2(context2) {
10375
10385
  if (!hasLintPreset(context2.preset)) {
@@ -10444,13 +10454,13 @@ function plan2(context2) {
10444
10454
  );
10445
10455
  const deleting = new Set(eslintConfigs);
10446
10456
  const rewritten = renames.filter((entry) => !deleting.has(entry.file));
10447
- const byFile3 = /* @__PURE__ */ new Map();
10457
+ const byFile = /* @__PURE__ */ new Map();
10448
10458
  for (const entry of rewritten) {
10449
- const list = byFile3.get(entry.file) ?? [];
10459
+ const list = byFile.get(entry.file) ?? [];
10450
10460
  list.push({ from: entry.from, to: entry.to });
10451
- byFile3.set(entry.file, list);
10461
+ byFile.set(entry.file, list);
10452
10462
  }
10453
- for (const [file, replacements] of byFile3) {
10463
+ for (const [file, replacements] of byFile) {
10454
10464
  operations.push({ kind: "replace-lines", path: file, replacements });
10455
10465
  }
10456
10466
  const notes = [
@@ -10654,12 +10664,12 @@ function moduleEslintDependencies(cwd) {
10654
10664
  // src/roles/lint/adapters/oxlint/oxlint.adapter.ts
10655
10665
  var CAPTURE_MAX_BUFFER = 64 * 1024 * 1024;
10656
10666
  function summariseByPlugin2(rules) {
10657
- const counts2 = /* @__PURE__ */ new Map();
10667
+ const counts = /* @__PURE__ */ new Map();
10658
10668
  for (const name of deferredRuleNames(rules)) {
10659
10669
  const plugin = name.includes("/") ? name.split("/")[0] ?? name : "core";
10660
- counts2.set(plugin, (counts2.get(plugin) ?? 0) + 1);
10670
+ counts.set(plugin, (counts.get(plugin) ?? 0) + 1);
10661
10671
  }
10662
- return [...counts2.entries()].sort((left, right) => right[1] - left[1]).map(([plugin, count]) => `${count} ${plugin}`).join(", ");
10672
+ return [...counts.entries()].sort((left, right) => right[1] - left[1]).map(([plugin, count]) => `${count} ${plugin}`).join(", ");
10663
10673
  }
10664
10674
  var STALE_STUB_MARKER = "**/node_modules/**";
10665
10675
  var OXLINT_VALUE_FLAGS = [
@@ -11366,7 +11376,9 @@ function explainUnreadableSqlConfig(error) {
11366
11376
  }
11367
11377
  function adopt4(exported) {
11368
11378
  if (exported === null || typeof exported !== "object") return defineSql();
11369
- if (Array.isArray(exported.moved)) return exported;
11379
+ if (Array.isArray(exported.moved)) {
11380
+ return withDefaults(exported);
11381
+ }
11370
11382
  return defineSql(exported);
11371
11383
  }
11372
11384
  function configProblem(config) {
@@ -11583,18 +11595,18 @@ function appliedMigrationChanges(cwd, sha, settings, nested = []) {
11583
11595
  reason: "git answered `git diff --raw` in a shape sentinel does not know, so the migrations this branch changes on its base cannot be read. Report it to sentinel's maintainers."
11584
11596
  };
11585
11597
  }
11586
- const isMigration = migrationMatcher(settings, nested);
11598
+ const isMigration2 = migrationMatcher(settings, nested);
11587
11599
  const deleted = [];
11588
11600
  const modified = [];
11589
11601
  const added = [];
11590
11602
  for (const entry of entries) {
11591
- if (!isMigration(entry.path)) continue;
11603
+ if (!isMigration2(entry.path)) continue;
11592
11604
  if (entry.status === "D") deleted.push(entry);
11593
11605
  else if (entry.status === "A") added.push(entry);
11594
11606
  else modified.push(entry);
11595
11607
  }
11596
11608
  for (const path2 of untracked.out.split("\0")) {
11597
- if (isMigration(path2)) added.push({ status: "A", path: path2, before: void 0, after: void 0 });
11609
+ if (isMigration2(path2)) added.push({ status: "A", path: path2, before: void 0, after: void 0 });
11598
11610
  }
11599
11611
  const unknown = [...modified, ...deleted.length > 0 ? added : []].filter((entry) => entry.after === void 0).map((entry) => entry.path);
11600
11612
  const ids = contentIds(cwd, unknown);
@@ -12484,7 +12496,10 @@ function readingOf(statements, {
12484
12496
  }
12485
12497
 
12486
12498
  // src/roles/sql/raw/template-rule.ts
12487
- var NO_CONTEXT = { trigramIndexes: () => [], indexesFrom: [] };
12499
+ var NO_CONTEXT = {
12500
+ trigramIndexes: () => [],
12501
+ indexesFrom: () => ({ read: [], empty: [] })
12502
+ };
12488
12503
 
12489
12504
  // src/roles/sql/raw/value-starts.ts
12490
12505
  var MAX_DEPTH2 = 8;
@@ -12530,16 +12545,18 @@ function nameStart(name, bindings, deeper) {
12530
12545
  function sqlTemplatesOf(program, prisma, fileText) {
12531
12546
  const templates = [];
12532
12547
  let bindings;
12548
+ const bindingsOnce = () => {
12549
+ bindings ??= bindingsOf(program);
12550
+ return bindings;
12551
+ };
12533
12552
  walk(program, (node) => {
12534
12553
  if (node.type !== "TaggedTemplateExpression") return;
12535
12554
  const tag = tagOf(node.tag, prisma);
12536
12555
  if (tag === void 0) return;
12537
12556
  const quasis = node.quasi.quasis;
12538
12557
  const parts = quasis.map((element) => partOf(element, fileText));
12539
- bindings ??= bindingsOf(program);
12540
- const known = bindings;
12541
12558
  const expressions = node.quasi.expressions;
12542
- const values = expressions.map((expression) => valueStart(expression, known));
12559
+ const values = expressions.map((expression) => valueStart(expression, bindingsOnce()));
12543
12560
  templates.push({ tag, parts, values, start: node.start });
12544
12561
  });
12545
12562
  return templates;
@@ -12562,7 +12579,7 @@ function partOf(element, fileText) {
12562
12579
  }
12563
12580
 
12564
12581
  // src/roles/sql/raw/check-templates.ts
12565
- async function checkSqlTemplates(cwd, files, readFile, rules, context2 = NO_CONTEXT) {
12582
+ async function checkSqlTemplates(cwd, files, readFile, { rules, context: context2 = NO_CONTEXT }) {
12566
12583
  const run = { templates: 0, read: 0, unread: [], unparsed: [], findings: [] };
12567
12584
  if (files.length === 0) return run;
12568
12585
  const loaded2 = await parserLoaded();
@@ -12713,40 +12730,41 @@ function firstLocation(node) {
12713
12730
  function wholeStatement(reading) {
12714
12731
  return reading.wrap === "statement" && reading.fill === "value";
12715
12732
  }
12716
- function expressionKey(node) {
12717
- const column = bodyOf(node, "ColumnRef");
12718
- if (column) {
12719
- const name = columnNames(column).at(-1);
12720
- return name === void 0 || name === "*" || name === "" ? void 0 : name;
12721
- }
12722
- const call = bodyOf(node, "FuncCall");
12723
- if (call) return callKey(call);
12724
- const cast = bodyOf(node, "TypeCast");
12725
- if (cast) {
12726
- const inner = expressionKey(cast.arg);
12727
- const names = cast.typeName?.names ?? [];
12728
- const type = bodyOf(names.at(-1), "String")?.sval;
12729
- return inner === void 0 || typeof type !== "string" ? void 0 : `${inner}::${type}`;
12730
- }
12731
- const constant = bodyOf(node, "A_Const");
12732
- if (constant) return constantKey(constant);
12733
- const operation = bodyOf(node, "A_Expr");
12734
- if (operation?.kind === "AEXPR_OP") {
12735
- const operator = bodyOf(operation.name?.at(-1), "String")?.sval;
12736
- const left = expressionKey(operation.lexpr);
12737
- const right = expressionKey(operation.rexpr);
12738
- if (typeof operator !== "string" || left === void 0 || right === void 0) return void 0;
12739
- return `${left} ${operator} ${right}`;
12740
- }
12741
- return void 0;
12733
+ function lastName(names) {
12734
+ const name = bodyOf(names?.at(-1), "String")?.sval;
12735
+ return typeof name === "string" ? name : void 0;
12742
12736
  }
12743
- function callKey(call) {
12744
- const name = bodyOf(call.funcname?.at(-1), "String")?.sval;
12745
- if (typeof name !== "string") return void 0;
12746
- const args = (call.args ?? []).map(expressionKey);
12747
- if (args.some((arg) => arg === void 0)) return void 0;
12737
+ var MAX_KEY_DEPTH = 32;
12738
+ function expressionKey(node, depth = 0) {
12739
+ if (depth > MAX_KEY_DEPTH || node === null || typeof node !== "object") return void 0;
12740
+ const [kind] = Object.keys(node);
12741
+ const keyOf = kind === void 0 ? void 0 : KEYS.get(kind);
12742
+ const body = kind === void 0 ? void 0 : bodyOf(node, kind);
12743
+ return keyOf && body ? keyOf(body, depth + 1) : void 0;
12744
+ }
12745
+ function columnKey(column) {
12746
+ const name = columnNames(column).at(-1);
12747
+ return name === void 0 || name === "*" || name === "" ? void 0 : name;
12748
+ }
12749
+ function callKey(call, depth) {
12750
+ const name = lastName(call.funcname);
12751
+ const args = (call.args ?? []).map((arg) => expressionKey(arg, depth));
12752
+ if (name === void 0 || args.some((arg) => arg === void 0)) return void 0;
12748
12753
  return `${name}(${args.join(", ")})`;
12749
12754
  }
12755
+ function castKey(cast, depth) {
12756
+ const inner = expressionKey(cast.arg, depth);
12757
+ const type = lastName(cast.typeName?.names);
12758
+ return inner === void 0 || type === void 0 ? void 0 : `${inner}::${type}`;
12759
+ }
12760
+ function operationKey(operation, depth) {
12761
+ if (operation.kind !== "AEXPR_OP") return void 0;
12762
+ const operator = lastName(operation.name);
12763
+ const left = expressionKey(operation.lexpr, depth);
12764
+ const right = expressionKey(operation.rexpr, depth);
12765
+ if (operator === void 0 || left === void 0 || right === void 0) return void 0;
12766
+ return `${left} ${operator} ${right}`;
12767
+ }
12750
12768
  function constantKey(constant) {
12751
12769
  if (constant.isnull === true) return "null";
12752
12770
  const text = bodyOf(constant, "sval")?.sval;
@@ -12761,6 +12779,13 @@ function constantKey(constant) {
12761
12779
  }
12762
12780
  return void 0;
12763
12781
  }
12782
+ var KEYS = /* @__PURE__ */ new Map([
12783
+ ["ColumnRef", columnKey],
12784
+ ["FuncCall", callKey],
12785
+ ["TypeCast", castKey],
12786
+ ["A_Const", constantKey],
12787
+ ["A_Expr", operationKey]
12788
+ ]);
12764
12789
  function qualifiersUnder(node) {
12765
12790
  const qualifiers = /* @__PURE__ */ new Set();
12766
12791
  for (const names of columnsUnder(node)) {
@@ -12853,6 +12878,7 @@ function unlistedInsert(statement) {
12853
12878
  // src/roles/sql/raw/rules/leading-wildcard-like.ts
12854
12879
  var QUERIES = /* @__PURE__ */ new Set(["SelectStmt", "UpdateStmt", "DeleteStmt", "InsertStmt"]);
12855
12880
  var KEEPS_START = /* @__PURE__ */ new Set(["lower", "upper", "unaccent", "immutable_unaccent", "like_escape"]);
12881
+ var MAX_PATTERN_DEPTH = 32;
12856
12882
  var leadingWildcardLike = {
12857
12883
  name: LIKE_WILDCARD_RULE,
12858
12884
  help: "anchor the pattern at its start when the search allows it (`LIKE 'abc%'`); for a search inside the text, a trigram index (`pg_trgm`) on this very expression; when that index is in another module's migrations, name their folder in `migrations.indexesFrom`",
@@ -12865,77 +12891,89 @@ var leadingWildcardLike = {
12865
12891
  }
12866
12892
  };
12867
12893
  function unservedLike(node, reading, context2) {
12868
- const like = bodyOf(node, "A_Expr");
12869
- if (like?.kind !== "AEXPR_LIKE" && like?.kind !== "AEXPR_ILIKE") return void 0;
12870
- if (typeof like.location !== "number" || !reading.own(like.location)) return void 0;
12871
- const pattern = patternStart(like.rexpr, reading);
12894
+ const like = ownLike(node, reading);
12895
+ if (like === void 0) return void 0;
12896
+ const pattern = patternStart(like.body.rexpr, { reading, depth: 0 });
12872
12897
  if (!pattern?.text.startsWith("%")) return void 0;
12873
- const expression = expressionKey(like.lexpr);
12898
+ const expression = expressionKey(like.body.lexpr);
12874
12899
  if (expression === void 0) return void 0;
12875
- const table = tableOf(like.lexpr, reading);
12900
+ const table = tableOf(like.body.lexpr, reading);
12876
12901
  if (served(context2.trigramIndexes(), expression, table)) return void 0;
12877
- return {
12878
- location: like.location,
12879
- operator: like.kind === "AEXPR_ILIKE" ? "ILIKE" : "LIKE",
12880
- pattern,
12881
- expression,
12882
- table
12883
- };
12884
- }
12885
- function patternStart(node, reading) {
12886
- const text = bodyOf(bodyOf(node, "A_Const"), "sval")?.sval;
12887
- if (typeof text === "string") return { text, shape: `'${text}'` };
12888
- const parameter = bodyOf(node, "ParamRef")?.number;
12889
- if (typeof parameter === "number") {
12890
- const start = reading.valueStart(parameter);
12891
- return start === void 0 ? void 0 : { text: start, shape: `$${parameter}`, bound: parameter };
12892
- }
12893
- const cast = bodyOf(node, "TypeCast");
12894
- if (cast) return patternStart(cast.arg, reading);
12895
- const joined2 = bodyOf(node, "A_Expr");
12896
- if (joined2?.kind === "AEXPR_OP" && operatorOf(joined2) === "||") {
12897
- return startOfSum(joined2.lexpr, joined2.rexpr, reading, (first2) => `${first2} || \u2026`);
12898
- }
12899
- const call = bodyOf(node, "FuncCall");
12900
- const name = call ? functionName(call) : void 0;
12901
- const [first, ...rest] = call?.args ?? [];
12902
- if (name === "concat")
12903
- return startOfSum(first, rest[0], reading, (inner) => `concat(${inner}, \u2026)`);
12904
- if (name !== void 0 && KEEPS_START.has(name)) {
12905
- const inner = patternStart(first, reading);
12906
- return inner && { ...inner, shape: `${name}(${inner.shape}${rest.length > 0 ? ", \u2026" : ""})` };
12907
- }
12908
- return void 0;
12909
- }
12910
- function startOfSum(left, right, reading, shapeOf) {
12911
- const first = patternStart(left, reading);
12912
- if (first === void 0) return void 0;
12913
- if (first.text !== "") return { ...first, shape: shapeOf(first.shape) };
12914
- const next = right === void 0 ? void 0 : patternStart(right, reading);
12915
- return next && { ...next, shape: shapeOf(first.shape) };
12916
- }
12917
- function operatorOf(operation) {
12918
- const name = bodyOf(operation.name?.at(-1), "String")?.sval;
12919
- return typeof name === "string" ? name : void 0;
12920
- }
12921
- function functionName(call) {
12922
- const name = bodyOf(call.funcname?.at(-1), "String")?.sval;
12923
- return typeof name === "string" ? name : void 0;
12924
- }
12902
+ const operator = like.body.kind === "AEXPR_ILIKE" ? "ILIKE" : "LIKE";
12903
+ return { location: like.location, operator, pattern, expression, table };
12904
+ }
12905
+ function ownLike(node, reading) {
12906
+ const body = bodyOf(node, "A_Expr");
12907
+ if (body?.kind !== "AEXPR_LIKE" && body?.kind !== "AEXPR_ILIKE") return void 0;
12908
+ const location = body.location;
12909
+ return typeof location === "number" && reading.own(location) ? { body, location } : void 0;
12910
+ }
12911
+ function patternStart(node, walk3) {
12912
+ if (walk3.depth > MAX_PATTERN_DEPTH || node === null || typeof node !== "object") return void 0;
12913
+ const [kind] = Object.keys(node);
12914
+ const startOf2 = kind === void 0 ? void 0 : STARTS.get(kind);
12915
+ const body = kind === void 0 ? void 0 : bodyOf(node, kind);
12916
+ return startOf2 && body ? startOf2(body, { ...walk3, depth: walk3.depth + 1 }) : void 0;
12917
+ }
12918
+ function literalStart(constant) {
12919
+ const text = bodyOf(constant, "sval")?.sval;
12920
+ return typeof text === "string" ? { text, shape: `'${text}'` } : void 0;
12921
+ }
12922
+ function boundStart(parameter, { reading }) {
12923
+ const number = parameter.number;
12924
+ if (typeof number !== "number") return void 0;
12925
+ const text = reading.valueStart(number);
12926
+ return text === void 0 ? void 0 : { text, shape: `$${number}`, bound: number };
12927
+ }
12928
+ function joinedStart(operation, walk3) {
12929
+ if (operation.kind !== "AEXPR_OP" || lastName(operation.name) !== "||") return void 0;
12930
+ const start = sumStart2(operation.lexpr, operation.rexpr, walk3);
12931
+ return start && { ...start, shape: `${start.shape} || \u2026` };
12932
+ }
12933
+ function callStart(call, walk3) {
12934
+ const name = lastName(call.funcname);
12935
+ const [first, ...rest] = call.args ?? [];
12936
+ if (name === "concat") {
12937
+ const start = sumStart2(first, rest[0], walk3);
12938
+ return start && { ...start, shape: `concat(${start.shape}, \u2026)` };
12939
+ }
12940
+ if (name === void 0 || !KEEPS_START.has(name)) return void 0;
12941
+ const inner = patternStart(first, walk3);
12942
+ return inner && { ...inner, shape: `${name}(${inner.shape}${rest.length > 0 ? ", \u2026" : ""})` };
12943
+ }
12944
+ function sumStart2(left, right, walk3) {
12945
+ const first = patternStart(left, walk3);
12946
+ if (first === void 0 || first.text !== "") return first;
12947
+ const next = right === void 0 ? void 0 : patternStart(right, walk3);
12948
+ return next && { ...next, shape: first.shape };
12949
+ }
12950
+ var STARTS = /* @__PURE__ */ new Map([
12951
+ ["A_Const", literalStart],
12952
+ ["ParamRef", boundStart],
12953
+ ["TypeCast", (cast, walk3) => patternStart(cast.arg, walk3)],
12954
+ ["A_Expr", joinedStart],
12955
+ ["FuncCall", callStart]
12956
+ ]);
12925
12957
  function tableOf(expression, reading) {
12958
+ const byName = tablesByName(reading);
12959
+ const qualifiers = [...qualifiersUnder(expression)];
12960
+ if (qualifiers.length > 1) return void 0;
12961
+ const [qualifier] = qualifiers;
12962
+ const tables = qualifier === void 0 ? new Set([...byName.values()].flatMap((names) => [...names])) : byName.get(qualifier) ?? /* @__PURE__ */ new Set();
12963
+ return tables.size === 1 ? [...tables][0] : void 0;
12964
+ }
12965
+ function tablesByName(reading) {
12926
12966
  const byName = /* @__PURE__ */ new Map();
12927
12967
  for (const node of pgNodes(reading.statements)) {
12928
12968
  const range = bodyOf(node, "RangeVar");
12929
- if (!range || typeof range.relname !== "string") continue;
12930
- if (typeof range.location !== "number" || !reading.own(range.location)) continue;
12969
+ const table = range?.relname;
12970
+ if (typeof table !== "string" || typeof range?.location !== "number") continue;
12971
+ if (!reading.own(range.location)) continue;
12931
12972
  const alias = range.alias?.aliasname;
12932
- const name = typeof alias === "string" ? alias : range.relname;
12933
- byName.set(name, /* @__PURE__ */ new Set([...byName.get(name) ?? [], range.relname]));
12973
+ const name = typeof alias === "string" ? alias : table;
12974
+ byName.set(name, /* @__PURE__ */ new Set([...byName.get(name) ?? [], table]));
12934
12975
  }
12935
- const qualifiers = [...qualifiersUnder(expression)];
12936
- if (qualifiers.length > 1) return void 0;
12937
- const tables = qualifiers.length === 1 ? [...byName.get(qualifiers[0] ?? "") ?? []] : [...new Set([...byName.values()].flatMap((names) => [...names]))];
12938
- return tables.length === 1 ? tables[0] : void 0;
12976
+ return byName;
12939
12977
  }
12940
12978
  function served(indexes, expression, table) {
12941
12979
  return indexes.some(
@@ -12946,12 +12984,18 @@ function hitOf(like, context2) {
12946
12984
  const { pattern, operator, expression, table } = like;
12947
12985
  const bound = pattern.bound === void 0 ? "" : ` (the TypeScript binds \`${pattern.text}\u2026\` to $${pattern.bound})`;
12948
12986
  const on = `\`${expression}\`${table === void 0 ? "" : ` of \`${table}\``}`;
12949
- const read2 = context2.indexesFrom.length === 0 ? "the module's own" : `the module's and those of ${context2.indexesFrom.map((folder) => `\`${folder}\``).join(", ")}`;
12950
12987
  return {
12951
12988
  location: like.location,
12952
- message: `the pattern ${pattern.shape} starts with a wildcard${bound}: no B-tree index can serve this ${operator}, and no trigram index on ${on} is in the migrations read (${read2}; an index created by hand in the database is not seen), so every row is read`
12989
+ message: `the pattern ${pattern.shape} starts with a wildcard${bound}: no B-tree index can serve this ${operator}, and no trigram index on ${on} is in the migrations read (${migrationsRead(context2)}; an index created by hand in the database is not seen), so every row is read`
12953
12990
  };
12954
12991
  }
12992
+ function migrationsRead(context2) {
12993
+ const { read: read2, empty } = context2.indexesFrom();
12994
+ const named = (folders) => folders.map((folder) => `\`${folder}\``).join(", ");
12995
+ const from = read2.length === 0 ? "the module's own" : `the module's and those of ${named(read2)}`;
12996
+ if (empty.length === 0) return from;
12997
+ return `${from}; ${named(empty)} ${empty.length === 1 ? "holds" : "hold"} no migration`;
12998
+ }
12955
12999
 
12956
13000
  // src/roles/sql/raw/rules/not-in-subquery.ts
12957
13001
  var notInSubquery = {
@@ -13196,18 +13240,39 @@ function excerptOf(lines, finding3) {
13196
13240
  const last = Math.min(finding3.endLine, finding3.line + EXCERPT_LINES - 1, lines.length);
13197
13241
  return lines.slice(finding3.line - 1, last).join("\n");
13198
13242
  }
13199
- function byRule(findings) {
13243
+ function findingsByFile(findings) {
13200
13244
  const groups = /* @__PURE__ */ new Map();
13201
- for (const finding3 of findings) {
13202
- if (finding3.rule === SYNTAX_ERROR) continue;
13203
- groups.set(finding3.rule, [...groups.get(finding3.rule) ?? [], finding3]);
13204
- }
13205
- return [...groups].map(([rule, list]) => ({ rule, findings: [...list].sort(byPlace) })).sort(
13206
- (a, b) => errorsFirst(a.findings, b.findings) || b.findings.length - a.findings.length || a.rule.localeCompare(b.rule)
13245
+ for (const finding3 of findings)
13246
+ groups.set(finding3.file, [...groups.get(finding3.file) ?? [], finding3]);
13247
+ const errors = (list) => list.filter((finding3) => finding3.level === "error").length;
13248
+ return [...groups].map(([file, list]) => [file, [...list].sort(byLineErrorsFirst)]).sort(
13249
+ ([fileA, a], [fileB, b]) => errors(b) - errors(a) || b.length - a.length || fileA.localeCompare(fileB)
13207
13250
  );
13208
13251
  }
13209
- function errorsFirst(a, b) {
13210
- return Number(b[0]?.level === "error") - Number(a[0]?.level === "error");
13252
+ function byLineErrorsFirst(a, b) {
13253
+ return a.line - b.line || Number(b.level === "error") - Number(a.level === "error") || a.column - b.column || a.rule.localeCompare(b.rule);
13254
+ }
13255
+ function levelCounts(findings) {
13256
+ const errors = findings.filter((finding3) => finding3.level === "error").length;
13257
+ const warnings = findings.length - errors;
13258
+ return [
13259
+ ...errors > 0 ? [plural(errors, "error")] : [],
13260
+ ...warnings > 0 ? [plural(warnings, "warning")] : []
13261
+ ].join(", ");
13262
+ }
13263
+ function plural(count, noun, many = `${noun}s`) {
13264
+ return `${count} ${count === 1 ? noun : many}`;
13265
+ }
13266
+ function problemOf(finding3) {
13267
+ const own = SENTINEL_RULES.includes(finding3.rule);
13268
+ return sentence(finding3.message) + (!own && finding3.help ? ` Fix: ${endOf(finding3.help)}` : "");
13269
+ }
13270
+ function sentence(text) {
13271
+ const ended = endOf(text);
13272
+ return `${ended.charAt(0).toUpperCase()}${ended.slice(1)}`;
13273
+ }
13274
+ function endOf(text) {
13275
+ return `${text.trim().replace(/\.+$/, "")}.`;
13211
13276
  }
13212
13277
  function countedFindings(findings) {
13213
13278
  return [
@@ -13217,394 +13282,331 @@ function countedFindings(findings) {
13217
13282
  }
13218
13283
  var errorFindings = (findings) => countedFindings(findings).filter((finding3) => finding3.level === "error");
13219
13284
  function unparsedMigrations(findings) {
13220
- const byFile3 = /* @__PURE__ */ new Map();
13285
+ const byFile = /* @__PURE__ */ new Map();
13221
13286
  for (const finding3 of findings) {
13222
13287
  if (finding3.rule !== SYNTAX_ERROR) continue;
13223
- byFile3.set(finding3.file, [...byFile3.get(finding3.file) ?? [], finding3]);
13288
+ byFile.set(finding3.file, [...byFile.get(finding3.file) ?? [], finding3]);
13224
13289
  }
13225
- return [...byFile3.values()].map((errors) => {
13290
+ return [...byFile.values()].map((errors) => {
13226
13291
  const [first] = [...errors].sort((a, b) => a.line - b.line || a.column - b.column);
13227
13292
  return { first, more: errors.length - 1 };
13228
13293
  });
13229
13294
  }
13230
- function byPlace(a, b) {
13231
- return a.file.localeCompare(b.file) || a.line - b.line || a.column - b.column;
13232
- }
13233
13295
  var placeOf = (finding3) => `${finding3.file}:${finding3.line}:${finding3.column}`;
13234
13296
 
13235
- // src/roles/sql/report/outputs.ts
13236
- import { existsSync as existsSync27, mkdirSync as mkdirSync5, unlinkSync as unlinkSync3, writeFileSync as writeFileSync10 } from "node:fs";
13237
- import { join as join42 } from "node:path";
13238
-
13239
- // src/roles/sql/adapters/squawk/summary.ts
13240
- var PLAIN = { count: String, name: (name) => name };
13241
- function checkedCalls({ calls, rawCalls }, rulesOff2, mark = PLAIN) {
13242
- const methods = !rulesOff2.includes(UNSAFE_RULE);
13243
- const raw = !rulesOff2.includes(RAW_FRAGMENT_RULE);
13244
- const text = `${mark.count(calls)} call(s) taking SQL text (${mark.name("$queryRawUnsafe")} / ${mark.name("$executeRawUnsafe")}, ${mark.name("pg")}, ${mark.name("postgres")})`;
13245
- const fragments = `${mark.count(rawCalls)} Prisma fragment(s) (${mark.name("Prisma.raw")}, ${mark.name("Prisma.join")})`;
13246
- if (methods && raw) return `${text} and ${fragments}`;
13247
- return methods ? text : fragments;
13248
- }
13249
- var CALLED = "raw SQL ($queryRawUnsafe / $executeRawUnsafe, pg, postgres, Prisma.raw, Prisma.join)";
13250
- function summariseMigrations(outcome) {
13251
- return [
13252
- whatWasRead(outcome),
13253
- ...codeReadLines(outcome),
13254
- ...templateLines(outcome.templates),
13255
- ...offLines(outcome),
13256
- ...unreadLines(outcome.unread),
13257
- ...unparsedLines(outcome.code.unparsed),
13258
- ...syntaxErrorLines(outcome.findings),
13259
- ...findingLines(outcome.findings)
13260
- ];
13261
- }
13262
- function whatWasRead({ total, read: read2, base }) {
13263
- if (total === 0 || base === null) return "no migration in this module.";
13264
- const against = `compared with ${base.ref} at ${base.commit}`;
13265
- if (read2 === 0) {
13266
- return `no migration added or changed by this branch, ${against}. The ${total} in this module are not read: only what a branch introduces is.`;
13267
- }
13268
- const others = total - read2;
13269
- return `read ${read2} migration(s) this branch adds or changes, ${against}.` + (others > 0 ? ` The ${others} other(s) in this module are unchanged and not read.` : "");
13270
- }
13271
- function offLines({ read: read2, rulesOff: rulesOff2, code }) {
13272
- if (read2 === 0 && code.files === 0 || rulesOff2.length === 0) return [];
13273
- return [
13274
- `this module turns off ${rulesOff2.length} rule(s) in sql.config.mjs, so they are not checked: ${rulesOff2.join(", ")}.`
13275
- ];
13276
- }
13277
- function codeReadLines({ code, rulesOff: rulesOff2 }) {
13278
- if (code.files === 0) return [];
13279
- if (rulesOff2.includes(UNSAFE_RULE) && rulesOff2.includes(RAW_FRAGMENT_RULE)) return [];
13280
- if (code.read === 0) {
13281
- return [
13282
- `${code.files} file(s) call ${CALLED}; none is added or changed by this branch, so none is read.`
13283
- ];
13284
- }
13285
- const others = code.files - code.read;
13286
- return [
13287
- `checked ${checkedCalls(code, rulesOff2)} in the ${code.read} file(s) this branch adds or changes.` + (others > 0 ? ` The ${others} other file(s) calling them are unchanged and not read.` : "")
13288
- ];
13289
- }
13290
- var TEMPLATE_PLACES = 3;
13291
- var TEMPLATE_TAGS = "$queryRaw, $executeRaw, Prisma.sql";
13292
- function templateLines(templates) {
13293
- if (templates.files === 0) return [];
13294
- if (templates.read === 0) {
13295
- return [
13296
- `${templates.files} file(s) hold SQL templates (${TEMPLATE_TAGS}); none is added or changed by this branch, so none is read.`
13297
- ];
13298
- }
13299
- const unread = templates.unread.length;
13300
- return [
13301
- `read ${templates.parsed} of the ${templates.templates} SQL template(s) (${TEMPLATE_TAGS}) in the ${templates.read} file(s) this branch adds or changes` + (unread === 0 ? "." : `; ${unread} could not be read alone by PostgreSQL's parser, so no rule checked them:`),
13302
- ...templates.unread.slice(0, TEMPLATE_PLACES).map(({ file, line }) => ` ${file}:${line}`),
13303
- ...unread > TEMPLATE_PLACES ? [` and ${unread - TEMPLATE_PLACES} more: pnpm run sql:html lists them all`] : [],
13304
- ...templates.unparsed.map(({ file, reason }) => ` ${file}: ${reason}`)
13305
- ];
13306
- }
13307
- function unparsedLines(unparsed) {
13308
- if (unparsed.length === 0) return [];
13309
- return [
13310
- `\u2717 ${unparsed.length} TypeScript file(s) could not be read, so their calls are not checked:`,
13311
- ...unparsed.map(({ file, reason }) => ` ${file}: ${reason}`)
13312
- ];
13313
- }
13314
- function unreadLines(unread) {
13315
- if (unread.length === 0) return [];
13316
- return [
13317
- `\u2717 ${unread.length} migration(s) could not be opened, so nothing about them is checked:`,
13318
- ...unread.map(({ file, reason }) => ` ${file}: ${reason}`)
13319
- ];
13320
- }
13321
- function syntaxErrorLines(findings) {
13322
- const files = unparsedMigrations(findings);
13323
- if (files.length === 0) return [];
13324
- return [
13325
- `\u2717 ${files.length} migration(s) do not parse: squawk could not read the SQL, so no other rule checked it, and PostgreSQL will refuse it too. The first error, the one to fix:`,
13326
- ...files.map(
13327
- ({ first, more }) => ` ${first.file}:${first.line}:${first.column} ${first.message}` + (more > 0 ? ` (and ${more} more after it)` : "")
13328
- )
13329
- ];
13330
- }
13331
- function findingLines(findings) {
13332
- const counted = countedFindings(findings);
13333
- const errors = errorFindings(findings);
13334
- const errorRules = new Set(errors.map((finding3) => finding3.rule));
13335
- const byRule2 = countByRule(counted).sort(
13336
- ([a], [b]) => Number(errorRules.has(b)) - Number(errorRules.has(a))
13337
- );
13338
- if (byRule2.length === 0) return ["no finding."];
13339
- const total = counted.length;
13340
- const width = Math.max(...byRule2.map(([rule]) => rule.length));
13341
- return [
13342
- errors.length === 0 ? `${total} finding(s), every one a warning while the role is being adopted:` : `\u2717 ${total} finding(s): ${errors.length} error(s), from the rule(s) this module sets to "error" in sql.config.mjs, which fail this run, and ${total - errors.length} warning(s):`,
13343
- ...byRule2.flatMap(([rule, count]) => {
13344
- const note = findings.find(
13345
- (finding3) => finding3.rule === rule && finding3.sentinelNote
13346
- )?.sentinelNote;
13347
- return [
13348
- ` ${rule.padEnd(width)} ${count}${errorRules.has(rule) ? " error" : ""}`,
13349
- // The one-sentence form: a console is read a line at a time. The full note and its proof
13350
- // are in the page, the json and `--inspect`.
13351
- ...note ? [` sentinel's note: ${note.short}`] : [],
13352
- // The syntax errors' places are listed above, with the error to fix.
13353
- ...rule === SYNTAX_ERROR ? [] : placeLines(counted, rule)
13354
- ];
13355
- })
13356
- ];
13357
- }
13358
- var CONSOLE_PLACES = 3;
13359
- function placeLines(findings, rule) {
13360
- const mine = findings.filter((finding3) => finding3.rule === rule).sort((a, b) => a.file.localeCompare(b.file) || a.line - b.line || a.column - b.column);
13361
- const shown = mine.slice(0, CONSOLE_PLACES).map((finding3) => ` ${finding3.file}:${finding3.line}:${finding3.column}`);
13362
- const more = mine.length - shown.length;
13363
- return more > 0 ? [...shown, ` and ${more} more: pnpm run sql:html lists them all`] : shown;
13364
- }
13365
- function countByRule(findings) {
13366
- const counts2 = /* @__PURE__ */ new Map();
13367
- for (const { rule } of findings) counts2.set(rule, (counts2.get(rule) ?? 0) + 1);
13368
- return [...counts2].sort(([a, x], [b, y]) => y - x || a.localeCompare(b));
13369
- }
13370
-
13297
+ // src/roles/sql/report/outputs.ts
13298
+ import { existsSync as existsSync27, mkdirSync as mkdirSync5, unlinkSync as unlinkSync3, writeFileSync as writeFileSync10 } from "node:fs";
13299
+ import { join as join42 } from "node:path";
13300
+
13371
13301
  // src/roles/sql/report/render-html.ts
13302
+ var PAGE_SIZE2 = 50;
13372
13303
  function renderHtml4(report, now = /* @__PURE__ */ new Date()) {
13304
+ const code = findingsOf(report, "code");
13305
+ const migrations = findingsOf(report, "migrations");
13373
13306
  return `<!doctype html>
13374
13307
  <html lang="en">
13375
13308
  <head>
13376
13309
  <meta charset="utf-8">
13377
13310
  <meta name="viewport" content="width=device-width, initial-scale=1">
13378
- <title>SQL \xB7 ${escape(report.module)}</title>
13379
- <style>${STYLES4}</style>
13311
+ <title>SQL: ${escape(report.module)}</title>
13312
+ <style>${REPORT_STYLES}${STYLES4}</style>
13380
13313
  </head>
13381
13314
  <body>
13382
13315
  <main>
13383
- <header>
13384
- <p class="eyebrow">sentinel \xB7 sql</p>
13385
- <h1>${escape(report.module)}</h1>
13386
- <p class="meta">${meta(report, now)}</p>
13387
- </header>
13388
- ${counts(report)}
13389
- ${offSection(report)}
13390
- ${unreadSection(report)}
13391
- ${syntaxSection(report)}
13392
- ${findingsSection(report)}
13393
- ${readSection(report)}
13394
- ${unsafeSection(report)}
13395
- ${settingsSection(report)}
13396
- <footer>Only the migrations this branch adds or changes are read. ${errorFindings(report.findings).length === 0 ? "Every finding is a warning while the role is being adopted: nothing here fails the run." : "A rule the module sets to <code>error</code> fails the module's <code>sql</code> run; every other finding is a warning."} squawk's text is squawk's; what is labelled sentinel is sentinel's, with how it was proven.</footer>
13316
+ ${header2(report, now)}
13317
+ <div class="tabs">
13318
+ <input type="radio" name="tab" id="tab-code" checked>
13319
+ <label for="tab-code">SQL in code <span>${grouped(code.length)}</span></label>
13320
+ <input type="radio" name="tab" id="tab-migrations">
13321
+ <label for="tab-migrations">Migrations <span>${grouped(migrationsCount(report))}</span></label>
13322
+ <input type="radio" name="tab" id="tab-settings">
13323
+ <label for="tab-settings">Settings</label>
13324
+ <div class="panel" id="panel-code">${codePanel(report, code)}</div>
13325
+ <div class="panel" id="panel-migrations">${migrationsPanel(report, migrations)}</div>
13326
+ <div class="panel" id="panel-settings">${settingsPanel2(report)}</div>
13327
+ </div>
13328
+ <footer>Only the SQL this branch adds or changes is read: its migrations, raw SQL calls and SQL
13329
+ templates. ${errorFindings(report.findings).length === 0 ? "Every finding here is a warning: nothing fails the run." : "A rule the module sets to <code>error</code> fails the module's <code>sql</code> run; every other finding is a warning."} squawk's text is squawk's; what is labelled sentinel is sentinel's, with how it was proven.</footer>
13397
13330
  </main>
13331
+ <script>${tableScript(PAGE_SIZE2, "findings", "finding")}</script>
13398
13332
  </body>
13399
13333
  </html>
13400
13334
  `;
13401
13335
  }
13336
+ function findingsOf(report, side) {
13337
+ return report.findings.filter(
13338
+ (finding3) => finding3.rule !== SYNTAX_ERROR && isMigration(finding3.file) === (side === "migrations")
13339
+ );
13340
+ }
13341
+ var isMigration = (file) => file.endsWith(".sql");
13342
+ function migrationsCount(report) {
13343
+ return countedFindings(report.findings).filter((finding3) => isMigration(finding3.file)).length;
13344
+ }
13345
+ function header2(report, now) {
13346
+ return `<header>
13347
+ <p class="top"><span><b>sentinel</b> sql</span><span class="top-right">${meta(report, now)}</span></p>
13348
+ <h1>${escape(report.module)}</h1>
13349
+ <p class="lead">sentinel reads the SQL this branch adds or changes: its migrations with squawk, its raw SQL calls and SQL templates with PostgreSQL's own parser.</p>
13350
+ <div class="summary">${resultCard(report)}${readCard(report)}${toolsCard(report)}</div>
13351
+ </header>`;
13352
+ }
13402
13353
  function meta(report, now) {
13403
- const parts = [
13404
- report.base ? `compared with <code>${escape(report.base.ref)}</code> at <code>${escape(report.base.commit)}</code>` : "no migration to compare",
13354
+ return [
13355
+ report.base ? `compared with <code>${escape(report.base.ref)}</code> at <code>${escape(report.base.commit)}</code>` : null,
13405
13356
  report.commit ? `commit <code>${escape(report.commit)}</code>` : null,
13406
13357
  `sentinel ${escape(report.sentinel)}`,
13407
- `generated ${escape(now.toISOString().slice(0, 16).replace("T", " "))} UTC`
13408
- ];
13409
- return parts.filter((part) => part !== null).join(" \xB7 ");
13358
+ `${escape(now.toISOString().slice(0, 16).replace("T", " "))} UTC`
13359
+ ].filter((part) => part !== null).join(" \xB7 ");
13410
13360
  }
13411
- function counts(report) {
13412
- const syntax = unparsedMigrations(report.findings).length;
13413
- const cell4 = (value, label, alarm = false) => `<div class="count${alarm && value > 0 ? " alarm" : ""}"><b>${grouped(value)}</b><span>${label}</span></div>`;
13361
+ function resultCard(report) {
13362
+ const counted = countedFindings(report.findings);
13414
13363
  const errors = errorFindings(report.findings).length;
13415
- return `<section class="counts">
13416
- ${cell4(report.read.length, `read, of ${grouped(report.migrations)} in the module`)}
13417
- ${cell4(countedFindings(report.findings).length, errors === 0 ? "findings, all warnings" : "findings")}
13418
- ${errors === 0 ? "" : cell4(errors, "errors, from rules set to error", true)}
13419
- ${cell4(report.unread.length, "could not be opened", true)}
13420
- ${cell4(syntax, "do not parse", true)}
13421
- ${cell4(report.unsafe.files.length, "files with a raw SQL call")}
13422
- ${cell4(report.templates.files.length, "files with a SQL template")}
13423
- </section>`;
13364
+ const big = counted.length === 0 ? "No finding" : levelCounts(counted);
13365
+ const pill = errors > 0 ? `<span class="pill">fails the module's sql run</span>` : counted.length > 0 ? '<span class="pill soft">advisory</span>' : "";
13366
+ return `<div class="kpi${errors > 0 ? " band-watch" : ""}">
13367
+ <p class="label">Result</p>
13368
+ <p class="big">${escape(big)}</p>${pill ? `<p>${pill}</p>` : ""}
13369
+ <p class="quiet">${errors > 0 ? "A rule this module sets to <code>error</code> found something." : "Every rule is at its default level, a warning, unless this module says otherwise."}</p>
13370
+ </div>`;
13424
13371
  }
13425
- function offSection(report) {
13426
- if (report.read.length === 0 && report.unsafe.files.length === 0 || report.rulesOff.length === 0)
13427
- return "";
13428
- const names = report.rulesOff.map((rule) => `<code>${escape(rule)}</code>`).join(", ");
13429
- return `<section><p class="quiet">Turned off by this module, so not checked: ${names}.</p></section>`;
13430
- }
13431
- function unreadSection(report) {
13432
- if (report.unread.length === 0) return "";
13433
- const items = report.unread.map(({ file, reason }) => `<li><code>${escape(file)}</code>: ${escape(reason)}</li>`).join("\n");
13434
- return `<section class="alarm-box">
13435
- <h2>Could not be opened</h2>
13436
- <p>Nothing about these migrations is checked.</p>
13437
- <ul>${items}</ul>
13438
- </section>`;
13372
+ function readCard(report) {
13373
+ const parts = [
13374
+ report.read.length > 0 ? plural(report.read.length, "migration") : null,
13375
+ report.unsafe.read.length > 0 ? `${plural(report.unsafe.read.length, "file")} with raw SQL calls` : null,
13376
+ report.templates.templates > 0 ? plural(report.templates.templates, "SQL template") : null
13377
+ ].filter((part) => part !== null);
13378
+ const notRead = notReadCount(report);
13379
+ return `<div class="kpi${notRead > 0 ? " band-above" : ""}">
13380
+ <p class="label">Read in this branch</p>
13381
+ ${parts.length === 0 ? '<p class="big">Nothing</p><p class="quiet">This branch adds or changes no SQL.</p>' : `<ul class="read-list">${parts.map((part) => `<li>${escape(part)}</li>`).join("")}</ul>`}
13382
+ <p class="quiet">${notRead === 0 ? "Everything was read." : `${plural(notRead, "item")} could not be read: see the tabs.`}</p>
13383
+ </div>`;
13384
+ }
13385
+ function notReadCount(report) {
13386
+ return report.unread.length + unparsedMigrations(report.findings).length + report.unsafe.unparsed.length + report.templates.unread.length + report.templates.unparsed.length;
13387
+ }
13388
+ function toolsCard(report) {
13389
+ const counted = countedFindings(report.findings);
13390
+ const line = (who) => {
13391
+ const own = counted.filter(
13392
+ (finding3) => SENTINEL_RULES.includes(finding3.rule) === (who === "sentinel")
13393
+ );
13394
+ if (own.length === 0) return "";
13395
+ const inCode = own.filter((finding3) => !isMigration(finding3.file)).length;
13396
+ const inMigrations = own.length - inCode;
13397
+ const where = inMigrations === 0 ? "in SQL in code" : inCode === 0 ? "in migrations" : `${grouped(inCode)} in SQL in code, ${grouped(inMigrations)} in migrations`;
13398
+ return `<p><span class="who">${who}</span> <b>${grouped(own.length)}</b> <span class="quiet">${where}</span></p>`;
13399
+ };
13400
+ return `<div class="kpi">
13401
+ <p class="label">Found by</p>
13402
+ ${counted.length === 0 ? '<p class="big">&ndash;</p><p class="quiet">No rule found anything.</p>' : `${line("squawk")}${line("sentinel")}`}
13403
+ </div>`;
13404
+ }
13405
+ function codePanel(report, findings) {
13406
+ const readAny = report.unsafe.read.length > 0 || report.templates.read.length > 0;
13407
+ const empty = readAny ? "No finding in the SQL in code this branch adds or changes." : "This branch adds or changes no raw SQL call and no SQL template.";
13408
+ return `${unparsedBox(
13409
+ "These TypeScript files could not be read, so nothing in them is checked.",
13410
+ [...report.unsafe.unparsed, ...report.templates.unparsed]
13411
+ )}
13412
+ ${findingsTable("code", findings, empty)}
13413
+ <h2>What was read</h2>
13414
+ <div class="card">${unsafeLine(report)}${templatesLine(report)}</div>`;
13415
+ }
13416
+ function migrationsPanel(report, findings) {
13417
+ if (report.migrations === 0) return '<p class="empty">This module holds no migration.</p>';
13418
+ const empty = report.read.length === 0 ? "This branch adds or changes no migration." : "No finding in the migrations this branch adds or changes.";
13419
+ return `${unparsedBox(
13420
+ "These migrations could not be opened, so nothing about them is checked.",
13421
+ report.unread
13422
+ )}
13423
+ ${syntaxBox(report)}
13424
+ ${offLine(report)}
13425
+ ${findingsTable("migrations", findings, empty)}
13426
+ <h2>What was read</h2>
13427
+ <div class="card"><p>${report.read.length === 0 ? `None of the ${plural(report.migrations, "migration")} of the module is added or changed by this branch.` : `${plural(report.read.length, "migration")} this branch adds or changes, of ${grouped(report.migrations)} in the module:`}</p>${fileList(report.read)}</div>`;
13428
+ }
13429
+ function unparsedBox(lead, files) {
13430
+ if (files.length === 0) return "";
13431
+ return `<div class="alarm-box"><p><b>${escape(lead)}</b></p><ul>${files.map(({ file, reason }) => `<li><code>${escape(file)}</code>: ${escape(reason)}</li>`).join("")}</ul></div>`;
13439
13432
  }
13440
- function syntaxSection(report) {
13433
+ function syntaxBox(report) {
13441
13434
  const files = unparsedMigrations(report.findings);
13442
13435
  if (files.length === 0) return "";
13443
- return `<section class="alarm-box">
13444
- <h2>Migrations that do not parse</h2>
13445
- <p>squawk could not read the SQL, so no other rule checked it, and PostgreSQL will refuse it
13446
- too. The first error of each file is the one to fix; the ones after it follow from it.</p>
13447
- ${files.map(
13448
- ({ first, more }) => place2(first, more > 0 ? `${first.message} (and ${more} more after it)` : first.message)
13449
- ).join("\n")}
13450
- </section>`;
13436
+ return `<div class="alarm-box">
13437
+ <p><b>${plural(files.length, "migration does not parse", "migrations do not parse")}.</b> squawk could not read the SQL, so no other rule checked it, and PostgreSQL will refuse it too. The first error of each file is the one to fix; the ones after it follow from it.</p>
13438
+ ${files.map(({ first, more }) => {
13439
+ const message = more > 0 ? `${first.message} (and ${more} more after it)` : first.message;
13440
+ return `<p><code>${escape(placeOf(first))}</code> ${prose2(message)}</p>${excerptOf2(first)}`;
13441
+ }).join("")}
13442
+ </div>`;
13451
13443
  }
13452
- function findingsSection(report) {
13453
- const groups = byRule(report.findings);
13454
- if (groups.length === 0) {
13455
- const why = report.read.length === 0 ? "No migration was read, so there is nothing to find." : "squawk read every migration listed below and found nothing.";
13456
- return `<section><h2>Findings</h2><p class="quiet">${why}</p></section>`;
13457
- }
13458
- return `<section>
13459
- <h2>Findings, by rule</h2>
13460
- ${groups.map(ruleBlock).join("\n")}
13461
- </section>`;
13444
+ function offLine(report) {
13445
+ if (report.rulesOff.length === 0) return "";
13446
+ const names = report.rulesOff.map((rule) => `<code>${escape(rule)}</code>`).join(", ");
13447
+ return `<p class="quiet">Turned off by this module, so not checked: ${names}.</p>`;
13448
+ }
13449
+ function findingsTable(id, findings, empty) {
13450
+ if (findings.length === 0) return `<p class="empty">${escape(empty)}</p>`;
13451
+ const ordered = findingsByFile(findings).flatMap(([, inFile]) => inFile);
13452
+ const fullNoteShown = /* @__PURE__ */ new Set();
13453
+ const rows = ordered.map((finding3) => rowOf(finding3, fullNoteShown)).join("\n");
13454
+ return `${toolbar2(id, ordered)}
13455
+ <div class="scroll"><table class="ctable" id="${id}"><thead><tr>
13456
+ <th scope="col" data-sort="text"><span class="th">File</span></th>
13457
+ <th scope="col" class="n" data-sort="num"><span class="th">Line</span></th>
13458
+ <th scope="col" data-sort="text"><span class="th">Level</span></th>
13459
+ <th scope="col" data-sort="text"><span class="th">Rule</span></th>
13460
+ <th scope="col" data-sort="text"><span class="th">Problem</span></th>
13461
+ </tr></thead><tbody>
13462
+ ${rows}
13463
+ </tbody></table></div>
13464
+ <nav class="pager" data-table="${id}" aria-label="Pages"></nav>
13465
+ ${guide(id)}`;
13462
13466
  }
13463
- function ruleBlock({ rule, findings }) {
13464
- const [first] = findings;
13465
- if (first === void 0) return "";
13466
- const note = findings.find((finding3) => finding3.sentinelNote !== null)?.sentinelNote ?? null;
13467
- return `<article class="rule">
13468
- <div class="rule-head"><code class="name">${escape(rule)}</code>${first.level === "error" ? '<span class="level">error</span>' : ""}<span class="n">${grouped(findings.length)}</span></div>
13469
- <p class="squawk"><span class="who">${SENTINEL_RULES.includes(rule) ? "sentinel" : "squawk"}</span> ${prose2(first.message)}${first.help ? `. <b>Fix:</b> ${prose2(first.help)}` : ""}.</p>${note ? `
13470
- <div class="note">
13471
- <p><span class="who">sentinel</span> ${prose2(note.short)}</p>
13472
- <details><summary>The full note, and how it was proven</summary>
13473
- <p>${prose2(note.note)}</p>
13474
- <p class="source">${prose2(note.source)}</p>
13475
- </details>
13476
- </div>` : ""}
13477
- ${places(findings)}
13478
- </article>`;
13479
- }
13480
- var OPEN_PLACES = 5;
13481
- function places(findings) {
13482
- const said = findings[0]?.message;
13483
- const folded = findings.slice(OPEN_PLACES);
13484
- const more = folded.length === 0 ? "" : `<details class="more"><summary>${grouped(folded.length)} more place(s)</summary>${byFile(folded, said)}</details>`;
13485
- return `${byFile(findings.slice(0, OPEN_PLACES), said)}${more}`;
13486
- }
13487
- function byFile(findings, said) {
13488
- const files = /* @__PURE__ */ new Map();
13489
- for (const finding3 of findings) {
13490
- files.set(finding3.file, [...files.get(finding3.file) ?? [], finding3]);
13491
- }
13492
- return [...files].map(
13493
- ([file, list]) => `<p class="file"><code>${escape(file)}</code></p>${list.map(
13494
- (finding3) => place2(finding3, void 0, finding3.message === said ? void 0 : finding3.message)
13495
- ).join("")}`
13496
- ).join("");
13467
+ function toolbar2(id, findings) {
13468
+ const count = (tag) => findings.filter((finding3) => tagsOf(finding3).includes(tag)).length;
13469
+ const rules = [...new Set(findings.map((finding3) => finding3.rule))].sort(
13470
+ (a, b) => count(b) - count(a) || a.localeCompare(b)
13471
+ );
13472
+ const chips = [
13473
+ ["error", "error"],
13474
+ ["warn", "warning"],
13475
+ ["squawk", "squawk"],
13476
+ ["sentinel", "sentinel"],
13477
+ ...rules.map((rule) => [rule, rule])
13478
+ ];
13479
+ return `<div class="tools">
13480
+ <input type="search" data-table="${id}" placeholder="Search a file, a rule, a word&hellip;" aria-label="Search a file, a rule, a word" autocomplete="off">
13481
+ <button type="button" class="guide" popovertarget="guide-${id}">How to read this table</button>
13482
+ </div>
13483
+ <div class="chips" data-table="${id}">
13484
+ <button type="button" class="chip on" data-tag="">All <span>${grouped(findings.length)}</span></button>
13485
+ ${chips.filter(([tag]) => count(tag) > 0).map(
13486
+ ([tag, label]) => `<button type="button" class="chip" data-tag="${escape(tag)}">${escape(label)} <span>${grouped(count(tag))}</span></button>`
13487
+ ).join("\n ")}
13488
+ </div>`;
13497
13489
  }
13498
- function place2(finding3, message, own) {
13499
- const code = finding3.excerpt === null ? "" : `<pre><code>${escape(finding3.excerpt)}</code></pre>`;
13500
- const where = message === void 0 ? `line ${finding3.line}:${finding3.column}` + (own === void 0 ? "" : ` <span class="said">${prose2(own)}</span>`) : `<code>${escape(placeOf(finding3))}</code> <span class="said">${prose2(message)}</span>`;
13501
- return `<div class="place"><p class="where">${where}</p>${code}</div>`;
13490
+ function tagsOf(finding3) {
13491
+ return [
13492
+ finding3.level,
13493
+ SENTINEL_RULES.includes(finding3.rule) ? "sentinel" : "squawk",
13494
+ finding3.rule
13495
+ ];
13502
13496
  }
13503
- function prose2(text) {
13504
- return escape(text).replace(/`([^`]+)`/g, "<code>$1</code>");
13497
+ function rowOf(finding3, fullNoteShown) {
13498
+ const who = SENTINEL_RULES.includes(finding3.rule) ? "sentinel" : "squawk";
13499
+ const problem = problemOf(finding3);
13500
+ const find = `${finding3.file} ${finding3.rule} ${problem}`.toLowerCase();
13501
+ const level = finding3.level === "error" ? '<span class="level-error">error</span>' : "warning";
13502
+ const details = detailsOf(finding3, fullNoteShown);
13503
+ return `<tr data-find="${escape(find)}" data-tags="${escape(tagsOf(finding3).join(" "))}">${pathCell2(finding3.file)}<td class="n" data-v="${finding3.line}">${finding3.line}:${finding3.column}</td><td data-v="${finding3.level}">${level}</td><td data-v="${escape(finding3.rule)}"><code>${escape(finding3.rule)}</code></td><td data-v="${escape(problem)}"><span class="who">${who}</span> ${prose2(problem)}${details}</td></tr>`;
13505
13504
  }
13506
- function readSection(report) {
13507
- if (report.read.length === 0) return "";
13508
- return `<section>
13509
- <details><summary>The ${grouped(report.read.length)} migration(s) read</summary>
13510
- <ul>${report.read.map((file) => `<li><code>${escape(file)}</code></li>`).join("")}</ul>
13511
- </details>
13512
- </section>`;
13505
+ function pathCell2(path2) {
13506
+ const cut = path2.lastIndexOf("/");
13507
+ const dir = cut === -1 ? "" : path2.slice(0, cut + 1);
13508
+ const name = cut === -1 ? path2 : path2.slice(cut + 1);
13509
+ return `<th scope="row" data-v="${escape(path2)}"><span class="dir">${escape(dir)}</span><b>${escape(name)}</b></th>`;
13510
+ }
13511
+ function detailsOf(finding3, fullNoteShown) {
13512
+ const note = noteOf(finding3, fullNoteShown);
13513
+ const code = excerptOf2(finding3);
13514
+ if (note === "" && code === "") return "";
13515
+ return `<details class="sql"><summary>${note === "" ? "The SQL" : "The SQL, and sentinel\u2019s note"}</summary>${note}${code}</details>`;
13516
+ }
13517
+ function excerptOf2(finding3) {
13518
+ return finding3.excerpt === null ? "" : `<pre><code>${escape(finding3.excerpt)}</code></pre>`;
13519
+ }
13520
+ function noteOf(finding3, fullNoteShown) {
13521
+ const note = finding3.sentinelNote;
13522
+ if (note === null) return "";
13523
+ const full = !fullNoteShown.has(finding3.rule);
13524
+ fullNoteShown.add(finding3.rule);
13525
+ const proof = full ? `<p>${prose2(note.note)}</p><p class="source">${prose2(note.source)}</p>` : '<p class="quiet">The full note, and how it was proven, is at the first place of this rule.</p>';
13526
+ return `<div class="note"><p><span class="who">sentinel</span> ${prose2(note.short)}</p>${proof}</div>`;
13527
+ }
13528
+ function guide(id) {
13529
+ const what = id === "code" ? "Each row is a problem in a raw SQL call or a SQL template this branch adds or changes." : "Each row is a problem in a migration this branch adds or changes.";
13530
+ return `<div popover id="guide-${id}" class="pop wide"><b>How to read this table</b>
13531
+ <p>${what} The files with the most errors come first, then each file by line.</p>
13532
+ <p><b>Level</b>: a <b>warning</b> informs, an <b>error</b> is a rule this module set to <code>error</code>, and fails its <code>sql</code> run.</p>
13533
+ <p><b>Problem</b>: in the words of the tool that found it, <span class="who">squawk</span> or <span class="who">sentinel</span>. squawk's fix follows its problem; sentinel's rules give the problem alone. Open <b>The SQL</b> under a problem for the code it points at, and sentinel's note when it has one.</p>
13534
+ <p>Type in the box to find a file, a rule or a word, click a tag to filter, a column title to sort.</p>
13535
+ </div>`;
13513
13536
  }
13514
- function unsafeSection(report) {
13515
- const { files, read: read2, unparsed } = report.unsafe;
13537
+ function unsafeLine(report) {
13538
+ const { files, read: read2 } = report.unsafe;
13516
13539
  const methods = "raw SQL (<code>$queryRawUnsafe</code> / <code>$executeRawUnsafe</code>, <code>pg</code>, <code>postgres</code>, <code>Prisma.raw</code>, <code>Prisma.join</code>)";
13517
- const checked = checkedCalls(report.unsafe, report.rulesOff, {
13518
- count: grouped,
13519
- name: (name) => `<code>${escape(name)}</code>`
13520
- });
13521
- const lead = files.length === 0 ? `No ${methods} call in ${grouped(report.unsafe.codeFiles)} TypeScript file(s).` : read2.length === 0 ? `${grouped(files.length)} file(s) call ${methods}; none is added or changed by this branch, so none is read.` : `${checked} checked in the ${grouped(read2.length)} file(s) this branch adds or changes, out of ${grouped(files.length)} calling them. Their findings are under <code>unsafe-sql-pasted-value</code> and <code>unsafe-sql-raw-fragment</code> above.`;
13522
- const list = read2.length === 0 ? "" : `<ul>${read2.map((file) => `<li><code>${escape(file)}</code></li>`).join("")}</ul>`;
13523
- const broken = unparsed.length === 0 ? "" : `<div class="alarm-box"><h2>Could not be read</h2><p>Nothing in these files is checked.</p><ul>${unparsed.map(({ file, reason }) => `<li><code>${escape(file)}</code>: ${escape(reason)}</li>`).join("")}</ul></div>`;
13524
- return `<section><h2>Raw SQL in code</h2><p>${lead}</p>${list}${broken}${templatesBlock(report)}</section>`;
13540
+ if (files.length === 0) return `<p><b>Raw SQL calls.</b> No ${methods} call in the module.</p>`;
13541
+ if (read2.length === 0) {
13542
+ return `<p><b>Raw SQL calls.</b> ${plural(files.length, "file")} of the module call ${methods}; none is added or changed by this branch, so none is read.</p>`;
13543
+ }
13544
+ return `<p><b>Raw SQL calls.</b> ${checkedLead(report)} in the ${plural(read2.length, "file")} this branch adds or changes, out of ${grouped(files.length)} calling them. ${whereFound(report)}</p>${fileList(read2)}`;
13525
13545
  }
13526
- function templatesBlock(report) {
13527
- const { files, read: read2, templates, parsed: parsed2, unread, unparsed } = report.templates;
13528
- if (files.length === 0) return "";
13546
+ function checkedLead(report) {
13547
+ const { calls, rawCalls } = report.unsafe;
13548
+ const kinds = [
13549
+ ...report.rulesOff.includes(UNSAFE_RULE) || calls === 0 ? [] : [`${plural(calls, "call")} taking SQL text`],
13550
+ ...report.rulesOff.includes(RAW_FRAGMENT_RULE) || rawCalls === 0 ? [] : [plural(rawCalls, "Prisma fragment")]
13551
+ ];
13552
+ return kinds.length === 0 ? "No call taking SQL text checked" : `${kinds.join(" and ")} checked`;
13553
+ }
13554
+ function whereFound(report) {
13555
+ const rules = [UNSAFE_RULE, RAW_FRAGMENT_RULE].filter(
13556
+ (rule) => report.findings.some((finding3) => finding3.rule === rule)
13557
+ );
13558
+ if (rules.length === 0) return "No finding in them.";
13559
+ return `Their findings are in the table above, under ${rules.map((rule) => `<code>${rule}</code>`).join(" and ")}.`;
13560
+ }
13561
+ function templatesLine(report) {
13562
+ const { files, read: read2, templates, parsed: parsed2, unread } = report.templates;
13529
13563
  const tags = "<code>$queryRaw</code>, <code>$executeRaw</code>, <code>Prisma.sql</code>";
13564
+ if (files.length === 0) return `<p><b>SQL templates.</b> No ${tags} template in the module.</p>`;
13530
13565
  if (read2.length === 0) {
13531
- return `<p>${grouped(files.length)} file(s) hold SQL templates (${tags}); none is added or changed by this branch, so none is read.</p>`;
13566
+ return `<p><b>SQL templates.</b> ${plural(files.length, "file")} of the module ${files.length === 1 ? "holds" : "hold"} SQL templates (${tags}); none is added or changed by this branch, so none is read.</p>`;
13532
13567
  }
13533
- const lead = `<p>${grouped(parsed2)} of the ${grouped(templates)} SQL template(s) (${tags}) read by PostgreSQL's parser, in the ${grouped(read2.length)} file(s) this branch adds or changes.</p>`;
13534
- const notRead = [
13535
- ...unread.map(
13536
- ({ file, line, reason }) => `<li><code>${escape(`${file}:${line}`)}</code>: ${escape(reason)}</li>`
13537
- ),
13538
- ...unparsed.map(
13539
- ({ file, reason }) => `<li><code>${escape(file)}</code>: ${escape(reason)}</li>`
13540
- )
13541
- ];
13542
- return notRead.length === 0 ? lead : `${lead}<details><summary>${grouped(notRead.length)} not read alone, so no rule checked them</summary><ul>${notRead.join("")}</ul></details>`;
13568
+ const lead = `<p><b>SQL templates.</b> ${grouped(parsed2)} of the ${plural(templates, "SQL template")} (${tags}) in the ${plural(read2.length, "file")} this branch adds or changes read by PostgreSQL's parser.</p>`;
13569
+ const notRead = unread.map(
13570
+ ({ file, line, reason }) => `<li><code>${escape(`${file}:${line}`)}</code>: ${escape(reason)}</li>`
13571
+ );
13572
+ return notRead.length === 0 ? `${lead}${fileList(read2)}` : `${lead}<details><summary>${grouped(notRead.length)} not read alone, so no rule checked them</summary><ul>${notRead.join("")}</ul></details>${fileList(read2)}`;
13573
+ }
13574
+ function fileList(files) {
13575
+ if (files.length === 0) return "";
13576
+ return `<details><summary>${files.length === 1 ? "The file" : `The ${grouped(files.length)} files`}</summary><ul>${files.map((file) => `<li><code>${escape(file)}</code></li>`).join("")}</ul></details>`;
13543
13577
  }
13544
- function settingsSection(report) {
13545
- const rows = report.settings.map(
13546
- (setting) => `<tr><th scope="row"><code>${escape(setting.key)}</code></th><td><code>${escape(setting.value)}</code></td><td>${setting.moved ? '<span class="moved">overridden by this module</span>' : '<span class="quiet">the role&rsquo;s value</span>'}</td></tr>`
13578
+ function settingsPanel2(report) {
13579
+ const rows = report.settings.filter((setting) => setting.key !== "sentinel").map(
13580
+ (setting) => `<tr><th scope="row"><code>${escape(setting.key)}</code></th><td><code>${escape(setting.value)}</code></td><td>${setting.moved ? '<span class="moved">set by this module</span>' : '<span class="quiet">the role&rsquo;s value</span>'}</td></tr>`
13547
13581
  ).join("\n");
13548
- return `<section><details><summary>Settings this run used</summary>
13549
- <table>${rows}</table>
13550
- </details></section>`;
13582
+ return `<h2>Settings this run used</h2>
13583
+ <table class="settings"><thead><tr><th scope="col">Setting</th><th scope="col">Value</th><th scope="col">From</th></tr></thead><tbody>
13584
+ ${rows}
13585
+ </tbody></table>
13586
+ <p class="quiet">A module moves a setting in <code>sql.config.mjs</code>; the page then marks it, because two modules measured differently no longer compare.</p>`;
13587
+ }
13588
+ function prose2(text) {
13589
+ return escape(text).replace(/`([^`]+)`/g, "<code>$1</code>");
13551
13590
  }
13552
13591
  var STYLES4 = `
13553
- :root {
13554
- color-scheme: light dark;
13555
- --page: #faf7f1; --surface: #ffffff; --ink: #23091c; --ink-soft: #4a3344; --label: #6f5a67;
13556
- --rule: #e1dcd0; --brand: #491b3c; --brand-bg: #f3e9ee; --moved: #a3341f; --over: #a3341f;
13557
- --note: #fdf6ee; --radius: 10px;
13558
- }
13559
- @media (prefers-color-scheme: dark) {
13560
- :root {
13561
- --page: #23091c; --surface: #2f1128; --ink: #faf7f1; --ink-soft: #d8c6d1; --label: #b298ab;
13562
- --rule: #45253d; --brand: #ffab93; --brand-bg: #3a1830; --moved: #ef8f78; --over: #ef8f78;
13563
- --note: #2f1128;
13564
- }
13565
- }
13566
- * { box-sizing: border-box; }
13567
- body { margin: 0; background: var(--page); color: var(--ink);
13568
- font: 15px/1.6 'Brand Sans', Inter, ui-sans-serif, system-ui, sans-serif; }
13569
- main { max-width: 960px; margin: 0 auto; padding: 32px 16px 48px; }
13570
- code, pre { font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
13571
- .eyebrow { margin: 0; color: var(--label); text-transform: uppercase; letter-spacing: .08em; font-size: 12px; }
13572
- h1 { margin: 4px 0; font-size: 26px; overflow-wrap: anywhere; }
13573
- h2 { font-size: 18px; margin: 0 0 12px; }
13574
- .meta { margin: 0; color: var(--label); overflow-wrap: anywhere; }
13575
- section { margin-top: 24px; }
13576
- .counts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
13577
- .count { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 12px 14px; }
13578
- .count b { display: block; font-size: 22px; }
13579
- .count span { color: var(--label); font-size: 13px; }
13580
- .count.alarm { border-color: var(--over); }
13581
- .count.alarm b { color: var(--over); }
13582
- .alarm-box { border: 1px solid var(--over); border-radius: var(--radius); padding: 14px 16px; background: var(--surface); }
13583
- .alarm-box h2 { color: var(--over); }
13584
- .rule { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; }
13585
- .rule-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
13586
- .rule-head .name { font-size: 15px; font-weight: 600; color: var(--brand); overflow-wrap: anywhere; }
13587
- .rule-head .n { color: var(--label); }
13588
- .rule-head .level { color: var(--over); font-weight: 600; margin-right: auto; margin-left: 8px; }
13589
- .who { display: inline-block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
13590
- padding: 1px 6px; border-radius: 4px; background: var(--brand-bg); color: var(--brand); margin-right: 6px; }
13591
- .squawk { color: var(--ink-soft); }
13592
- .note { background: var(--note); border-radius: 8px; padding: 8px 12px; margin: 8px 0; }
13593
- .note p { margin: 4px 0; }
13594
- .source { color: var(--label); font-size: 13px; }
13595
- details summary { cursor: pointer; color: var(--brand); }
13596
- .place { border-top: 1px solid var(--rule); padding-top: 8px; margin-top: 8px; }
13597
- .where { margin: 0 0 4px; overflow-wrap: anywhere; color: var(--label); font-size: 13px; }
13598
- .file { margin: 12px 0 0; overflow-wrap: anywhere; font-weight: 600; }
13599
- .more { margin-top: 10px; }
13600
- .said { color: var(--ink-soft); }
13601
- pre { margin: 0; padding: 8px 10px; background: var(--page); border-radius: 6px; overflow-x: auto; }
13602
- .quiet { color: var(--label); }
13603
- .moved { color: var(--moved); }
13604
- table { border-collapse: collapse; width: 100%; margin-top: 8px; }
13605
- th, td { text-align: left; padding: 6px 8px; border-top: 1px solid var(--rule); vertical-align: top; overflow-wrap: anywhere; }
13606
- ul { padding-left: 20px; }
13607
- footer { margin-top: 32px; color: var(--label); font-size: 13px; }
13592
+ #tab-code:checked ~ #panel-code, #tab-migrations:checked ~ #panel-migrations,
13593
+ #tab-settings:checked ~ #panel-settings { display: block; }
13594
+ .pill.soft { background: var(--brand-bg); color: var(--brand); }
13595
+ .read-list { margin: 0.2rem 0 0.4rem; padding-left: 1.1rem; font-size: 0.95rem; }
13596
+ .who { display: inline-block; font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.06em;
13597
+ padding: 0 0.4rem; border-radius: 4px; background: var(--brand-bg); color: var(--brand); margin-right: 0.3rem; }
13598
+ .level-error { color: var(--over); font-weight: 600; }
13599
+ .alarm-box { border: 1px solid var(--over); border-radius: var(--radius); padding: 0.6rem 1rem; margin-bottom: 1rem; background: var(--surface); }
13600
+ .alarm-box b { color: var(--over); }
13601
+ details.sql { margin-top: 0.3rem; }
13602
+ details.sql summary, .card details summary { cursor: pointer; color: var(--brand); font-size: 0.8rem; }
13603
+ .note { background: var(--note); border-left: 3px solid var(--brand); border-radius: 4px; padding: 0.3rem 0.7rem; margin: 0.4rem 0; }
13604
+ .note p { margin: 0.25rem 0; }
13605
+ .source { color: var(--label); font-size: 0.8rem; }
13606
+ pre { margin: 0.4rem 0 0; padding: 0.5rem 0.7rem; background: var(--page); border-radius: 6px; overflow-x: auto; }
13607
+ td { min-width: 5rem; }
13608
+ td:nth-child(4) code { white-space: nowrap; }
13609
+ td:last-child { min-width: 24rem; }
13608
13610
  `;
13609
13611
 
13610
13612
  // src/roles/sql/report/render-json.ts
@@ -13642,7 +13644,7 @@ function renderMarkdown5(report) {
13642
13644
  ...unreadBlock(report),
13643
13645
  ...syntaxBlock(report),
13644
13646
  ...unsafeBlock(report),
13645
- ...templatesLine(report),
13647
+ ...templatesLine2(report),
13646
13648
  ...fileBlocks(report),
13647
13649
  "",
13648
13650
  `<sub>Every place, with the SQL behind it and sentinel's notes, is in the \`sql.html\` this run keeps. Measured by sentinel ${report.sentinel}.</sub>`,
@@ -13658,15 +13660,15 @@ function headline3(report) {
13658
13660
  if (migrations === 0 && files === 0 && templates === 0) {
13659
13661
  return `No migration or raw SQL call added or changed by this branch, ${against}: nothing to check.`;
13660
13662
  }
13661
- const counts2 = (count, what, noun) => `**${count}** ${what} ${noun}${count === 1 ? "" : "s"}`;
13663
+ const counts = (count, what, noun) => `**${count}** ${what} ${noun}${count === 1 ? "" : "s"}`;
13662
13664
  const calls = [
13663
- ...report.rulesOff.includes(UNSAFE_RULE) || report.unsafe.calls === 0 ? [] : [counts2(report.unsafe.calls, "raw SQL", "call")],
13664
- ...report.rulesOff.includes(RAW_FRAGMENT_RULE) || report.unsafe.rawCalls === 0 ? [] : [counts2(report.unsafe.rawCalls, "Prisma", "fragment")]
13665
+ ...report.rulesOff.includes(UNSAFE_RULE) || report.unsafe.calls === 0 ? [] : [counts(report.unsafe.calls, "raw SQL", "call")],
13666
+ ...report.rulesOff.includes(RAW_FRAGMENT_RULE) || report.unsafe.rawCalls === 0 ? [] : [counts(report.unsafe.rawCalls, "Prisma", "fragment")]
13665
13667
  ];
13666
13668
  const items = [
13667
13669
  ...migrations > 0 ? [`**${migrations}** migration${migrations === 1 ? "" : "s"}`] : [],
13668
13670
  ...files > 0 ? calls : [],
13669
- ...templates > 0 ? [counts2(templates, "SQL", "template")] : []
13671
+ ...templates > 0 ? [counts(templates, "SQL", "template")] : []
13670
13672
  ];
13671
13673
  const codeFiles2 = (/* @__PURE__ */ new Set([...report.unsafe.read, ...report.templates.read])).size;
13672
13674
  const where = codeFiles2 > 0 ? ` in ${codeFiles2} file${codeFiles2 === 1 ? "" : "s"}` : "";
@@ -13691,7 +13693,7 @@ function fileBlocks(report) {
13691
13693
  }
13692
13694
  const lines = [];
13693
13695
  let left = ROWS_PER_MODULE;
13694
- for (const [file, inFile] of byFile2(findings)) {
13696
+ for (const [file, inFile] of findingsByFile(findings)) {
13695
13697
  if (left === 0) break;
13696
13698
  const shown = inFile.slice(0, left);
13697
13699
  left -= shown.length;
@@ -13701,7 +13703,7 @@ function fileBlocks(report) {
13701
13703
  "",
13702
13704
  "| Line | Level | Rule | Problem |",
13703
13705
  "| ---: | --- | --- | --- |",
13704
- ...shown.map(rowOf)
13706
+ ...shown.map(rowOf2)
13705
13707
  );
13706
13708
  }
13707
13709
  const more = findings.length - ROWS_PER_MODULE;
@@ -13709,42 +13711,9 @@ function fileBlocks(report) {
13709
13711
  lines.push("", `**${more} more**, with every other place, in the \`sql.html\` this run keeps.`);
13710
13712
  return lines;
13711
13713
  }
13712
- function byFile2(findings) {
13713
- const groups = /* @__PURE__ */ new Map();
13714
- for (const finding3 of findings)
13715
- groups.set(finding3.file, [...groups.get(finding3.file) ?? [], finding3]);
13716
- const errors = (list) => list.filter((finding3) => finding3.level === "error").length;
13717
- return [...groups].map(([file, list]) => [
13718
- file,
13719
- // By line; on one line, a finding at `error` first, since it is what the module refuses.
13720
- [...list].sort(
13721
- (a, b) => a.line - b.line || Number(b.level === "error") - Number(a.level === "error") || a.column - b.column || a.rule.localeCompare(b.rule)
13722
- )
13723
- ]).sort(
13724
- ([fileA, a], [fileB, b]) => errors(b) - errors(a) || b.length - a.length || fileA.localeCompare(fileB)
13725
- );
13726
- }
13727
- function levelCounts(findings) {
13728
- const errors = findings.filter((finding3) => finding3.level === "error").length;
13729
- const warnings = findings.length - errors;
13730
- const plural = (count, noun) => `${count} ${noun}${count === 1 ? "" : "s"}`;
13731
- return [
13732
- ...errors > 0 ? [plural(errors, "error")] : [],
13733
- ...warnings > 0 ? [plural(warnings, "warning")] : []
13734
- ].join(", ");
13735
- }
13736
- function rowOf(finding3) {
13737
- const own = SENTINEL_RULES.includes(finding3.rule);
13738
- const problem = sentence(finding3.message) + (!own && finding3.help ? ` Fix: ${endOf(finding3.help)}` : "");
13714
+ function rowOf2(finding3) {
13739
13715
  const level = finding3.level === "error" ? "\u2717 error" : "warn";
13740
- return `| ${finding3.line} | ${level} | \`${finding3.rule}\` | ${cell3(problem)} |`;
13741
- }
13742
- function sentence(text) {
13743
- const ended = endOf(text);
13744
- return `${ended.charAt(0).toUpperCase()}${ended.slice(1)}`;
13745
- }
13746
- function endOf(text) {
13747
- return `${text.trim().replace(/\.+$/, "")}.`;
13716
+ return `| ${finding3.line} | ${level} | \`${finding3.rule}\` | ${cell3(problemOf(finding3))} |`;
13748
13717
  }
13749
13718
  function cell3(text) {
13750
13719
  return text.replace(/\|/g, "\\|").replace(/\s*\n\s*/g, " ");
@@ -13776,7 +13745,7 @@ function syntaxBlock(report) {
13776
13745
  )
13777
13746
  ];
13778
13747
  }
13779
- function templatesLine(report) {
13748
+ function templatesLine2(report) {
13780
13749
  const { read: read2, templates, parsed: parsed2, unread, unparsed } = report.templates;
13781
13750
  if (read2.length === 0) return [];
13782
13751
  const missed = [
@@ -13973,7 +13942,7 @@ function migrationsInNested(cwd, settings = defaults3, nested = adoptedInnerDirs
13973
13942
  }
13974
13943
  const root = resolve4(cwd);
13975
13944
  const owner = /* @__PURE__ */ new Map();
13976
- const counts2 = /* @__PURE__ */ new Map();
13945
+ const counts = /* @__PURE__ */ new Map();
13977
13946
  for (const file of migrationFiles(cwd, settings, nested)) {
13978
13947
  const folder = dirname8(join43(root, file));
13979
13948
  if (!owner.has(folder)) {
@@ -13984,9 +13953,9 @@ function migrationsInNested(cwd, settings = defaults3, nested = adoptedInnerDirs
13984
13953
  );
13985
13954
  }
13986
13955
  const dir = owner.get(folder);
13987
- if (dir !== void 0 && dir !== "") counts2.set(dir, (counts2.get(dir) ?? 0) + 1);
13956
+ if (dir !== void 0 && dir !== "") counts.set(dir, (counts.get(dir) ?? 0) + 1);
13988
13957
  }
13989
- for (const [dir, count] of counts2) out.push({ dir, count, adopted: false });
13958
+ for (const [dir, count] of counts) out.push({ dir, count, adopted: false });
13990
13959
  return out.sort((a, b) => a.dir.localeCompare(b.dir));
13991
13960
  }
13992
13961
 
@@ -13995,21 +13964,25 @@ import { readdirSync as readdirSync5, readFileSync as readFileSync23 } from "nod
13995
13964
  import { join as join44 } from "node:path";
13996
13965
  var TRIGRAM_CLASSES = /* @__PURE__ */ new Set(["gin_trgm_ops", "gist_trgm_ops"]);
13997
13966
  function trigramContext(cwd, own, indexesFrom) {
13998
- let indexes;
13999
- return {
14000
- indexesFrom,
14001
- trigramIndexes: () => {
14002
- indexes ??= trigramIndexesOf([
14003
- ...own.flatMap((file) => readable(cwd, file)),
14004
- ...indexesFrom.flatMap(
14005
- (folder) => migrationsIn(join44(cwd, folder)).flatMap(
14006
- (name) => readable(cwd, `${folder}/${name}/migration.sql`)
14007
- )
14008
- )
14009
- ]);
14010
- return indexes;
14011
- }
13967
+ let loaded2;
13968
+ const once = () => {
13969
+ loaded2 ??= readIndexes(cwd, own, indexesFrom);
13970
+ return loaded2;
14012
13971
  };
13972
+ return { trigramIndexes: () => once().indexes, indexesFrom: () => once().folders };
13973
+ }
13974
+ function readIndexes(cwd, own, indexesFrom) {
13975
+ const read2 = [];
13976
+ const empty = [];
13977
+ const shared = indexesFrom.flatMap((folder) => {
13978
+ const migrations = migrationsIn(join44(cwd, folder)).flatMap(
13979
+ (name) => migrationText(cwd, `${folder}/${name}/migration.sql`)
13980
+ );
13981
+ (migrations.length > 0 ? read2 : empty).push(folder);
13982
+ return migrations;
13983
+ });
13984
+ const ownMigrations = own.flatMap((file) => migrationText(cwd, file));
13985
+ return { indexes: trigramIndexesOf([...ownMigrations, ...shared]), folders: { read: read2, empty } };
14013
13986
  }
14014
13987
  function migrationsIn(directory) {
14015
13988
  try {
@@ -14018,7 +13991,7 @@ function migrationsIn(directory) {
14018
13991
  return [];
14019
13992
  }
14020
13993
  }
14021
- function readable(cwd, file) {
13994
+ function migrationText(cwd, file) {
14022
13995
  try {
14023
13996
  return [{ file, text: readFileSync23(join44(cwd, file), "utf8") }];
14024
13997
  } catch {
@@ -14055,15 +14028,13 @@ function indexesOf(index, file) {
14055
14028
  });
14056
14029
  }
14057
14030
  function isTrigram(element) {
14058
- const classes = element.opclass ?? [];
14059
- const name = bodyOf(classes.at(-1), "String")?.sval;
14060
- return typeof name === "string" && TRIGRAM_CLASSES.has(name);
14031
+ const name = lastName(element.opclass);
14032
+ return name !== void 0 && TRIGRAM_CLASSES.has(name);
14061
14033
  }
14062
14034
  function withoutDropped(indexes, drop) {
14063
14035
  const names = (drop.objects ?? []).flatMap((object) => {
14064
- const items = bodyOf(object, "List")?.items ?? [];
14065
- const last = bodyOf(items.at(-1), "String")?.sval;
14066
- return typeof last === "string" ? [last] : [];
14036
+ const last = lastName(bodyOf(object, "List")?.items);
14037
+ return last === void 0 ? [] : [last];
14067
14038
  });
14068
14039
  if (drop.removeType === "OBJECT_INDEX")
14069
14040
  return indexes.filter((index) => !names.includes(index.name ?? ""));
@@ -14221,14 +14192,14 @@ var BATCH_FILES = 200;
14221
14192
  var BATCH_CHARACTERS = 2e4;
14222
14193
  var OUTPUT_BUFFER = 64 * 1024 * 1024;
14223
14194
  function runSquawk(invocation, files) {
14224
- const { readable: readable2, unread } = openable(invocation.cwd, files);
14225
- const statements = statementsOf(invocation, readable2);
14195
+ const { readable, unread } = openable(invocation.cwd, files);
14196
+ const statements = statementsOf(invocation, readable);
14226
14197
  const wrapped = (file) => (statements.get(file)?.count ?? 0) > 1;
14227
14198
  const quietNesting = (file) => !invocation.reportNesting && statements.get(file)?.ownTransaction === "paired";
14228
14199
  const findings = [];
14229
14200
  for (const [list, inTransaction] of [
14230
- [readable2.filter((file) => !wrapped(file)), false],
14231
- [readable2.filter(wrapped), true]
14201
+ [readable.filter((file) => !wrapped(file)), false],
14202
+ [readable.filter(wrapped), true]
14232
14203
  ]) {
14233
14204
  for (const batch of batches(list)) {
14234
14205
  const reading = runBatch(invocation, batch, inTransaction);
@@ -14240,18 +14211,18 @@ function runSquawk(invocation, files) {
14240
14211
  );
14241
14212
  }
14242
14213
  }
14243
- const quietTimeouts = quietTimeoutFiles(invocation, readable2, statements, wrapped);
14214
+ const quietTimeouts = quietTimeoutFiles(invocation, readable, statements, wrapped);
14244
14215
  const kept = findings.filter(
14245
14216
  (finding3) => !(TIMEOUTS.has(finding3.rule) && quietTimeouts.has(finding3.file))
14246
14217
  );
14247
- const order = new Map(readable2.map((file, index) => [file, index]));
14218
+ const order = new Map(readable.map((file, index) => [file, index]));
14248
14219
  kept.sort((a, b) => (order.get(a.file) ?? 0) - (order.get(b.file) ?? 0));
14249
14220
  const statementCounts = new Map([...statements].map(([file, read2]) => [file, read2.count]));
14250
14221
  return { ok: true, findings: kept, unread, statementCounts };
14251
14222
  }
14252
- function quietTimeoutFiles(invocation, readable2, statements, wrapped) {
14223
+ function quietTimeoutFiles(invocation, readable, statements, wrapped) {
14253
14224
  const texts = /* @__PURE__ */ new Map();
14254
- for (const file of readable2) {
14225
+ for (const file of readable) {
14255
14226
  const read2 = statements.get(file);
14256
14227
  if (read2 === void 0 || !wrapped(file)) continue;
14257
14228
  const text = readText(invocation.cwd, file);
@@ -14287,7 +14258,7 @@ function readText(cwd, file) {
14287
14258
  }
14288
14259
  }
14289
14260
  function statementsOf(invocation, files) {
14290
- const counts2 = /* @__PURE__ */ new Map();
14261
+ const counts = /* @__PURE__ */ new Map();
14291
14262
  const plan3 = batches(files);
14292
14263
  const budget = plan3.length + CUT_BUDGET;
14293
14264
  let starts = 0;
@@ -14309,7 +14280,7 @@ function statementsOf(invocation, files) {
14309
14280
  const types = stmts.map((stmt) => stmt?.type);
14310
14281
  if (!types.every((type) => typeof type === "string")) return;
14311
14282
  const real = types.filter((type) => type !== "EMPTY_STMT");
14312
- counts2.set(file, { count: real.length, ownTransaction: ownTransaction(real), types: real });
14283
+ counts.set(file, { count: real.length, ownTransaction: ownTransaction(real), types: real });
14313
14284
  });
14314
14285
  return "read";
14315
14286
  };
@@ -14324,7 +14295,7 @@ function statementsOf(invocation, files) {
14324
14295
  read2(batch.slice(half));
14325
14296
  };
14326
14297
  for (const batch of plan3) read2(batch);
14327
- return known ? counts2 : /* @__PURE__ */ new Map();
14298
+ return known ? counts : /* @__PURE__ */ new Map();
14328
14299
  }
14329
14300
  var CUT_BUDGET = 64;
14330
14301
  function jsonObjects(text) {
@@ -14358,18 +14329,18 @@ function jsonObjects(text) {
14358
14329
  return depth === 0 ? objects : void 0;
14359
14330
  }
14360
14331
  function openable(cwd, files) {
14361
- const readable2 = [];
14332
+ const readable = [];
14362
14333
  const unread = [];
14363
14334
  const utf8 = new TextDecoder("utf-8", { fatal: true });
14364
14335
  for (const file of files) {
14365
14336
  try {
14366
14337
  utf8.decode(readFileSync24(join46(cwd, file)));
14367
- readable2.push(file);
14338
+ readable.push(file);
14368
14339
  } catch (error) {
14369
14340
  unread.push({ file, reason: unreadReason(error) });
14370
14341
  }
14371
14342
  }
14372
- return { readable: readable2, unread };
14343
+ return { readable, unread };
14373
14344
  }
14374
14345
  function unreadReason(error) {
14375
14346
  const code = error?.code;
@@ -14451,6 +14422,138 @@ function onlyWhatWasAsked(findings, batch) {
14451
14422
  };
14452
14423
  }
14453
14424
 
14425
+ // src/roles/sql/adapters/squawk/summary.ts
14426
+ var PLAIN = { count: String, name: (name) => name };
14427
+ function checkedCalls({ calls, rawCalls }, rulesOff2, mark = PLAIN) {
14428
+ const methods = !rulesOff2.includes(UNSAFE_RULE);
14429
+ const raw = !rulesOff2.includes(RAW_FRAGMENT_RULE);
14430
+ const text = `${mark.count(calls)} call(s) taking SQL text (${mark.name("$queryRawUnsafe")} / ${mark.name("$executeRawUnsafe")}, ${mark.name("pg")}, ${mark.name("postgres")})`;
14431
+ const fragments = `${mark.count(rawCalls)} Prisma fragment(s) (${mark.name("Prisma.raw")}, ${mark.name("Prisma.join")})`;
14432
+ if (methods && raw) return `${text} and ${fragments}`;
14433
+ return methods ? text : fragments;
14434
+ }
14435
+ var CALLED = "raw SQL ($queryRawUnsafe / $executeRawUnsafe, pg, postgres, Prisma.raw, Prisma.join)";
14436
+ function summariseMigrations(outcome) {
14437
+ return [
14438
+ whatWasRead(outcome),
14439
+ ...codeReadLines(outcome),
14440
+ ...templateLines(outcome.templates),
14441
+ ...offLines(outcome),
14442
+ ...unreadLines(outcome.unread),
14443
+ ...unparsedLines(outcome.code.unparsed),
14444
+ ...syntaxErrorLines(outcome.findings),
14445
+ ...findingLines(outcome.findings)
14446
+ ];
14447
+ }
14448
+ function whatWasRead({ total, read: read2, base }) {
14449
+ if (total === 0 || base === null) return "no migration in this module.";
14450
+ const against = `compared with ${base.ref} at ${base.commit}`;
14451
+ if (read2 === 0) {
14452
+ return `no migration added or changed by this branch, ${against}. The ${total} in this module are not read: only what a branch introduces is.`;
14453
+ }
14454
+ const others = total - read2;
14455
+ return `read ${read2} migration(s) this branch adds or changes, ${against}.` + (others > 0 ? ` The ${others} other(s) in this module are unchanged and not read.` : "");
14456
+ }
14457
+ function offLines({ read: read2, rulesOff: rulesOff2, code }) {
14458
+ if (read2 === 0 && code.files === 0 || rulesOff2.length === 0) return [];
14459
+ return [
14460
+ `this module turns off ${rulesOff2.length} rule(s) in sql.config.mjs, so they are not checked: ${rulesOff2.join(", ")}.`
14461
+ ];
14462
+ }
14463
+ function codeReadLines({ code, rulesOff: rulesOff2 }) {
14464
+ if (code.files === 0) return [];
14465
+ if (rulesOff2.includes(UNSAFE_RULE) && rulesOff2.includes(RAW_FRAGMENT_RULE)) return [];
14466
+ if (code.read === 0) {
14467
+ return [
14468
+ `${code.files} file(s) call ${CALLED}; none is added or changed by this branch, so none is read.`
14469
+ ];
14470
+ }
14471
+ const others = code.files - code.read;
14472
+ return [
14473
+ `checked ${checkedCalls(code, rulesOff2)} in the ${code.read} file(s) this branch adds or changes.` + (others > 0 ? ` The ${others} other file(s) calling them are unchanged and not read.` : "")
14474
+ ];
14475
+ }
14476
+ var TEMPLATE_PLACES = 3;
14477
+ var TEMPLATE_TAGS = "$queryRaw, $executeRaw, Prisma.sql";
14478
+ function templateLines(templates) {
14479
+ if (templates.files === 0) return [];
14480
+ if (templates.read === 0) {
14481
+ return [
14482
+ `${templates.files} file(s) hold SQL templates (${TEMPLATE_TAGS}); none is added or changed by this branch, so none is read.`
14483
+ ];
14484
+ }
14485
+ const unread = templates.unread.length;
14486
+ return [
14487
+ `read ${templates.parsed} of the ${templates.templates} SQL template(s) (${TEMPLATE_TAGS}) in the ${templates.read} file(s) this branch adds or changes` + (unread === 0 ? "." : `; ${unread} could not be read alone by PostgreSQL's parser, so no rule checked them:`),
14488
+ ...templates.unread.slice(0, TEMPLATE_PLACES).map(({ file, line }) => ` ${file}:${line}`),
14489
+ ...unread > TEMPLATE_PLACES ? [` and ${unread - TEMPLATE_PLACES} more: pnpm run sql:html lists them all`] : [],
14490
+ ...templates.unparsed.map(({ file, reason }) => ` ${file}: ${reason}`)
14491
+ ];
14492
+ }
14493
+ function unparsedLines(unparsed) {
14494
+ if (unparsed.length === 0) return [];
14495
+ return [
14496
+ `\u2717 ${unparsed.length} TypeScript file(s) could not be read, so their calls are not checked:`,
14497
+ ...unparsed.map(({ file, reason }) => ` ${file}: ${reason}`)
14498
+ ];
14499
+ }
14500
+ function unreadLines(unread) {
14501
+ if (unread.length === 0) return [];
14502
+ return [
14503
+ `\u2717 ${unread.length} migration(s) could not be opened, so nothing about them is checked:`,
14504
+ ...unread.map(({ file, reason }) => ` ${file}: ${reason}`)
14505
+ ];
14506
+ }
14507
+ function syntaxErrorLines(findings) {
14508
+ const files = unparsedMigrations(findings);
14509
+ if (files.length === 0) return [];
14510
+ return [
14511
+ `\u2717 ${files.length} migration(s) do not parse: squawk could not read the SQL, so no other rule checked it, and PostgreSQL will refuse it too. The first error, the one to fix:`,
14512
+ ...files.map(
14513
+ ({ first, more }) => ` ${first.file}:${first.line}:${first.column} ${first.message}` + (more > 0 ? ` (and ${more} more after it)` : "")
14514
+ )
14515
+ ];
14516
+ }
14517
+ function findingLines(findings) {
14518
+ const counted = countedFindings(findings);
14519
+ const errors = errorFindings(findings);
14520
+ const errorRules = new Set(errors.map((finding3) => finding3.rule));
14521
+ const byRule = countByRule(counted).sort(
14522
+ ([a], [b]) => Number(errorRules.has(b)) - Number(errorRules.has(a))
14523
+ );
14524
+ if (byRule.length === 0) return ["no finding."];
14525
+ const total = counted.length;
14526
+ const width = Math.max(...byRule.map(([rule]) => rule.length));
14527
+ return [
14528
+ errors.length === 0 ? `${total} finding(s), every one a warning while the role is being adopted:` : `\u2717 ${total} finding(s): ${errors.length} error(s), from the rule(s) this module sets to "error" in sql.config.mjs, which fail this run, and ${total - errors.length} warning(s):`,
14529
+ ...byRule.flatMap(([rule, count]) => {
14530
+ const note = findings.find(
14531
+ (finding3) => finding3.rule === rule && finding3.sentinelNote
14532
+ )?.sentinelNote;
14533
+ return [
14534
+ ` ${rule.padEnd(width)} ${count}${errorRules.has(rule) ? " error" : ""}`,
14535
+ // The one-sentence form: a console is read a line at a time. The full note and its proof
14536
+ // are in the page, the json and `--inspect`.
14537
+ ...note ? [` sentinel's note: ${note.short}`] : [],
14538
+ // The syntax errors' places are listed above, with the error to fix.
14539
+ ...rule === SYNTAX_ERROR ? [] : placeLines(counted, rule)
14540
+ ];
14541
+ })
14542
+ ];
14543
+ }
14544
+ var CONSOLE_PLACES = 3;
14545
+ function placeLines(findings, rule) {
14546
+ const mine = findings.filter((finding3) => finding3.rule === rule).sort((a, b) => a.file.localeCompare(b.file) || a.line - b.line || a.column - b.column);
14547
+ const shown = mine.slice(0, CONSOLE_PLACES).map((finding3) => ` ${finding3.file}:${finding3.line}:${finding3.column}`);
14548
+ const more = mine.length - shown.length;
14549
+ return more > 0 ? [...shown, ` and ${more} more: pnpm run sql:html lists them all`] : shown;
14550
+ }
14551
+ function countByRule(findings) {
14552
+ const counts = /* @__PURE__ */ new Map();
14553
+ for (const { rule } of findings) counts.set(rule, (counts.get(rule) ?? 0) + 1);
14554
+ return [...counts].sort(([a, x], [b, y]) => y - x || a.localeCompare(b));
14555
+ }
14556
+
14454
14557
  // src/roles/sql/adapters/squawk/squawk.adapter.ts
14455
14558
  var scripts2 = () => ({
14456
14559
  [SCRIPTS3.console]: `sentinel --run --${TARGET3}`,
@@ -14633,13 +14736,10 @@ var SquawkAdapter = class extends BaseAdapter {
14633
14736
  const history = appliedChanges(ctx.cwd, config, base ?? selection.quietBase, reading.nested);
14634
14737
  if (!history.ok) return failing(history.reason, countsOf(reading));
14635
14738
  const { unsafe, unsafeOff } = unsafeCalls(ctx.cwd, config, code);
14636
- const templates = await checkSqlTemplates(
14637
- ctx.cwd,
14638
- templateCode,
14639
- readAbsolute,
14640
- templateRules(config.rules),
14641
- trigramContext(ctx.cwd, reading.migrations, config.migrations.indexesFrom)
14642
- );
14739
+ const templates = await checkSqlTemplates(ctx.cwd, templateCode, readAbsolute, {
14740
+ rules: templateRules(config.rules),
14741
+ context: trigramContext(ctx.cwd, reading.migrations, config.migrations.indexesFrom)
14742
+ });
14643
14743
  const findings = withNotes(
14644
14744
  [
14645
14745
  ...history.findings,
@@ -15303,10 +15403,10 @@ function hasUnreadableCode(coverage) {
15303
15403
  }
15304
15404
  function coverageOf(cwd, config) {
15305
15405
  const ignore = exclusions(config, "product");
15306
- const readable2 = extensionsOf(config.languages).map((extension) => extension.slice(1)).join(",");
15406
+ const readable = extensionsOf(config.languages).map((extension) => extension.slice(1)).join(",");
15307
15407
  const roots = measuredRoots(cwd);
15308
15408
  const under2 = (extensions) => roots.map((root) => root === "." ? `**/*.{${extensions}}` : `${root}/**/*.{${extensions}}`);
15309
- const read2 = readable2 ? globSync7(under2(readable2), { cwd, ignore, dot: false }).length : 0;
15409
+ const read2 = readable ? globSync7(under2(readable), { cwd, ignore, dot: false }).length : 0;
15310
15410
  const unreadable = UNREADABLE_EXTENSIONS.map((extension) => extension.slice(1)).join(",");
15311
15411
  const found = globSync7(under2(unreadable), { cwd, ignore, dot: false });
15312
15412
  const total = read2 + found.length;
@@ -15398,11 +15498,11 @@ var DEAD_CODE = /* @__PURE__ */ new Set([
15398
15498
  "usedOnlyByTests",
15399
15499
  "deadLinesPercent"
15400
15500
  ]);
15401
- function fileOf(place4) {
15402
- return place4.replace(/:\d+$/, "");
15501
+ function fileOf(place3) {
15502
+ return place3.replace(/:\d+$/, "");
15403
15503
  }
15404
- function lineOf2(place4) {
15405
- const match = /:(\d+)$/.exec(place4);
15504
+ function lineOf2(place3) {
15505
+ const match = /:(\d+)$/.exec(place3);
15406
15506
  return match === null ? 0 : Number(match[1]);
15407
15507
  }
15408
15508
  function normalisedFragment(fragment) {
@@ -15446,10 +15546,10 @@ function placeIdentities(findings) {
15446
15546
  }
15447
15547
 
15448
15548
  // src/roles/static-analysis/delta/compare.ts
15449
- function renamedPlace(place4, renames) {
15450
- const file = fileOf(place4);
15549
+ function renamedPlace(place3, renames) {
15550
+ const file = fileOf(place3);
15451
15551
  const moved = renames.get(file);
15452
- return moved === void 0 ? place4 : `${moved}${place4.slice(file.length)}`;
15552
+ return moved === void 0 ? place3 : `${moved}${place3.slice(file.length)}`;
15453
15553
  }
15454
15554
  function renamed2(finding3, renames) {
15455
15555
  if (renames.size === 0) return finding3;
@@ -15580,7 +15680,7 @@ function writeGraphPicture(drawn, path2) {
15580
15680
  }
15581
15681
 
15582
15682
  // src/roles/static-analysis/graph/explorer.ts
15583
- function place3(graph) {
15683
+ function place2(graph) {
15584
15684
  const nodes = graph.nodes();
15585
15685
  let minX = Infinity;
15586
15686
  let maxX = -Infinity;
@@ -15625,7 +15725,7 @@ function jsonInScript(value) {
15625
15725
  return value.replace(/</g, "\\u003c");
15626
15726
  }
15627
15727
  function buildExplorer(drawn, communities) {
15628
- const placed = place3(drawn);
15728
+ const placed = place2(drawn);
15629
15729
  const nodes = [...placed.keys()];
15630
15730
  const index = new Map(nodes.map((node, position) => [node, position]));
15631
15731
  const edges = [];
@@ -16730,10 +16830,10 @@ function assembleReport({
16730
16830
  rows.push({ metric: "measuredFiles", value: size.files, unit: "files" });
16731
16831
  }
16732
16832
  if (size) {
16733
- const counts2 = /* @__PURE__ */ new Map();
16734
- for (const breach of size.breaches) counts2.set(breach.rule, (counts2.get(breach.rule) ?? 0) + 1);
16833
+ const counts = /* @__PURE__ */ new Map();
16834
+ for (const breach of size.breaches) counts.set(breach.rule, (counts.get(breach.rule) ?? 0) + 1);
16735
16835
  for (const [rule, threshold] of Object.entries(GAUGE_THRESHOLDS)) {
16736
- const count = counts2.get(rule) ?? 0;
16836
+ const count = counts.get(rule) ?? 0;
16737
16837
  rows.push({
16738
16838
  metric: rule,
16739
16839
  value: count,