@girardelli/architect 1.1.0
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/CONTRIBUTING.md +140 -0
- package/LICENSE +21 -0
- package/PROJECT_STRUCTURE.txt +168 -0
- package/README.md +269 -0
- package/dist/analyzer.d.ts +17 -0
- package/dist/analyzer.d.ts.map +1 -0
- package/dist/analyzer.js +254 -0
- package/dist/analyzer.js.map +1 -0
- package/dist/anti-patterns.d.ts +17 -0
- package/dist/anti-patterns.d.ts.map +1 -0
- package/dist/anti-patterns.js +211 -0
- package/dist/anti-patterns.js.map +1 -0
- package/dist/cli.d.ts +15 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +164 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +6 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +73 -0
- package/dist/config.js.map +1 -0
- package/dist/diagram.d.ts +9 -0
- package/dist/diagram.d.ts.map +1 -0
- package/dist/diagram.js +116 -0
- package/dist/diagram.js.map +1 -0
- package/dist/html-reporter.d.ts +23 -0
- package/dist/html-reporter.d.ts.map +1 -0
- package/dist/html-reporter.js +454 -0
- package/dist/html-reporter.js.map +1 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +151 -0
- package/dist/index.js.map +1 -0
- package/dist/reporter.d.ts +13 -0
- package/dist/reporter.d.ts.map +1 -0
- package/dist/reporter.js +135 -0
- package/dist/reporter.js.map +1 -0
- package/dist/scanner.d.ts +25 -0
- package/dist/scanner.d.ts.map +1 -0
- package/dist/scanner.js +288 -0
- package/dist/scanner.js.map +1 -0
- package/dist/scorer.d.ts +15 -0
- package/dist/scorer.d.ts.map +1 -0
- package/dist/scorer.js +172 -0
- package/dist/scorer.js.map +1 -0
- package/dist/types.d.ts +106 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/examples/sample-report.md +207 -0
- package/jest.config.js +18 -0
- package/package.json +70 -0
- package/src/analyzer.ts +310 -0
- package/src/anti-patterns.ts +264 -0
- package/src/cli.ts +183 -0
- package/src/config.ts +82 -0
- package/src/diagram.ts +144 -0
- package/src/html-reporter.ts +485 -0
- package/src/index.ts +212 -0
- package/src/reporter.ts +166 -0
- package/src/scanner.ts +298 -0
- package/src/scorer.ts +193 -0
- package/src/types.ts +114 -0
- package/tests/anti-patterns.test.ts +94 -0
- package/tests/scanner.test.ts +55 -0
- package/tests/scorer.test.ts +80 -0
- package/tsconfig.json +24 -0
package/dist/analyzer.js
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { readFileSync } from 'fs';
|
|
2
|
+
import { extname } from 'path';
|
|
3
|
+
export class ArchitectureAnalyzer {
|
|
4
|
+
constructor(projectPath) {
|
|
5
|
+
this.dependencyGraph = new Map();
|
|
6
|
+
this.fileExtensions = new Map();
|
|
7
|
+
this.projectPath = projectPath;
|
|
8
|
+
}
|
|
9
|
+
analyzeDependencies(fileTree) {
|
|
10
|
+
this.buildDependencyGraph(fileTree);
|
|
11
|
+
return this.buildEdgeList();
|
|
12
|
+
}
|
|
13
|
+
detectLayers(fileTree) {
|
|
14
|
+
const layers = [];
|
|
15
|
+
const apiFiles = [];
|
|
16
|
+
const serviceFiles = [];
|
|
17
|
+
const dataFiles = [];
|
|
18
|
+
const uiFiles = [];
|
|
19
|
+
const infraFiles = [];
|
|
20
|
+
this.categorizeFiles(fileTree, apiFiles, serviceFiles, dataFiles, uiFiles, infraFiles);
|
|
21
|
+
if (apiFiles.length > 0) {
|
|
22
|
+
layers.push({
|
|
23
|
+
name: 'API',
|
|
24
|
+
files: apiFiles,
|
|
25
|
+
description: 'API layer - handles external interfaces and routing',
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
if (serviceFiles.length > 0) {
|
|
29
|
+
layers.push({
|
|
30
|
+
name: 'Service',
|
|
31
|
+
files: serviceFiles,
|
|
32
|
+
description: 'Service layer - business logic and orchestration',
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
if (dataFiles.length > 0) {
|
|
36
|
+
layers.push({
|
|
37
|
+
name: 'Data',
|
|
38
|
+
files: dataFiles,
|
|
39
|
+
description: 'Data layer - database access and persistence',
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
if (uiFiles.length > 0) {
|
|
43
|
+
layers.push({
|
|
44
|
+
name: 'UI',
|
|
45
|
+
files: uiFiles,
|
|
46
|
+
description: 'UI layer - user interface components and views',
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
if (infraFiles.length > 0) {
|
|
50
|
+
layers.push({
|
|
51
|
+
name: 'Infrastructure',
|
|
52
|
+
files: infraFiles,
|
|
53
|
+
description: 'Infrastructure layer - configuration and setup',
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return layers;
|
|
57
|
+
}
|
|
58
|
+
buildDependencyGraph(node) {
|
|
59
|
+
if (node.type === 'file') {
|
|
60
|
+
const imports = this.parseImports(node.path);
|
|
61
|
+
this.dependencyGraph.set(node.path, new Set(imports));
|
|
62
|
+
}
|
|
63
|
+
if (node.children) {
|
|
64
|
+
for (const child of node.children) {
|
|
65
|
+
this.buildDependencyGraph(child);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
parseImports(filePath) {
|
|
70
|
+
try {
|
|
71
|
+
const content = readFileSync(filePath, 'utf-8');
|
|
72
|
+
const ext = extname(filePath);
|
|
73
|
+
const imports = [];
|
|
74
|
+
if (ext === '.ts' || ext === '.tsx' || ext === '.js' || ext === '.jsx') {
|
|
75
|
+
const importRegex = /(?:import|require)\s*(?:\{[^}]+\}|[^\s]+)\s*from\s*['"]([^'"]+)['"]/g;
|
|
76
|
+
let match;
|
|
77
|
+
while ((match = importRegex.exec(content)) !== null) {
|
|
78
|
+
imports.push(match[1]);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else if (ext === '.py') {
|
|
82
|
+
const importRegex = /(?:from|import)\s+(?:[^\s]+)\s*(?:import\s+)?([^\n]+)?/g;
|
|
83
|
+
let match;
|
|
84
|
+
while ((match = importRegex.exec(content)) !== null) {
|
|
85
|
+
if (match[1]) {
|
|
86
|
+
imports.push(match[1].trim());
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
else if (ext === '.java') {
|
|
91
|
+
const importRegex = /import\s+([^\s;]+);/g;
|
|
92
|
+
let match;
|
|
93
|
+
while ((match = importRegex.exec(content)) !== null) {
|
|
94
|
+
imports.push(match[1]);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return imports;
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
return [];
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
buildEdgeList() {
|
|
104
|
+
const edges = [];
|
|
105
|
+
const seenEdges = new Set();
|
|
106
|
+
for (const [from, toSet] of this.dependencyGraph.entries()) {
|
|
107
|
+
for (const to of toSet) {
|
|
108
|
+
const edgeKey = `${from}->${to}`;
|
|
109
|
+
if (!seenEdges.has(edgeKey)) {
|
|
110
|
+
edges.push({
|
|
111
|
+
from,
|
|
112
|
+
to,
|
|
113
|
+
type: 'import',
|
|
114
|
+
weight: 1,
|
|
115
|
+
});
|
|
116
|
+
seenEdges.add(edgeKey);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return edges;
|
|
121
|
+
}
|
|
122
|
+
categorizeFiles(node, apiFiles, serviceFiles, dataFiles, uiFiles, infraFiles) {
|
|
123
|
+
if (node.type === 'file') {
|
|
124
|
+
const path = node.path.toLowerCase();
|
|
125
|
+
const name = node.name.toLowerCase();
|
|
126
|
+
// Data layer — check first (more specific patterns)
|
|
127
|
+
if (path.includes('/entities/') ||
|
|
128
|
+
path.includes('/entity/') ||
|
|
129
|
+
path.includes('/migrations/') ||
|
|
130
|
+
path.includes('/migration/') ||
|
|
131
|
+
path.includes('/seeds/') ||
|
|
132
|
+
path.includes('/seeders/') ||
|
|
133
|
+
path.includes('/data/') ||
|
|
134
|
+
path.includes('/db/') ||
|
|
135
|
+
path.includes('/database/') ||
|
|
136
|
+
path.includes('/models/') ||
|
|
137
|
+
path.includes('/schema/') ||
|
|
138
|
+
path.includes('/subscribers/') ||
|
|
139
|
+
name.endsWith('.entity.ts') ||
|
|
140
|
+
name.endsWith('.entity.js') ||
|
|
141
|
+
name.endsWith('.model.ts') ||
|
|
142
|
+
name.endsWith('.model.js') ||
|
|
143
|
+
name.includes('repository') ||
|
|
144
|
+
name.includes('dao') ||
|
|
145
|
+
name.includes('mapper') ||
|
|
146
|
+
name.includes('migration') ||
|
|
147
|
+
name.includes('seed') ||
|
|
148
|
+
name.includes('subscriber')) {
|
|
149
|
+
dataFiles.push(node.path);
|
|
150
|
+
}
|
|
151
|
+
// Infrastructure layer
|
|
152
|
+
else if (path.includes('/config/') ||
|
|
153
|
+
path.includes('/infra/') ||
|
|
154
|
+
path.includes('/infrastructure/') ||
|
|
155
|
+
path.includes('/setup/') ||
|
|
156
|
+
path.includes('/guards/') ||
|
|
157
|
+
path.includes('/pipes/') ||
|
|
158
|
+
path.includes('/interceptors/') ||
|
|
159
|
+
path.includes('/filters/') ||
|
|
160
|
+
path.includes('/decorators/') ||
|
|
161
|
+
path.includes('/middleware/') ||
|
|
162
|
+
path.includes('/middlewares/') ||
|
|
163
|
+
path.includes('/common/') ||
|
|
164
|
+
path.includes('/shared/') ||
|
|
165
|
+
path.includes('docker') ||
|
|
166
|
+
path.includes('kubernetes') ||
|
|
167
|
+
name.endsWith('.guard.ts') ||
|
|
168
|
+
name.endsWith('.pipe.ts') ||
|
|
169
|
+
name.endsWith('.interceptor.ts') ||
|
|
170
|
+
name.endsWith('.filter.ts') ||
|
|
171
|
+
name.endsWith('.decorator.ts') ||
|
|
172
|
+
name.endsWith('.middleware.ts') ||
|
|
173
|
+
name.includes('.config.') ||
|
|
174
|
+
name.includes('.module.')) {
|
|
175
|
+
infraFiles.push(node.path);
|
|
176
|
+
}
|
|
177
|
+
// API layer
|
|
178
|
+
else if (path.includes('/api/') ||
|
|
179
|
+
path.includes('/routes/') ||
|
|
180
|
+
path.includes('/controllers/') ||
|
|
181
|
+
name.endsWith('.controller.ts') ||
|
|
182
|
+
name.endsWith('.controller.js') ||
|
|
183
|
+
name.includes('route') ||
|
|
184
|
+
name.includes('controller') ||
|
|
185
|
+
name.includes('handler') ||
|
|
186
|
+
name.endsWith('.dto.ts') ||
|
|
187
|
+
name.endsWith('.dto.js')) {
|
|
188
|
+
apiFiles.push(node.path);
|
|
189
|
+
}
|
|
190
|
+
// Service layer
|
|
191
|
+
else if (path.includes('/service') ||
|
|
192
|
+
path.includes('/business') ||
|
|
193
|
+
path.includes('/logic') ||
|
|
194
|
+
path.includes('/use-cases/') ||
|
|
195
|
+
path.includes('/usecases/') ||
|
|
196
|
+
name.endsWith('.service.ts') ||
|
|
197
|
+
name.endsWith('.service.js') ||
|
|
198
|
+
name.includes('service') ||
|
|
199
|
+
name.includes('manager') ||
|
|
200
|
+
name.includes('facade') ||
|
|
201
|
+
name.includes('usecase')) {
|
|
202
|
+
serviceFiles.push(node.path);
|
|
203
|
+
}
|
|
204
|
+
// UI layer
|
|
205
|
+
else if (path.includes('/ui/') ||
|
|
206
|
+
path.includes('/components/') ||
|
|
207
|
+
path.includes('/pages/') ||
|
|
208
|
+
path.includes('/views/') ||
|
|
209
|
+
path.includes('/screens/') ||
|
|
210
|
+
path.includes('/templates/') ||
|
|
211
|
+
node.extension === '.tsx' ||
|
|
212
|
+
node.extension === '.jsx' ||
|
|
213
|
+
node.extension === '.vue' ||
|
|
214
|
+
node.extension === '.html') {
|
|
215
|
+
uiFiles.push(node.path);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
if (node.children) {
|
|
219
|
+
for (const child of node.children) {
|
|
220
|
+
this.categorizeFiles(child, apiFiles, serviceFiles, dataFiles, uiFiles, infraFiles);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
getModuleBoundaries(fileTree) {
|
|
225
|
+
const modules = new Map();
|
|
226
|
+
this.identifyModules(fileTree, '', modules);
|
|
227
|
+
return modules;
|
|
228
|
+
}
|
|
229
|
+
identifyModules(node, parentPath, modules) {
|
|
230
|
+
if (node.type === 'directory') {
|
|
231
|
+
const moduleFiles = [];
|
|
232
|
+
this.collectFilesInModule(node, moduleFiles);
|
|
233
|
+
if (moduleFiles.length > 0) {
|
|
234
|
+
modules.set(node.name, moduleFiles);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
if (node.children) {
|
|
238
|
+
for (const child of node.children) {
|
|
239
|
+
this.identifyModules(child, parentPath + '/' + node.name, modules);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
collectFilesInModule(node, files) {
|
|
244
|
+
if (node.type === 'file') {
|
|
245
|
+
files.push(node.path);
|
|
246
|
+
}
|
|
247
|
+
if (node.children) {
|
|
248
|
+
for (const child of node.children) {
|
|
249
|
+
this.collectFilesInModule(child, files);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
//# sourceMappingURL=analyzer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyzer.js","sourceRoot":"","sources":["../src/analyzer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,OAAO,EAAqB,MAAM,MAAM,CAAC;AAGlD,MAAM,OAAO,oBAAoB;IAK/B,YAAY,WAAmB;QAHvB,oBAAe,GAA6B,IAAI,GAAG,EAAE,CAAC;QACtD,mBAAc,GAAwB,IAAI,GAAG,EAAE,CAAC;QAGtD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED,mBAAmB,CAAC,QAAkB;QACpC,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;QACpC,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,CAAC,oBAAoB,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;YAE7C,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC3B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;YACtC,CAAC;QACH,CAAC;QAED,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAClC,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,UAAU,GAAG,GAAG,GAAG,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YACrE,CAAC;QACH,CAAC;IACH,CAAC;IAEO,oBAAoB,CAAC,IAAc,EAAE,KAAe;QAC1D,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YACzB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACxB,CAAC;QAED,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAClC,IAAI,CAAC,oBAAoB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YAC1C,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AntiPattern, FileNode, ArchitectConfig } from './types.js';
|
|
2
|
+
export declare class AntiPatternDetector {
|
|
3
|
+
private config;
|
|
4
|
+
private dependencyGraph;
|
|
5
|
+
constructor(config: ArchitectConfig);
|
|
6
|
+
detect(fileTree: FileNode, dependencies: Map<string, Set<string>>): AntiPattern[];
|
|
7
|
+
private detectGodClasses;
|
|
8
|
+
private detectCircularDependencies;
|
|
9
|
+
private findCycle;
|
|
10
|
+
private detectLeakyAbstractions;
|
|
11
|
+
private detectFeatureEnvy;
|
|
12
|
+
private detectShotgunSurgery;
|
|
13
|
+
private countMethods;
|
|
14
|
+
private countInternalExports;
|
|
15
|
+
private walkFileTree;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=anti-patterns.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anti-patterns.d.ts","sourceRoot":"","sources":["../src/anti-patterns.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEpE,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,eAAe,CAA2B;gBAEtC,MAAM,EAAE,eAAe;IAKnC,MAAM,CACJ,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,GACrC,WAAW,EAAE;IAqBhB,OAAO,CAAC,gBAAgB;IA8BxB,OAAO,CAAC,0BAA0B;IAyBlC,OAAO,CAAC,SAAS;IAyBjB,OAAO,CAAC,uBAAuB;IAyB/B,OAAO,CAAC,iBAAiB;IA8CzB,OAAO,CAAC,oBAAoB;IA4B5B,OAAO,CAAC,YAAY;IAapB,OAAO,CAAC,oBAAoB;IAwB5B,OAAO,CAAC,YAAY;CAWrB"}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { readFileSync } from 'fs';
|
|
2
|
+
export class AntiPatternDetector {
|
|
3
|
+
constructor(config) {
|
|
4
|
+
this.config = config;
|
|
5
|
+
this.dependencyGraph = new Map();
|
|
6
|
+
}
|
|
7
|
+
detect(fileTree, dependencies) {
|
|
8
|
+
this.dependencyGraph = dependencies;
|
|
9
|
+
const patterns = [];
|
|
10
|
+
patterns.push(...this.detectGodClasses(fileTree));
|
|
11
|
+
patterns.push(...this.detectCircularDependencies());
|
|
12
|
+
patterns.push(...this.detectLeakyAbstractions(fileTree));
|
|
13
|
+
patterns.push(...this.detectFeatureEnvy(fileTree, dependencies));
|
|
14
|
+
patterns.push(...this.detectShotgunSurgery(dependencies));
|
|
15
|
+
return patterns.sort((a, b) => {
|
|
16
|
+
const severityOrder = {
|
|
17
|
+
CRITICAL: 0,
|
|
18
|
+
HIGH: 1,
|
|
19
|
+
MEDIUM: 2,
|
|
20
|
+
LOW: 3,
|
|
21
|
+
};
|
|
22
|
+
return severityOrder[a.severity] - severityOrder[b.severity];
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
detectGodClasses(node) {
|
|
26
|
+
const patterns = [];
|
|
27
|
+
const threshold = this.config.antiPatterns?.godClass?.linesThreshold || 500;
|
|
28
|
+
const methodThreshold = this.config.antiPatterns?.godClass?.methodsThreshold || 10;
|
|
29
|
+
this.walkFileTree(node, (file) => {
|
|
30
|
+
if (file.type === 'file' && (file.lines || 0) > threshold) {
|
|
31
|
+
const methods = this.countMethods(file.path);
|
|
32
|
+
if (methods > methodThreshold) {
|
|
33
|
+
patterns.push({
|
|
34
|
+
name: 'God Class',
|
|
35
|
+
severity: 'CRITICAL',
|
|
36
|
+
location: file.path,
|
|
37
|
+
description: `Class with ${file.lines} lines and ${methods} methods violates single responsibility principle`,
|
|
38
|
+
suggestion: 'Consider splitting into smaller, focused classes with specific responsibilities',
|
|
39
|
+
metrics: {
|
|
40
|
+
lines: file.lines || 0,
|
|
41
|
+
methods,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
return patterns;
|
|
48
|
+
}
|
|
49
|
+
detectCircularDependencies() {
|
|
50
|
+
const patterns = [];
|
|
51
|
+
const visited = new Set();
|
|
52
|
+
const recursionStack = new Set();
|
|
53
|
+
for (const file of this.dependencyGraph.keys()) {
|
|
54
|
+
if (!visited.has(file)) {
|
|
55
|
+
const cycle = this.findCycle(file, visited, recursionStack);
|
|
56
|
+
if (cycle) {
|
|
57
|
+
patterns.push({
|
|
58
|
+
name: 'Circular Dependency',
|
|
59
|
+
severity: 'HIGH',
|
|
60
|
+
location: cycle.join(' -> '),
|
|
61
|
+
description: `Circular dependency detected: ${cycle.join(' -> ')}`,
|
|
62
|
+
suggestion: 'Refactor code to break the circular dependency using dependency injection or intermediate abstractions',
|
|
63
|
+
affectedFiles: cycle,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return patterns;
|
|
69
|
+
}
|
|
70
|
+
findCycle(node, visited, recursionStack) {
|
|
71
|
+
visited.add(node);
|
|
72
|
+
recursionStack.add(node);
|
|
73
|
+
const neighbors = this.dependencyGraph.get(node) || new Set();
|
|
74
|
+
for (const neighbor of neighbors) {
|
|
75
|
+
if (!visited.has(neighbor)) {
|
|
76
|
+
const cycle = this.findCycle(neighbor, visited, recursionStack);
|
|
77
|
+
if (cycle) {
|
|
78
|
+
cycle.unshift(node);
|
|
79
|
+
return cycle;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else if (recursionStack.has(neighbor)) {
|
|
83
|
+
return [node, neighbor];
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
recursionStack.delete(node);
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
detectLeakyAbstractions(node) {
|
|
90
|
+
const patterns = [];
|
|
91
|
+
this.walkFileTree(node, (file) => {
|
|
92
|
+
if (file.type === 'file') {
|
|
93
|
+
const internalExports = this.countInternalExports(file.path);
|
|
94
|
+
if (internalExports > 5) {
|
|
95
|
+
patterns.push({
|
|
96
|
+
name: 'Leaky Abstraction',
|
|
97
|
+
severity: 'MEDIUM',
|
|
98
|
+
location: file.path,
|
|
99
|
+
description: `Exports ${internalExports} internal types that should be private`,
|
|
100
|
+
suggestion: 'Use private/internal access modifiers and facade patterns to hide implementation details',
|
|
101
|
+
metrics: {
|
|
102
|
+
exportedInternalTypes: internalExports,
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
return patterns;
|
|
109
|
+
}
|
|
110
|
+
detectFeatureEnvy(node, dependencies) {
|
|
111
|
+
const patterns = [];
|
|
112
|
+
this.walkFileTree(node, (file) => {
|
|
113
|
+
if (file.type === 'file') {
|
|
114
|
+
const externalMethodCalls = (dependencies.get(file.path) || new Set())
|
|
115
|
+
.size;
|
|
116
|
+
const internalMethods = this.countMethods(file.path);
|
|
117
|
+
const name = file.name.toLowerCase();
|
|
118
|
+
// Skip NestJS infrastructure files where external deps are by design
|
|
119
|
+
const isInfraFile = name.endsWith('.module.ts') ||
|
|
120
|
+
name.endsWith('.dto.ts') ||
|
|
121
|
+
name.endsWith('.entity.ts') ||
|
|
122
|
+
name.endsWith('.guard.ts') ||
|
|
123
|
+
name.endsWith('.pipe.ts') ||
|
|
124
|
+
name.endsWith('.interceptor.ts') ||
|
|
125
|
+
name.endsWith('.filter.ts') ||
|
|
126
|
+
name.endsWith('.decorator.ts') ||
|
|
127
|
+
name.endsWith('.spec.ts') ||
|
|
128
|
+
name.endsWith('.test.ts');
|
|
129
|
+
if (!isInfraFile && internalMethods > 0 && externalMethodCalls > internalMethods * 3) {
|
|
130
|
+
patterns.push({
|
|
131
|
+
name: 'Feature Envy',
|
|
132
|
+
severity: 'MEDIUM',
|
|
133
|
+
location: file.path,
|
|
134
|
+
description: `Uses more external methods (${externalMethodCalls}) than internal methods (${internalMethods})`,
|
|
135
|
+
suggestion: 'Move functionality closer to where it is used or extract to shared utility',
|
|
136
|
+
metrics: {
|
|
137
|
+
externalMethodCalls,
|
|
138
|
+
internalMethods,
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
return patterns;
|
|
145
|
+
}
|
|
146
|
+
detectShotgunSurgery(dependencies) {
|
|
147
|
+
const patterns = [];
|
|
148
|
+
const threshold = this.config.antiPatterns?.shotgunSurgery
|
|
149
|
+
?.changePropagationThreshold || 8;
|
|
150
|
+
for (const [file, dependents] of dependencies) {
|
|
151
|
+
if (dependents.size >= threshold) {
|
|
152
|
+
patterns.push({
|
|
153
|
+
name: 'Shotgun Surgery',
|
|
154
|
+
severity: 'HIGH',
|
|
155
|
+
location: file,
|
|
156
|
+
description: `Changes to this file likely require modifications in ${dependents.size} other files`,
|
|
157
|
+
suggestion: 'Refactor to reduce coupling and consolidate related functionality into modules',
|
|
158
|
+
affectedFiles: Array.from(dependents),
|
|
159
|
+
metrics: {
|
|
160
|
+
dependentFileCount: dependents.size,
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return patterns;
|
|
166
|
+
}
|
|
167
|
+
countMethods(filePath) {
|
|
168
|
+
try {
|
|
169
|
+
const content = readFileSync(filePath, 'utf-8');
|
|
170
|
+
const methodRegex = /(?:async\s+)?(?:function|public|private|protected|static)\s+\w+\s*\(/g;
|
|
171
|
+
const arrowMethodRegex = /(?:readonly\s+)?\w+\s*=\s*(?:async\s+)?\(/g;
|
|
172
|
+
const matches = content.match(methodRegex);
|
|
173
|
+
const arrowMatches = content.match(arrowMethodRegex);
|
|
174
|
+
return (matches ? matches.length : 0) + (arrowMatches ? arrowMatches.length : 0);
|
|
175
|
+
}
|
|
176
|
+
catch {
|
|
177
|
+
return 0;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
countInternalExports(filePath) {
|
|
181
|
+
try {
|
|
182
|
+
const content = readFileSync(filePath, 'utf-8');
|
|
183
|
+
const internalTypes = [
|
|
184
|
+
'_',
|
|
185
|
+
'Internal',
|
|
186
|
+
'Private',
|
|
187
|
+
'Impl',
|
|
188
|
+
'Detail',
|
|
189
|
+
];
|
|
190
|
+
let count = 0;
|
|
191
|
+
for (const type of internalTypes) {
|
|
192
|
+
const regex = new RegExp(`export\\s+\\w*${type}\\w*`, 'g');
|
|
193
|
+
const matches = content.match(regex);
|
|
194
|
+
count += matches ? matches.length : 0;
|
|
195
|
+
}
|
|
196
|
+
return count;
|
|
197
|
+
}
|
|
198
|
+
catch {
|
|
199
|
+
return 0;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
walkFileTree(node, callback) {
|
|
203
|
+
callback(node);
|
|
204
|
+
if (node.children) {
|
|
205
|
+
for (const child of node.children) {
|
|
206
|
+
this.walkFileTree(child, callback);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
//# sourceMappingURL=anti-patterns.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anti-patterns.js","sourceRoot":"","sources":["../src/anti-patterns.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAGlC,MAAM,OAAO,mBAAmB;IAI9B,YAAY,MAAuB;QACjC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,eAAe,GAAG,IAAI,GAAG,EAAE,CAAC;IACnC,CAAC;IAED,MAAM,CACJ,QAAkB,EAClB,YAAsC;QAEtC,IAAI,CAAC,eAAe,GAAG,YAAY,CAAC;QACpC,MAAM,QAAQ,GAAkB,EAAE,CAAC;QAEnC,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC;QAClD,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,0BAA0B,EAAE,CAAC,CAAC;QACpD,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,uBAAuB,CAAC,QAAQ,CAAC,CAAC,CAAC;QACzD,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,iBAAiB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC;QACjE,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,oBAAoB,CAAC,YAAY,CAAC,CAAC,CAAC;QAE1D,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YAC5B,MAAM,aAAa,GAA2B;gBAC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CAAC;IAEO,oBAAoB,CAAC,QAAgB;QAC3C,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YAChD,MAAM,aAAa,GAAG;gBACpB,GAAG;gBACH,UAAU;gBACV,SAAS;gBACT,MAAM;gBACN,QAAQ;aACT,CAAC;YACF,IAAI,KAAK,GAAG,CAAC,CAAC;YAEd,KAAK,MAAM,IAAI,IAAI,aAAa,EAAE,CAAC;gBACjC,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,iBAAiB,IAAI,MAAM,EAAE,GAAG,CAAC,CAAC;gBAC3D,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;gBACrC,KAAK,IAAI,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YACxC,CAAC;YAED,OAAO,KAAK,CAAC;QACf,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,CAAC,CAAC;QACX,CAAC;IACH,CAAC;IAEO,YAAY,CAClB,IAAc,EACd,QAAkC;QAElC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACf,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAClC,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;YACrC,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Architect CLI
|
|
4
|
+
* Executa análise arquitetural e gera relatórios em múltiplos formatos
|
|
5
|
+
*
|
|
6
|
+
* Uso:
|
|
7
|
+
* npx architect analyze ./src
|
|
8
|
+
* npx architect analyze ./src --format html --output report.html
|
|
9
|
+
* npx architect diagram ./src
|
|
10
|
+
* npx architect score ./src
|
|
11
|
+
* npx architect anti-patterns ./src
|
|
12
|
+
* npx architect layers ./src
|
|
13
|
+
*/
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;GAWG"}
|