# 6 Essential Metrics Extracted from Code Review Graph Analysis

> Discover 6 key metrics from code review graph analysis like changed nodes and blast radius depth to measure code modification impact. Improve your codebase understanding.

- Repository: [Tirth Kanani/code-review-graph](https://github.com/tirth8205/code-review-graph)
- Tags: how-to-guide
- Published: 2026-08-17

---

**The code-review-graph extension extracts six primary metrics from your SQLite-backed codebase graph—including changed nodes, impacted nodes, blast radius depth, and graph topology statistics—to quantify the exact scope and impact of any code modification.**

The `tirth8205/code-review-graph` extension builds a persistent SQLite graph of your workspace's source code entities, enabling precise impact analysis. By querying this graph through the `SqliteReader` class, developers can extract quantitative **code review graph metrics** that reveal how deeply a change ripples through the codebase. These metrics help teams prioritize reviews, assess refactoring risk, and maintain architectural health.

## Core Metrics Available in Code Review Graph Analysis

### Changed Nodes

**Changed nodes** represent the set of graph entities that have been directly modified, such as a specific function or file you edited. According to the source code in [`src/features/blastRadius.ts`](https://github.com/tirth8205/code-review-graph/blob/main/src/features/blastRadius.ts), these are retrieved via `reader.getImpactRadius` and accessed through `impact.changedNodes` (line 55). This metric establishes the starting point for all impact calculations.

### Impacted Nodes (Blast Radius)

**Impacted nodes** comprise all entities transitively affected by the changed nodes, representing the complete **blast radius** of a modification. The extension traverses the call- and import-graph to identify these dependencies, returning them as `impact.impactedNodes` (lines 55-58 of [`blastRadius.ts`](https://github.com/tirth8205/code-review-graph/blob/main/blastRadius.ts)). This metric answers the critical question: "If I change this function, what else breaks?"

### Impacted File Count

The **impacted file count** calculates the number of distinct files containing impacted nodes, providing a quick sense of review scope. The implementation in [`src/features/blastRadius.ts`](https://github.com/tirth8205/code-review-graph/blob/main/src/features/blastRadius.ts) (lines 64-66) computes this using:

```ts
new Set(impact.impactedNodes.map((n) => n.filePath)).size

```

This metric helps reviewers understand how many files may require examination beyond the primary change.

### Blast Radius Depth

**Blast radius depth** is a configurable limit controlling how many hops the impact query traverses through the dependency graph. This allows developers to trade precision for performance based on their analysis needs. The extension reads this value from the VS Code setting `codeReviewGraph.blastRadiusDepth` (lines 50-53), enabling customizable analysis boundaries.

### Node-Level Metadata

Each graph node includes rich **metadata** essential for contextual analysis: `filePath`, line range, entity kind (function, class, variable), and a unique identifier. Defined in the SQLite schema used by `SqliteReader` ([`src/backend/sqlite.ts`](https://github.com/tirth8205/code-review-graph/blob/main/src/backend/sqlite.ts)), this data enables custom metrics such as "functions per file" or "average class size" when aggregated through direct SQL queries.

### Graph Size Statistics

High-level **graph topology metrics**—including total node count, total edge count, and average degree—provide architectural health indicators. These statistics are exposed through `SqliteReader` methods that execute aggregate queries like `SELECT COUNT(*) FROM nodes` against the underlying SQLite store ([`src/backend/sqlite.ts`](https://github.com/tirth8205/code-review-graph/blob/main/src/backend/sqlite.ts)).

## Source Code Implementation of Metric Calculation

The **Blast-Radius** feature wires these metrics into VS Code through the command `codeReviewGraph.showBlastRadius`. The workflow implemented in [`src/features/blastRadius.ts`](https://github.com/tirth8205/code-review-graph/blob/main/src/features/blastRadius.ts) follows four precise steps:

1. Resolve the cursor location to a graph node (or fall back to the file node).
2. Read the user-configured blast-radius depth from `codeReviewGraph.blastRadiusDepth`.
3. Call `reader.getImpactRadius([filePath], depth)` to fetch changed and impacted node arrays.
4. Update the `BlastRadiusTreeProvider` with results and display a summary message showing impacted node and file counts.

The underlying SQLite implementation stores the graph in `nodes` and `edges` tables, enabling both the extension's internal metrics and custom analytical queries.

## Programmatically Extracting Impact Metrics

For CI/CD integration or automated analysis tools, you can extract these metrics programmatically using the `SqliteReader` class:

```ts
import { SqliteReader } from './backend/sqlite';

function getImpactMetrics(file: string, depth = 2) {
  const reader = new SqliteReader('path/to/graph.db');
  const impact = reader.getImpactRadius([file], depth);

  const impactedFiles = new Set(
    impact.impactedNodes.map((n) => n.filePath)
  ).size;

  return {
    changedNodeCount: impact.changedNodes.length,
    impactedNodeCount: impact.impactedNodes.length,
    impactedFileCount: impactedFiles,
  };
}

// Usage
const metrics = getImpactMetrics('src/lib/utils.ts', 3);
console.log(metrics);
// → { changedNodeCount: 1, impactedNodeCount: 12, impactedFileCount: 4 }

```

This approach leverages the same `getImpactRadius` method used by the VS Code extension, ensuring consistency between local development metrics and automated pipeline analysis.

## Querying Graph Topology Statistics

To assess overall codebase complexity, extract aggregate statistics directly from the SQLite database:

```ts
import { SqliteReader } from './backend/sqlite';

async function getGraphStats(dbPath: string) {
  const reader = new SqliteReader(dbPath);
  const totalNodes = await reader.runQuery('SELECT COUNT(*) FROM nodes');
  const totalEdges = await reader.runQuery('SELECT COUNT(*) FROM edges');
  const avgDegree = totalEdges / totalNodes;

  return { totalNodes, totalEdges, avgDegree };
}

```

These metrics enable architectural health-checks by quantifying the total number of entities and their interconnectivity.

## VS Code Integration and Visualization

To enable the metrics visualization within VS Code, register the blast radius command during extension activation:

```ts
// In an extension activation routine
import { registerBlastRadiusCommand } from './features/blastRadius';
import { createSqliteReader } from './backend/sqlite';
import { BlastRadiusTreeProvider } from './views/treeView';

const reader = createSqliteReader(/* … */);
const provider = new BlastRadiusTreeProvider();

registerBlastRadiusCommand(context, () => reader, provider, workspaceRoot);

```

When invoked, the command displays a tree view via `BlastRadiusTreeProvider` ([`src/views/treeView.ts`](https://github.com/tirth8205/code-review-graph/blob/main/src/views/treeView.ts)) and renders a toast notification such as:

```

Blast radius: 23 nodes impacted across 5 files

```

## Summary

- **Changed nodes** identify directly modified entities via `impact.changedNodes`.
- **Impacted nodes** measure transitive dependencies through the blast radius calculation.
- **Impacted file count** quantifies the breadth of review required across distinct files.
- **Blast radius depth** provides configurable traversal limits via `codeReviewGraph.blastRadiusDepth`.
- **Node-level metadata** includes file paths, line ranges, and entity kinds for granular analysis.
- **Graph size statistics** offer architectural health metrics through node and edge counting.

## Frequently Asked Questions

### What is the blast radius metric in code review graph analysis?

The blast radius metric measures the total scope of impact for a code change, calculated as the set of **impacted nodes** transitively reachable from the **changed nodes** through call- and import-dependencies. According to the `tirth8205/code-review-graph` implementation, this includes all functions, classes, and files that might be affected by modifying a specific entity, helping developers understand the true scope of their changes before committing.

### How does the configurable depth limit affect the extracted metrics?

The `codeReviewGraph.blastRadiusDepth` setting controls how many dependency hops the analysis traverses from the changed node. A depth of 1 captures only direct dependencies, while higher values reveal deeper transitive impacts. This parameter directly affects the **impacted node count** and **impacted file count** metrics, allowing developers to balance between analysis precision and computational performance.

### Can these metrics be extracted for use in CI/CD pipelines?

Yes, the metrics can be extracted programmatically outside of VS Code by importing the `SqliteReader` class from [`src/backend/sqlite.ts`](https://github.com/tirth8205/code-review-graph/blob/main/src/backend/sqlite.ts) and calling `getImpactRadius()` with specific file paths and depth parameters. This enables automated impact analysis in continuous integration workflows, allowing build systems to flag changes with unusually large blast radii for mandatory additional review.

### Where does the extension store the graph data used for metric calculation?

The extension stores all graph data in a local SQLite database managed by the `SqliteReader` class in [`src/backend/sqlite.ts`](https://github.com/tirth8205/code-review-graph/blob/main/src/backend/sqlite.ts). The database contains `nodes` and `edges` tables that map source code entities (files, functions, classes) and their relationships, enabling persistent, queryable storage of the codebase structure for metric extraction and impact analysis.