Aalexbit-codemod

angularjs-routing-inventory

Mine AngularJS ui-router/ngRoute states, resolves, nested routes; read-only metrics

miningmetricsangularjscode-miningmigration-assessmentangularjs_route
PRO
0 executions
Use dashboard

Run locally

npx codemod angularjs-routing-inventory

This is a Pro codemod. Preview changes and insights for free, no login or code sharing required. Applying changes and accessing insights requires a paid plan and sign in.Learn more

angularjs-routing-inventory

Read-only mining codemod that inventories AngularJS routing configuration for migration assessment: ui-router $stateProvider.state(...) registrations (including nested, dot-separated state names, and resolve blocks) and ngRoute $routeProvider.when(...) / .otherwise(...) registrations. Each finding is classified with a risk level, an automation confidence, an effort-point estimate, and a recommended migration phase. No files are written to the target repo.

What it does

PatternRouterhas_resolveis_nestedAutomationRiskEffortPhase
.state('name', {...})ui-routerfalsefalsefulllow2phase-3
.state('name', {...}) or .when(path, {...})eithertrue or true-partialmedium5phase-3
.state('parent.child', {...}) (nested, no resolve)ui-routerfalsetruepartialmedium5phase-3
.state('parent.child', {...}) (nested + resolve)ui-routertruetruepartialhigh8phase-4
.when(path, {...})ngRoutefalsefalsefulllow2phase-3
.otherwise(...)ngRoute--fulllow1phase-3

Supports both .state() call shapes: .state('name', config) and the single-argument object-literal form .state({ name: 'name', ... }). For .otherwise(...), the route is recorded as the redirectTo path when present (object-argument form), the literal string argument (string form), or the placeholder (otherwise) when neither can be resolved.

State/route names and paths are only recorded when they are string literals; dynamically computed names or paths (e.g. .state(dynamicName, ...), .when(path, ...) where path is a variable) are skipped since they can't be resolved statically. Calls with no arguments are also skipped safely.

Heuristic limitation: detection is name-based (matches any call whose callee property is state/when/otherwise), so it does not verify that the receiver is actually $stateProvider/$routeProvider. In practice this is rarely an issue for AngularJS codebases, but unrelated APIs that happen to share these method names could produce false positives.

Metrics

MetricCardinalities
angularjs_routefile, line, snippet, route_name_or_path, router_type (ui-router|ngRoute), has_resolve, is_nested, migration_category (routing), risk, automation, effort_points, recommended_phase

Installation

bash

Usage

bash

Development

bash

License

MIT

Ready to contribute?

Build your own codemod and share it with the community.