Skip to content

no-restated-comment

Flag a short comment attached to an HCL declaration when it only repeats that declaration's kind, label, or attribute name.

Why

A declaration-label comment adds no durable information and can drift; comments that explain constraints, grouping, or operational rationale remain useful.

Fix

Delete the restatement or replace it with the constraint the configuration cannot express. Improve an author-controlled label when the declaration itself is unclear.

Examples

Before — flagged Comment merely narrates an assignment
main.tf
# Set instance type
instance_type = var.instance_type
After — preferred Comment records a provider constraint
main.tf
# Keep this type because the provider rejects ARM nodes.
instance_type = var.instance_type
Before — flagged Maintained block comment repeats its attribute
main.tf
/* Set instance type */
instance_type = var.instance_type
After — preferred Generated HCL is owned by its generator
generated.tf
/* Code generated by schema compiler.
* DO NOT EDIT.
*/
# Set instance type
instance_type = var.instance_type
Before — flagged Comment repeats one declaration label
main.tf
# Service account
service_account_email = module.iam.api_email
After — preferred Comment labels a group of sibling attributes
main.tf
# Service accounts
api_service_account_email = module.iam.api_email
worker_service_account_email = module.iam.worker_email