fcis 0.1.0 → 0.2.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/.plans/003-code-cleanup-consolidation.md +242 -0
- package/.plans/004-directory-depth-rollup.md +408 -0
- package/.plans/005-code-refinements.md +210 -0
- package/.plans/006-minor-refinements.md +149 -0
- package/.plans/007-compositional-function-scoring.md +514 -0
- package/README.md +38 -3
- package/TECHNICAL.md +125 -2
- package/dist/cli.js +595 -327
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +15 -2
- package/dist/index.js +409 -240
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
- package/src/cli-utils.ts +201 -0
- package/src/cli.ts +99 -117
- package/src/detection/markers.ts +0 -222
- package/src/extraction/extract-functions.ts +106 -2
- package/src/extraction/extractor.ts +35 -74
- package/src/reporting/report-console.ts +188 -102
- package/src/reporting/report-json.ts +26 -3
- package/src/scoring/scorer.ts +425 -160
- package/src/types.ts +9 -2
- package/tests/classifier.test.ts +0 -1
- package/tests/cli.test.ts +356 -0
- package/tests/detect-markers.test.ts +1 -3
- package/tests/extractor.test.ts +95 -1
- package/tests/integration.test.ts +344 -0
- package/tests/report-console.test.ts +92 -0
- package/tests/scorer.test.ts +886 -0
package/dist/index.d.ts
CHANGED
|
@@ -36,6 +36,8 @@ type ExtractedFunction = {
|
|
|
36
36
|
hasAwait: boolean;
|
|
37
37
|
propertyAccessChains: string[];
|
|
38
38
|
kind: 'function' | 'method' | 'arrow' | 'function-expression' | 'getter' | 'setter';
|
|
39
|
+
enclosingFunctionStartLine: number | null;
|
|
40
|
+
isInlineCallback: boolean;
|
|
39
41
|
};
|
|
40
42
|
/**
|
|
41
43
|
* Represents imports in a file
|
|
@@ -52,7 +54,7 @@ type FileImports = {
|
|
|
52
54
|
* Note: 'async-function' removed — async alone is not an impurity marker
|
|
53
55
|
* Note: React hook markers deferred to v2
|
|
54
56
|
*/
|
|
55
|
-
type MarkerType = 'await-expression' | 'database-call' | 'network-fetch' | 'network-http' | 'fs-
|
|
57
|
+
type MarkerType = 'await-expression' | 'database-call' | 'network-fetch' | 'network-http' | 'fs-call' | 'env-access' | 'console-log' | 'logging' | 'telemetry' | 'queue-enqueue' | 'event-emit';
|
|
56
58
|
/**
|
|
57
59
|
* Represents a detected impurity marker in a function
|
|
58
60
|
*/
|
|
@@ -153,6 +155,7 @@ type ProjectScore = {
|
|
|
153
155
|
subset?: boolean;
|
|
154
156
|
filesGlob?: string;
|
|
155
157
|
errors?: AnalysisError[];
|
|
158
|
+
rolledUpDirectories?: DirectoryScore[];
|
|
156
159
|
};
|
|
157
160
|
/**
|
|
158
161
|
* Error encountered during analysis
|
|
@@ -174,6 +177,7 @@ type AnalyzerConfig = {
|
|
|
174
177
|
outputPath?: string;
|
|
175
178
|
quiet?: boolean;
|
|
176
179
|
verbose?: boolean;
|
|
180
|
+
dirDepth?: number;
|
|
177
181
|
};
|
|
178
182
|
/**
|
|
179
183
|
* Quality scoring thresholds (configurable)
|
|
@@ -457,9 +461,14 @@ declare function getStatusColor(status: Status): 'green' | 'yellow' | 'red';
|
|
|
457
461
|
* all functions take data in and return data out with no I/O.
|
|
458
462
|
*
|
|
459
463
|
* Metrics:
|
|
460
|
-
* - Purity: percentage of pure functions
|
|
464
|
+
* - Purity: percentage of pure functions (top-level only, excluding inline callbacks)
|
|
461
465
|
* - Impurity Quality: average quality score of impure functions
|
|
462
466
|
* - Health: percentage of functions with status 'ok'
|
|
467
|
+
*
|
|
468
|
+
* Compositional Scoring (Plan 007):
|
|
469
|
+
* - Inline callbacks are absorbed into their parent function's score
|
|
470
|
+
* - Function counts only include top-level functions
|
|
471
|
+
* - Line counts don't double-count (parent bodyLineCount includes nested callbacks)
|
|
463
472
|
*/
|
|
464
473
|
|
|
465
474
|
/**
|
|
@@ -537,6 +546,7 @@ declare function getDiagnosticInsights(score: Pick<ProjectScore, 'purity' | 'imp
|
|
|
537
546
|
* - Directory and file breakdowns
|
|
538
547
|
* - Refactoring candidates
|
|
539
548
|
* - Any errors encountered during analysis
|
|
549
|
+
* - Rolled-up directories (when --dir-depth is used)
|
|
540
550
|
*/
|
|
541
551
|
|
|
542
552
|
/**
|
|
@@ -545,6 +555,8 @@ declare function getDiagnosticInsights(score: Pick<ProjectScore, 'purity' | 'imp
|
|
|
545
555
|
type JsonReportOptions = {
|
|
546
556
|
pretty?: boolean;
|
|
547
557
|
includeFunction?: boolean;
|
|
558
|
+
dirDepth?: number;
|
|
559
|
+
projectRoot?: string;
|
|
548
560
|
};
|
|
549
561
|
/**
|
|
550
562
|
* Generate JSON report string from project score
|
|
@@ -635,6 +647,7 @@ declare function generateComparisonReport(current: ProjectScore, previous: Proje
|
|
|
635
647
|
*/
|
|
636
648
|
declare function printConsoleReport(score: ProjectScore, options?: {
|
|
637
649
|
verbose?: boolean;
|
|
650
|
+
dirDepth?: number;
|
|
638
651
|
}): void;
|
|
639
652
|
/**
|
|
640
653
|
* Generate a single-line summary suitable for CI output
|