Skip to content

OctoLintUnusedVariables

Matthew Casperson edited this page Apr 1, 2024 · 7 revisions

OctoLintUnusedVariables lists variables that do not appear in the deployment process or runbooks.

Recommendation

Project level environments are only able to be referenced by the project deployment process, runbooks, or other variables. Unused variables can clutter the project settings and make it harder to manage.

Warning

octolint can only detect if variables are not referenced by the deployment process or by other variables. There are edge cases octolint can not detect, for example if an output variable from a step references the project variable, or if an external package includes files that have variable substitution or Structured Configuration Variables applied to them.

This check also only verifies the current state of the variables and deployment processes. Variables are not checked against previous release snapshots.

Always use a two step process to delete variables that may be unused. This involves renaming the variable, testing deployments or runbooks over time to verify the variable is not used, and then finally removing it.

Remediation

To clean up unused variables, first rename the variables with a common prefix like [UNUSED]. For example, if octolint reported the variable ConnectionString was unused, you would rename it to [UNUSED] ConnectionString.

Test that the deployment or runbooks continue to work as expected with the renamed variables.

If there are no issues, then the variable can be deleted. If it turns out the variable is still used, rename it back.

This process ensures you do not delete the variable before proving that it is in fact no longer used by the deployment.

Clone this wiki locally