diff --git a/eslint.config.js b/eslint.config.js index b071b36..c4c4a75 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -16,11 +16,13 @@ export default [ '@typescript-eslint': typescriptPlugin, }, rules: { - '@typescript-eslint/no-unused-vars': 'warn', - '@typescript-eslint/explicit-function-return-type': 'warn', - '@typescript-eslint/consistent-type-definitions': 'warn', - 'prefer-const': 'warn', - 'no-console': 'off' + // Core TypeScript rules + '@typescript-eslint/no-unused-vars': 'warn', // Quick scan for unused variables + 'no-undef': 'warn', // Prevent use of undefined variables + '@typescript-eslint/no-redeclare': 'warn', // Prevent variable redeclaration + 'no-extra-semi': 'warn', // Check for unnecessary semicolons + 'no-constant-condition': 'warn', // Warn about constant conditions in control statements + 'no-console': 'off', // Allow console.log }, }, { @@ -32,10 +34,12 @@ export default [ }, }, rules: { - 'no-unused-vars': 'warn', - 'consistent-return': 'warn', - 'prefer-const': 'warn', - 'no-console': 'off', + 'no-unused-vars': 'warn', // Warn about unused variables + 'no-undef': 'warn', // Prevent use of undefined variables + 'no-redeclare': 'warn', // Prevent variable redeclaration + 'no-extra-semi': 'warn', // Check for unnecessary semicolons + 'no-constant-condition': 'warn', // Warn about constant conditions in control statements + 'no-console': 'off', // Allow console.log }, }, ]; \ No newline at end of file diff --git a/src/busFactor.ts b/src/busFactor.ts index 92006d7..fc5711b 100644 --- a/src/busFactor.ts +++ b/src/busFactor.ts @@ -109,18 +109,18 @@ export function calculateBusFactor(contributors: CommitNode[]): number { }); // Log the number of commits per contributor - logMessage('INFO', 'Commit count by author:'); + logMessage('DEBUG', 'Commit count by author:'); Object.entries(commitCountByAuthor).forEach(([author, count]) => { - logMessage('INFO', `${author}: ${count} commits`); + logMessage('DEBUG', `${author}: ${count} commits`); }); // Sort contributors by commit count const sortedContributors = Object.entries(commitCountByAuthor).sort((a, b) => b[1] - a[1]); // Log the sorted contributors - logMessage('INFO', 'Sorted contributors by commit count:'); + logMessage('DEBUG', 'Sorted contributors by commit count:'); sortedContributors.forEach(([author, count]) => { - logMessage('INFO', `${author}: ${count} commits`); + logMessage('DEBUG', `${author}: ${count} commits`); }); // Calculate the bus factor (e.g., contributors covering 50% of the total commits) diff --git a/src/correctness.ts b/src/correctness.ts index 5fa99e7..d1471db 100644 --- a/src/correctness.ts +++ b/src/correctness.ts @@ -10,13 +10,36 @@ export async function cleanUp(repoDir: string): Promise { logMessage('INFO', `Cleaning up ${repoDir}`); try { await fs.rm(repoDir, { recursive: true, force: true }); - await new Promise(resolve => setTimeout(resolve, 5000)); - logMessage('INFO', 'Repository contents cleaned up successfully'); + + // Retry logic: Check if directory is truly deleted + const maxRetries = 5; + const delayBetweenRetries = 500; // 0.5 seconds between retries + let retries = 0; + let dirExists = true; + + while (retries < maxRetries && dirExists) { + try { + await fs.access(repoDir); + logMessage('INFO', `Directory still exists after removal attempt. Retrying...`); + await new Promise(resolve => setTimeout(resolve, delayBetweenRetries)); + } catch { + // Directory doesn't exist anymore + dirExists = false; + } + retries++; + } + + if (dirExists) { + logMessage('ERROR', `Failed to fully clean up ${repoDir} after ${maxRetries} retries`); + } else { + logMessage('INFO', 'Repository contents cleaned up successfully'); + } } catch (error) { logMessage('ERROR', `Error cleaning up repository contents: ${error instanceof Error ? error.message : String(error)}`); } } + export async function ensureRepoDir(repoDir: string): Promise { try { await fs.access(repoDir); diff --git a/src/irmMetric.ts b/src/irmMetric.ts index 86f6188..4473a77 100644 --- a/src/irmMetric.ts +++ b/src/irmMetric.ts @@ -150,7 +150,7 @@ export function calculateIRM(issues: IssueNode[]) { const averageResponseTime = issueCount > 0 ? totalResponseTime / issueCount : 0; - logMessage('INFO', `Calculated IRM (Average Issue Response Time): ${averageResponseTime} minutes`); + logMessage('DEBUG', `Calculated IRM (Average Issue Response Time): ${averageResponseTime} minutes`); // Normalize IRM to a score between 0 and 1 return normalizeIRM(averageResponseTime, maxResponseTime); @@ -178,7 +178,7 @@ export function calculateIRM(issues: IssueNode[]) { export function normalizeIRM (averageResponseTime: number, maxResponseTime: number) { // Clamp response time to maxResponseTime and normalize between 0 and 1 const clampedResponseTime = Math.min(averageResponseTime, maxResponseTime); - logMessage('INFO', `Clamped Response Time: ${clampedResponseTime} minutes`); + logMessage('DEBUG', `Clamped Response Time: ${clampedResponseTime} minutes`); logMessage('INFO', `Normalized IRM Score: ${1 - clampedResponseTime / maxResponseTime}`); return 1 - clampedResponseTime / maxResponseTime;