angularjs-route-blast-radius
Mine AngularJS route blast radius (components, services, complexity); read-only metrics
# angularjs-route-blast-radius
Read-only **mining codemod** that estimates the migration "blast radius" of every ui-router
`$stateProvider.state(...)` and ngRoute `$routeProvider.when(...)` registration in a file — how
many downstream artifacts (component, controller, template, resolves, nested/child states) a
given route touches. No files are written to the target repo.
## What it detects
- `$stateProvider.state('name', { ... })` and the single-object `state({ name: '...', ... })`
form (ui-router), including chained `.state(a).state(b).state(c)` registrations.
- `$routeProvider.when('/path', { ... })` (ngRoute).
- Per registration: `component`, `controller`, `template`/`templateUrl` (including inside a
`views` map), and `resolve` key count.
- ui-router nested states, detected by dot-separated state names (`dashboard.settings`), plus
how many _other_ states in the same file are children of this one (`dashboard.settings.*`).
## Estimated touch points
```
estimated_touch_points =
1 (the route itself)
+ (has_controller ? 1 : 0)
+ (has_component ? 1 : 0)
+ (has_template_url ? 1 : 0)
+ resolve_count
+ (is_nested ? 1 : 0)
+ <count of other states in this file nested under this one>
```
| Touch points | Risk |
| ------------ | ------ |
| ≤2 | low |
| 3–5 | medium |
| 6+ | high |
`automation` is `partial` when the route has no resolves and isn't nested (a fairly mechanical
Angular Router mapping), and `manual` otherwise (resolves and nested state hierarchies usually
require re-architecting, not a 1:1 route conversion). `effort_points` and `recommended_phase`
scale with `resolve_count` and `is_nested`.
## Metrics
| Metric | Cardinalities |
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `route_blast_radius` | `route_id`, `router_type`, `has_component`, `has_controller`, `has_template_url`, `resolve_count`, `is_nested`, `estimated_touch_points`, `file`, `line`, `snippet`, `migration_category`, `risk`, `automation`, `effort_points`, `recommended_phase` |
## Limitations
- File-local: the "child state" count only considers other `.state()` calls in the _same_ file.
A large ui-router app that splits state definitions across multiple files will under-count
nested-state blast radius; combine with `angularjs-routing-inventory` for a full cross-file
picture.
- `line`/`snippet` are anchored to the `.state`/`.when` token and its arguments rather than the
whole call expression, because chained calls (`$stateProvider.state(a).state(b)`) all share the
same call-expression start position at `$stateProvider`.
- `component`/`controller`/`template` detection inside a `views` map only looks one level deep.
## Run
```bash
npx codemod@latest workflow run -w codemods/angularjs-to-angular/angularjs-route-blast-radius \
-t /path/to/angularjs/repo \
--allow-dirty --no-interactive
```
## Testing
```bash
pnpm test
```
## Development
```bash
# Test the transformation
pnpm test
# Validate the workflow
codemod workflow validate -w workflow.yaml
# Publish to registry
codemod login
codemod publish
```
## License
MIT