@angular-modernizer/api 0.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.
Files changed (108) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +507 -0
  3. package/dist/analysis/complexity-metrics-calculator.d.ts +99 -0
  4. package/dist/analysis/complexity-metrics-calculator.d.ts.map +1 -0
  5. package/dist/analysis/complexity-metrics-calculator.js +195 -0
  6. package/dist/analysis/complexity-metrics-calculator.js.map +1 -0
  7. package/dist/analysis/dependency-analyzer.d.ts +227 -0
  8. package/dist/analysis/dependency-analyzer.d.ts.map +1 -0
  9. package/dist/analysis/dependency-analyzer.js +451 -0
  10. package/dist/analysis/dependency-analyzer.js.map +1 -0
  11. package/dist/analysis/external-template-loader.d.ts +44 -0
  12. package/dist/analysis/external-template-loader.d.ts.map +1 -0
  13. package/dist/analysis/external-template-loader.js +69 -0
  14. package/dist/analysis/external-template-loader.js.map +1 -0
  15. package/dist/analysis/selector-mapper.d.ts +77 -0
  16. package/dist/analysis/selector-mapper.d.ts.map +1 -0
  17. package/dist/analysis/selector-mapper.js +146 -0
  18. package/dist/analysis/selector-mapper.js.map +1 -0
  19. package/dist/analysis/service-detector.d.ts +164 -0
  20. package/dist/analysis/service-detector.d.ts.map +1 -0
  21. package/dist/analysis/service-detector.js +231 -0
  22. package/dist/analysis/service-detector.js.map +1 -0
  23. package/dist/analysis/service-pattern-recognizer.d.ts +247 -0
  24. package/dist/analysis/service-pattern-recognizer.d.ts.map +1 -0
  25. package/dist/analysis/service-pattern-recognizer.js +444 -0
  26. package/dist/analysis/service-pattern-recognizer.js.map +1 -0
  27. package/dist/analysis/symbol-locator.d.ts +81 -0
  28. package/dist/analysis/symbol-locator.d.ts.map +1 -0
  29. package/dist/analysis/symbol-locator.js +128 -0
  30. package/dist/analysis/symbol-locator.js.map +1 -0
  31. package/dist/analysis/template-analyzer-usage.d.ts +144 -0
  32. package/dist/analysis/template-analyzer-usage.d.ts.map +1 -0
  33. package/dist/analysis/template-analyzer-usage.js +474 -0
  34. package/dist/analysis/template-analyzer-usage.js.map +1 -0
  35. package/dist/analysis/template-analyzer.d.ts +80 -0
  36. package/dist/analysis/template-analyzer.d.ts.map +1 -0
  37. package/dist/analysis/template-analyzer.js +146 -0
  38. package/dist/analysis/template-analyzer.js.map +1 -0
  39. package/dist/index.d.ts +23 -0
  40. package/dist/index.d.ts.map +1 -0
  41. package/dist/index.js +22 -0
  42. package/dist/index.js.map +1 -0
  43. package/dist/investigation/angular-symbol-finder.d.ts +76 -0
  44. package/dist/investigation/angular-symbol-finder.d.ts.map +1 -0
  45. package/dist/investigation/angular-symbol-finder.js +199 -0
  46. package/dist/investigation/angular-symbol-finder.js.map +1 -0
  47. package/dist/investigation/call-graph-builder.d.ts +85 -0
  48. package/dist/investigation/call-graph-builder.d.ts.map +1 -0
  49. package/dist/investigation/call-graph-builder.js +196 -0
  50. package/dist/investigation/call-graph-builder.js.map +1 -0
  51. package/dist/investigation/codebase-searcher.d.ts +99 -0
  52. package/dist/investigation/codebase-searcher.d.ts.map +1 -0
  53. package/dist/investigation/codebase-searcher.js +201 -0
  54. package/dist/investigation/codebase-searcher.js.map +1 -0
  55. package/dist/investigation/stack-trace-parser.d.ts +70 -0
  56. package/dist/investigation/stack-trace-parser.d.ts.map +1 -0
  57. package/dist/investigation/stack-trace-parser.js +117 -0
  58. package/dist/investigation/stack-trace-parser.js.map +1 -0
  59. package/dist/investigation/type-resolver.d.ts +59 -0
  60. package/dist/investigation/type-resolver.d.ts.map +1 -0
  61. package/dist/investigation/type-resolver.js +111 -0
  62. package/dist/investigation/type-resolver.js.map +1 -0
  63. package/dist/investigation/usage-finder.d.ts +69 -0
  64. package/dist/investigation/usage-finder.d.ts.map +1 -0
  65. package/dist/investigation/usage-finder.js +132 -0
  66. package/dist/investigation/usage-finder.js.map +1 -0
  67. package/dist/metrics/complexity-metrics.d.ts +196 -0
  68. package/dist/metrics/complexity-metrics.d.ts.map +1 -0
  69. package/dist/metrics/complexity-metrics.js +445 -0
  70. package/dist/metrics/complexity-metrics.js.map +1 -0
  71. package/dist/public-api.d.ts +77 -0
  72. package/dist/public-api.d.ts.map +1 -0
  73. package/dist/public-api.js +50 -0
  74. package/dist/public-api.js.map +1 -0
  75. package/dist/transformation/import-manager.d.ts +276 -0
  76. package/dist/transformation/import-manager.d.ts.map +1 -0
  77. package/dist/transformation/import-manager.js +488 -0
  78. package/dist/transformation/import-manager.js.map +1 -0
  79. package/dist/transformation/ng-morph-adapter.d.ts +111 -0
  80. package/dist/transformation/ng-morph-adapter.d.ts.map +1 -0
  81. package/dist/transformation/ng-morph-adapter.js +179 -0
  82. package/dist/transformation/ng-morph-adapter.js.map +1 -0
  83. package/dist/transformation/ngmodule-manager.d.ts +145 -0
  84. package/dist/transformation/ngmodule-manager.d.ts.map +1 -0
  85. package/dist/transformation/ngmodule-manager.js +356 -0
  86. package/dist/transformation/ngmodule-manager.js.map +1 -0
  87. package/package.json +62 -0
  88. package/src/analysis/complexity-metrics-calculator.ts +253 -0
  89. package/src/analysis/dependency-analyzer.ts +720 -0
  90. package/src/analysis/external-template-loader.ts +79 -0
  91. package/src/analysis/selector-mapper.ts +186 -0
  92. package/src/analysis/service-detector.ts +280 -0
  93. package/src/analysis/service-pattern-recognizer.ts +545 -0
  94. package/src/analysis/symbol-locator.ts +170 -0
  95. package/src/analysis/template-analyzer-usage.ts +614 -0
  96. package/src/analysis/template-analyzer.ts +208 -0
  97. package/src/index.ts +51 -0
  98. package/src/investigation/angular-symbol-finder.ts +263 -0
  99. package/src/investigation/call-graph-builder.ts +298 -0
  100. package/src/investigation/codebase-searcher.ts +286 -0
  101. package/src/investigation/stack-trace-parser.ts +166 -0
  102. package/src/investigation/type-resolver.ts +144 -0
  103. package/src/investigation/usage-finder.ts +198 -0
  104. package/src/metrics/complexity-metrics.ts +617 -0
  105. package/src/public-api.ts +119 -0
  106. package/src/transformation/import-manager.ts +626 -0
  107. package/src/transformation/ng-morph-adapter.ts +252 -0
  108. package/src/transformation/ngmodule-manager.ts +450 -0
