Skip to content
Sarj Code Standards

no-boolean-enable-variable

Require a retirement date and removal plan, or a permanent rationale, for Boolean inputs.

Why

Enable switches add configuration plumbing and keep alternate implementations alive. An infrastructure change should normally configure its intended behavior directly. Necessary temporary gates need a deadline for deleting the switch and old path; lasting controls need an explicit rationale.

Fix

Remove the switch and configure the intended behavior directly. If deployments need different values, pass the actual typed configuration instead. Otherwise add description lines 'Retire by: YYYY-MM-DD' and 'Remove when: <cutover condition and removal action>', or 'Permanent: <why both settings remain useful>'. Prefer cutover now; aim to retire temporary gates within 30 days and remove them earlier when ready. Review every environment, resource address, prerequisite and consumer before removal.

Examples

Before — flagged An extra switch gates the intended implementation
main.tf
variable "keyless_storage_enabled" {
type = bool
}
After — preferred Record the deadline and deletion condition in the input description
main.tf
variable "private_route_enabled" {
type = bool
description = "Retire by: 2099-12-31\nRemove when: All deployments use the private route; delete this input and the legacy route."
}
Before — flagged Explicit lifecycle records also expire on migration modes
main.tf
variable "migration_phase" {
type = string
description = "Retire by: 2000-01-01\nRemove when: Every deployment uses the new store; delete the old phase and input."
}
After — preferred Keep an explicitly scheduled migration mode until cutover
main.tf
variable "migration_phase" {
type = string
description = "Retire by: 2099-12-31\nRemove when: Every deployment uses the new store; delete the old phase and input."
}
Before — flagged A permanent exemption needs a rationale
main.tf
variable "paging_enabled" {
type = bool
description = "Permanent:"
}
After — preferred Explain a lasting per-environment control
main.tf
variable "paging_enabled" {
type = bool
description = "Permanent: Production pages on-call; disposable environments must keep paging off."
}