fix(maintainability): require git-tracked scan for gate

This commit is contained in:
Tam Nhu Tran
2026-02-12 14:50:54 +07:00
parent 8f0ba481ed
commit b7481cf346
2 changed files with 5 additions and 29 deletions
+1 -1
View File
@@ -201,7 +201,7 @@ All criteria achieved:
- `bun run maintainability:check`
- `npm run maintainability:check`
The baseline/check scripts enumerate git-tracked files under `src` for deterministic results, with filesystem traversal fallback when git is unavailable.
The baseline/check scripts enumerate git-tracked files under `src` for deterministic results and fail fast if git file listing is unavailable.
The check mode supports a maintainability regression gate that blocks increases in:
- `process.exit` references
+4 -28
View File
@@ -118,27 +118,6 @@ function parseArgs(argv) {
return options;
}
function collectFilesFromFileSystem(dirPath) {
const collected = [];
const entries = fs
.readdirSync(dirPath, { withFileTypes: true })
.sort((left, right) => left.name.localeCompare(right.name));
for (const entry of entries) {
const fullPath = path.join(dirPath, entry.name);
if (entry.isDirectory()) {
collected.push(...collectFilesFromFileSystem(fullPath));
continue;
}
if (entry.isFile()) {
collected.push(fullPath);
}
}
return collected;
}
function collectTrackedFilesFromGit() {
try {
const output = execFileSync('git', ['ls-files', '-z', '--', 'src'], {
@@ -169,17 +148,14 @@ function collectTrackedFilesFromGit() {
}
});
} catch {
return null;
throw new Error(
'Unable to enumerate tracked files via git. Run this command from a git checkout with git installed.'
);
}
}
function collectFilesInSrc() {
const trackedFiles = collectTrackedFilesFromGit();
if (trackedFiles !== null) {
return trackedFiles;
}
return collectFilesFromFileSystem(SRC_DIR);
return collectTrackedFilesFromGit();
}
function countLines(content) {