@@ -0,0 +1,196 @@
1
+ /**
2
+ * @angular-modernizer/api - Complexity Metrics
3
+ *
4
+ * Calculates code complexity metrics for Angular components and services.
5
+ * Helps identify candidates for refactoring.
6
+ *
7
+ * Analyzes:
8
+ * - Cyclomatic complexity for control flow complexity
9
+ * - Lines of code and method count for size metrics
10
+ * - Dependency count for coupling analysis
11
+ * - Additional Angular-specific metrics (template complexity, lifecycle method usage)
12
+ */
13
+ import { type SourceFile, type ClassDeclaration, type MethodDeclaration } from 'ts-morph';
14
+ /**
15
+ * Complexity metrics for a source file.
16
+ */
17
+ export interface ComplexityMetrics {
18
+ /**
19
+ * Cyclomatic complexity.
20
+ */
21
+ cyclomaticComplexity: number;
22
+ /**
23
+ * Lines of code.
24
+ */
25
+ linesOfCode: number;
26
+ /**
27
+ * Number of methods/functions.
28
+ */
29
+ methodCount: number;
30
+ /**
31
+ * Number of dependencies.
32
+ */
33
+ dependencyCount: number;
34
+ /**
35
+ * Additional metrics.
36
+ */
37
+ metadata?: Record<string, unknown>;
38
+ }
39
+ /**
40
+ * Angular-specific metrics for components and directives.
41
+ */
42
+ export interface AngularMetrics {
43
+ /**
44
+ * Number of lifecycle hooks (ngOnInit, ngOnDestroy, etc.).
45
+ */
46
+ lifecycleHooks: number;
47
+ /**
48
+ * Number of @Input properties.
49
+ */
50
+ inputs: number;
51
+ /**
52
+ * Number of @Output properties.
53
+ */
54
+ outputs: number;
55
+ /**
56
+ * Number of Angular decorators (@Component, @Directive, etc.).
57
+ */
58
+ decorators: number;
59
+ /**
60
+ * Template complexity score (structural directives, bindings, etc.).
61
+ */
62
+ templateComplexity?: number;
63
+ }
64
+ /**
65
+ * Complexity Metrics Calculator.
66
+ */
67
+ export declare class ComplexityMetricsCalculator {
68
+ /**
69
+ * Calculate overall complexity score for a class (0-100 scale).
70
+ *
71
+ * Combines multiple metrics:
72
+ * - Cyclomatic complexity
73
+ * - Lines of code
74
+ * - Method count
75
+ * - Angular-specific complexity
76
+ *
77
+ * @param classDecl - The class declaration to analyze
78
+ * @returns Complexity score (0-100)
79
+ */
80
+ calculateOverallComplexity(classDecl: ClassDeclaration): number;
81
+ /**
82
+ * Calculate cyclomatic complexity for a class.
83
+ *
84
+ * Measures the number of linearly independent paths through the code.
85
+ * Higher values indicate more complex control flow.
86
+ *
87
+ * @param classDecl - The class declaration
88
+ * @returns Cyclomatic complexity score
89
+ */
90
+ calculateCyclomaticComplexity(classDecl: ClassDeclaration): number;
91
+ calculateCyclomaticComplexity(method: MethodDeclaration): number;
92
+ /**
93
+ * Calculate cyclomatic complexity for a single method.
94
+ */
95
+ private calculateMethodComplexity;
96
+ /**
97
+ * Calculate lines of code for a source file.
98
+ *
99
+ * Excludes comments and whitespace for meaningful LOC count.
100
+ *
101
+ * @param sourceFile - The source file
102
+ * @returns Number of lines of code
103
+ */
104
+ calculateLOC(sourceFile: SourceFile): number;
105
+ /**
106
+ * Calculate the number of methods in a class.
107
+ * Includes methods, getters, and setters.
108
+ *
109
+ * @param classDecl - The class declaration
110
+ * @returns Number of methods (including accessors)
111
+ */
112
+ calculateMethodCount(classDecl: ClassDeclaration): number;
113
+ /**
114
+ * Calculate dependency count for a source file.
115
+ *
116
+ * Counts all import declarations (including duplicates).
117
+ *
118
+ * @param sourceFile - The source file
119
+ * @returns Number of import declarations
120
+ */
121
+ calculateDependencyCount(sourceFile: SourceFile): number;
122
+ /**
123
+ * Calculate Angular-specific metrics for a class.
124
+ *
125
+ * Analyzes Angular decorators and patterns.
126
+ *
127
+ * @param classDecl - The class declaration
128
+ * @returns Angular-specific metrics
129
+ */
130
+ calculateAngularSpecificMetrics(classDecl: ClassDeclaration): AngularMetrics;
131
+ /**
132
+ * Calculate complexity metrics for a source file.
133
+ *
134
+ * @param sourceFile - The source file to analyze
135
+ * @returns Complexity metrics
136
+ *
137
+ * Calculates actual metrics using ts-morph AST analysis:
138
+ * - Cyclomatic complexity: count decision points (if, for, while, case, &&, ||, ?)
139
+ * - Lines of code: count non-empty, non-comment lines
140
+ * - Method count: count function/method declarations
141
+ * - Dependency count: analyze constructor parameters and property injections
142
+ */
143
+ calculate(sourceFile: SourceFile): ComplexityMetrics;
144
+ /**
145
+ * Calculate cyclomatic complexity for a source file.
146
+ * Counts decision points: if, for, while, do-while, case, catch, &&, ||, ?
147
+ *
148
+ * @param sourceFile - The source file
149
+ * @returns Cyclomatic complexity value
150
+ */
151
+ private calculateCyclomaticComplexitySourceFile;
152
+ /**
153
+ * Calculate lines of code (excluding comments and whitespace).
154
+ *
155
+ * @param sourceFile - The source file
156
+ * @returns Lines of code count
157
+ */
158
+ private calculateLinesOfCode;
159
+ /**
160
+ * Calculate method/function count.
161
+ *
162
+ * @param sourceFile - The source file
163
+ * @returns Method count
164
+ */
165
+ private calculateMethodCountSourceFile;
166
+ /**
167
+ * Calculate Angular-specific metrics.
168
+ *
169
+ * @param sourceFile - The source file
170
+ * @returns Angular-specific metrics
171
+ */
172
+ private calculateAngularMetrics;
173
+ /**
174
+ * Count lifecycle hook methods in a class.
175
+ *
176
+ * @param classDecl - The class declaration
177
+ * @returns Count of lifecycle hooks
178
+ */
179
+ private countLifecycleHooks;
180
+ /**
181
+ * Count @Input and @Output decorators in a class.
182
+ *
183
+ * @param classDecl - The class declaration
184
+ * @returns Input and output counts
185
+ */
186
+ private countInputsAndOutputs;
187
+ /**
188
+ * Calculate template complexity for a component.
189
+ * Looks for inline templates in @Component decorator.
190
+ *
191
+ * @param classDecl - The class declaration
192
+ * @returns Template complexity score
193
+ */
194
+ private calculateTemplateComplexity;
195
+ }
196
+ //# sourceMappingURL=complexity-metrics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"complexity-metrics.d.ts","sourceRoot":"","sources":["../../src/metrics/complexity-metrics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,KAAK,UAAU,EAEf,KAAK,gBAAgB,EAErB,KAAK,iBAAiB,EACvB,MAAM,UAAU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OAAO,CAAC,uCAAuC;IA+C/C;;;;;OAKG;IACH,OAAO,CAAC,oBAAoB;IA2B5B;;;;;OAKG;IACH,OAAO,CAAC,8BAA8B;IAoBtC;;;;;OAKG;IACH,OAAO,CAAC,uBAAuB;IAgC/B;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB;IAwB3B;;;;;OAKG;IACH,OAAO,CAAC,qBAAqB;IAgC7B;;;;;;OAMG;IACH,OAAO,CAAC,2BAA2B;CAsCpC"}
@@ -0,0 +1,445 @@
1
+ /**
2
+ * @angular-modernizer/api - Complexity Metrics
3
+ *
4
+ * Calculates code complexity metrics for Angular components and services.
5
+ * Helps identify candidates for refactoring.
6
+ *
7
+ * Analyzes:
8
+ * - Cyclomatic complexity for control flow complexity
9
+ * - Lines of code and method count for size metrics
10
+ * - Dependency count for coupling analysis
11
+ * - Additional Angular-specific metrics (template complexity, lifecycle method usage)
12
+ */
13
+ import { SyntaxKind, ClassDeclaration as ClassDeclarationClass, } from 'ts-morph';
14
+ /**
15
+ * Complexity Metrics Calculator.
16
+ */
17
+ export class ComplexityMetricsCalculator {
18
+ /**
19
+ * Calculate overall complexity score for a class (0-100 scale).
20
+ *
21
+ * Combines multiple metrics:
22
+ * - Cyclomatic complexity
23
+ * - Lines of code
24
+ * - Method count
25
+ * - Angular-specific complexity
26
+ *
27
+ * @param classDecl - The class declaration to analyze
28
+ * @returns Complexity score (0-100)
29
+ */
30
+ calculateOverallComplexity(classDecl) {
31
+ const cyclomatic = this.calculateCyclomaticComplexity(classDecl);
32
+ const loc = this.calculateLOC(classDecl.getSourceFile());
33
+ const methods = this.calculateMethodCount(classDecl);
34
+ const angularMetrics = this.calculateAngularSpecificMetrics(classDecl);
35
+ // Weighted formula for overall complexity
36
+ const score = cyclomatic * 0.4 +
37
+ (loc / 10) * 0.2 +
38
+ methods * 2 * 0.2 +
39
+ (angularMetrics.lifecycleHooks +
40
+ angularMetrics.inputs +
41
+ angularMetrics.outputs) *
42
+ 1.5 *
43
+ 0.2;
44
+ return Math.min(100, Math.max(0, score));
45
+ }
46
+ calculateCyclomaticComplexity(node) {
47
+ let complexity = 1; // Base complexity
48
+ if (node instanceof ClassDeclarationClass) {
49
+ const methods = node.getMethods();
50
+ for (const method of methods) {
51
+ complexity += this.calculateMethodComplexity(method);
52
+ }
53
+ }
54
+ else {
55
+ complexity = this.calculateMethodComplexity(node);
56
+ }
57
+ return complexity;
58
+ }
59
+ /**
60
+ * Calculate cyclomatic complexity for a single method.
61
+ */
62
+ calculateMethodComplexity(method) {
63
+ let complexity = 1; // Base complexity
64
+ // Count control flow statements
65
+ const statements = method.getStatements();
66
+ for (const statement of statements) {
67
+ const text = statement.getText();
68
+ // Count if statements (including else if)
69
+ const ifMatches = text.match(/\bif\s*\(/g);
70
+ if (ifMatches) {
71
+ complexity += ifMatches.length;
72
+ }
73
+ // Count loops
74
+ const loopMatches = text.match(/\b(for|while|do)\s*\(/g);
75
+ if (loopMatches) {
76
+ complexity += loopMatches.length;
77
+ }
78
+ // Count switch cases
79
+ const caseMatches = text.match(/\bcase\s+/g);
80
+ if (caseMatches) {
81
+ complexity += caseMatches.length;
82
+ }
83
+ // Count ternary operators
84
+ const ternaryMatches = text.match(/\?/g);
85
+ if (ternaryMatches) {
86
+ complexity += ternaryMatches.length;
87
+ }
88
+ // Count logical operators (&&, ||)
89
+ const logicalMatches = text.match(/(&&|\|\|)/g);
90
+ if (logicalMatches) {
91
+ complexity += logicalMatches.length;
92
+ }
93
+ }
94
+ return complexity;
95
+ }
96
+ /**
97
+ * Calculate lines of code for a source file.
98
+ *
99
+ * Excludes comments and whitespace for meaningful LOC count.
100
+ *
101
+ * @param sourceFile - The source file
102
+ * @returns Number of lines of code
103
+ */
104
+ calculateLOC(sourceFile) {
105
+ const text = sourceFile.getText();
106
+ const lines = text.split('\n');
107
+ let loc = 0;
108
+ for (const line of lines) {
109
+ const trimmed = line.trim();
110
+ // Count non-empty, non-comment lines
111
+ if (trimmed &&
112
+ !trimmed.startsWith('//') &&
113
+ !trimmed.startsWith('/*') &&
114
+ !trimmed.startsWith('*')) {
115
+ loc++;
116
+ }
117
+ }
118
+ return loc;
119
+ }
120
+ /**
121
+ * Calculate the number of methods in a class.
122
+ * Includes methods, getters, and setters.
123
+ *
124
+ * @param classDecl - The class declaration
125
+ * @returns Number of methods (including accessors)
126
+ */
127
+ calculateMethodCount(classDecl) {
128
+ const methods = classDecl.getMethods().length;
129
+ const getters = classDecl.getGetAccessors().length;
130
+ const setters = classDecl.getSetAccessors().length;
131
+ return methods + getters + setters;
132
+ }
133
+ /**
134
+ * Calculate dependency count for a source file.
135
+ *
136
+ * Counts all import declarations (including duplicates).
137
+ *
138
+ * @param sourceFile - The source file
139
+ * @returns Number of import declarations
140
+ */
141
+ calculateDependencyCount(sourceFile) {
142
+ return sourceFile.getImportDeclarations().length;
143
+ }
144
+ /**
145
+ * Calculate Angular-specific metrics for a class.
146
+ *
147
+ * Analyzes Angular decorators and patterns.
148
+ *
149
+ * @param classDecl - The class declaration
150
+ * @returns Angular-specific metrics
151
+ */
152
+ calculateAngularSpecificMetrics(classDecl) {
153
+ const metrics = {
154
+ lifecycleHooks: 0,
155
+ inputs: 0,
156
+ outputs: 0,
157
+ decorators: 0,
158
+ templateComplexity: 0,
159
+ };
160
+ const lifecycleHookNames = new Set([
161
+ 'ngOnInit',
162
+ 'ngOnDestroy',
163
+ 'ngOnChanges',
164
+ 'ngDoCheck',
165
+ 'ngAfterContentInit',
166
+ 'ngAfterContentChecked',
167
+ 'ngAfterViewInit',
168
+ 'ngAfterViewChecked',
169
+ ]);
170
+ const angularTypes = new Set(['Component', 'Directive']);
171
+ // Count Angular decorators and analyze Component/Directive classes
172
+ classDecl.getDecorators().forEach((decorator) => {
173
+ const name = decorator.getName();
174
+ metrics.decorators++;
175
+ if (!angularTypes.has(name)) {
176
+ return;
177
+ }
178
+ // Count lifecycle hook methods
179
+ metrics.lifecycleHooks += classDecl
180
+ .getMethods()
181
+ .filter((method) => lifecycleHookNames.has(method.getName())).length;
182
+ // Count @Input decorators on properties and setters
183
+ const countInputOutput = (nodes) => {
184
+ nodes.forEach((node) => {
185
+ node.getDecorators().forEach((dec) => {
186
+ const decName = dec.getName();
187
+ if (decName === 'Input') {
188
+ metrics.inputs++;
189
+ }
190
+ if (decName === 'Output') {
191
+ metrics.outputs++;
192
+ }
193
+ });
194
+ });
195
+ };
196
+ countInputOutput(classDecl.getProperties());
197
+ countInputOutput(classDecl.getSetAccessors());
198
+ // Calculate template complexity for components only
199
+ if (name === 'Component') {
200
+ metrics.templateComplexity =
201
+ this.calculateTemplateComplexity(classDecl);
202
+ }
203
+ });
204
+ return metrics;
205
+ }
206
+ /**
207
+ * Calculate complexity metrics for a source file.
208
+ *
209
+ * @param sourceFile - The source file to analyze
210
+ * @returns Complexity metrics
211
+ *
212
+ * Calculates actual metrics using ts-morph AST analysis:
213
+ * - Cyclomatic complexity: count decision points (if, for, while, case, &&, ||, ?)
214
+ * - Lines of code: count non-empty, non-comment lines
215
+ * - Method count: count function/method declarations
216
+ * - Dependency count: analyze constructor parameters and property injections
217
+ */
218
+ calculate(sourceFile) {
219
+ const cyclomaticComplexity = this.calculateCyclomaticComplexitySourceFile(sourceFile);
220
+ const linesOfCode = this.calculateLinesOfCode(sourceFile);
221
+ const methodCount = this.calculateMethodCountSourceFile(sourceFile);
222
+ const dependencyCount = this.calculateDependencyCount(sourceFile);
223
+ // Angular-specific metrics
224
+ const metadata = {
225
+ ...this.calculateAngularMetrics(sourceFile),
226
+ };
227
+ return {
228
+ cyclomaticComplexity,
229
+ linesOfCode,
230
+ methodCount,
231
+ dependencyCount,
232
+ metadata,
233
+ };
234
+ }
235
+ /**
236
+ * Calculate cyclomatic complexity for a source file.
237
+ * Counts decision points: if, for, while, do-while, case, catch, &&, ||, ?
238
+ *
239
+ * @param sourceFile - The source file
240
+ * @returns Cyclomatic complexity value
241
+ */
242
+ calculateCyclomaticComplexitySourceFile(sourceFile) {
243
+ let complexity = 1; // Base complexity
244
+ // Decision point node types
245
+ const decisionPoints = new Set([
246
+ SyntaxKind.IfStatement,
247
+ SyntaxKind.ForStatement,
248
+ SyntaxKind.ForInStatement,
249
+ SyntaxKind.ForOfStatement,
250
+ SyntaxKind.WhileStatement,
251
+ SyntaxKind.DoStatement,
252
+ SyntaxKind.CaseClause,
253
+ SyntaxKind.CatchClause,
254
+ SyntaxKind.ConditionalExpression, // ternary operator
255
+ ]);
256
+ const logicalOperators = new Set([
257
+ SyntaxKind.AmpersandAmpersandToken,
258
+ SyntaxKind.BarBarToken,
259
+ ]);
260
+ // Count decision points and logical operators
261
+ sourceFile.forEachDescendant((node) => {
262
+ const kind = node.getKind();
263
+ if (decisionPoints.has(kind)) {
264
+ complexity++;
265
+ return;
266
+ }
267
+ // Count logical operators (&&, ||) in binary expressions
268
+ if (kind === SyntaxKind.BinaryExpression) {
269
+ const operator = node
270
+ .asKind(SyntaxKind.BinaryExpression)
271
+ ?.getOperatorToken()
272
+ .getKind();
273
+ if (operator && logicalOperators.has(operator)) {
274
+ complexity++;
275
+ }
276
+ }
277
+ });
278
+ return complexity;
279
+ }
280
+ /**
281
+ * Calculate lines of code (excluding comments and whitespace).
282
+ *
283
+ * @param sourceFile - The source file
284
+ * @returns Lines of code count
285
+ */
286
+ calculateLinesOfCode(sourceFile) {
287
+ const text = sourceFile.getFullText();
288
+ const lines = text.split('\n');
289
+ let inBlockComment = false;
290
+ return lines.reduce((loc, line) => {
291
+ const trimmed = line.trim();
292
+ // Track block comment state
293
+ if (trimmed.startsWith('/*')) {
294
+ inBlockComment = true;
295
+ }
296
+ // Skip lines inside block comments
297
+ if (inBlockComment) {
298
+ if (trimmed.endsWith('*/')) {
299
+ inBlockComment = false;
300
+ }
301
+ return loc;
302
+ }
303
+ // Skip empty lines and single-line comments, count everything else
304
+ return trimmed.length === 0 || trimmed.startsWith('//') ? loc : loc + 1;
305
+ }, 0);
306
+ }
307
+ /**
308
+ * Calculate method/function count.
309
+ *
310
+ * @param sourceFile - The source file
311
+ * @returns Method count
312
+ */
313
+ calculateMethodCountSourceFile(sourceFile) {
314
+ let count = 0;
315
+ sourceFile.forEachDescendant((node) => {
316
+ const kind = node.getKind();
317
+ if (kind === SyntaxKind.MethodDeclaration ||
318
+ kind === SyntaxKind.FunctionDeclaration ||
319
+ kind === SyntaxKind.FunctionExpression ||
320
+ kind === SyntaxKind.ArrowFunction ||
321
+ kind === SyntaxKind.GetAccessor ||
322
+ kind === SyntaxKind.SetAccessor) {
323
+ count++;
324
+ }
325
+ });
326
+ return count;
327
+ }
328
+ /**
329
+ * Calculate Angular-specific metrics.
330
+ *
331
+ * @param sourceFile - The source file
332
+ * @returns Angular-specific metrics
333
+ */
334
+ calculateAngularMetrics(sourceFile) {
335
+ const metrics = {
336
+ lifecycleHookCount: 0,
337
+ inputCount: 0,
338
+ outputCount: 0,
339
+ templateComplexity: 0,
340
+ };
341
+ const classes = sourceFile.getClasses();
342
+ for (const classDecl of classes) {
343
+ // Count lifecycle hooks
344
+ metrics['lifecycleHookCount'] =
345
+ metrics['lifecycleHookCount'] +
346
+ this.countLifecycleHooks(classDecl);
347
+ // Count @Input and @Output decorators
348
+ const { inputCount, outputCount } = this.countInputsAndOutputs(classDecl);
349
+ metrics['inputCount'] = metrics['inputCount'] + inputCount;
350
+ metrics['outputCount'] = metrics['outputCount'] + outputCount;
351
+ // Calculate template complexity (if component)
352
+ const templateComplexity = this.calculateTemplateComplexity(classDecl);
353
+ metrics['templateComplexity'] =
354
+ metrics['templateComplexity'] + templateComplexity;
355
+ }
356
+ return metrics;
357
+ }
358
+ /**
359
+ * Count lifecycle hook methods in a class.
360
+ *
361
+ * @param classDecl - The class declaration
362
+ * @returns Count of lifecycle hooks
363
+ */
364
+ countLifecycleHooks(classDecl) {
365
+ const lifecycleHooks = [
366
+ 'ngOnInit',
367
+ 'ngOnDestroy',
368
+ 'ngOnChanges',
369
+ 'ngDoCheck',
370
+ 'ngAfterContentInit',
371
+ 'ngAfterContentChecked',
372
+ 'ngAfterViewInit',
373
+ 'ngAfterViewChecked',
374
+ ];
375
+ let count = 0;
376
+ const methods = classDecl.getMethods();
377
+ for (const method of methods) {
378
+ if (lifecycleHooks.includes(method.getName())) {
379
+ count++;
380
+ }
381
+ }
382
+ return count;
383
+ }
384
+ /**
385
+ * Count @Input and @Output decorators in a class.
386
+ *
387
+ * @param classDecl - The class declaration
388
+ * @returns Input and output counts
389
+ */
390
+ countInputsAndOutputs(classDecl) {
391
+ let inputCount = 0;
392
+ let outputCount = 0;
393
+ // Helper to count decorators by name
394
+ const countDecorators = (nodes, decoratorName) => {
395
+ return nodes.reduce((count, node) => {
396
+ return (count +
397
+ node.getDecorators().filter((d) => d.getName() === decoratorName)
398
+ .length);
399
+ }, 0);
400
+ };
401
+ // Count @Input on properties and setters
402
+ inputCount =
403
+ countDecorators(classDecl.getProperties(), 'Input') +
404
+ countDecorators(classDecl.getSetAccessors(), 'Input');
405
+ // Count @Output on properties
406
+ outputCount = countDecorators(classDecl.getProperties(), 'Output');
407
+ return { inputCount, outputCount };
408
+ }
409
+ /**
410
+ * Calculate template complexity for a component.
411
+ * Looks for inline templates in @Component decorator.
412
+ *
413
+ * @param classDecl - The class declaration
414
+ * @returns Template complexity score
415
+ */
416
+ calculateTemplateComplexity(classDecl) {
417
+ const componentDecorator = classDecl
418
+ .getDecorators()
419
+ .find((d) => d.getName() === 'Component');
420
+ if (!componentDecorator) {
421
+ return 0;
422
+ }
423
+ const decoratorText = componentDecorator.getText();
424
+ // Extract inline template
425
+ const templateMatch = /template\s*:\s*`([^`]*)`/s.exec(decoratorText);
426
+ if (!templateMatch?.[1]) {
427
+ return 0;
428
+ }
429
+ const template = templateMatch[1];
430
+ // Count complexity indicators in template
431
+ let complexity = 0;
432
+ // Structural directives
433
+ complexity += (template.match(/\*ngIf/g) ?? []).length;
434
+ complexity += (template.match(/\*ngFor/g) ?? []).length;
435
+ complexity += (template.match(/\*ngSwitch/g) ?? []).length;
436
+ // Event bindings
437
+ complexity += (template.match(/\([a-zA-Z]+\)/g) ?? []).length;
438
+ // Property bindings
439
+ complexity += (template.match(/\[[a-zA-Z]+\]/g) ?? []).length;
440
+ // Pipes (complexity factor)
441
+ complexity += (template.match(/\|/g) ?? []).length;
442
+ return complexity;
443
+ }
444
+ }
445
+ //# sourceMappingURL=complexity-metrics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"complexity-metrics.js","sourceRoot":"","sources":["../../src/metrics/complexity-metrics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAEL,UAAU,EAEV,gBAAgB,IAAI,qBAAqB,GAE1C,MAAM,UAAU,CAAC;AA8DlB;;GAEG;AACH,MAAM,OAAO,2BAA2B;IACtC;;;;;;;;;;;OAWG;IACH,0BAA0B,CAAC,SAA2B;QACpD,MAAM,UAAU,GAAG,IAAI,CAAC,6BAA6B,CAAC,SAAS,CAAC,CAAC;QACjE,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,aAAa,EAAE,CAAC,CAAC;QACzD,MAAM,OAAO,GAAG,IAAI,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC;QACrD,MAAM,cAAc,GAAG,IAAI,CAAC,+BAA+B,CAAC,SAAS,CAAC,CAAC;QAEvE,0CAA0C;QAC1C,MAAM,KAAK,GACT,UAAU,GAAG,GAAG;YAChB,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG;YAChB,OAAO,GAAG,CAAC,GAAG,GAAG;YACjB,CAAC,cAAc,CAAC,cAAc;gBAC5B,cAAc,CAAC,MAAM;gBACrB,cAAc,CAAC,OAAO,CAAC;gBACvB,GAAG;gBACH,GAAG,CAAC;QAER,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;IAC3C,CAAC;IAaD,6BAA6B,CAC3B,IAA0C;QAE1C,IAAI,UAAU,GAAG,CAAC,CAAC,CAAC,kBAAkB;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