angularjs-shared-service-fanout
Read-only mining codemod that finds AngularJS .service() / .factory() / .provider()
registrations and estimates how many places in the same file inject each one. High-fanout
services are the ones most likely to block or gate a migration phase, since every consumer
needs to keep working while the service itself moves to Angular. No files are written to the
target repo.
What it detects
For every service/factory/provider registration, the codemod looks for injections via any of
the three classic AngularJS DI styles:
| DI style | Example |
|---|---|
| Array annotation | ['$scope', 'DataService', function ($scope, DataService) {}] |
$inject property | Ctrl.$inject = ['$scope', 'DataService'] |
| Implicit parameter naming | function Ctrl($scope, DataService) {} |
Each registration is emitted once (finding_type: "registration"), plus one row per injection
site found (finding_type: "injection"), so you can see both the aggregate fanout count and
where each injection lives.
Metrics
| Metric | Cardinalities |
|---|---|
service_fanout | finding_type, service_name, registration_type, injection_sites_in_file, injection_kind, consumer, file, line, snippet, migration_category, risk, automation, effort_points, recommended_phase |
risk/effort_points/recommended_phase are derived from injection_sites_in_file:
| Injection sites | Risk | Effort | Phase |
|---|---|---|---|
| 0–1 | low | 1 | phase-3 (leaf features) |
| 2–4 | medium | 3 | phase-2 (shared services) |
| 5+ | high | 8 | phase-2 (shared services) |
Limitations
- File-local only. This codemod analyzes one file at a time (the JSSG execution model), so
it cannot see a service injected from a different file. A service that looks "low fanout"
here may actually be widely used across the whole app. Combine results with
angularjs-service-inventoryand cross-file usage search for an accurate picture, or run this
as a stepping stone toward workspace-level analysis. - Detection is heuristic: implicit-parameter matching assumes a function parameter named exactly
like a known registered service is really that service being injected (true in the vast
majority of real AngularJS code, but not guaranteed). - Only
.service(),.factory(), and.provider()registrations are tracked;.value()and
.constant()are intentionally excluded since they are rarely gating dependencies.
Run
bash
Testing
bash
Development
bash
License
MIT