@optave/codegraph 3.9.0 → 3.9.2
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/README.md +12 -13
- package/dist/ast-analysis/engine.d.ts.map +1 -1
- package/dist/ast-analysis/engine.js +78 -48
- package/dist/ast-analysis/engine.js.map +1 -1
- package/dist/ast-analysis/visitors/ast-store-visitor.d.ts.map +1 -1
- package/dist/ast-analysis/visitors/ast-store-visitor.js +15 -18
- package/dist/ast-analysis/visitors/ast-store-visitor.js.map +1 -1
- package/dist/cli/commands/batch.d.ts.map +1 -1
- package/dist/cli/commands/batch.js +5 -17
- package/dist/cli/commands/batch.js.map +1 -1
- package/dist/cli/commands/structure.d.ts.map +1 -1
- package/dist/cli/commands/structure.js +18 -1
- package/dist/cli/commands/structure.js.map +1 -1
- package/dist/db/connection.d.ts +3 -0
- package/dist/db/connection.d.ts.map +1 -1
- package/dist/db/connection.js +24 -6
- package/dist/db/connection.js.map +1 -1
- package/dist/db/index.d.ts +1 -1
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/index.js +1 -1
- package/dist/db/index.js.map +1 -1
- package/dist/db/repository/base.d.ts +35 -0
- package/dist/db/repository/base.d.ts.map +1 -1
- package/dist/db/repository/base.js +8 -0
- package/dist/db/repository/base.js.map +1 -1
- package/dist/db/repository/index.d.ts +1 -0
- package/dist/db/repository/index.d.ts.map +1 -1
- package/dist/db/repository/index.js.map +1 -1
- package/dist/db/repository/native-repository.d.ts +7 -1
- package/dist/db/repository/native-repository.d.ts.map +1 -1
- package/dist/db/repository/native-repository.js +46 -1
- package/dist/db/repository/native-repository.js.map +1 -1
- package/dist/domain/analysis/context.d.ts.map +1 -1
- package/dist/domain/analysis/context.js +5 -15
- package/dist/domain/analysis/context.js.map +1 -1
- package/dist/domain/analysis/dependencies.d.ts +6 -33
- package/dist/domain/analysis/dependencies.d.ts.map +1 -1
- package/dist/domain/analysis/dependencies.js +18 -16
- package/dist/domain/analysis/dependencies.js.map +1 -1
- package/dist/domain/analysis/fn-impact.js +2 -2
- package/dist/domain/analysis/fn-impact.js.map +1 -1
- package/dist/domain/analysis/implementations.d.ts.map +1 -1
- package/dist/domain/analysis/implementations.js +3 -13
- package/dist/domain/analysis/implementations.js.map +1 -1
- package/dist/domain/graph/builder/context.d.ts +4 -0
- package/dist/domain/graph/builder/context.d.ts.map +1 -1
- package/dist/domain/graph/builder/context.js +4 -0
- package/dist/domain/graph/builder/context.js.map +1 -1
- package/dist/domain/graph/builder/incremental.d.ts.map +1 -1
- package/dist/domain/graph/builder/incremental.js +18 -0
- package/dist/domain/graph/builder/incremental.js.map +1 -1
- package/dist/domain/graph/builder/native-db-proxy.d.ts +24 -0
- package/dist/domain/graph/builder/native-db-proxy.d.ts.map +1 -0
- package/dist/domain/graph/builder/native-db-proxy.js +87 -0
- package/dist/domain/graph/builder/native-db-proxy.js.map +1 -0
- package/dist/domain/graph/builder/pipeline.d.ts.map +1 -1
- package/dist/domain/graph/builder/pipeline.js +410 -349
- package/dist/domain/graph/builder/pipeline.js.map +1 -1
- package/dist/domain/graph/builder/stages/build-edges.d.ts.map +1 -1
- package/dist/domain/graph/builder/stages/build-edges.js +44 -4
- package/dist/domain/graph/builder/stages/build-edges.js.map +1 -1
- package/dist/domain/graph/builder/stages/build-structure.js +2 -2
- package/dist/domain/graph/builder/stages/build-structure.js.map +1 -1
- package/dist/domain/graph/builder/stages/detect-changes.d.ts.map +1 -1
- package/dist/domain/graph/builder/stages/detect-changes.js +6 -28
- package/dist/domain/graph/builder/stages/detect-changes.js.map +1 -1
- package/dist/domain/graph/builder/stages/finalize.js +1 -1
- package/dist/domain/graph/builder/stages/finalize.js.map +1 -1
- package/dist/domain/graph/builder/stages/insert-nodes.d.ts.map +1 -1
- package/dist/domain/graph/builder/stages/insert-nodes.js +16 -12
- package/dist/domain/graph/builder/stages/insert-nodes.js.map +1 -1
- package/dist/domain/graph/builder/stages/resolve-imports.d.ts.map +1 -1
- package/dist/domain/graph/builder/stages/resolve-imports.js +21 -26
- package/dist/domain/graph/builder/stages/resolve-imports.js.map +1 -1
- package/dist/domain/graph/watcher.d.ts.map +1 -1
- package/dist/domain/graph/watcher.js +99 -95
- package/dist/domain/graph/watcher.js.map +1 -1
- package/dist/domain/parser.d.ts.map +1 -1
- package/dist/domain/parser.js +7 -2
- package/dist/domain/parser.js.map +1 -1
- package/dist/domain/queries.d.ts +1 -1
- package/dist/domain/queries.d.ts.map +1 -1
- package/dist/domain/queries.js +1 -1
- package/dist/domain/queries.js.map +1 -1
- package/dist/extractors/go.js +53 -35
- package/dist/extractors/go.js.map +1 -1
- package/dist/extractors/javascript.js +66 -27
- package/dist/extractors/javascript.js.map +1 -1
- package/dist/features/audit.d.ts.map +1 -1
- package/dist/features/audit.js +3 -2
- package/dist/features/audit.js.map +1 -1
- package/dist/features/boundaries.d.ts.map +1 -1
- package/dist/features/boundaries.js +3 -5
- package/dist/features/boundaries.js.map +1 -1
- package/dist/features/branch-compare.d.ts.map +1 -1
- package/dist/features/branch-compare.js +2 -1
- package/dist/features/branch-compare.js.map +1 -1
- package/dist/features/complexity.d.ts.map +1 -1
- package/dist/features/complexity.js +78 -58
- package/dist/features/complexity.js.map +1 -1
- package/dist/features/dataflow.d.ts.map +1 -1
- package/dist/features/dataflow.js +109 -118
- package/dist/features/dataflow.js.map +1 -1
- package/dist/features/flow.d.ts.map +1 -1
- package/dist/features/flow.js +2 -1
- package/dist/features/flow.js.map +1 -1
- package/dist/features/manifesto.d.ts.map +1 -1
- package/dist/features/manifesto.js +15 -1
- package/dist/features/manifesto.js.map +1 -1
- package/dist/features/structure.d.ts.map +1 -1
- package/dist/features/structure.js +147 -97
- package/dist/features/structure.js.map +1 -1
- package/dist/graph/algorithms/louvain.d.ts.map +1 -1
- package/dist/graph/algorithms/louvain.js +4 -2
- package/dist/graph/algorithms/louvain.js.map +1 -1
- package/dist/graph/classifiers/roles.d.ts +2 -0
- package/dist/graph/classifiers/roles.d.ts.map +1 -1
- package/dist/graph/classifiers/roles.js +13 -5
- package/dist/graph/classifiers/roles.js.map +1 -1
- package/dist/infrastructure/config.d.ts +1 -0
- package/dist/infrastructure/config.d.ts.map +1 -1
- package/dist/infrastructure/config.js +1 -0
- package/dist/infrastructure/config.js.map +1 -1
- package/dist/presentation/batch.d.ts.map +1 -1
- package/dist/presentation/batch.js +1 -0
- package/dist/presentation/batch.js.map +1 -1
- package/dist/presentation/communities.d.ts.map +1 -1
- package/dist/presentation/communities.js +38 -34
- package/dist/presentation/communities.js.map +1 -1
- package/dist/presentation/manifesto.d.ts.map +1 -1
- package/dist/presentation/manifesto.js +31 -33
- package/dist/presentation/manifesto.js.map +1 -1
- package/dist/presentation/queries-cli/inspect.d.ts.map +1 -1
- package/dist/presentation/queries-cli/inspect.js +47 -46
- package/dist/presentation/queries-cli/inspect.js.map +1 -1
- package/dist/presentation/structure.d.ts +1 -1
- package/dist/presentation/structure.d.ts.map +1 -1
- package/dist/presentation/structure.js +1 -1
- package/dist/presentation/structure.js.map +1 -1
- package/dist/shared/file-utils.d.ts.map +1 -1
- package/dist/shared/file-utils.js +94 -72
- package/dist/shared/file-utils.js.map +1 -1
- package/dist/shared/normalize.d.ts +12 -0
- package/dist/shared/normalize.d.ts.map +1 -1
- package/dist/shared/normalize.js +4 -0
- package/dist/shared/normalize.js.map +1 -1
- package/dist/types.d.ts +82 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +7 -7
- package/src/ast-analysis/engine.ts +99 -55
- package/src/ast-analysis/visitors/ast-store-visitor.ts +19 -21
- package/src/cli/commands/batch.ts +5 -26
- package/src/cli/commands/structure.ts +21 -1
- package/src/db/connection.ts +26 -7
- package/src/db/index.ts +2 -0
- package/src/db/repository/base.ts +43 -0
- package/src/db/repository/index.ts +1 -0
- package/src/db/repository/native-repository.ts +67 -1
- package/src/domain/analysis/context.ts +5 -15
- package/src/domain/analysis/dependencies.ts +19 -16
- package/src/domain/analysis/fn-impact.ts +2 -2
- package/src/domain/analysis/implementations.ts +3 -13
- package/src/domain/graph/builder/context.ts +4 -0
- package/src/domain/graph/builder/incremental.ts +21 -0
- package/src/domain/graph/builder/native-db-proxy.ts +98 -0
- package/src/domain/graph/builder/pipeline.ts +514 -416
- package/src/domain/graph/builder/stages/build-edges.ts +45 -3
- package/src/domain/graph/builder/stages/build-structure.ts +2 -2
- package/src/domain/graph/builder/stages/detect-changes.ts +11 -33
- package/src/domain/graph/builder/stages/finalize.ts +1 -1
- package/src/domain/graph/builder/stages/insert-nodes.ts +17 -14
- package/src/domain/graph/builder/stages/resolve-imports.ts +22 -23
- package/src/domain/graph/watcher.ts +118 -98
- package/src/domain/parser.ts +8 -2
- package/src/domain/queries.ts +1 -1
- package/src/extractors/go.ts +57 -32
- package/src/extractors/javascript.ts +67 -27
- package/src/features/audit.ts +3 -2
- package/src/features/boundaries.ts +3 -5
- package/src/features/branch-compare.ts +2 -3
- package/src/features/complexity.ts +94 -58
- package/src/features/dataflow.ts +153 -132
- package/src/features/flow.ts +2 -1
- package/src/features/manifesto.ts +15 -1
- package/src/features/structure.ts +167 -95
- package/src/graph/algorithms/louvain.ts +5 -2
- package/src/graph/classifiers/roles.ts +14 -5
- package/src/infrastructure/config.ts +1 -0
- package/src/presentation/batch.ts +1 -0
- package/src/presentation/communities.ts +44 -39
- package/src/presentation/manifesto.ts +35 -38
- package/src/presentation/queries-cli/inspect.ts +48 -46
- package/src/presentation/structure.ts +2 -2
- package/src/shared/file-utils.ts +116 -77
- package/src/shared/normalize.ts +10 -0
- package/src/types.ts +86 -0
package/src/features/dataflow.ts
CHANGED
|
@@ -23,6 +23,7 @@ import { hasDataflowTable, openReadonlyOrFail, openReadonlyWithNative } from '..
|
|
|
23
23
|
import { ALL_SYMBOL_KINDS, normalizeSymbol } from '../domain/queries.js';
|
|
24
24
|
import { debug, info } from '../infrastructure/logger.js';
|
|
25
25
|
import { isTestFile } from '../infrastructure/test-filter.js';
|
|
26
|
+
import type { NormalizedSymbol } from '../shared/normalize.js';
|
|
26
27
|
import { paginateResult } from '../shared/paginate.js';
|
|
27
28
|
import type { BetterSqlite3Database, NativeDatabase, NodeRow, TreeSitterNode } from '../types.js';
|
|
28
29
|
import { findNodes } from './shared/find-nodes.js';
|
|
@@ -438,85 +439,126 @@ function prepareDataflowStmts(db: BetterSqlite3Database): DataflowStmts {
|
|
|
438
439
|
};
|
|
439
440
|
}
|
|
440
441
|
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
442
|
+
// ─── Shared dataflow result builder ──────────────────────────────────
|
|
443
|
+
|
|
444
|
+
/** Pre-mapped raw dataflow edge arrays shared between SQL and native paths. */
|
|
445
|
+
interface RawDataflowEdges {
|
|
446
|
+
flowsTo: {
|
|
447
|
+
target: string;
|
|
448
|
+
kind: string;
|
|
449
|
+
file: string;
|
|
450
|
+
line: number;
|
|
451
|
+
paramIndex: number;
|
|
452
|
+
expression: string;
|
|
453
|
+
confidence: number;
|
|
454
|
+
}[];
|
|
455
|
+
flowsFrom: {
|
|
456
|
+
source: string;
|
|
457
|
+
kind: string;
|
|
458
|
+
file: string;
|
|
459
|
+
line: number;
|
|
460
|
+
paramIndex: number;
|
|
461
|
+
expression: string;
|
|
462
|
+
confidence: number;
|
|
463
|
+
}[];
|
|
464
|
+
returnConsumers: {
|
|
465
|
+
consumer: string;
|
|
466
|
+
kind: string;
|
|
467
|
+
file: string;
|
|
468
|
+
line: number;
|
|
469
|
+
expression: string;
|
|
470
|
+
}[];
|
|
471
|
+
returnedBy: { producer: string; kind: string; file: string; line: number; expression: string }[];
|
|
472
|
+
mutatesTargets: { target: string; expression: string; line: number }[];
|
|
473
|
+
mutatedBy: { source: string; expression: string; line: number }[];
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* Build a unified dataflow result from pre-mapped edge data.
|
|
478
|
+
* Shared between the SQL and native code paths.
|
|
479
|
+
*/
|
|
480
|
+
function buildDataflowResult(
|
|
481
|
+
sym: NormalizedSymbol,
|
|
482
|
+
edges: RawDataflowEdges,
|
|
446
483
|
noTests: boolean,
|
|
447
484
|
): Record<string, unknown> {
|
|
448
|
-
const sym = normalizeSymbol(node, db, hc);
|
|
449
|
-
|
|
450
|
-
const flowsTo = stmts.flowsToOut.all(node.id).map((r: any) => ({
|
|
451
|
-
target: r.target_name,
|
|
452
|
-
kind: r.target_kind,
|
|
453
|
-
file: r.target_file,
|
|
454
|
-
line: r.line,
|
|
455
|
-
paramIndex: r.param_index,
|
|
456
|
-
expression: r.expression,
|
|
457
|
-
confidence: r.confidence,
|
|
458
|
-
}));
|
|
459
|
-
|
|
460
|
-
const flowsFrom = stmts.flowsToIn.all(node.id).map((r: any) => ({
|
|
461
|
-
source: r.source_name,
|
|
462
|
-
kind: r.source_kind,
|
|
463
|
-
file: r.source_file,
|
|
464
|
-
line: r.line,
|
|
465
|
-
paramIndex: r.param_index,
|
|
466
|
-
expression: r.expression,
|
|
467
|
-
confidence: r.confidence,
|
|
468
|
-
}));
|
|
469
|
-
|
|
470
|
-
const returnConsumers = stmts.returnsOut.all(node.id).map((r: any) => ({
|
|
471
|
-
consumer: r.target_name,
|
|
472
|
-
kind: r.target_kind,
|
|
473
|
-
file: r.target_file,
|
|
474
|
-
line: r.line,
|
|
475
|
-
expression: r.expression,
|
|
476
|
-
}));
|
|
477
|
-
|
|
478
|
-
const returnedBy = stmts.returnsIn.all(node.id).map((r: any) => ({
|
|
479
|
-
producer: r.source_name,
|
|
480
|
-
kind: r.source_kind,
|
|
481
|
-
file: r.source_file,
|
|
482
|
-
line: r.line,
|
|
483
|
-
expression: r.expression,
|
|
484
|
-
}));
|
|
485
|
-
|
|
486
|
-
const mutatesTargets = stmts.mutatesOut.all(node.id).map((r: any) => ({
|
|
487
|
-
target: r.target_name,
|
|
488
|
-
expression: r.expression,
|
|
489
|
-
line: r.line,
|
|
490
|
-
}));
|
|
491
|
-
|
|
492
|
-
const mutatedBy = stmts.mutatesIn.all(node.id).map((r: any) => ({
|
|
493
|
-
source: r.source_name,
|
|
494
|
-
expression: r.expression,
|
|
495
|
-
line: r.line,
|
|
496
|
-
}));
|
|
497
|
-
|
|
498
485
|
if (noTests) {
|
|
499
486
|
const filter = (arr: any[]) => arr.filter((r: any) => !isTestFile(r.file));
|
|
500
487
|
return {
|
|
501
488
|
...sym,
|
|
502
|
-
flowsTo: filter(flowsTo),
|
|
503
|
-
flowsFrom: filter(flowsFrom),
|
|
504
|
-
returns: returnConsumers.filter((r) => !isTestFile(r.file)),
|
|
505
|
-
returnedBy: returnedBy.filter((r) => !isTestFile(r.file)),
|
|
506
|
-
mutates: mutatesTargets,
|
|
507
|
-
mutatedBy,
|
|
489
|
+
flowsTo: filter(edges.flowsTo),
|
|
490
|
+
flowsFrom: filter(edges.flowsFrom),
|
|
491
|
+
returns: edges.returnConsumers.filter((r: any) => !isTestFile(r.file)),
|
|
492
|
+
returnedBy: edges.returnedBy.filter((r: any) => !isTestFile(r.file)),
|
|
493
|
+
mutates: edges.mutatesTargets,
|
|
494
|
+
mutatedBy: edges.mutatedBy,
|
|
508
495
|
};
|
|
509
496
|
}
|
|
510
497
|
|
|
511
498
|
return {
|
|
512
499
|
...sym,
|
|
513
|
-
flowsTo,
|
|
514
|
-
flowsFrom,
|
|
515
|
-
returns: returnConsumers,
|
|
516
|
-
returnedBy,
|
|
517
|
-
mutates: mutatesTargets,
|
|
518
|
-
mutatedBy,
|
|
500
|
+
flowsTo: edges.flowsTo,
|
|
501
|
+
flowsFrom: edges.flowsFrom,
|
|
502
|
+
returns: edges.returnConsumers,
|
|
503
|
+
returnedBy: edges.returnedBy,
|
|
504
|
+
mutates: edges.mutatesTargets,
|
|
505
|
+
mutatedBy: edges.mutatedBy,
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
function buildNodeDataflowResult(
|
|
510
|
+
node: NodeRow,
|
|
511
|
+
stmts: DataflowStmts,
|
|
512
|
+
db: BetterSqlite3Database,
|
|
513
|
+
hc: Map<string, string | null>,
|
|
514
|
+
noTests: boolean,
|
|
515
|
+
): Record<string, unknown> {
|
|
516
|
+
const sym = normalizeSymbol(node, db, hc);
|
|
517
|
+
const edges: RawDataflowEdges = {
|
|
518
|
+
flowsTo: stmts.flowsToOut.all(node.id).map((r: any) => ({
|
|
519
|
+
target: r.target_name,
|
|
520
|
+
kind: r.target_kind,
|
|
521
|
+
file: r.target_file,
|
|
522
|
+
line: r.line,
|
|
523
|
+
paramIndex: r.param_index,
|
|
524
|
+
expression: r.expression,
|
|
525
|
+
confidence: r.confidence,
|
|
526
|
+
})),
|
|
527
|
+
flowsFrom: stmts.flowsToIn.all(node.id).map((r: any) => ({
|
|
528
|
+
source: r.source_name,
|
|
529
|
+
kind: r.source_kind,
|
|
530
|
+
file: r.source_file,
|
|
531
|
+
line: r.line,
|
|
532
|
+
paramIndex: r.param_index,
|
|
533
|
+
expression: r.expression,
|
|
534
|
+
confidence: r.confidence,
|
|
535
|
+
})),
|
|
536
|
+
returnConsumers: stmts.returnsOut.all(node.id).map((r: any) => ({
|
|
537
|
+
consumer: r.target_name,
|
|
538
|
+
kind: r.target_kind,
|
|
539
|
+
file: r.target_file,
|
|
540
|
+
line: r.line,
|
|
541
|
+
expression: r.expression,
|
|
542
|
+
})),
|
|
543
|
+
returnedBy: stmts.returnsIn.all(node.id).map((r: any) => ({
|
|
544
|
+
producer: r.source_name,
|
|
545
|
+
kind: r.source_kind,
|
|
546
|
+
file: r.source_file,
|
|
547
|
+
line: r.line,
|
|
548
|
+
expression: r.expression,
|
|
549
|
+
})),
|
|
550
|
+
mutatesTargets: stmts.mutatesOut.all(node.id).map((r: any) => ({
|
|
551
|
+
target: r.target_name,
|
|
552
|
+
expression: r.expression,
|
|
553
|
+
line: r.line,
|
|
554
|
+
})),
|
|
555
|
+
mutatedBy: stmts.mutatesIn.all(node.id).map((r: any) => ({
|
|
556
|
+
source: r.source_name,
|
|
557
|
+
expression: r.expression,
|
|
558
|
+
line: r.line,
|
|
559
|
+
})),
|
|
519
560
|
};
|
|
561
|
+
return buildDataflowResult(sym, edges, noTests);
|
|
520
562
|
}
|
|
521
563
|
|
|
522
564
|
function buildNativeDataflowResult(
|
|
@@ -528,72 +570,51 @@ function buildNativeDataflowResult(
|
|
|
528
570
|
): Record<string, unknown> {
|
|
529
571
|
const sym = normalizeSymbol(node, db, hc);
|
|
530
572
|
const d = nativeDb.getDataflowEdges!(node.id);
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
if (noTests) {
|
|
576
|
-
const filter = (arr: any[]) => arr.filter((r: any) => !isTestFile(r.file));
|
|
577
|
-
return {
|
|
578
|
-
...sym,
|
|
579
|
-
flowsTo: filter(flowsTo),
|
|
580
|
-
flowsFrom: filter(flowsFrom),
|
|
581
|
-
returns: returnConsumers.filter((r: any) => !isTestFile(r.file)),
|
|
582
|
-
returnedBy: returnedBy.filter((r: any) => !isTestFile(r.file)),
|
|
583
|
-
mutates: mutatesTargets,
|
|
584
|
-
mutatedBy,
|
|
585
|
-
};
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
return {
|
|
589
|
-
...sym,
|
|
590
|
-
flowsTo,
|
|
591
|
-
flowsFrom,
|
|
592
|
-
returns: returnConsumers,
|
|
593
|
-
returnedBy,
|
|
594
|
-
mutates: mutatesTargets,
|
|
595
|
-
mutatedBy,
|
|
573
|
+
const edges: RawDataflowEdges = {
|
|
574
|
+
flowsTo: d.flowsToOut.map((r: any) => ({
|
|
575
|
+
target: r.name,
|
|
576
|
+
kind: r.kind,
|
|
577
|
+
file: r.file,
|
|
578
|
+
line: r.line,
|
|
579
|
+
paramIndex: r.paramIndex,
|
|
580
|
+
expression: r.expression,
|
|
581
|
+
confidence: r.confidence,
|
|
582
|
+
})),
|
|
583
|
+
flowsFrom: d.flowsToIn.map((r: any) => ({
|
|
584
|
+
source: r.name,
|
|
585
|
+
kind: r.kind,
|
|
586
|
+
file: r.file,
|
|
587
|
+
line: r.line,
|
|
588
|
+
paramIndex: r.paramIndex,
|
|
589
|
+
expression: r.expression,
|
|
590
|
+
confidence: r.confidence,
|
|
591
|
+
})),
|
|
592
|
+
returnConsumers: d.returnsOut.map((r: any) => ({
|
|
593
|
+
consumer: r.name,
|
|
594
|
+
kind: r.kind,
|
|
595
|
+
file: r.file,
|
|
596
|
+
line: r.line,
|
|
597
|
+
expression: r.expression,
|
|
598
|
+
})),
|
|
599
|
+
returnedBy: d.returnsIn.map((r: any) => ({
|
|
600
|
+
producer: r.name,
|
|
601
|
+
kind: r.kind,
|
|
602
|
+
file: r.file,
|
|
603
|
+
line: r.line,
|
|
604
|
+
expression: r.expression,
|
|
605
|
+
})),
|
|
606
|
+
mutatesTargets: d.mutatesOut.map((r: any) => ({
|
|
607
|
+
target: r.name,
|
|
608
|
+
expression: r.expression,
|
|
609
|
+
line: r.line,
|
|
610
|
+
})),
|
|
611
|
+
mutatedBy: d.mutatesIn.map((r: any) => ({
|
|
612
|
+
source: r.name,
|
|
613
|
+
expression: r.expression,
|
|
614
|
+
line: r.line,
|
|
615
|
+
})),
|
|
596
616
|
};
|
|
617
|
+
return buildDataflowResult(sym, edges, noTests);
|
|
597
618
|
}
|
|
598
619
|
|
|
599
620
|
export function dataflowData(
|
package/src/features/flow.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import { openReadonlyOrFail } from '../db/index.js';
|
|
9
9
|
import { CORE_SYMBOL_KINDS, findMatchingNodes } from '../domain/queries.js';
|
|
10
10
|
import { isTestFile } from '../infrastructure/test-filter.js';
|
|
11
|
+
import { toSymbolRef } from '../shared/normalize.js';
|
|
11
12
|
import { paginateResult } from '../shared/paginate.js';
|
|
12
13
|
import { FRAMEWORK_ENTRY_PREFIXES } from './structure.js';
|
|
13
14
|
|
|
@@ -175,7 +176,7 @@ function bfsCallees(
|
|
|
175
176
|
|
|
176
177
|
visited.add(c.id);
|
|
177
178
|
nextFrontier.push(c.id);
|
|
178
|
-
const nodeInfo: NodeInfo =
|
|
179
|
+
const nodeInfo: NodeInfo = toSymbolRef(c);
|
|
179
180
|
levelNodes.push(nodeInfo);
|
|
180
181
|
nodeDepths.set(c.id, d);
|
|
181
182
|
idToNode.set(c.id, nodeInfo);
|
|
@@ -5,6 +5,7 @@ import { loadConfig } from '../infrastructure/config.js';
|
|
|
5
5
|
import { debug } from '../infrastructure/logger.js';
|
|
6
6
|
import { paginateResult } from '../shared/paginate.js';
|
|
7
7
|
import type { BetterSqlite3Database, CodegraphConfig, ThresholdRule } from '../types.js';
|
|
8
|
+
import type { BoundaryViolation } from './boundaries.js';
|
|
8
9
|
import { evaluateBoundaries } from './boundaries.js';
|
|
9
10
|
|
|
10
11
|
// ─── Rule Definitions ─────────────────────────────────────────────────
|
|
@@ -416,7 +417,20 @@ function evaluateBoundaryRules(
|
|
|
416
417
|
return;
|
|
417
418
|
}
|
|
418
419
|
|
|
419
|
-
|
|
420
|
+
let result: { violations: BoundaryViolation[]; violationCount: number };
|
|
421
|
+
try {
|
|
422
|
+
result = evaluateBoundaries(db, boundaryConfig, { noTests: opts.noTests || false });
|
|
423
|
+
} catch (e: unknown) {
|
|
424
|
+
debug(`boundary check failed: ${(e as Error).message}`);
|
|
425
|
+
ruleResults.push({
|
|
426
|
+
name: 'boundaries',
|
|
427
|
+
level: 'graph',
|
|
428
|
+
status: 'warn',
|
|
429
|
+
thresholds: effectiveThresholds,
|
|
430
|
+
violationCount: 0,
|
|
431
|
+
});
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
420
434
|
const hasBoundaryViolations = result.violationCount > 0;
|
|
421
435
|
|
|
422
436
|
if (!hasBoundaryViolations) {
|