mirror of
https://github.com/giancarloerra/socraticode.git
synced 2026-07-03 14:05:21 +02:00
fix: address CodeRabbit PR review feedback
- Use Object.hasOwn() instead of `in` for log level validation - Normalize relativePath in shouldIgnore() for Windows compatibility - Reject zero/negative/decimal values in embedding config (Number() instead of parseInt()) - Update aggregate test count to 765 - Harden code-graph test assertion with explicit toBeDefined()
This commit is contained in:
+1
-1
@@ -515,7 +515,7 @@ Uses depth-first search (DFS) with a recursion stack to find cycles in the direc
|
||||
|
||||
## Testing
|
||||
|
||||
SocratiCode uses **vitest** as its test framework with **634 tests** across three layers.
|
||||
SocratiCode uses **vitest** as its test framework with **765 tests** across three layers.
|
||||
|
||||
### Running Tests
|
||||
|
||||
|
||||
@@ -129,13 +129,12 @@ export function loadEmbeddingConfig(): EmbeddingConfig {
|
||||
|
||||
// ── Model & dimensions (provider-specific defaults) ─────────────────
|
||||
const embeddingModel = process.env.EMBEDDING_MODEL || providerDefaults.model;
|
||||
const rawDimensions = parseInt(
|
||||
process.env.EMBEDDING_DIMENSIONS || String(providerDefaults.dimensions),
|
||||
10,
|
||||
const rawDimensions = Number(
|
||||
process.env.EMBEDDING_DIMENSIONS || providerDefaults.dimensions,
|
||||
);
|
||||
if (Number.isNaN(rawDimensions)) {
|
||||
if (!Number.isInteger(rawDimensions) || rawDimensions <= 0) {
|
||||
throw new Error(
|
||||
`Invalid EMBEDDING_DIMENSIONS: "${process.env.EMBEDDING_DIMENSIONS}". Must be a number.`,
|
||||
`Invalid EMBEDDING_DIMENSIONS: "${process.env.EMBEDDING_DIMENSIONS}". Must be a positive integer.`,
|
||||
);
|
||||
}
|
||||
const embeddingDimensions = rawDimensions;
|
||||
@@ -150,10 +149,10 @@ export function loadEmbeddingConfig(): EmbeddingConfig {
|
||||
embeddingDimensions,
|
||||
embeddingContextLength: contextLengthEnv
|
||||
? (() => {
|
||||
const parsed = parseInt(contextLengthEnv, 10);
|
||||
if (Number.isNaN(parsed)) {
|
||||
const parsed = Number(contextLengthEnv);
|
||||
if (!Number.isInteger(parsed) || parsed <= 0) {
|
||||
throw new Error(
|
||||
`Invalid EMBEDDING_CONTEXT_LENGTH: "${contextLengthEnv}". Must be a number.`,
|
||||
`Invalid EMBEDDING_CONTEXT_LENGTH: "${contextLengthEnv}". Must be a positive integer.`,
|
||||
);
|
||||
}
|
||||
return parsed;
|
||||
|
||||
@@ -158,5 +158,6 @@ function findNestedGitignores(rootPath: string, currentPath: string, ig: Ignore)
|
||||
* Check if a relative path should be ignored.
|
||||
*/
|
||||
export function shouldIgnore(ig: Ignore, relativePath: string): boolean {
|
||||
return ig.ignores(relativePath);
|
||||
const normalized = relativePath.split(path.sep).join("/");
|
||||
return ig.ignores(normalized);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ const LOG_LEVELS: Record<LogLevel, number> = {
|
||||
};
|
||||
|
||||
const envLevel = process.env.SOCRATICODE_LOG_LEVEL?.toLowerCase();
|
||||
const currentLevel: LogLevel = envLevel && envLevel in LOG_LEVELS
|
||||
const currentLevel: LogLevel = envLevel && Object.hasOwn(LOG_LEVELS, envLevel)
|
||||
? (envLevel as LogLevel)
|
||||
: "info";
|
||||
const logFilePath: string | undefined = process.env.SOCRATICODE_LOG_FILE || undefined;
|
||||
|
||||
@@ -110,10 +110,9 @@ describe("code-graph service", () => {
|
||||
const helpersNode = graph.nodes.find((n) =>
|
||||
n.relativePath.includes("helpers.ts"),
|
||||
);
|
||||
if (helpersNode) {
|
||||
// If the graph correctly resolves imports, helpers should have dependents
|
||||
expect(helpersNode.dependents.length).toBeGreaterThan(0);
|
||||
}
|
||||
expect(helpersNode).toBeDefined();
|
||||
// If the graph correctly resolves imports, helpers should have dependents
|
||||
expect(helpersNode?.dependents.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it("includes Python files in the graph", async () => {
|
||||
|
||||
Reference in New Issue
Block a user