angularjs-automation-readiness
Mine AngularJS automation readiness scores by pattern; read-only metrics
# angularjs-automation-readiness
Read-only mining codemod that scans for representative AngularJS patterns and
classifies each match as `full`, `partial`, or `manual` automation, so an
assessment can roll up an automation-readiness score for a codebase (or any
slice of it, e.g. by team or feature module).
Emits the `automation_readiness_score` metric. Does not modify any files.
## Patterns detected
| Automation | Pattern | Notes |
| ---------- | --------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| `full` | `component-registration` | `.component(...)` registration |
| `full` | `simple-ng-directive-string` | `ng-if`/`ng-repeat`/`ng-show`/`ng-hide`/`ng-model`/`ng-class`/`ng-click`/`ng-disabled`/`ng-switch` in template strings |
| `full` | `$http` | `$http(...)` / `$http.get(...)` / etc. |
| `full` | `$timeout` | `$timeout(...)` / `$timeout.cancel(...)` |
| `partial` | `factory-or-service-registration` | `.factory(...)` / `.service(...)` |
| `partial` | `filter-registration` | `.filter(...)` custom filter definitions |
| `partial` | `filter-pipe-usage` | `{{ value \| filterName }}` in template strings |
| `partial` | `$q` | `$q(...)` / `$q.defer()` / `$q.all(...)` / etc. |
| `partial` | `$resource` | `$resource(...)` |
| `partial` | `ng-include-like-string` | `ng-include` substrings (attribute or templateUrl-style strings) |
| `manual` | `directive-with-link-or-compile` | a `.directive(...)` factory whose returned definition object has a `link` or `compile` key |
| `manual` | `$compile` | `$compile(...)` service usage |
| `manual` | `$rootScope.$broadcast` | global event bus usage |
| `manual` | `jquery-dom-manipulation` | bare `$(...)` calls or `angular.element(...)` |
## Cardinalities
| Field | Description |
| -------------------- | -------------------------------------------------------------------------------------------------- |
| `file` | Relative file path |
| `line` | 1-based line number of the match |
| `snippet` | Truncated source snippet (whitespace-collapsed, 120 chars) |
| `pattern` | One of the pattern names above |
| `automation` | `full` \| `partial` \| `manual` |
| `readiness_weight` | `1.0` (full) \| `0.5` (partial) \| `0.0` (manual) — sum/average these to compute a readiness score |
| `migration_category` | `component` \| `service` \| `template` \| `directive` \| `scope` \| `dom` |
| `risk` | `low` \| `medium` \| `high` \| `critical` |
| `effort_points` | Fibonacci effort estimate |
| `recommended_phase` | `phase-1` .. `phase-5` |
## Heuristics and known limitations
- `$http`/`$timeout`/`$q`/`$resource`/`$compile` are matched by identifier
text on the callee (either a bare call, e.g. `$timeout(fn, 100)`, or a
member call whose object is that identifier, e.g. `$http.get(...)`).
Matching is exact (`^\$http$`), so lookalikes like `$httpBackend` or a
locally shadowed variable named `$http` are not confused with the real
service — but a locally-scoped variable that happens to be named exactly
`$http` would still be counted (rare in practice for AngularJS DI-style
code).
- `directive-with-link-or-compile` only looks for `link`/`compile` object
keys _inside_ a `.directive(...)` call. A directive that merely returns
`{ restrict: 'E', template: '...' }` with no `link`/`compile` is not
flagged — those are comparatively cheap to port.
- `jquery-dom-manipulation` flags the jQuery/jqLite _entry point_ only
(`$(...)` or `angular.element(...)`), not every chained method call after
it (e.g. `.css()`, `.html()`), to avoid inflating counts.
- `$rootScope.$broadcast` requires the object to be literally named
`$rootScope`; `$scope.$broadcast(...)` (much lower blast radius) is
intentionally not flagged here — see `angularjs-scope-coupling` for
broader `$scope`/`$rootScope` coupling analysis.
- String-based detectors (`simple-ng-directive-string`, `filter-pipe-usage`,
`ng-include-like-string`) scan any string or template literal in the file,
including inline templates. They will not see patterns that only exist in
separate `.html` template files (this codemod's `include` glob is JS/TS
only).
## Installation
```bash
# Install from registry
codemod run angularjs-automation-readiness
# Or run locally
codemod run -w workflow.yaml
```
## 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