Skip to content

no-comment-cruft

Commented-out HCL declarations or decorative divider comments must be removed; retain comments that explain constraints or rationale.

Why

Disabled declarations drift from executable infrastructure, while decorative banners duplicate structure already expressed by modules and resource blocks.

Fix

Delete disabled HCL and decorative dividers; use executable structure and concise rationale comments.

Examples

Before — flagged Disabled HCL resource
main.tf
# resource "google_storage_bucket" "old" {
# name = "legacy-artifacts"
# location = "US"
# force_destroy = true
# }
resource "google_storage_bucket" "new" {}
After — preferred Comment explaining an infrastructure constraint
main.tf
# Keep this bucket in us-central1 for data residency.
resource "google_storage_bucket" "records" {}
Before — flagged Decorative divider around a section title
main.tf
# ==== Networking ====
module "networking" {}
After — preferred Section comment that explains a constraint
main.tf
# Networking is isolated to preserve the production trust boundary.
module "networking" {}