mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-16 12:15:57 +00:00
fix(maintainability): require git-tracked scan for gate
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user