@hublo/sentinel 1.7.0-alpha.24 → 1.7.0-alpha.26

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.
@@ -13,7 +13,7 @@ import {
13
13
  presetNotInstalledYet,
14
14
  registerAdapters,
15
15
  resolve
16
- } from "../chunk-EQQMY6NH.js";
16
+ } from "../chunk-D2Z7H3AD.js";
17
17
  import {
18
18
  resolveContext,
19
19
  separateToolArgs
@@ -5767,14 +5767,14 @@ var FAMILIES = [
5767
5767
  }
5768
5768
  ];
5769
5769
  function familyOf(metric) {
5770
- return FAMILIES.find((family) => family.metrics.includes(metric))?.label;
5770
+ return FAMILIES.find((family2) => family2.metrics.includes(metric))?.label;
5771
5771
  }
5772
- var CLAIMED_METRICS = FAMILIES.flatMap((family) => family.metrics);
5772
+ var CLAIMED_METRICS = FAMILIES.flatMap((family2) => family2.metrics);
5773
5773
  function byFamily(rows) {
5774
- const grouped2 = FAMILIES.map((family) => ({
5775
- label: family.label,
5776
- rows: rows.filter((row) => family.metrics.includes(row.metric))
5777
- })).filter((family) => family.rows.length > 0);
5774
+ const grouped2 = FAMILIES.map((family2) => ({
5775
+ label: family2.label,
5776
+ rows: rows.filter((row) => family2.metrics.includes(row.metric))
5777
+ })).filter((family2) => family2.rows.length > 0);
5778
5778
  const orphans = rows.filter((row) => familyOf(row.metric) === void 0);
5779
5779
  return orphans.length > 0 ? [...grouped2, { label: "Other", rows: orphans }] : grouped2;
5780
5780
  }
