Aalexbit-codemod

angularjs-automation-readiness

Mine AngularJS automation readiness scores by pattern; read-only metrics

miningmetricsangularjscode-miningmigration-assessmentautomation_readiness_score
PRO
0 executions

Run locally

npx codemod angularjs-automation-readiness

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

AutomationPatternNotes
fullcomponent-registration.component(...) registration
fullsimple-ng-directive-stringng-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(...)
partialfactory-or-service-registration.factory(...) / .service(...)
partialfilter-registration.filter(...) custom filter definitions
partialfilter-pipe-usage{{ value | filterName }} in template strings
partial$q$q(...) / $q.defer() / $q.all(...) / etc.
partial$resource$resource(...)
partialng-include-like-stringng-include substrings (attribute or templateUrl-style strings)
manualdirective-with-link-or-compilea .directive(...) factory whose returned definition object has a link or compile key
manual$compile$compile(...) service usage
manual$rootScope.$broadcastglobal event bus usage
manualjquery-dom-manipulationbare $(...) calls or angular.element(...)

Cardinalities

FieldDescription
fileRelative file path
line1-based line number of the match
snippetTruncated source snippet (whitespace-collapsed, 120 chars)
patternOne of the pattern names above
automationfull | partial | manual
readiness_weight1.0 (full) | 0.5 (partial) | 0.0 (manual) — sum/average these to compute a readiness score
migration_categorycomponent | service | template | directive | scope | dom
risklow | medium | high | critical
effort_pointsFibonacci effort estimate
recommended_phasephase-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

Development

bash

License

MIT

Ready to contribute?

Build your own codemod and share it with the community.