@hublo/sentinel 1.7.0-alpha.30 → 1.7.0-alpha.32

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-HYXFUUF5.js";
16
+ } from "../chunk-UJ5VLEZF.js";
17
17
  import "../chunk-ZZMYV576.js";
18
18
  import {
19
19
  resolveContext,
@@ -2537,16 +2537,16 @@ function analyseModule(options) {
2537
2537
  const members = entry.members !== void 0 && entry.members.length > 0 ? entry.members : [];
2538
2538
  const all2 = members.length > 0 ? members : entry.allNames.length > 0 ? entry.allNames : ["*"];
2539
2539
  const values = new Set(members.length > 0 ? members : entry.names);
2540
- const byFile2 = /* @__PURE__ */ new Map();
2540
+ const byFile3 = /* @__PURE__ */ new Map();
2541
2541
  const fileOfName = /* @__PURE__ */ new Map();
2542
2542
  for (const name of all2) {
2543
2543
  const file = definingFile(resolution.path, name);
2544
- const typeOnly = (byFile2.get(file) ?? true) && !values.has(name);
2545
- byFile2.set(file, typeOnly);
2544
+ const typeOnly = (byFile3.get(file) ?? true) && !values.has(name);
2545
+ byFile3.set(file, typeOnly);
2546
2546
  fileOfName.set(name, file);
2547
2547
  }
2548
2548
  const targets4 = /* @__PURE__ */ new Map();
2549
- for (const [workspacePath, typeOnly] of byFile2) {
2549
+ for (const [workspacePath, typeOnly] of byFile3) {
2550
2550
  const target = targetFile(workspacePath, typeOnly);
2551
2551
  if (target !== void 0) targets4.set(workspacePath, target);
2552
2552
  }
@@ -3146,14 +3146,14 @@ var FAMILIES = [
3146
3146
  }
3147
3147
  ];
3148
3148
  function familyOf(metric) {
3149
- return FAMILIES.find((family2) => family2.metrics.includes(metric))?.label;
3149
+ return FAMILIES.find((family) => family.metrics.includes(metric))?.label;
3150
3150
  }
3151
- var CLAIMED_METRICS = FAMILIES.flatMap((family2) => family2.metrics);
3151
+ var CLAIMED_METRICS = FAMILIES.flatMap((family) => family.metrics);
3152
3152
  function byFamily(rows) {
3153
- const grouped2 = FAMILIES.map((family2) => ({
3154
- label: family2.label,
3155
- rows: rows.filter((row) => family2.metrics.includes(row.metric))
3156
- })).filter((family2) => family2.rows.length > 0);
3153
+ const grouped2 = FAMILIES.map((family) => ({
3154
+ label: family.label,
3155
+ rows: rows.filter((row) => family.metrics.includes(row.metric))
3156
+ })).filter((family) => family.rows.length > 0);
3157
3157
  const orphans = rows.filter((row) => familyOf(row.metric) === void 0);
3158
3158
  return orphans.length > 0 ? [...grouped2, { label: "Other", rows: orphans }] : grouped2;
3159
3159
  }
@@ -3252,9 +3252,9 @@ function renderConsole(report) {
3252
3252
  const labelWidth = width(label);
3253
3253
  const valueWidth = width(value);
3254
3254
  lines.push(`sentinel static-analysis: ${report.module}`);
3255
- for (const family2 of byFamily(report.rows)) {
3256
- lines.push("", ` ${family2.label.toLowerCase()}`);
3257
- for (const row of family2.rows) {
3255
+ for (const family of byFamily(report.rows)) {
3256
+ lines.push("", ` ${family.label.toLowerCase()}`);
3257
+ for (const row of family.rows) {
3258
3258
  lines.push(` ${label(row).padEnd(labelWidth)} ${value(row).padStart(valueWidth)}`);
3259
3259
  }
3260
3260
  }
@@ -3343,9 +3343,9 @@ function renderMarkdown(report) {
3343
3343
  };
3344
3344
  const byLabel = byFamily(report.rows);
3345
3345
  const families = [
3346
- ...byLabel.filter((family2) => family2.label === "Bundle"),
3347
- ...byLabel.filter((family2) => family2.label !== "Bundle")
3348
- ].flatMap((family2) => [`##### ${family2.label}`, "", ...family2.rows.flatMap(figureLine)]);
3346
+ ...byLabel.filter((family) => family.label === "Bundle"),
3347
+ ...byLabel.filter((family) => family.label !== "Bundle")
3348
+ ].flatMap((family) => [`##### ${family.label}`, "", ...family.rows.flatMap(figureLine)]);
3349
3349
  const notes = report.notes.length === 0 ? [] : ["", ...report.notes.map((note) => `- ${note.split(". ")[0] ?? note}`)];
3350
3350
  if (report.delta !== void 0 && report.delta.status !== "unavailable")
3351
3351
  return deltaMarkdown(
@@ -4092,24 +4092,24 @@ function renderHtml(report) {
4092
4092
  ${orphanHelp === void 0 ? "" : helpDetails(orphanHelp, true)}
4093
4093
  ${places2}
4094
4094
  </div>`;
4095
- const family2 = familyOf(metric) ?? "Other";
4096
- orphansByFamily.set(family2, [...orphansByFamily.get(family2) ?? [], block]);
4095
+ const family = familyOf(metric) ?? "Other";
4096
+ orphansByFamily.set(family, [...orphansByFamily.get(family) ?? [], block]);
4097
4097
  }
4098
4098
  const orphansFor = (label) => (orphansByFamily.get(label) ?? []).join("\n");
4099
4099
  const families = byFamily(report.rows);
4100
4100
  const withOrphansOnly = FAMILIES.filter(
4101
- (family2) => orphansByFamily.has(family2.label) && !families.some((f) => f.label === family2.label)
4102
- ).map((family2) => ({ label: family2.label, rows: [] }));
4101
+ (family) => orphansByFamily.has(family.label) && !families.some((f) => f.label === family.label)
4102
+ ).map((family) => ({ label: family.label, rows: [] }));
4103
4103
  const complete = [...families, ...withOrphansOnly];
4104
4104
  const ordered = [
4105
- ...complete.filter((family2) => family2.label === "Bundle"),
4106
- ...complete.filter((family2) => family2.label !== "Bundle")
4105
+ ...complete.filter((family) => family.label === "Bundle"),
4106
+ ...complete.filter((family) => family.label !== "Bundle")
4107
4107
  ];
4108
4108
  const absences = report.notes.length === 0 ? "" : ` <div class="notes"><h2>Not measured</h2>${report.notes.map((note) => `<p>${escape(note)}</p>`).join("")}</div>`;
4109
4109
  const overview = `${ordered.map(
4110
- (family2, index) => ` <section class="fam">
4111
- <h2>${escape(family2.label)}</h2>
4112
- ${family2.rows.map((row) => figureBlock(row, placesByMetric.get(row.metric) ?? "")).join("\n")}${orphansFor(family2.label)}${index === 0 ? absences : ""}
4110
+ (family, index) => ` <section class="fam">
4111
+ <h2>${escape(family.label)}</h2>
4112
+ ${family.rows.map((row) => figureBlock(row, placesByMetric.get(row.metric) ?? "")).join("\n")}${orphansFor(family.label)}${index === 0 ? absences : ""}
4113
4113
  </section>`
4114
4114
  ).join(
4115
4115
  "\n"
@@ -7502,9 +7502,9 @@ function read(report) {
7502
7502
  return `Read: ${figures.commits} commit(s) of \`${report.base.ref}\` up to \`${report.base.commit}\`${skipped}.`;
7503
7503
  }
7504
7504
  function codeCell(path2) {
7505
- const cell3 = path2.replace(/\|/g, "\\|");
7506
- if (!cell3.includes("`")) return `\`${cell3}\``;
7507
- return `\`\` ${cell3} \`\``;
7505
+ const cell4 = path2.replace(/\|/g, "\\|");
7506
+ if (!cell4.includes("`")) return `\`${cell4}\``;
7507
+ return `\`\` ${cell4} \`\``;
7508
7508
  }
7509
7509
  function kindsLine(report) {
7510
7510
  const { changes, rewritten } = report.figures.kinds;
@@ -10444,13 +10444,13 @@ function plan2(context2) {
10444
10444
  );
10445
10445
  const deleting = new Set(eslintConfigs);
10446
10446
  const rewritten = renames.filter((entry) => !deleting.has(entry.file));
10447
- const byFile2 = /* @__PURE__ */ new Map();
10447
+ const byFile3 = /* @__PURE__ */ new Map();
10448
10448
  for (const entry of rewritten) {
10449
- const list = byFile2.get(entry.file) ?? [];
10449
+ const list = byFile3.get(entry.file) ?? [];
10450
10450
  list.push({ from: entry.from, to: entry.to });
10451
- byFile2.set(entry.file, list);
10451
+ byFile3.set(entry.file, list);
10452
10452
  }
10453
- for (const [file, replacements] of byFile2) {
10453
+ for (const [file, replacements] of byFile3) {
10454
10454
  operations.push({ kind: "replace-lines", path: file, replacements });
10455
10455
  }
10456
10456
  const notes = [
@@ -12659,13 +12659,13 @@ function wholeStatement(reading) {
12659
12659
  // src/roles/sql/raw/rules/exists-union-correlated-outside.ts
12660
12660
  var existsUnionCorrelatedOutside = {
12661
12661
  name: EXISTS_UNION_RULE,
12662
- help: "repeat the correlation inside each branch of the union (`WHERE a.profile_id = np.id` in every SELECT), or write one EXISTS per branch joined by OR, so PostgreSQL filters each branch with its own index.",
12662
+ help: "repeat the correlation inside each branch of the union (`WHERE a.profile_id = np.id` in every SELECT), or write one EXISTS per branch joined by OR, so PostgreSQL filters each branch with its own index",
12663
12663
  check: (reading) => existsSublinks(reading).flatMap(({ location, select }) => {
12664
12664
  const union = unionFilteredOutside(select);
12665
12665
  return union === void 0 ? [] : [
12666
12666
  {
12667
12667
  location,
12668
- message: `this EXISTS reads the UNION \`${union.alias}\` and filters it only outside the union (\`${union.filter}\`): PostgreSQL cannot push that filter into the branches, so it builds the whole union for every outer row. This is the shape of the 19 May incident.`
12668
+ message: `this EXISTS reads the UNION \`${union.alias}\` and filters it only outside the union (\`${union.filter}\`): PostgreSQL cannot push that filter into the branches, so it builds the whole union for every outer row. This is the shape of the 19 May incident`
12669
12669
  }
12670
12670
  ];
12671
12671
  })
@@ -12712,7 +12712,7 @@ function isCorrelated(branch) {
12712
12712
  // src/roles/sql/raw/rules/insert-without-columns.ts
12713
12713
  var insertWithoutColumns = {
12714
12714
  name: INSERT_COLUMNS_RULE,
12715
- help: "name the columns, `INSERT INTO t (a, b) VALUES (\u2026)`, so a new column cannot shift the values.",
12715
+ help: "name the columns, `INSERT INTO t (a, b) VALUES (\u2026)`, so a new column cannot shift the values",
12716
12716
  check: (reading) => {
12717
12717
  if (!wholeStatement(reading)) return [];
12718
12718
  return reading.statements.flatMap((statement) => {
@@ -12740,7 +12740,7 @@ function unlistedInsert(statement) {
12740
12740
  var QUERIES = /* @__PURE__ */ new Set(["SelectStmt", "UpdateStmt", "DeleteStmt", "InsertStmt"]);
12741
12741
  var leadingWildcardLike = {
12742
12742
  name: LIKE_WILDCARD_RULE,
12743
- 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`) is what serves it.",
12743
+ 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`) is what serves it",
12744
12744
  check: (reading) => {
12745
12745
  if (!statementKinds(reading.statements).every((kind) => QUERIES.has(kind))) return [];
12746
12746
  return [...pgNodes(reading.statements)].flatMap((node) => {
@@ -12775,7 +12775,7 @@ function hitOf({
12775
12775
  // src/roles/sql/raw/rules/not-in-subquery.ts
12776
12776
  var notInSubquery = {
12777
12777
  name: NOT_IN_RULE,
12778
- help: "write `NOT EXISTS (SELECT 1 FROM \u2026 WHERE \u2026 = x)`, which a NULL cannot empty.",
12778
+ help: "write `NOT EXISTS (SELECT 1 FROM \u2026 WHERE \u2026 = x)`, which a NULL cannot empty",
12779
12779
  check: (reading) => [...pgNodes(reading.statements)].flatMap((node) => {
12780
12780
  const not = bodyOf(node, "BoolExpr");
12781
12781
  const args = not?.boolop === "NOT_EXPR" ? not.args ?? [] : [];
@@ -12794,7 +12794,7 @@ var notInSubquery = {
12794
12794
  // src/roles/sql/raw/rules/offset-pagination.ts
12795
12795
  var offsetPagination = {
12796
12796
  name: OFFSET_RULE,
12797
- help: "page by the last key seen instead (`WHERE (created_at, id) < (${lastAt}, ${lastId}) ORDER BY created_at DESC, id DESC LIMIT ${size}`), which reads one page whatever its number.",
12797
+ help: "page by the last key seen instead (`WHERE (created_at, id) < (${lastAt}, ${lastId}) ORDER BY created_at DESC, id DESC LIMIT ${size}`), which reads one page whatever its number",
12798
12798
  check: (reading) => selectsUnder(reading.statements).flatMap((select) => {
12799
12799
  const location = firstLocation(select.limitOffset);
12800
12800
  if (location === void 0 || !reading.own(location)) return [];
@@ -12810,7 +12810,7 @@ var offsetPagination = {
12810
12810
  // src/roles/sql/raw/rules/select-distinct.ts
12811
12811
  var selectDistinct = {
12812
12812
  name: DISTINCT_RULE,
12813
- help: "look for the join that repeats rows and filter it with EXISTS, or aggregate; keep the DISTINCT when duplicates are expected, and say why beside the query.",
12813
+ help: "look for the join that repeats rows and filter it with EXISTS, or aggregate; keep the DISTINCT when duplicates are expected, and say why beside the query",
12814
12814
  check: (reading) => selectsUnder(reading.statements).flatMap((select) => {
12815
12815
  const location = isPlainDistinct(select) ? firstLocation(select.targetList) : void 0;
12816
12816
  if (location === void 0 || !reading.own(location)) return [];
@@ -12832,7 +12832,7 @@ function isPlainDistinct(select) {
12832
12832
  // src/roles/sql/raw/rules/select-star.ts
12833
12833
  var selectStar = {
12834
12834
  name: SELECT_STAR_RULE,
12835
- help: "name the columns the code reads, so the query reads only those and keeps its shape.",
12835
+ help: "name the columns the code reads, so the query reads only those and keeps its shape",
12836
12836
  check: (reading) => {
12837
12837
  const exempt = existsSelects(reading.statements);
12838
12838
  const defined = withNames(reading.statements);
@@ -12888,7 +12888,7 @@ function isDefinedHere(item, defined) {
12888
12888
  // src/roles/sql/raw/rules/update-delete-without-where.ts
12889
12889
  var updateDeleteWithoutWhere = {
12890
12890
  name: UPDATE_DELETE_RULE,
12891
- help: "add the WHERE that names the rows to change; if every row is meant, say so in a comment beside the query, where the next reader will look.",
12891
+ help: "add the WHERE that names the rows to change; if every row is meant, say so in a comment beside the query, where the next reader will look",
12892
12892
  check: (reading) => wholeStatement(reading) ? hitsOf(reading) : []
12893
12893
  };
12894
12894
  function hitsOf(reading) {
@@ -13036,12 +13036,12 @@ function countedFindings(findings) {
13036
13036
  }
13037
13037
  var errorFindings = (findings) => countedFindings(findings).filter((finding3) => finding3.level === "error");
13038
13038
  function unparsedMigrations(findings) {
13039
- const byFile2 = /* @__PURE__ */ new Map();
13039
+ const byFile3 = /* @__PURE__ */ new Map();
13040
13040
  for (const finding3 of findings) {
13041
13041
  if (finding3.rule !== SYNTAX_ERROR) continue;
13042
- byFile2.set(finding3.file, [...byFile2.get(finding3.file) ?? [], finding3]);
13042
+ byFile3.set(finding3.file, [...byFile3.get(finding3.file) ?? [], finding3]);
13043
13043
  }
13044
- return [...byFile2.values()].map((errors) => {
13044
+ return [...byFile3.values()].map((errors) => {
13045
13045
  const [first] = [...errors].sort((a, b) => a.line - b.line || a.column - b.column);
13046
13046
  return { first, more: errors.length - 1 };
13047
13047
  });
@@ -13229,16 +13229,16 @@ function meta(report, now) {
13229
13229
  }
13230
13230
  function counts(report) {
13231
13231
  const syntax = unparsedMigrations(report.findings).length;
13232
- const cell3 = (value, label, alarm = false) => `<div class="count${alarm && value > 0 ? " alarm" : ""}"><b>${grouped(value)}</b><span>${label}</span></div>`;
13232
+ const cell4 = (value, label, alarm = false) => `<div class="count${alarm && value > 0 ? " alarm" : ""}"><b>${grouped(value)}</b><span>${label}</span></div>`;
13233
13233
  const errors = errorFindings(report.findings).length;
13234
13234
  return `<section class="counts">
13235
- ${cell3(report.read.length, `read, of ${grouped(report.migrations)} in the module`)}
13236
- ${cell3(countedFindings(report.findings).length, errors === 0 ? "findings, all warnings" : "findings")}
13237
- ${errors === 0 ? "" : cell3(errors, "errors, from rules set to error", true)}
13238
- ${cell3(report.unread.length, "could not be opened", true)}
13239
- ${cell3(syntax, "do not parse", true)}
13240
- ${cell3(report.unsafe.files.length, "files with a raw SQL call")}
13241
- ${cell3(report.templates.files.length, "files with a SQL template")}
13235
+ ${cell4(report.read.length, `read, of ${grouped(report.migrations)} in the module`)}
13236
+ ${cell4(countedFindings(report.findings).length, errors === 0 ? "findings, all warnings" : "findings")}
13237
+ ${errors === 0 ? "" : cell4(errors, "errors, from rules set to error", true)}
13238
+ ${cell4(report.unread.length, "could not be opened", true)}
13239
+ ${cell4(syntax, "do not parse", true)}
13240
+ ${cell4(report.unsafe.files.length, "files with a raw SQL call")}
13241
+ ${cell4(report.templates.files.length, "files with a SQL template")}
13242
13242
  </section>`;
13243
13243
  }
13244
13244
  function offSection(report) {
@@ -13450,7 +13450,8 @@ function countedAsEverywhere(findings) {
13450
13450
  }
13451
13451
 
13452
13452
  // src/roles/sql/report/render-markdown.ts
13453
- var PLACES_PER_RULE = 3;
13453
+ var UNREAD_NAMED = 3;
13454
+ var ROWS_PER_MODULE = 30;
13454
13455
  function renderMarkdown5(report) {
13455
13456
  return [
13456
13457
  `#### \`${report.module}\``,
@@ -13460,15 +13461,10 @@ function renderMarkdown5(report) {
13460
13461
  ...unreadBlock(report),
13461
13462
  ...syntaxBlock(report),
13462
13463
  ...unsafeBlock(report),
13463
- ...family(report, "Migrations", report.read.length > 0, false),
13464
- ...family(
13465
- report,
13466
- "Raw SQL in code",
13467
- report.unsafe.read.length > 0 || report.templates.read.length > 0,
13468
- true
13469
- ),
13464
+ ...templatesLine(report),
13465
+ ...fileBlocks(report),
13470
13466
  "",
13471
- `<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>`,
13467
+ `<sub>${levelsLine(report)}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>`,
13472
13468
  ""
13473
13469
  ].join("\n");
13474
13470
  }
@@ -13500,27 +13496,79 @@ function headline3(report) {
13500
13496
  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"}`;
13501
13497
  return `Read ${read2} this branch adds or changes, ${against}: ${found}.`;
13502
13498
  }
13503
- var RAW_SQL_RULES = [UNSAFE_RULE, RAW_FRAGMENT_RULE, ...TEMPLATE_RULES];
13504
- function family(report, name, read2, raw) {
13505
- const findings = report.findings.filter(
13506
- (finding3) => finding3.rule !== SYNTAX_ERROR && RAW_SQL_RULES.includes(finding3.rule) === raw
13499
+ function readAnything(report) {
13500
+ return report.read.length > 0 || report.unsafe.read.length > 0 || report.templates.read.length > 0;
13501
+ }
13502
+ function fileBlocks(report) {
13503
+ const findings = report.findings.filter((finding3) => finding3.rule !== SYNTAX_ERROR);
13504
+ if (findings.length === 0) {
13505
+ if (!readAnything(report)) return [];
13506
+ return [
13507
+ "",
13508
+ unparsedMigrations(report.findings).length > 0 ? "No other finding." : "No finding."
13509
+ ];
13510
+ }
13511
+ const lines = [];
13512
+ let left = ROWS_PER_MODULE;
13513
+ for (const [file, inFile] of byFile2(findings)) {
13514
+ if (left === 0) break;
13515
+ const shown = inFile.slice(0, left);
13516
+ left -= shown.length;
13517
+ lines.push(
13518
+ "",
13519
+ `**\`${file}\`**: ${levelCounts(inFile)}`,
13520
+ "",
13521
+ "| Line | Level | Rule | Problem |",
13522
+ "| ---: | --- | --- | --- |",
13523
+ ...shown.map(rowOf)
13524
+ );
13525
+ }
13526
+ const more = findings.length - ROWS_PER_MODULE;
13527
+ if (more > 0)
13528
+ lines.push("", `**${more} more**, with every other place, in the \`sql.html\` this run keeps.`);
13529
+ return lines;
13530
+ }
13531
+ function byFile2(findings) {
13532
+ const groups = /* @__PURE__ */ new Map();
13533
+ for (const finding3 of findings)
13534
+ groups.set(finding3.file, [...groups.get(finding3.file) ?? [], finding3]);
13535
+ const errors = (list) => list.filter((finding3) => finding3.level === "error").length;
13536
+ return [...groups].map(([file, list]) => [
13537
+ file,
13538
+ [...list].sort(
13539
+ (a, b) => a.line - b.line || a.column - b.column || a.rule.localeCompare(b.rule)
13540
+ )
13541
+ ]).sort(
13542
+ ([fileA, a], [fileB, b]) => errors(b) - errors(a) || b.length - a.length || fileA.localeCompare(fileB)
13507
13543
  );
13508
- if (!read2 && findings.length === 0) return [];
13509
- const errors = errorFindings(findings).length;
13510
- const body = ruleBlocks(findings);
13544
+ }
13545
+ function levelCounts(findings) {
13546
+ const errors = findings.filter((finding3) => finding3.level === "error").length;
13547
+ const warnings = findings.length - errors;
13548
+ const plural = (count, noun) => `${count} ${noun}${count === 1 ? "" : "s"}`;
13511
13549
  return [
13512
- "",
13513
- `##### ${name}${errors > 0 ? ` \xB7 ${errors} error${errors === 1 ? "" : "s"}` : ""}`,
13514
- ...raw ? templatesLine(report) : [],
13515
- // Said apart from a migration that does not parse, already named above: its other rules did not run.
13516
- ...body.length > 0 ? body : [
13517
- "",
13518
- !raw && unparsedMigrations(report.findings).length > 0 ? "No other finding." : "No finding."
13519
- ]
13520
- ];
13550
+ ...errors > 0 ? [plural(errors, "error")] : [],
13551
+ ...warnings > 0 ? [plural(warnings, "warning")] : []
13552
+ ].join(", ");
13553
+ }
13554
+ function rowOf(finding3) {
13555
+ const own = SENTINEL_RULES.includes(finding3.rule);
13556
+ const problem = sentence(finding3.message) + (!own && finding3.help ? ` Fix: ${endOf(finding3.help)}` : "");
13557
+ const level = finding3.level === "error" ? "\u2717 error" : "warn";
13558
+ return `| ${finding3.line} | ${level} | \`${finding3.rule}\` | ${cell3(problem)} |`;
13559
+ }
13560
+ function sentence(text) {
13561
+ const ended = endOf(text);
13562
+ return `${ended.charAt(0).toUpperCase()}${ended.slice(1)}`;
13563
+ }
13564
+ function endOf(text) {
13565
+ return `${text.trim().replace(/\.+$/, "")}.`;
13566
+ }
13567
+ function cell3(text) {
13568
+ return text.replace(/\|/g, "\\|").replace(/\s*\n\s*/g, " ");
13521
13569
  }
13522
13570
  function levelsLine(report) {
13523
- 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.";
13571
+ return errorFindings(report.findings).length === 0 ? "" : "A rule the module sets to `error` fails the module's `sql` run; every other finding is a warning. ";
13524
13572
  }
13525
13573
  function offBlock(report) {
13526
13574
  if (report.read.length === 0 && report.unsafe.files.length === 0 || report.rulesOff.length === 0)
@@ -13549,28 +13597,6 @@ function syntaxBlock(report) {
13549
13597
  )
13550
13598
  ];
13551
13599
  }
13552
- function ruleBlocks(findings) {
13553
- return byRule(findings).flatMap(({ rule, findings: findings2 }) => {
13554
- const [first] = findings2;
13555
- if (first === void 0) return [];
13556
- const more = findings2.length - Math.min(findings2.length, PLACES_PER_RULE);
13557
- const places2 = placesText(findings2.slice(0, PLACES_PER_RULE)) + (more > 0 ? ` and ${more} more` : "");
13558
- const note = findings2.find((finding3) => finding3.sentinelNote !== null)?.sentinelNote;
13559
- return [
13560
- "",
13561
- `**${rule}**${first.level === "error" ? " \u2717 error" : ""} \xB7 ${findings2.length} \xB7 ${places2}`,
13562
- // sentinel's own rules speak as sentinel: their words are not squawk's.
13563
- `> ${SENTINEL_RULES.includes(rule) ? "sentinel" : "squawk"}: ${first.message}${first.help ? `. Fix: ${first.help}` : ""}.`,
13564
- ...note ? [`> **sentinel:** ${note.short}`] : []
13565
- ];
13566
- });
13567
- }
13568
- function placesText(findings) {
13569
- const byFile2 = /* @__PURE__ */ new Map();
13570
- for (const finding3 of findings)
13571
- byFile2.set(finding3.file, [...byFile2.get(finding3.file) ?? [], finding3.line]);
13572
- return [...byFile2].map(([file, lines]) => `\`${file}\` line${lines.length === 1 ? "" : "s"} ${lines.join(", ")}`).join("; ");
13573
- }
13574
13600
  function templatesLine(report) {
13575
13601
  const { read: read2, templates, parsed: parsed2, unread, unparsed } = report.templates;
13576
13602
  if (read2.length === 0) return [];
@@ -13578,10 +13604,9 @@ function templatesLine(report) {
13578
13604
  ...unread.map(({ file, line }) => ({ file, line })),
13579
13605
  ...unparsed.map(({ file }) => ({ file, line: void 0 }))
13580
13606
  ];
13581
- if (missed.length === 0)
13582
- return ["", `All ${templates} SQL templates read by PostgreSQL's parser.`];
13583
- const shown = missed.slice(0, PLACES_PER_RULE).map(({ file, line }) => `\`${file}\`${line === void 0 ? "" : ` line ${line}`}`);
13584
- const more = missed.length > PLACES_PER_RULE ? ` and ${missed.length - PLACES_PER_RULE} more` : "";
13607
+ if (missed.length === 0) return [];
13608
+ const shown = missed.slice(0, UNREAD_NAMED).map(({ file, line }) => `\`${file}\`${line === void 0 ? "" : ` line ${line}`}`);
13609
+ const more = missed.length > UNREAD_NAMED ? ` and ${missed.length - UNREAD_NAMED} more` : "";
13585
13610
  return [
13586
13611
  "",
13587
13612
  `${parsed2} of ${templates} SQL templates read by PostgreSQL's parser. Not read alone, so no rule checked them: ${shown.join("; ")}${more}.`
@@ -17238,12 +17263,12 @@ function diffLines(before, after) {
17238
17263
  { length: from.length + 1 },
17239
17264
  () => new Array(to.length + 1).fill(0)
17240
17265
  );
17241
- const cell3 = (i2, j2) => lcs[i2]?.[j2] ?? 0;
17266
+ const cell4 = (i2, j2) => lcs[i2]?.[j2] ?? 0;
17242
17267
  for (let i2 = from.length - 1; i2 >= 0; i2--) {
17243
17268
  const row = lcs[i2];
17244
17269
  if (!row) continue;
17245
17270
  for (let j2 = to.length - 1; j2 >= 0; j2--) {
17246
- row[j2] = from[i2] === to[j2] ? cell3(i2 + 1, j2 + 1) + 1 : Math.max(cell3(i2 + 1, j2), cell3(i2, j2 + 1));
17271
+ row[j2] = from[i2] === to[j2] ? cell4(i2 + 1, j2 + 1) + 1 : Math.max(cell4(i2 + 1, j2), cell4(i2, j2 + 1));
17247
17272
  }
17248
17273
  }
17249
17274
  const out = [];
@@ -17254,7 +17279,7 @@ function diffLines(before, after) {
17254
17279
  out.push(` ${from[i] ?? ""}`);
17255
17280
  i++;
17256
17281
  j++;
17257
- } else if (cell3(i + 1, j) >= cell3(i, j + 1)) {
17282
+ } else if (cell4(i + 1, j) >= cell4(i, j + 1)) {
17258
17283
  out.push(`- ${from[i] ?? ""}`);
17259
17284
  i++;
17260
17285
  } else {
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  registerAdapters,
7
7
  resolve,
8
8
  setDefaultRunner
9
- } from "./chunk-HYXFUUF5.js";
9
+ } from "./chunk-UJ5VLEZF.js";
10
10
  import "./chunk-ZZMYV576.js";
11
11
  import {
12
12
  BaseAdapter
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hublo/sentinel",
3
- "version": "1.7.0-alpha.30",
3
+ "version": "1.7.0-alpha.32",
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",