tech-debt-score 0.1.3 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -55,6 +55,12 @@ export class TerminalReporter implements IReporter {
|
|
|
55
55
|
console.log(` ${finding.filePath}${finding.location ? `:${finding.location.startLine}` : ''}`);
|
|
56
56
|
}
|
|
57
57
|
console.log('\n');
|
|
58
|
+
} else if (report.metadata.filesAnalyzed > 0) {
|
|
59
|
+
console.log('✨ No issues found! Your codebase looks clean.');
|
|
60
|
+
console.log('\n');
|
|
61
|
+
} else {
|
|
62
|
+
console.log('❓ No files were analyzed. Check your configuration or directory.');
|
|
63
|
+
console.log('\n');
|
|
58
64
|
}
|
|
59
65
|
|
|
60
66
|
console.log('═'.repeat(60));
|
|
@@ -38,8 +38,16 @@ export interface AnalysisConfig {
|
|
|
38
38
|
* Default configuration values
|
|
39
39
|
*/
|
|
40
40
|
export const DEFAULT_CONFIG: Omit<AnalysisConfig, 'rootPath'> = {
|
|
41
|
-
patterns: ['
|
|
42
|
-
ignore: [
|
|
41
|
+
patterns: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
|
|
42
|
+
ignore: [
|
|
43
|
+
'**/node_modules/**',
|
|
44
|
+
'**/dist/**',
|
|
45
|
+
'**/build/**',
|
|
46
|
+
'**/coverage/**',
|
|
47
|
+
'**/.git/**',
|
|
48
|
+
'**/.next/**',
|
|
49
|
+
'**/out/**',
|
|
50
|
+
],
|
|
43
51
|
weights: {
|
|
44
52
|
complexity: 0.30,
|
|
45
53
|
size: 0.25,
|
|
@@ -34,27 +34,46 @@ export class AnalysisService {
|
|
|
34
34
|
config.patterns,
|
|
35
35
|
config.ignore
|
|
36
36
|
);
|
|
37
|
-
|
|
37
|
+
|
|
38
|
+
if (filePaths.length === 0) {
|
|
39
|
+
console.log(' ❌ No files found matching patterns.');
|
|
40
|
+
console.log(` Root: ${config.rootPath}`);
|
|
41
|
+
console.log(` Patterns: ${config.patterns.join(', ')}`);
|
|
42
|
+
console.log(' Check your directory structure and ensure files exist.');
|
|
43
|
+
} else {
|
|
44
|
+
console.log(` Found ${filePaths.length} files`);
|
|
45
|
+
}
|
|
38
46
|
|
|
39
47
|
// 2. Read and parse files
|
|
40
48
|
console.log('🔍 Parsing files...');
|
|
41
49
|
const allMetrics: Metric[] = [];
|
|
42
50
|
const fileContents = new Map<string, string>();
|
|
43
51
|
|
|
52
|
+
let supportedFilesCount = 0;
|
|
44
53
|
for (const filePath of filePaths) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
+
try {
|
|
55
|
+
const fileResult = await this.fileReader.read(filePath);
|
|
56
|
+
fileContents.set(filePath, fileResult.content);
|
|
57
|
+
|
|
58
|
+
if (this.parser.supports(filePath)) {
|
|
59
|
+
supportedFilesCount++;
|
|
60
|
+
const parseResult = await this.parser.parse(filePath, fileResult.content);
|
|
61
|
+
if (parseResult.success) {
|
|
62
|
+
allMetrics.push(...parseResult.metrics);
|
|
63
|
+
} else {
|
|
64
|
+
console.warn(` ⚠️ Failed to parse ${filePath}: ${parseResult.error}`);
|
|
65
|
+
}
|
|
54
66
|
}
|
|
67
|
+
} catch (err) {
|
|
68
|
+
console.warn(` ⚠️ Error reading ${filePath}: ${err instanceof Error ? err.message : String(err)}`);
|
|
55
69
|
}
|
|
56
70
|
}
|
|
57
|
-
|
|
71
|
+
|
|
72
|
+
if (filePaths.length > 0 && supportedFilesCount === 0) {
|
|
73
|
+
console.log(' ⚠️ None of the found files are supported by the parser (.ts, .js, etc)');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
console.log(` Extracted ${allMetrics.length} metrics from ${supportedFilesCount} files`);
|
|
58
77
|
|
|
59
78
|
// 3. Analyze dependencies and duplication
|
|
60
79
|
console.log('🔗 Analyzing dependencies and duplication...');
|
|
@@ -55,23 +55,9 @@ export async function analyzeCommand(rootPath: string, jsonOutputPath?: string):
|
|
|
55
55
|
);
|
|
56
56
|
|
|
57
57
|
// Build configuration
|
|
58
|
-
//
|
|
59
|
-
//
|
|
60
|
-
|
|
61
|
-
// - If 'src' folder exists, use 'src/**/*.ts'
|
|
62
|
-
// - Otherwise, scan all files in root '**/*.ts'
|
|
63
|
-
const isCwd = resolve(rootPath) === process.cwd();
|
|
64
|
-
const hasSrcFolder = existsSync(resolve(rootPath, 'src'));
|
|
65
|
-
|
|
66
|
-
let defaultPatterns: string[];
|
|
67
|
-
|
|
68
|
-
if (!isCwd) {
|
|
69
|
-
defaultPatterns = ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'];
|
|
70
|
-
} else if (hasSrcFolder) {
|
|
71
|
-
defaultPatterns = DEFAULT_CONFIG.patterns; // ['src/**/*.ts', 'src/**/*.js']
|
|
72
|
-
} else {
|
|
73
|
-
defaultPatterns = ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'];
|
|
74
|
-
}
|
|
58
|
+
// Use broad patterns by default and rely on ignore list for exclusions.
|
|
59
|
+
// This makes the tool structure-agnostic (works for src/, lib/, or root files).
|
|
60
|
+
const defaultPatterns = ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'];
|
|
75
61
|
|
|
76
62
|
const config: AnalysisConfig = {
|
|
77
63
|
rootPath,
|
|
@@ -79,6 +65,11 @@ export async function analyzeCommand(rootPath: string, jsonOutputPath?: string):
|
|
|
79
65
|
patterns: defaultPatterns,
|
|
80
66
|
};
|
|
81
67
|
|
|
68
|
+
// Log scan start for transparency
|
|
69
|
+
if (config.patterns.length > 0) {
|
|
70
|
+
console.log(`📂 Scanning for patterns: ${config.patterns.join(', ')}`);
|
|
71
|
+
}
|
|
72
|
+
|
|
82
73
|
// Execute analysis
|
|
83
74
|
await analysisService.analyze(config);
|
|
84
75
|
|