Ccodemod

codemod/location-parameter-allowedvalues

Read-only audit of deployment templates for location parameters constrained by allowedValues lists.

code-miningreportingjsondeploymentportability
Public
0 executions

Run locally

npx codemod @codemod/location-parameter-allowedvalues

@codemod/location-parameter-allowedvalues

Read-only audit of deployment templates for location parameters constrained by allowedValues lists.

What It Reports

  • Scans deployment JSON and commented JSON files.
  • Reports allowedValues on string parameters whose name indicates a deployment location.
  • Applies to top-level template parameters and nested deployment templates.
  • Leaves other parameters and deployment parameter value files unchanged.

Usage

bash

This workflow scans **/*.{json,jsonc} and uses parser-backed detection to report matching parameter definitions without editing source files.

Match Rules

  • The file must look like a deployment template or parameter document.
  • The codemod only inspects objects under a parameters property.
  • The parameter name must contain location.
  • The parameter definition must declare "type": "string".
  • The parameter definition must contain allowedValues.

Preserve Cases

  • Non-location parameters that use allowedValues.
  • Parameter value files where parameters.<name> only contains value.
  • Location parameters that already omit allowedValues.

Example

Before:

json

Reported finding:

location is constrained by an allowedValues list. Remove the list and use a dynamic default such as resourceGroup().location or deployment().location.

Metrics

  • location_parameter_allowedvalues_files
  • location_parameter_allowedvalues_findings
  • location_parameters_scanned

Development

bash

License

MIT

Ready to contribute?

Build your own codemod and share it with the community.