@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.
- package/dist/index.js +13 -12
- 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.
|
|
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
|
-
|
|
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
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
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 (
|
|
584
|
+
if (filtered.length > 0 && threshold !== void 0) {
|
|
584
585
|
process.exit(1);
|
|
585
586
|
}
|
|
586
587
|
});
|