@staff0rd/assist 0.37.0 → 0.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +13 -12
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import { Command } from "commander";
7
7
  // package.json
8
8
  var package_default = {
9
9
  name: "@staff0rd/assist",
10
- version: "0.37.0",
10
+ version: "0.38.0",
11
11
  type: "module",
12
12
  main: "dist/index.js",
13
13
  bin: {
@@ -560,27 +560,28 @@ async function maintainability(pattern2 = "**/*.ts", options = {}) {
560
560
  }
561
561
  });
562
562
  const results = [];
563
- let hasViolation = false;
563
+ const { threshold } = options;
564
564
  for (const [file, metrics] of fileMetrics) {
565
565
  if (metrics.functions.length === 0) continue;
566
566
  const avgMaintainability = metrics.functions.reduce((a, b) => a + b, 0) / metrics.functions.length;
567
567
  const minMaintainability = Math.min(...metrics.functions);
568
568
  results.push({ file, avgMaintainability, minMaintainability });
569
- if (options.threshold !== void 0 && minMaintainability < options.threshold) {
570
- hasViolation = true;
571
- }
572
569
  }
573
570
  results.sort((a, b) => a.minMaintainability - b.minMaintainability);
574
- for (const { file, avgMaintainability, minMaintainability } of results) {
575
- const exceedsThreshold = options.threshold !== void 0 && minMaintainability < options.threshold;
576
- const color = exceedsThreshold ? chalk5.red : chalk5.white;
577
- console.log(
578
- `${color(file)} \u2192 avg: ${chalk5.cyan(avgMaintainability.toFixed(1))}, min: ${chalk5.yellow(minMaintainability.toFixed(1))}`
579
- );
571
+ const filtered = threshold !== void 0 ? results.filter((r) => r.minMaintainability < threshold) : results;
572
+ if (threshold !== void 0 && filtered.length === 0) {
573
+ console.log(chalk5.green("All files pass maintainability threshold"));
574
+ } else {
575
+ for (const { file, avgMaintainability, minMaintainability } of filtered) {
576
+ const color = threshold !== void 0 ? chalk5.red : chalk5.white;
577
+ console.log(
578
+ `${color(file)} \u2192 avg: ${chalk5.cyan(avgMaintainability.toFixed(1))}, min: ${chalk5.yellow(minMaintainability.toFixed(1))}`
579
+ );
580
+ }
580
581
  }
581
582
  console.log(chalk5.dim(`
582
583
  Analyzed ${results.length} files`));
583
- if (hasViolation) {
584
+ if (filtered.length > 0 && threshold !== void 0) {
584
585
  process.exit(1);
585
586
  }
586
587
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.37.0",
3
+ "version": "0.38.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {