@aiready/consistency 0.8.4 → 0.8.6
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 +7 -7
- package/.turbo/turbo-test.log +10 -7
- package/dist/__tests__/analyzer.test.d.ts +2 -0
- package/dist/__tests__/analyzer.test.d.ts.map +1 -0
- package/dist/__tests__/analyzer.test.js +157 -0
- package/dist/__tests__/analyzer.test.js.map +1 -0
- package/dist/__tests__/language-filter.test.d.ts +2 -0
- package/dist/__tests__/language-filter.test.d.ts.map +1 -0
- package/dist/__tests__/language-filter.test.js +46 -0
- package/dist/__tests__/language-filter.test.js.map +1 -0
- package/dist/__tests__/scoring.test.d.ts +2 -0
- package/dist/__tests__/scoring.test.d.ts.map +1 -0
- package/dist/__tests__/scoring.test.js +118 -0
- package/dist/__tests__/scoring.test.js.map +1 -0
- package/dist/analyzer.d.ts +7 -0
- package/dist/analyzer.d.ts.map +1 -0
- package/dist/analyzer.js +160 -0
- package/dist/analyzer.js.map +1 -0
- package/dist/analyzers/naming-ast.d.ts +7 -0
- package/dist/analyzers/naming-ast.d.ts.map +1 -0
- package/dist/analyzers/naming-ast.js +253 -0
- package/dist/analyzers/naming-ast.js.map +1 -0
- package/dist/analyzers/naming-constants.d.ts +21 -0
- package/dist/analyzers/naming-constants.d.ts.map +1 -0
- package/dist/analyzers/naming-constants.js +96 -0
- package/dist/analyzers/naming-constants.js.map +1 -0
- package/dist/analyzers/naming-python.d.ts +16 -0
- package/dist/analyzers/naming-python.d.ts.map +1 -0
- package/dist/analyzers/naming-python.js +165 -0
- package/dist/analyzers/naming-python.js.map +1 -0
- package/dist/analyzers/naming.d.ts +6 -0
- package/dist/analyzers/naming.d.ts.map +1 -0
- package/dist/analyzers/naming.js +234 -0
- package/dist/analyzers/naming.js.map +1 -0
- package/dist/analyzers/patterns.d.ts +10 -0
- package/dist/analyzers/patterns.d.ts.map +1 -0
- package/dist/analyzers/patterns.js +197 -0
- package/dist/analyzers/patterns.js.map +1 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js.map +1 -0
- package/dist/scoring.d.ts +12 -0
- package/dist/scoring.d.ts.map +1 -0
- package/dist/scoring.js +110 -0
- package/dist/scoring.js.map +1 -0
- package/dist/types.d.ts +53 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/ast-parser.d.ts +46 -0
- package/dist/utils/ast-parser.d.ts.map +1 -0
- package/dist/utils/ast-parser.js +157 -0
- package/dist/utils/ast-parser.js.map +1 -0
- package/dist/utils/config-loader.d.ts +19 -0
- package/dist/utils/config-loader.d.ts.map +1 -0
- package/dist/utils/config-loader.js +31 -0
- package/dist/utils/config-loader.js.map +1 -0
- package/dist/utils/context-detector.d.ts +40 -0
- package/dist/utils/context-detector.d.ts.map +1 -0
- package/dist/utils/context-detector.js +225 -0
- package/dist/utils/context-detector.js.map +1 -0
- package/dist/utils/scope-tracker.d.ts +87 -0
- package/dist/utils/scope-tracker.d.ts.map +1 -0
- package/dist/utils/scope-tracker.js +161 -0
- package/dist/utils/scope-tracker.js.map +1 -0
- package/package.json +2 -2
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,253 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,UAAU,gBAAgB,CAAC,KAAe;IACpD,MAAM,MAAM,GAAkB,EAAE,CAAC;IAEjC,+BAA+B;IAC/B,MAAM,EAAE,gBAAgB,EAAE,aAAa,EAAE,cAAc,EAAE,GAAG,MAAM,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAE1F,mEAAmE;IACnE,MAAM,cAAc,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CACzC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CACjC,CAAC;IAEF,KAAK,MAAM,IAAI,IAAI,cAAc,EAAE,CAAC;QAClC,IAAI,C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AM,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"}
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,96 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"naming-constants.js","sourceRoot":"","sources":["../../src/analyzers/naming-constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,4EAA4E;AAC5E,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC;IACxC,mCAAmC;IACnC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK;IACzE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK;IAC3E,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAA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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"}
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,165 @@
|
|
|
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 { getParser } from '@aiready/core';
|
|
8
|
+
/**
|
|
9
|
+
* Analyze Python files for PEP 8 naming violations
|
|
10
|
+
*/
|
|
11
|
+
export async function analyzePythonNaming(files) {
|
|
12
|
+
const issues = [];
|
|
13
|
+
const parser = getParser('dummy.py'); // Get Python parser instance
|
|
14
|
+
if (!parser) {
|
|
15
|
+
console.warn('Python parser not available');
|
|
16
|
+
return issues;
|
|
17
|
+
}
|
|
18
|
+
// Filter to only Python files
|
|
19
|
+
const pythonFiles = files.filter(f => f.toLowerCase().endsWith('.py'));
|
|
20
|
+
for (const file of pythonFiles) {
|
|
21
|
+
try {
|
|
22
|
+
const fs = await import('fs');
|
|
23
|
+
const code = await fs.promises.readFile(file, 'utf-8');
|
|
24
|
+
const result = parser.parse(code, file);
|
|
25
|
+
// Analyze each export for naming violations
|
|
26
|
+
for (const exp of result.exports) {
|
|
27
|
+
const nameIssue = checkPythonNaming(exp.name, exp.type, file, exp.loc?.start.line || 0);
|
|
28
|
+
if (nameIssue) {
|
|
29
|
+
issues.push(nameIssue);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
// Analyze imports for naming issues (optional, less critical)
|
|
33
|
+
for (const imp of result.imports) {
|
|
34
|
+
for (const spec of imp.specifiers) {
|
|
35
|
+
if (spec !== '*' && spec !== 'default') {
|
|
36
|
+
const nameIssue = checkPythonNaming(spec, 'variable', file, imp.loc?.start.line || 0);
|
|
37
|
+
if (nameIssue) {
|
|
38
|
+
issues.push(nameIssue);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
console.warn(`Skipping ${file} due to error:`, error);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return issues;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Check a Python identifier against PEP 8 conventions
|
|
52
|
+
*/
|
|
53
|
+
function checkPythonNaming(identifier, type, file, line) {
|
|
54
|
+
// Get naming conventions from parser
|
|
55
|
+
const parser = getParser('dummy.py');
|
|
56
|
+
const conventions = parser?.getNamingConventions();
|
|
57
|
+
if (!conventions)
|
|
58
|
+
return null;
|
|
59
|
+
// Skip special methods and exceptions
|
|
60
|
+
if (conventions.exceptions?.includes(identifier)) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
// Check based on type
|
|
64
|
+
if (type === 'class') {
|
|
65
|
+
// Classes should be PascalCase
|
|
66
|
+
if (!conventions.classPattern.test(identifier)) {
|
|
67
|
+
return {
|
|
68
|
+
type: 'poor-naming',
|
|
69
|
+
identifier,
|
|
70
|
+
file,
|
|
71
|
+
line,
|
|
72
|
+
column: 0,
|
|
73
|
+
severity: 'major',
|
|
74
|
+
category: 'naming',
|
|
75
|
+
suggestion: `Class names should use PascalCase (e.g., ${toPascalCase(identifier)})`,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else if (type === 'function') {
|
|
80
|
+
// Functions should be snake_case
|
|
81
|
+
if (!conventions.functionPattern.test(identifier)) {
|
|
82
|
+
// Check if it's incorrectly using camelCase
|
|
83
|
+
if (/^[a-z][a-zA-Z0-9]*$/.test(identifier) && /[A-Z]/.test(identifier)) {
|
|
84
|
+
return {
|
|
85
|
+
type: 'convention-mix',
|
|
86
|
+
identifier,
|
|
87
|
+
file,
|
|
88
|
+
line,
|
|
89
|
+
column: 0,
|
|
90
|
+
severity: 'major',
|
|
91
|
+
category: 'naming',
|
|
92
|
+
suggestion: `Function names should use snake_case, not camelCase (e.g., ${toSnakeCase(identifier)})`,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else if (type === 'const' || type === 'variable') {
|
|
98
|
+
// Check if it looks like a constant (all uppercase)
|
|
99
|
+
if (identifier === identifier.toUpperCase() && identifier.length > 1) {
|
|
100
|
+
// Constants should be UPPER_CASE_WITH_UNDERSCORES
|
|
101
|
+
if (!conventions.constantPattern.test(identifier)) {
|
|
102
|
+
return {
|
|
103
|
+
type: 'poor-naming',
|
|
104
|
+
identifier,
|
|
105
|
+
file,
|
|
106
|
+
line,
|
|
107
|
+
column: 0,
|
|
108
|
+
severity: 'minor',
|
|
109
|
+
category: 'naming',
|
|
110
|
+
suggestion: 'Constants should use UPPER_CASE_WITH_UNDERSCORES',
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
// Regular variables should be snake_case
|
|
116
|
+
if (!conventions.variablePattern.test(identifier)) {
|
|
117
|
+
// Check if it's using camelCase (common mistake from JS/TS developers)
|
|
118
|
+
if (/^[a-z][a-zA-Z0-9]*$/.test(identifier) && /[A-Z]/.test(identifier)) {
|
|
119
|
+
return {
|
|
120
|
+
type: 'convention-mix',
|
|
121
|
+
identifier,
|
|
122
|
+
file,
|
|
123
|
+
line,
|
|
124
|
+
column: 0,
|
|
125
|
+
severity: 'major',
|
|
126
|
+
category: 'naming',
|
|
127
|
+
suggestion: `Variable names should use snake_case, not camelCase (e.g., ${toSnakeCase(identifier)})`,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Convert camelCase to snake_case
|
|
137
|
+
*/
|
|
138
|
+
function toSnakeCase(str) {
|
|
139
|
+
return str
|
|
140
|
+
.replace(/([A-Z])/g, '_$1')
|
|
141
|
+
.toLowerCase()
|
|
142
|
+
.replace(/^_/, '');
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Convert snake_case to PascalCase
|
|
146
|
+
*/
|
|
147
|
+
function toPascalCase(str) {
|
|
148
|
+
return str
|
|
149
|
+
.split('_')
|
|
150
|
+
.map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
151
|
+
.join('');
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Detect common Python anti-patterns in naming
|
|
155
|
+
*/
|
|
156
|
+
export function detectPythonNamingAntiPatterns(files) {
|
|
157
|
+
const issues = [];
|
|
158
|
+
// Anti-pattern 1: Using camelCase in Python (common for JS/TS developers)
|
|
159
|
+
// Anti-pattern 2: Using PascalCase for functions
|
|
160
|
+
// Anti-pattern 3: Not using leading underscore for private methods
|
|
161
|
+
// Anti-pattern 4: Using single letter names outside of comprehensions
|
|
162
|
+
// These will be implemented as we refine the analyzer
|
|
163
|
+
return issues;
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=naming-python.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"naming-python.js","sourceRoot":"","sources":["../../src/analyzers/naming-python.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAY,MAAM,eAAe,CAAC;AAGpD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,KAAe;IACvD,MAAM,MAAM,GAAkB,EAAE,CAAC;IACjC,MAAM,MAAM,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,6BAA6B;IAEnE,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC;QAC5C,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,8BAA8B;IAC9B,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;IAEvE,KAAK,MAAM,IAAI,IAAI,WAAW,EAAE,CAAC;QAC/B,IAAI,CAAC;YACH,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC;YAC9B,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,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