mirror of
https://github.com/tiennm99/ccs.git
synced 2026-08-18 06:25:36 +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`
|
- `bun run maintainability:check`
|
||||||
- `npm 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:
|
The check mode supports a maintainability regression gate that blocks increases in:
|
||||||
- `process.exit` references
|
- `process.exit` references
|
||||||
|
|||||||
@@ -118,27 +118,6 @@ function parseArgs(argv) {
|
|||||||
return options;
|
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() {
|
function collectTrackedFilesFromGit() {
|
||||||
try {
|
try {
|
||||||
const output = execFileSync('git', ['ls-files', '-z', '--', 'src'], {
|
const output = execFileSync('git', ['ls-files', '-z', '--', 'src'], {
|
||||||
@@ -169,17 +148,14 @@ function collectTrackedFilesFromGit() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch {
|
} 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() {
|
function collectFilesInSrc() {
|
||||||
const trackedFiles = collectTrackedFilesFromGit();
|
return collectTrackedFilesFromGit();
|
||||||
if (trackedFiles !== null) {
|
|
||||||
return trackedFiles;
|
|
||||||
}
|
|
||||||
|
|
||||||
return collectFilesFromFileSystem(SRC_DIR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function countLines(content) {
|
function countLines(content) {
|
||||||
|
|||||||
Reference in New Issue
Block a user