@@ -5865,9 +5865,9 @@ function renderConsole2(report) {
5865
5865
  const labelWidth = width(label);
5866
5866
  const valueWidth = width(value);
5867
5867
  lines.push(`sentinel static-analysis: ${report.module}`);
5868
- for (const family of byFamily(report.rows)) {
5869
- lines.push("", ` ${family.label.toLowerCase()}`);
5870
- for (const row of family.rows) {
5868
+ for (const family2 of byFamily(report.rows)) {
5869
+ lines.push("", ` ${family2.label.toLowerCase()}`);
5870
+ for (const row of family2.rows) {
5871
5871
  lines.push(` ${label(row).padEnd(labelWidth)} ${value(row).padStart(valueWidth)}`);
5872
5872
  }
5873
5873
  }
@@ -5947,9 +5947,9 @@ function renderMarkdown2(report) {
5947
5947
  };
5948
5948
  const byLabel = byFamily(report.rows);
5949
5949
  const families = [
5950
- ...byLabel.filter((family) => family.label === "Bundle"),
5951
- ...byLabel.filter((family) => family.label !== "Bundle")
5952
- ].flatMap((family) => [`##### ${family.label}`, "", ...family.rows.flatMap(figureLine)]);
5950
+ ...byLabel.filter((family2) => family2.label === "Bundle"),
5951
+ ...byLabel.filter((family2) => family2.label !== "Bundle")
5952
+ ].flatMap((family2) => [`##### ${family2.label}`, "", ...family2.rows.flatMap(figureLine)]);
5953
5953
  const notes = report.notes.length === 0 ? [] : ["", ...report.notes.map((note) => `- ${note.split(". ")[0] ?? note}`)];
5954
5954
  return [
5955
5955
  `#### \`${report.module}\``,
@@ -6650,24 +6650,24 @@ function renderHtml(report) {
6650
6650
  ${orphanHelp === void 0 ? "" : helpDetails(orphanHelp, true)}
6651
6651
  ${places2}
6652
6652
  </div>`;
6653
- const family = familyOf(metric) ?? "Other";
6654
- orphansByFamily.set(family, [...orphansByFamily.get(family) ?? [], block]);
6653
+ const family2 = familyOf(metric) ?? "Other";
6654
+ orphansByFamily.set(family2, [...orphansByFamily.get(family2) ?? [], block]);
6655
6655
  }
6656
6656
  const orphansFor = (label) => (orphansByFamily.get(label) ?? []).join("\n");
6657
6657
  const families = byFamily(report.rows);
6658
6658
  const withOrphansOnly = FAMILIES.filter(
6659
- (family) => orphansByFamily.has(family.label) && !families.some((f) => f.label === family.label)
6660
- ).map((family) => ({ label: family.label, rows: [] }));
6659
+ (family2) => orphansByFamily.has(family2.label) && !families.some((f) => f.label === family2.label)
6660
+ ).map((family2) => ({ label: family2.label, rows: [] }));
6661
6661
  const complete = [...families, ...withOrphansOnly];
6662
6662
  const ordered = [
6663
- ...complete.filter((family) => family.label === "Bundle"),
6664
- ...complete.filter((family) => family.label !== "Bundle")
6663
+ ...complete.filter((family2) => family2.label === "Bundle"),
6664
+ ...complete.filter((family2) => family2.label !== "Bundle")
6665
6665
  ];
6666
6666
  const absences = report.notes.length === 0 ? "" : ` <div class="notes"><h2>Not measured</h2>${report.notes.map((note) => `<p>${escape(note)}</p>`).join("")}</div>`;
6667
6667
  const overview = `${ordered.map(
6668
- (family, index) => ` <section class="fam">
6669
- <h2>${escape(family.label)}</h2>
6670
- ${family.rows.map((row) => figureBlock(row, placesByMetric.get(row.metric) ?? "")).join("\n")}${orphansFor(family.label)}${index === 0 ? absences : ""}
6668
+ (family2, index) => ` <section class="fam">
6669
+ <h2>${escape(family2.label)}</h2>
6670
+ ${family2.rows.map((row) => figureBlock(row, placesByMetric.get(row.metric) ?? "")).join("\n")}${orphansFor(family2.label)}${index === 0 ? absences : ""}
6671
6671
  </section>`
6672
6672
  ).join(
6673
6673
  "\n"
@@ -7103,7 +7103,8 @@ function renderMarkdown3(report) {
7103
7103
  ...unreadBlock(report),
7104
7104
  ...syntaxBlock(report),
7105
7105
  ...unsafeBlock(report),
7106
- ...ruleBlocks(report),
7106
+ ...family(report, "Migrations", report.read.length > 0, false),
7107
+ ...family(report, "Raw SQL in code", report.unsafe.read.length > 0, true),
7107
7108
  "",
7108
7109
  `<sub>Only the migrations this branch adds or changes are read. ${levelsLine(report)} Every place, with the SQL behind it and sentinel's full notes, is in the \`sql.html\` this run keeps. Measured by sentinel ${report.sentinel}.</sub>`,
7109
7110
  ""
@@ -7134,6 +7135,24 @@ function headline2(report) {
7134
7135
  const found = findings === 0 ? "no finding" : errors === 0 ? `${counted}, every one a warning` : `${counted}: \u2717 **${errors} error${errors === 1 ? "" : "s"}**, from rules this module sets to \`error\`, and ${findings - errors} warning${findings - errors === 1 ? "" : "s"}`;
7135
7136
  return `Read ${read} this branch adds or changes, ${against}: ${found}.`;
7136
7137
  }
7138
+ var RAW_SQL_RULES = [UNSAFE_RULE, RAW_FRAGMENT_RULE];
7139
+ function family(report, name, read, raw) {
7140
+ const findings = report.findings.filter(
7141
+ (finding3) => finding3.rule !== SYNTAX_ERROR && RAW_SQL_RULES.includes(finding3.rule) === raw
7142
+ );
7143
+ if (!read && findings.length === 0) return [];
7144
+ const errors = errorFindings(findings).length;
7145
+ const body = ruleBlocks(findings);
7146
+ return [
7147
+ "",
7148
+ `##### ${name}${errors > 0 ? ` \xB7 ${errors} error${errors === 1 ? "" : "s"}` : ""}`,
7149
+ // Said apart from a migration that does not parse, already named above: its other rules did not run.
7150
+ ...body.length > 0 ? body : [
7151
+ "",
7152
+ !raw && unparsedMigrations(report.findings).length > 0 ? "No other finding." : "No finding."
7153
+ ]
7154
+ ];
7155
+ }
7137
7156
  function levelsLine(report) {
7138
7157
  return 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 `error` fails the module's `sql` run; every other finding is a warning.";
7139
7158
  }
@@ -7164,16 +7183,16 @@ function syntaxBlock(report) {
7164
7183
  )
7165
7184
  ];
7166
7185
  }
7167
- function ruleBlocks(report) {
7168
- return byRule(report.findings).flatMap(({ rule, findings }) => {
7169
- const [first] = findings;
7186
+ function ruleBlocks(findings) {
7187
+ return byRule(findings).flatMap(({ rule, findings: findings2 }) => {
7188
+ const [first] = findings2;
7170
7189
  if (first === void 0) return [];
7171
- const more = findings.length - Math.min(findings.length, PLACES_PER_RULE);
7172
- const places2 = placesText(findings.slice(0, PLACES_PER_RULE)) + (more > 0 ? ` and ${more} more` : "");
7173
- const note = findings.find((finding3) => finding3.sentinelNote !== null)?.sentinelNote;
7190
+ const more = findings2.length - Math.min(findings2.length, PLACES_PER_RULE);
7191
+ const places2 = placesText(findings2.slice(0, PLACES_PER_RULE)) + (more > 0 ? ` and ${more} more` : "");
7192
+ const note = findings2.find((finding3) => finding3.sentinelNote !== null)?.sentinelNote;
7174
7193
  return [
7175
7194
  "",
7176
- `**${rule}**${first.level === "error" ? " \u2717 error" : ""} \xB7 ${findings.length} \xB7 ${places2}`,
7195
+ `**${rule}**${first.level === "error" ? " \u2717 error" : ""} \xB7 ${findings2.length} \xB7 ${places2}`,
7177
7196
  // sentinel's own rules speak as sentinel: their words are not squawk's.
7178
7197
  `> ${SENTINEL_RULES.includes(rule) ? "sentinel" : "squawk"}: ${first.message}${first.help ? `. Fix: ${first.help}` : ""}.`,
7179
7198
  ...note ? [`> **sentinel:** ${note.short}`] : []
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  registerAdapters,
7
7
  resolve,
8
8
  setDefaultRunner
9
- } from "./chunk-EQQMY6NH.js";
9
+ } from "./chunk-D2Z7H3AD.js";
10
10
  import {
11
11
  BaseAdapter
12
12
  } from "./chunk-F3Q3JQJ6.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hublo/sentinel",
3
- "version": "1.7.0-alpha.24",
3
+ "version": "1.7.0-alpha.26",
4
4
  "description": "One CLI that guards code health across Hublo repos: shared lint/typescript/build/test presets, static & dynamic analysis, and architecture checks.",
5
5
  "type": "module",
6
6
  "license": "MIT",