@aiready/consistency 0.21.9 → 0.21.12
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/.turbo/turbo-build.log +23 -24
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +4 -4
- package/dist/index.mjs +3 -3
- package/package.json +2 -2
- package/src/__tests__/provider.test.ts +6 -34
- package/src/index.ts +3 -3
- package/src/provider.ts +2 -2
- package/dist/__tests__/analyzer.test.d.ts +0 -2
- package/dist/__tests__/analyzer.test.d.ts.map +0 -1
- package/dist/__tests__/analyzer.test.js +0 -157
- package/dist/__tests__/analyzer.test.js.map +0 -1
- package/dist/__tests__/language-filter.test.d.ts +0 -2
- package/dist/__tests__/language-filter.test.d.ts.map +0 -1
- package/dist/__tests__/language-filter.test.js +0 -46
- package/dist/__tests__/language-filter.test.js.map +0 -1
- package/dist/__tests__/scoring.test.d.ts +0 -2
- package/dist/__tests__/scoring.test.d.ts.map +0 -1
- package/dist/__tests__/scoring.test.js +0 -118
- package/dist/__tests__/scoring.test.js.map +0 -1
- package/dist/analyzer.d.ts +0 -7
- package/dist/analyzer.d.ts.map +0 -1
- package/dist/analyzer.js +0 -160
- package/dist/analyzer.js.map +0 -1
- package/dist/analyzers/naming-ast.d.ts +0 -7
- package/dist/analyzers/naming-ast.d.ts.map +0 -1
- package/dist/analyzers/naming-ast.js +0 -253
- package/dist/analyzers/naming-ast.js.map +0 -1
- package/dist/analyzers/naming-constants.d.ts +0 -21
- package/dist/analyzers/naming-constants.d.ts.map +0 -1
- package/dist/analyzers/naming-constants.js +0 -96
- package/dist/analyzers/naming-constants.js.map +0 -1
- package/dist/analyzers/naming-python.d.ts +0 -16
- package/dist/analyzers/naming-python.d.ts.map +0 -1
- package/dist/analyzers/naming-python.js +0 -165
- package/dist/analyzers/naming-python.js.map +0 -1
- package/dist/analyzers/naming.d.ts +0 -6
- package/dist/analyzers/naming.d.ts.map +0 -1
- package/dist/analyzers/naming.js +0 -234
- package/dist/analyzers/naming.js.map +0 -1
- package/dist/analyzers/patterns.d.ts +0 -10
- package/dist/analyzers/patterns.d.ts.map +0 -1
- package/dist/analyzers/patterns.js +0 -197
- package/dist/analyzers/patterns.js.map +0 -1
- package/dist/chunk-2BTBNG6X.mjs +0 -814
- package/dist/chunk-3ZB6FFRL.mjs +0 -661
- package/dist/chunk-5UFRGXSB.mjs +0 -783
- package/dist/chunk-66M3TIO7.mjs +0 -837
- package/dist/chunk-6BM5MV3S.mjs +0 -719
- package/dist/chunk-6H3JHDP7.mjs +0 -832
- package/dist/chunk-7PHHJOGC.mjs +0 -1374
- package/dist/chunk-AASFXGUR.mjs +0 -1622
- package/dist/chunk-AR7DIZLP.mjs +0 -827
- package/dist/chunk-BDDMOIU2.mjs +0 -385
- package/dist/chunk-BMILMNKJ.mjs +0 -1633
- package/dist/chunk-BYY6MD5T.mjs +0 -729
- package/dist/chunk-CA4Q5JBK.mjs +0 -1143
- package/dist/chunk-CF4LU7KE.mjs +0 -384
- package/dist/chunk-CJINEUIH.mjs +0 -1369
- package/dist/chunk-CLWNLHDB.mjs +0 -909
- package/dist/chunk-CZUJTDNH.mjs +0 -848
- package/dist/chunk-DNGW3WQK.mjs +0 -810
- package/dist/chunk-DSI3TEO2.mjs +0 -662
- package/dist/chunk-EIQ5K6OO.mjs +0 -1579
- package/dist/chunk-FEJODRK5.mjs +0 -783
- package/dist/chunk-FK56AZ43.mjs +0 -817
- package/dist/chunk-H6S7WKSQ.mjs +0 -729
- package/dist/chunk-HAOJLJNB.mjs +0 -1290
- package/dist/chunk-HJCP36VW.mjs +0 -821
- package/dist/chunk-HPG7P6PD.mjs +0 -1372
- package/dist/chunk-IVRBV7SE.mjs +0 -1295
- package/dist/chunk-IXBC6GVT.mjs +0 -832
- package/dist/chunk-J5IFYDVU.mjs +0 -1579
- package/dist/chunk-KWQVBF7K.mjs +0 -831
- package/dist/chunk-LD3CHHU2.mjs +0 -1297
- package/dist/chunk-LMOXGPCM.mjs +0 -722
- package/dist/chunk-LSXZH6X6.mjs +0 -810
- package/dist/chunk-LUAREV6A.mjs +0 -508
- package/dist/chunk-MAPVFXBP.mjs +0 -708
- package/dist/chunk-MM2PLUCH.mjs +0 -1376
- package/dist/chunk-NPWCJZUG.mjs +0 -708
- package/dist/chunk-ON73WHHU.mjs +0 -1310
- package/dist/chunk-P6NVKUBB.mjs +0 -831
- package/dist/chunk-Q3KTWDSL.mjs +0 -808
- package/dist/chunk-Q5XMWG33.mjs +0 -661
- package/dist/chunk-QOIPVP6P.mjs +0 -1607
- package/dist/chunk-RMEQWG52.mjs +0 -1633
- package/dist/chunk-S6BZVTWN.mjs +0 -731
- package/dist/chunk-TE6JYZD3.mjs +0 -810
- package/dist/chunk-TLVLM3M5.mjs +0 -771
- package/dist/chunk-TXHPUU7A.mjs +0 -863
- package/dist/chunk-UMBBTNQN.mjs +0 -787
- package/dist/chunk-V2UPXL7L.mjs +0 -842
- package/dist/chunk-VODCPPET.mjs +0 -1292
- package/dist/chunk-W6UGMKRV.mjs +0 -1310
- package/dist/chunk-WGH4TGZ3.mjs +0 -1288
- package/dist/chunk-WTBDNCEN.mjs +0 -1352
- package/dist/chunk-XVW5DKJQ.mjs +0 -1619
- package/dist/chunk-YCDCIOJN.mjs +0 -842
- package/dist/chunk-YEHXYHGY.mjs +0 -1497
- package/dist/chunk-YHHXE2JX.mjs +0 -912
- package/dist/chunk-ZB6UK276.mjs +0 -662
- package/dist/chunk-ZG3KFSD3.mjs +0 -1142
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/scoring.d.ts +0 -12
- package/dist/scoring.d.ts.map +0 -1
- package/dist/scoring.js +0 -110
- package/dist/scoring.js.map +0 -1
- package/dist/types.d.ts +0 -53
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/utils/ast-parser.d.ts +0 -46
- package/dist/utils/ast-parser.d.ts.map +0 -1
- package/dist/utils/ast-parser.js +0 -157
- package/dist/utils/ast-parser.js.map +0 -1
- package/dist/utils/config-loader.d.ts +0 -19
- package/dist/utils/config-loader.d.ts.map +0 -1
- package/dist/utils/config-loader.js +0 -31
- package/dist/utils/config-loader.js.map +0 -1
- package/dist/utils/context-detector.d.ts +0 -40
- package/dist/utils/context-detector.d.ts.map +0 -1
- package/dist/utils/context-detector.js +0 -225
- package/dist/utils/context-detector.js.map +0 -1
- package/dist/utils/scope-tracker.d.ts +0 -87
- package/dist/utils/scope-tracker.d.ts.map +0 -1
- package/dist/utils/scope-tracker.js +0 -161
- package/dist/utils/scope-tracker.js.map +0 -1
package/dist/analyzer.js
DELETED
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import { scanFiles } from '@aiready/core';
|
|
2
|
-
import { analyzeNamingAST } from './analyzers/naming-ast';
|
|
3
|
-
import { analyzePythonNaming } from './analyzers/naming-python';
|
|
4
|
-
import { analyzePatterns } from './analyzers/patterns';
|
|
5
|
-
/**
|
|
6
|
-
* Main consistency analyzer that orchestrates all analysis types
|
|
7
|
-
* Supports: TypeScript, JavaScript, Python
|
|
8
|
-
*/
|
|
9
|
-
export async function analyzeConsistency(options) {
|
|
10
|
-
const { checkNaming = true, checkPatterns = true, checkArchitecture = false, // Not implemented yet
|
|
11
|
-
minSeverity = 'info', ...scanOptions } = options;
|
|
12
|
-
// Scan files
|
|
13
|
-
const filePaths = await scanFiles(scanOptions);
|
|
14
|
-
// Separate files by language
|
|
15
|
-
const tsJsFiles = filePaths.filter(f => /\.(ts|tsx|js|jsx)$/i.test(f));
|
|
16
|
-
const pythonFiles = filePaths.filter(f => /\.py$/i.test(f));
|
|
17
|
-
// Collect issues by category - now handles multiple languages
|
|
18
|
-
let namingIssues = [];
|
|
19
|
-
if (checkNaming) {
|
|
20
|
-
const tsJsNamingIssues = tsJsFiles.length > 0 ? await analyzeNamingAST(tsJsFiles) : [];
|
|
21
|
-
const pythonNamingIssues = pythonFiles.length > 0 ? await analyzePythonNaming(pythonFiles) : [];
|
|
22
|
-
namingIssues = [...tsJsNamingIssues, ...pythonNamingIssues];
|
|
23
|
-
}
|
|
24
|
-
const patternIssues = checkPatterns ? await analyzePatterns(filePaths) : [];
|
|
25
|
-
// Convert to AnalysisResult format
|
|
26
|
-
const results = [];
|
|
27
|
-
const fileIssuesMap = new Map();
|
|
28
|
-
// Process naming issues
|
|
29
|
-
for (const issue of namingIssues) {
|
|
30
|
-
if (!shouldIncludeSeverity(issue.severity, minSeverity)) {
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
const consistencyIssue = {
|
|
34
|
-
type: issue.type === 'convention-mix' ? 'naming-inconsistency' : 'naming-quality',
|
|
35
|
-
category: 'naming',
|
|
36
|
-
severity: issue.severity,
|
|
37
|
-
message: `${issue.type}: ${issue.identifier}`,
|
|
38
|
-
location: {
|
|
39
|
-
file: issue.file,
|
|
40
|
-
line: issue.line,
|
|
41
|
-
column: issue.column
|
|
42
|
-
},
|
|
43
|
-
suggestion: issue.suggestion
|
|
44
|
-
};
|
|
45
|
-
if (!fileIssuesMap.has(issue.file)) {
|
|
46
|
-
fileIssuesMap.set(issue.file, []);
|
|
47
|
-
}
|
|
48
|
-
fileIssuesMap.get(issue.file).push(consistencyIssue);
|
|
49
|
-
}
|
|
50
|
-
// Process pattern issues
|
|
51
|
-
for (const issue of patternIssues) {
|
|
52
|
-
if (!shouldIncludeSeverity(issue.severity, minSeverity)) {
|
|
53
|
-
continue;
|
|
54
|
-
}
|
|
55
|
-
const consistencyIssue = {
|
|
56
|
-
type: 'pattern-inconsistency',
|
|
57
|
-
category: 'patterns',
|
|
58
|
-
severity: issue.severity,
|
|
59
|
-
message: issue.description,
|
|
60
|
-
location: {
|
|
61
|
-
file: issue.files[0] || 'multiple files',
|
|
62
|
-
line: 1
|
|
63
|
-
},
|
|
64
|
-
examples: issue.examples,
|
|
65
|
-
suggestion: `Standardize ${issue.type} patterns across ${issue.files.length} files`
|
|
66
|
-
};
|
|
67
|
-
// Add to first file in the pattern
|
|
68
|
-
const firstFile = issue.files[0];
|
|
69
|
-
if (firstFile && !fileIssuesMap.has(firstFile)) {
|
|
70
|
-
fileIssuesMap.set(firstFile, []);
|
|
71
|
-
}
|
|
72
|
-
if (firstFile) {
|
|
73
|
-
fileIssuesMap.get(firstFile).push(consistencyIssue);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
// Convert to AnalysisResult format
|
|
77
|
-
for (const [fileName, issues] of fileIssuesMap) {
|
|
78
|
-
results.push({
|
|
79
|
-
fileName,
|
|
80
|
-
issues: issues,
|
|
81
|
-
metrics: {
|
|
82
|
-
consistencyScore: calculateConsistencyScore(issues)
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
// Sort results by severity first, then by issue count per file
|
|
87
|
-
results.sort((fileResultA, fileResultB) => {
|
|
88
|
-
const severityOrder = { critical: 0, major: 1, minor: 2, info: 3 };
|
|
89
|
-
// Get highest severity in each file
|
|
90
|
-
const maxSeverityA = Math.min(...fileResultA.issues.map(i => severityOrder[i.severity]));
|
|
91
|
-
const maxSeverityB = Math.min(...fileResultB.issues.map(i => severityOrder[i.severity]));
|
|
92
|
-
// Sort by severity first
|
|
93
|
-
if (maxSeverityA !== maxSeverityB) {
|
|
94
|
-
return maxSeverityA - maxSeverityB;
|
|
95
|
-
}
|
|
96
|
-
// Then by issue count (descending)
|
|
97
|
-
return fileResultB.issues.length - fileResultA.issues.length;
|
|
98
|
-
});
|
|
99
|
-
// Generate recommendations
|
|
100
|
-
const recommendations = generateRecommendations(namingIssues, patternIssues);
|
|
101
|
-
// Compute filtered counts (respecting minSeverity) to report accurate summary
|
|
102
|
-
const namingCountFiltered = namingIssues.filter(i => shouldIncludeSeverity(i.severity, minSeverity)).length;
|
|
103
|
-
const patternCountFiltered = patternIssues.filter(i => shouldIncludeSeverity(i.severity, minSeverity)).length;
|
|
104
|
-
// Detect naming conventions (TODO: re-implement for AST version)
|
|
105
|
-
// const conventionAnalysis = detectNamingConventions(filePaths, namingIssues);
|
|
106
|
-
return {
|
|
107
|
-
summary: {
|
|
108
|
-
totalIssues: namingCountFiltered + patternCountFiltered,
|
|
109
|
-
namingIssues: namingCountFiltered,
|
|
110
|
-
patternIssues: patternCountFiltered,
|
|
111
|
-
architectureIssues: 0,
|
|
112
|
-
filesAnalyzed: filePaths.length
|
|
113
|
-
},
|
|
114
|
-
results,
|
|
115
|
-
recommendations
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
function shouldIncludeSeverity(severity, minSeverity) {
|
|
119
|
-
const severityLevels = { info: 0, minor: 1, major: 2, critical: 3 };
|
|
120
|
-
return severityLevels[severity] >= severityLevels[minSeverity];
|
|
121
|
-
}
|
|
122
|
-
function calculateConsistencyScore(issues) {
|
|
123
|
-
// Higher score = more consistent (fewer issues)
|
|
124
|
-
const weights = { critical: 10, major: 5, minor: 2, info: 1 };
|
|
125
|
-
const totalWeight = issues.reduce((sum, issue) => sum + weights[issue.severity], 0);
|
|
126
|
-
// Score from 0-1, where 1 is perfect
|
|
127
|
-
return Math.max(0, 1 - totalWeight / 100);
|
|
128
|
-
}
|
|
129
|
-
function generateRecommendations(namingIssues, patternIssues) {
|
|
130
|
-
const recommendations = [];
|
|
131
|
-
if (namingIssues.length > 0) {
|
|
132
|
-
const conventionMixCount = namingIssues.filter(i => i.type === 'convention-mix').length;
|
|
133
|
-
if (conventionMixCount > 0) {
|
|
134
|
-
recommendations.push(`Standardize naming conventions: Found ${conventionMixCount} snake_case variables in TypeScript/JavaScript (use camelCase)`);
|
|
135
|
-
}
|
|
136
|
-
const poorNamingCount = namingIssues.filter(i => i.type === 'poor-naming').length;
|
|
137
|
-
if (poorNamingCount > 0) {
|
|
138
|
-
recommendations.push(`Improve variable naming: Found ${poorNamingCount} single-letter or unclear variable names`);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
if (patternIssues.length > 0) {
|
|
142
|
-
const errorHandlingIssues = patternIssues.filter(i => i.type === 'error-handling');
|
|
143
|
-
if (errorHandlingIssues.length > 0) {
|
|
144
|
-
recommendations.push('Standardize error handling strategy across the codebase (prefer try-catch with typed errors)');
|
|
145
|
-
}
|
|
146
|
-
const asyncIssues = patternIssues.filter(i => i.type === 'async-style');
|
|
147
|
-
if (asyncIssues.length > 0) {
|
|
148
|
-
recommendations.push('Use async/await consistently instead of mixing with promise chains or callbacks');
|
|
149
|
-
}
|
|
150
|
-
const importIssues = patternIssues.filter(i => i.type === 'import-style');
|
|
151
|
-
if (importIssues.length > 0) {
|
|
152
|
-
recommendations.push('Use ES modules consistently across the project (avoid mixing with CommonJS)');
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
if (recommendations.length === 0) {
|
|
156
|
-
recommendations.push('No major consistency issues found! Your codebase follows good practices.');
|
|
157
|
-
}
|
|
158
|
-
return recommendations;
|
|
159
|
-
}
|
|
160
|
-
//# sourceMappingURL=analyzer.js.map
|
package/dist/analyzer.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"analyzer.js","sourceRoot":"","sources":["../src/analyzer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,OAA2B;IAE3B,MAAM,EACJ,WAAW,GAAG,IAAI,EAClB,aAAa,GAAG,IAAI,EACpB,iBAAiB,GAAG,KAAK,EAAE,sBAAsB;IACjD,WAAW,GAAG,MAAM,EACpB,GAAG,WAAW,EACf,GAAG,OAAO,CAAC;IAEZ,aAAa;IACb,MAAM,SAAS,GAAG,MAAM,S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J,CAAC;QAED,MAAM,WAAW,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,aAAa,CAAC,CAAC;QACxE,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3B,eAAe,CAAC,IAAI,CAClB,iFAAiF,CAClF,CAAC;QACJ,CAAC;QAED,MAAM,YAAY,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,cAAc,CAAC,CAAC;QAC1E,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC5B,eAAe,CAAC,IAAI,CAClB,6EAA6E,CAC9E,CAAC;QACJ,CAAC;IACH,CAAC;IAED,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACjC,eAAe,CAAC,IAAI,CAAC,0EAA0E,CAAC,CAAC;IACnG,CAAC;IAED,OAAO,eAAe,CAAC;AACzB,CAAC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { NamingIssue } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* AST-based naming analyzer
|
|
4
|
-
* Only supports TypeScript/JavaScript files (.ts, .tsx, .js, .jsx)
|
|
5
|
-
*/
|
|
6
|
-
export declare function analyzeNamingAST(files: string[]): Promise<NamingIssue[]>;
|
|
7
|
-
//# sourceMappingURL=naming-ast.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"naming-ast.d.ts","sourceRoot":"","sources":["../../src/analyzers/naming-ast.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAmB5C;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CA8B9E"}
|
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
import { parseFile, traverseAST, getFunctionName, getLineNumber, isCoverageContext, isLoopStatement, } from '../utils/ast-parser';
|
|
2
|
-
import { ScopeTracker } from '../utils/scope-tracker';
|
|
3
|
-
import { buildCodeContext, adjustSeverity, isAcceptableInContext, calculateComplexity, } from '../utils/context-detector';
|
|
4
|
-
import { loadNamingConfig } from '../utils/config-loader';
|
|
5
|
-
/**
|
|
6
|
-
* AST-based naming analyzer
|
|
7
|
-
* Only supports TypeScript/JavaScript files (.ts, .tsx, .js, .jsx)
|
|
8
|
-
*/
|
|
9
|
-
export async function analyzeNamingAST(files) {
|
|
10
|
-
const issues = [];
|
|
11
|
-
// Load and merge configuration
|
|
12
|
-
const { allAbbreviations, allShortWords, disabledChecks } = await loadNamingConfig(files);
|
|
13
|
-
// Filter to only JS/TS files that the TypeScript parser can handle
|
|
14
|
-
const supportedFiles = files.filter(file => /\.(js|jsx|ts|tsx)$/i.test(file));
|
|
15
|
-
for (const file of supportedFiles) {
|
|
16
|
-
try {
|
|
17
|
-
const ast = parseFile(file);
|
|
18
|
-
if (!ast)
|
|
19
|
-
continue; // Skip files that fail to parse
|
|
20
|
-
const fileIssues = analyzeFileNamingAST(file, ast, allAbbreviations, allShortWords, disabledChecks);
|
|
21
|
-
issues.push(...fileIssues);
|
|
22
|
-
}
|
|
23
|
-
catch (error) {
|
|
24
|
-
console.warn(`Skipping ${file} due to parse error:`, error);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return issues;
|
|
28
|
-
}
|
|
29
|
-
function analyzeFileNamingAST(file, ast, allAbbreviations, allShortWords, disabledChecks) {
|
|
30
|
-
const issues = [];
|
|
31
|
-
const scopeTracker = new ScopeTracker(ast);
|
|
32
|
-
const context = buildCodeContext(file, ast);
|
|
33
|
-
const ancestors = [];
|
|
34
|
-
// First pass: Build scope tree and track all variables
|
|
35
|
-
traverseAST(ast, {
|
|
36
|
-
enter: (node, parent) => {
|
|
37
|
-
ancestors.push(node);
|
|
38
|
-
// Enter scopes
|
|
39
|
-
if (node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression' || node.type === 'ArrowFunctionExpression') {
|
|
40
|
-
scopeTracker.enterScope('function', node);
|
|
41
|
-
// Track parameters
|
|
42
|
-
if ('params' in node) {
|
|
43
|
-
for (const param of node.params) {
|
|
44
|
-
if (param.type === 'Identifier') {
|
|
45
|
-
scopeTracker.declareVariable(param.name, param, getLineNumber(param), {
|
|
46
|
-
isParameter: true,
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
else if (param.type === 'ObjectPattern' || param.type === 'ArrayPattern') {
|
|
50
|
-
// Handle destructured parameters
|
|
51
|
-
extractIdentifiersFromPattern(param, scopeTracker, true);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
else if (node.type === 'BlockStatement') {
|
|
57
|
-
scopeTracker.enterScope('block', node);
|
|
58
|
-
}
|
|
59
|
-
else if (isLoopStatement(node)) {
|
|
60
|
-
scopeTracker.enterScope('loop', node);
|
|
61
|
-
}
|
|
62
|
-
else if (node.type === 'ClassDeclaration') {
|
|
63
|
-
scopeTracker.enterScope('class', node);
|
|
64
|
-
}
|
|
65
|
-
// Track variable declarations
|
|
66
|
-
if (node.type === 'VariableDeclarator') {
|
|
67
|
-
if (node.id.type === 'Identifier') {
|
|
68
|
-
const isInCoverage = isCoverageContext(node, ancestors);
|
|
69
|
-
scopeTracker.declareVariable(node.id.name, node.id, getLineNumber(node.id), {
|
|
70
|
-
type: ('typeAnnotation' in node.id) ? node.id.typeAnnotation : null,
|
|
71
|
-
isDestructured: false,
|
|
72
|
-
isLoopVariable: scopeTracker.getCurrentScopeType() === 'loop',
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
else if (node.id.type === 'ObjectPattern' || node.id.type === 'ArrayPattern') {
|
|
76
|
-
extractIdentifiersFromPattern(node.id, scopeTracker, false, ancestors);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
// Track references
|
|
80
|
-
if (node.type === 'Identifier' && parent) {
|
|
81
|
-
// Only count as reference if it's not a declaration
|
|
82
|
-
if (parent.type !== 'VariableDeclarator' || parent.id !== node) {
|
|
83
|
-
if (parent.type !== 'FunctionDeclaration' || parent.id !== node) {
|
|
84
|
-
scopeTracker.addReference(node.name, node);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
leave: (node) => {
|
|
90
|
-
ancestors.pop();
|
|
91
|
-
// Exit scopes
|
|
92
|
-
if (node.type === 'FunctionDeclaration' ||
|
|
93
|
-
node.type === 'FunctionExpression' ||
|
|
94
|
-
node.type === 'ArrowFunctionExpression' ||
|
|
95
|
-
node.type === 'BlockStatement' ||
|
|
96
|
-
isLoopStatement(node) ||
|
|
97
|
-
node.type === 'ClassDeclaration') {
|
|
98
|
-
scopeTracker.exitScope();
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
});
|
|
102
|
-
// Second pass: Analyze all variables
|
|
103
|
-
const allVariables = scopeTracker.getAllVariables();
|
|
104
|
-
for (const varInfo of allVariables) {
|
|
105
|
-
const name = varInfo.name;
|
|
106
|
-
const line = varInfo.declarationLine;
|
|
107
|
-
// Skip if checks are disabled
|
|
108
|
-
if (disabledChecks.has('single-letter') && name.length === 1)
|
|
109
|
-
continue;
|
|
110
|
-
if (disabledChecks.has('abbreviation') && name.length <= 3)
|
|
111
|
-
continue;
|
|
112
|
-
// Check coverage context
|
|
113
|
-
const isInCoverage = ['s', 'b', 'f', 'l'].includes(name) && varInfo.isDestructured;
|
|
114
|
-
if (isInCoverage)
|
|
115
|
-
continue;
|
|
116
|
-
// Check if acceptable in context
|
|
117
|
-
const functionComplexity = varInfo.node.type === 'Identifier' && 'parent' in varInfo.node
|
|
118
|
-
? calculateComplexity(varInfo.node)
|
|
119
|
-
: context.complexity;
|
|
120
|
-
if (isAcceptableInContext(name, context, {
|
|
121
|
-
isLoopVariable: varInfo.isLoopVariable || allAbbreviations.has(name),
|
|
122
|
-
isParameter: varInfo.isParameter,
|
|
123
|
-
isDestructured: varInfo.isDestructured,
|
|
124
|
-
complexity: functionComplexity,
|
|
125
|
-
})) {
|
|
126
|
-
continue;
|
|
127
|
-
}
|
|
128
|
-
// Single letter check
|
|
129
|
-
if (name.length === 1 && !allAbbreviations.has(name) && !allShortWords.has(name)) {
|
|
130
|
-
// Check if short-lived
|
|
131
|
-
const isShortLived = scopeTracker.isShortLived(varInfo, 5);
|
|
132
|
-
if (!isShortLived) {
|
|
133
|
-
issues.push({
|
|
134
|
-
file,
|
|
135
|
-
line,
|
|
136
|
-
type: 'poor-naming',
|
|
137
|
-
identifier: name,
|
|
138
|
-
severity: adjustSeverity('minor', context, 'poor-naming'),
|
|
139
|
-
suggestion: `Use descriptive variable name instead of single letter '${name}'`,
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
continue;
|
|
143
|
-
}
|
|
144
|
-
// Abbreviation check (2-3 letters)
|
|
145
|
-
if (name.length >= 2 && name.length <= 3) {
|
|
146
|
-
if (!allShortWords.has(name.toLowerCase()) && !allAbbreviations.has(name.toLowerCase())) {
|
|
147
|
-
// Check if short-lived for abbreviations too
|
|
148
|
-
const isShortLived = scopeTracker.isShortLived(varInfo, 5);
|
|
149
|
-
if (!isShortLived) {
|
|
150
|
-
issues.push({
|
|
151
|
-
file,
|
|
152
|
-
line,
|
|
153
|
-
type: 'abbreviation',
|
|
154
|
-
identifier: name,
|
|
155
|
-
severity: adjustSeverity('info', context, 'abbreviation'),
|
|
156
|
-
suggestion: `Consider using full word instead of abbreviation '${name}'`,
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
continue;
|
|
161
|
-
}
|
|
162
|
-
// Snake_case check for TypeScript/JavaScript
|
|
163
|
-
if (!disabledChecks.has('convention-mix') && file.match(/\.(ts|tsx|js|jsx)$/)) {
|
|
164
|
-
if (name.includes('_') && !name.startsWith('_') && name.toLowerCase() === name) {
|
|
165
|
-
const camelCase = name.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
166
|
-
issues.push({
|
|
167
|
-
file,
|
|
168
|
-
line,
|
|
169
|
-
type: 'convention-mix',
|
|
170
|
-
identifier: name,
|
|
171
|
-
severity: adjustSeverity('minor', context, 'convention-mix'),
|
|
172
|
-
suggestion: `Use camelCase '${camelCase}' instead of snake_case in TypeScript/JavaScript`,
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
// Third pass: Analyze function names
|
|
178
|
-
if (!disabledChecks.has('unclear')) {
|
|
179
|
-
traverseAST(ast, {
|
|
180
|
-
enter: (node) => {
|
|
181
|
-
if (node.type === 'FunctionDeclaration' || node.type === 'MethodDefinition') {
|
|
182
|
-
const name = getFunctionName(node);
|
|
183
|
-
if (!name)
|
|
184
|
-
return;
|
|
185
|
-
const line = getLineNumber(node);
|
|
186
|
-
// Skip entry points
|
|
187
|
-
if (['main', 'init', 'setup', 'bootstrap'].includes(name))
|
|
188
|
-
return;
|
|
189
|
-
// Check for action verbs and patterns
|
|
190
|
-
const hasActionVerb = name.match(/^(get|set|is|has|can|should|create|update|delete|fetch|load|save|process|handle|validate|check|find|search|filter|map|reduce|make|do|run|start|stop|build|parse|format|render|calculate|compute|generate|transform|convert|normalize|sanitize|encode|decode|compress|extract|merge|split|join|sort|compare|test|verify|ensure|apply|execute|invoke|call|emit|dispatch|trigger|listen|subscribe|unsubscribe|add|remove|clear|reset|toggle|enable|disable|open|close|connect|disconnect|send|receive|read|write|import|export|register|unregister|mount|unmount|track|store|persist|upsert|derive|classify|combine|discover|activate|require|assert|expect|mask|escape|sign|put|list|complete|page|safe|mock|pick|pluralize|text|count|detect|select)/);
|
|
191
|
-
const isFactoryPattern = name.match(/(Factory|Builder|Creator|Generator|Provider|Adapter|Mock)$/);
|
|
192
|
-
const isEventHandler = name.match(/^on[A-Z]/);
|
|
193
|
-
const isDescriptiveLong = name.length > 15;
|
|
194
|
-
const isReactHook = name.match(/^use[A-Z]/);
|
|
195
|
-
const isHelperPattern = name.match(/^(to|from|with|without|for|as|into)\w+/) ||
|
|
196
|
-
name.match(/^\w+(To|From|With|Without|For|As|Into)\w*$/); // xForY, xToY patterns
|
|
197
|
-
const isUtilityName = ['cn', 'proxy', 'sitemap', 'robots', 'gtag'].includes(name);
|
|
198
|
-
const isLanguageKeyword = ['constructor', 'toString', 'valueOf', 'toJSON'].includes(name);
|
|
199
|
-
const isFrameworkPattern = name.match(/^(goto|fill|click|select|submit|wait|expect)\w*/); // Page Object Model, test framework patterns
|
|
200
|
-
// Descriptive patterns: countX, totalX, etc.
|
|
201
|
-
const isDescriptivePattern = name.match(/^(default|total|count|sum|avg|max|min|initial|current|previous|next)\w+/) ||
|
|
202
|
-
name.match(/\w+(Count|Total|Sum|Average|List|Map|Set|Config|Settings|Options|Props|Data|Info|Details|State|Status|Response|Result)$/);
|
|
203
|
-
// Count capital letters for compound detection
|
|
204
|
-
const capitalCount = (name.match(/[A-Z]/g) || []).length;
|
|
205
|
-
const isCompoundWord = capitalCount >= 3; // daysSinceLastCommit has 4 capitals
|
|
206
|
-
if (!hasActionVerb && !isFactoryPattern && !isEventHandler && !isDescriptiveLong && !isReactHook && !isHelperPattern && !isUtilityName && !isDescriptivePattern && !isCompoundWord && !isLanguageKeyword && !isFrameworkPattern) {
|
|
207
|
-
issues.push({
|
|
208
|
-
file,
|
|
209
|
-
line,
|
|
210
|
-
type: 'unclear',
|
|
211
|
-
identifier: name,
|
|
212
|
-
severity: adjustSeverity('info', context, 'unclear'),
|
|
213
|
-
suggestion: `Function '${name}' should start with an action verb (get, set, create, etc.)`,
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
},
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
return issues;
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Extract all identifiers from a destructuring pattern
|
|
224
|
-
*/
|
|
225
|
-
function extractIdentifiersFromPattern(pattern, scopeTracker, isParameter, ancestors) {
|
|
226
|
-
if (pattern.type === 'ObjectPattern') {
|
|
227
|
-
for (const prop of pattern.properties) {
|
|
228
|
-
if (prop.type === 'Property' && prop.value.type === 'Identifier') {
|
|
229
|
-
scopeTracker.declareVariable(prop.value.name, prop.value, getLineNumber(prop.value), {
|
|
230
|
-
isParameter,
|
|
231
|
-
isDestructured: true,
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
else if (prop.type === 'RestElement' && prop.argument.type === 'Identifier') {
|
|
235
|
-
scopeTracker.declareVariable(prop.argument.name, prop.argument, getLineNumber(prop.argument), {
|
|
236
|
-
isParameter,
|
|
237
|
-
isDestructured: true,
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
else if (pattern.type === 'ArrayPattern') {
|
|
243
|
-
for (const element of pattern.elements) {
|
|
244
|
-
if (element && element.type === 'Identifier') {
|
|
245
|
-
scopeTracker.declareVariable(element.name, element, getLineNumber(element), {
|
|
246
|
-
isParameter,
|
|
247
|
-
isDestructured: true,
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
//# sourceMappingURL=naming-ast.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"naming-ast.js","sourceRoot":"","sources":["../../src/analyzers/naming-ast.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,SAAS,EACT,WAAW,EACX,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,eAAe,GAEhB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D;;;GAGG;AACH,MAAM,CAAC,KAAK,U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AC,IAAI,KAAK,aAAa,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;gBAC9E,YAAY,CAAC,eAAe,CAC1B,IAAI,CAAC,QAAQ,CAAC,IAAI,EAClB,IAAI,CAAC,QAAQ,EACb,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,EAC5B;oBACE,WAAW;oBACX,cAAc,EAAE,IAAI;iBACrB,CACF,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;SAAM,IAAI,OAAO,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;QAC3C,KAAK,MAAM,OAAO,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;YACvC,IAAI,OAAO,IAAI,OAAO,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;gBAC7C,YAAY,CAAC,eAAe,CAC1B,OAAO,CAAC,IAAI,EACZ,OAAO,EACP,aAAa,CAAC,OAAO,CAAC,EACtB;oBACE,WAAW;oBACX,cAAc,EAAE,IAAI;iBACrB,CACF,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared constants and utilities for naming analysis
|
|
3
|
-
* Extracted from naming.ts and naming-ast.ts to reduce duplication
|
|
4
|
-
*/
|
|
5
|
-
export declare const COMMON_SHORT_WORDS: Set<string>;
|
|
6
|
-
export declare const ACCEPTABLE_ABBREVIATIONS: Set<string>;
|
|
7
|
-
/**
|
|
8
|
-
* Convert snake_case to camelCase
|
|
9
|
-
*/
|
|
10
|
-
export declare function snakeCaseToCamelCase(str: string): string;
|
|
11
|
-
/**
|
|
12
|
-
* Detect naming convention patterns across the codebase
|
|
13
|
-
*/
|
|
14
|
-
export declare function detectNamingConventions(files: string[], allIssues: Array<{
|
|
15
|
-
type: string;
|
|
16
|
-
[key: string]: any;
|
|
17
|
-
}>): {
|
|
18
|
-
dominantConvention: 'camelCase' | 'snake_case' | 'PascalCase' | 'mixed';
|
|
19
|
-
conventionScore: number;
|
|
20
|
-
};
|
|
21
|
-
//# sourceMappingURL=naming-constants.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"naming-constants.d.ts","sourceRoot":"","sources":["../../src/analyzers/naming-constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,eAAO,MAAM,kBAAkB,aAiB7B,CAAC;AAGH,eAAO,MAAM,wBAAwB,aAmDnC,CAAC;AAEH;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAExD;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,MAAM,EAAE,EACf,SAAS,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,CAAC,GACrD;IACD,kBAAkB,EAAE,WAAW,GAAG,YAAY,GAAG,YAAY,GAAG,OAAO,CAAC;IACxE,eAAe,EAAE,MAAM,CAAC;CACzB,CAWA"}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared constants and utilities for naming analysis
|
|
3
|
-
* Extracted from naming.ts and naming-ast.ts to reduce duplication
|
|
4
|
-
*/
|
|
5
|
-
// Common short English words that are NOT abbreviations (full, valid words)
|
|
6
|
-
export const COMMON_SHORT_WORDS = new Set([
|
|
7
|
-
// Full English words (1-3 letters)
|
|
8
|
-
'day', 'key', 'net', 'to', 'go', 'for', 'not', 'new', 'old', 'top', 'end',
|
|
9
|
-
'run', 'try', 'use', 'get', 'set', 'add', 'put', 'map', 'log', 'row', 'col',
|
|
10
|
-
'tab', 'box', 'div', 'nav', 'tag', 'any', 'all', 'one', 'two', 'out', 'off',
|
|
11
|
-
'on', 'yes', 'no', 'now', 'max', 'min', 'sum', 'avg', 'ref', 'src', 'dst',
|
|
12
|
-
'raw', 'def', 'sub', 'pub', 'pre', 'mid', 'alt', 'opt', 'tmp', 'ext', 'sep',
|
|
13
|
-
// Prepositions and conjunctions
|
|
14
|
-
'and', 'from', 'how', 'pad', 'bar', 'non',
|
|
15
|
-
// Additional full words commonly flagged
|
|
16
|
-
'tax', 'cat', 'dog', 'car', 'bus', 'web', 'app', 'war', 'law', 'pay', 'buy',
|
|
17
|
-
'win', 'cut', 'hit', 'hot', 'pop', 'job', 'age', 'act', 'let', 'lot', 'bad',
|
|
18
|
-
'big', 'far', 'few', 'own', 'per', 'red', 'low', 'see', 'six', 'ten', 'way',
|
|
19
|
-
'who', 'why', 'yet', 'via', 'due', 'fee', 'fun', 'gas', 'gay', 'god', 'gun',
|
|
20
|
-
'guy', 'ice', 'ill', 'kid', 'mad', 'man', 'mix', 'mom', 'mrs', 'nor', 'odd',
|
|
21
|
-
'oil', 'pan', 'pet', 'pit', 'pot', 'pow', 'pro', 'raw', 'rep', 'rid', 'sad',
|
|
22
|
-
'sea', 'sit', 'sky', 'son', 'tea', 'tie', 'tip', 'van', 'war', 'win', 'won'
|
|
23
|
-
]);
|
|
24
|
-
// Comprehensive list of acceptable abbreviations and acronyms
|
|
25
|
-
export const ACCEPTABLE_ABBREVIATIONS = new Set([
|
|
26
|
-
// Standard identifiers
|
|
27
|
-
'id', 'uid', 'gid', 'pid',
|
|
28
|
-
// Loop counters and iterators
|
|
29
|
-
'i', 'j', 'k', 'n', 'm',
|
|
30
|
-
// Web/Network
|
|
31
|
-
'url', 'uri', 'api', 'cdn', 'dns', 'ip', 'tcp', 'udp', 'http', 'ssl', 'tls',
|
|
32
|
-
'utm', 'seo', 'rss', 'xhr', 'ajax', 'cors', 'ws', 'wss',
|
|
33
|
-
// Data formats
|
|
34
|
-
'json', 'xml', 'yaml', 'csv', 'html', 'css', 'svg', 'pdf',
|
|
35
|
-
// File types & extensions
|
|
36
|
-
'img', 'txt', 'doc', 'docx', 'xlsx', 'ppt', 'md', 'rst', 'jpg', 'png', 'gif',
|
|
37
|
-
// Databases
|
|
38
|
-
'db', 'sql', 'orm', 'dao', 'dto', 'ddb', 'rds', 'nosql',
|
|
39
|
-
// File system
|
|
40
|
-
'fs', 'dir', 'tmp', 'src', 'dst', 'bin', 'lib', 'pkg',
|
|
41
|
-
// Operating system
|
|
42
|
-
'os', 'env', 'arg', 'cli', 'cmd', 'exe', 'cwd', 'pwd',
|
|
43
|
-
// UI/UX
|
|
44
|
-
'ui', 'ux', 'gui', 'dom', 'ref',
|
|
45
|
-
// Request/Response
|
|
46
|
-
'req', 'res', 'ctx', 'err', 'msg', 'auth',
|
|
47
|
-
// Mathematics/Computing
|
|
48
|
-
'max', 'min', 'avg', 'sum', 'abs', 'cos', 'sin', 'tan', 'log', 'exp',
|
|
49
|
-
'pow', 'sqrt', 'std', 'var', 'int', 'num', 'idx',
|
|
50
|
-
// Time
|
|
51
|
-
'now', 'utc', 'tz', 'ms', 'sec', 'hr', 'min', 'yr', 'mo',
|
|
52
|
-
// Common patterns
|
|
53
|
-
'app', 'cfg', 'config', 'init', 'len', 'val', 'str', 'obj', 'arr',
|
|
54
|
-
'gen', 'def', 'raw', 'new', 'old', 'pre', 'post', 'sub', 'pub',
|
|
55
|
-
// Programming/Framework specific
|
|
56
|
-
'ts', 'js', 'jsx', 'tsx', 'py', 'rb', 'vue', 're', 'fn', 'fns', 'mod', 'opts', 'dev',
|
|
57
|
-
// Cloud/Infrastructure
|
|
58
|
-
's3', 'ec2', 'sqs', 'sns', 'vpc', 'ami', 'iam', 'acl', 'elb', 'alb', 'nlb', 'aws',
|
|
59
|
-
'ses', 'gst', 'cdk', 'btn', 'buf', 'agg', 'ocr', 'ai', 'cf', 'cfn', 'ga',
|
|
60
|
-
// Metrics/Performance
|
|
61
|
-
'fcp', 'lcp', 'cls', 'ttfb', 'tti', 'fid', 'fps', 'qps', 'rps', 'tps', 'wpm',
|
|
62
|
-
// Testing & i18n
|
|
63
|
-
'po', 'e2e', 'a11y', 'i18n', 'l10n', 'spy',
|
|
64
|
-
// Domain-specific abbreviations (context-aware)
|
|
65
|
-
'sk', 'fy', 'faq', 'og', 'seo', 'cta', 'roi', 'kpi', 'ttl', 'pct',
|
|
66
|
-
// Technical abbreviations
|
|
67
|
-
'mac', 'hex', 'esm', 'git', 'rec', 'loc', 'dup',
|
|
68
|
-
// Boolean helpers (these are intentional short names)
|
|
69
|
-
'is', 'has', 'can', 'did', 'was', 'are',
|
|
70
|
-
// Date/Time context (when in date contexts)
|
|
71
|
-
'd', 't', 'dt',
|
|
72
|
-
// Coverage metrics (industry standard: statements/branches/functions/lines)
|
|
73
|
-
's', 'b', 'f', 'l',
|
|
74
|
-
// Common media/content abbreviations
|
|
75
|
-
'vid', 'pic', 'img', 'doc', 'msg'
|
|
76
|
-
]);
|
|
77
|
-
/**
|
|
78
|
-
* Convert snake_case to camelCase
|
|
79
|
-
*/
|
|
80
|
-
export function snakeCaseToCamelCase(str) {
|
|
81
|
-
return str.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Detect naming convention patterns across the codebase
|
|
85
|
-
*/
|
|
86
|
-
export function detectNamingConventions(files, allIssues) {
|
|
87
|
-
// Count conventions
|
|
88
|
-
const camelCaseCount = allIssues.filter(i => i.type === 'convention-mix').length;
|
|
89
|
-
const totalChecks = files.length * 10; // Rough estimate
|
|
90
|
-
if (camelCaseCount / totalChecks > 0.3) {
|
|
91
|
-
return { dominantConvention: 'mixed', conventionScore: 0.5 };
|
|
92
|
-
}
|
|
93
|
-
// For TypeScript/JavaScript, default to camelCase
|
|
94
|
-
return { dominantConvention: 'camelCase', conventionScore: 0.9 };
|
|
95
|
-
}
|
|
96
|
-
//# sourceMappingURL=naming-constants.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"naming-constants.js","sourceRoot":"","sources":["../../src/analyzers/naming-constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,4EAA4E;AAC5E,MAAM,CAAC,MAAM,kB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,CAAC;AACvE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CACrC,KAAe,EACf,SAAsD;IAKtD,oBAAoB;IACpB,MAAM,cAAc,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,gBAAgB,CAAC,CAAC,MAAM,CAAC;IACjF,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,iBAAiB;IAExD,IAAI,cAAc,GAAG,WAAW,GAAG,GAAG,EAAE,CAAC;QACvC,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,eAAe,EAAE,GAAG,EAAE,CAAC;IAC/D,CAAC;IAED,kDAAkD;IAClD,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,eAAe,EAAE,GAAG,EAAE,CAAC;AACnE,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Python Naming Analyzer - PEP 8 Compliant
|
|
3
|
-
*
|
|
4
|
-
* Analyzes Python code for PEP 8 naming convention violations
|
|
5
|
-
* https://peps.python.org/pep-0008/#naming-conventions
|
|
6
|
-
*/
|
|
7
|
-
import type { NamingIssue } from '../types';
|
|
8
|
-
/**
|
|
9
|
-
* Analyze Python files for PEP 8 naming violations
|
|
10
|
-
*/
|
|
11
|
-
export declare function analyzePythonNaming(files: string[]): Promise<NamingIssue[]>;
|
|
12
|
-
/**
|
|
13
|
-
* Detect common Python anti-patterns in naming
|
|
14
|
-
*/
|
|
15
|
-
export declare function detectPythonNamingAntiPatterns(files: string[]): NamingIssue[];
|
|
16
|
-
//# sourceMappingURL=naming-python.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"naming-python.d.ts","sourceRoot":"","sources":["../../src/analyzers/naming-python.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CA2CjF;AAgHD;;GAEG;AACH,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,WAAW,EAAE,CAW7E"}
|