Aalexbit-codemod

angularjs-scope-coupling

Mine AngularJS $scope/$rootScope coupling, watchers, events, broadcasts; read-only metrics

miningmetricsangularjscode-miningmigration-assessmentscope_coupling
PRO
0 executions

Run locally

npx codemod angularjs-scope-coupling

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-scope-coupling

Read-only mining codemod that scans AngularJS JavaScript source for $scope/$rootScope
coupling and emits a scope_coupling metric for migration assessment. It never modifies
files — every match is reported via codemod:metrics and the transform always returns null.

What it detects

  • Bare $scope / $rootScope references (DI parameters, arguments, generic property access)
  • $watch, $watchCollection, $watchGroup
  • $on, $broadcast, $emit — flagged high risk when bound to $rootScope (global event
    bus coupling), medium risk on plain $scope
  • $apply, $applyAsync, $digest, $evalAsync — safe to drop under Angular's zone-based
    change detection, so these are fully automatable

Metric cardinality

Each finding increments scope_coupling with:

ts

Installation

bash

Development

bash

License

MIT

Ready to contribute?

Build your own codemod and share it with the community.