Skip to content

add uniqueness check for variables, outputs - #375

Merged
bendrucker merged 5 commits into
terraform-linters:mainfrom
chernetskyi:unique-descriptions
Sep 9, 2026
Merged

bendrucker merged 5 commits into
terraform-linters:mainfrom
chernetskyi:unique-descriptions

Conversation

@chernetskyi

Copy link
Copy Markdown
Contributor

Implemented optional description uniqueness check for outputs and variables within terraform_documented_outputs and terraform_documented_variables rules as discussed in #112 (comment).

@bendrucker bendrucker left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, will do a code review pass later but overall looks good. Figured I'd send you these two docs nits in the meantime.

```hcl
rule "terraform_documented_outputs" {
enabled = true
unique = false # default

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leave the example as the minimum required attributes

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, are you asking to remove the unique parameter from the examples?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bendrucker a kind reminder 🙂

Comment thread docs/rules/terraform_documented_outputs.md Outdated
chernetskyi and others added 4 commits August 20, 2026 18:46
The two documented rules were identical apart from the block type they
read. Move the rule name, block type, and check onto an embedded
documentedRule, leaving each rule a constructor and a Check that
delegates. Issues are attributed to the concrete rule, so tflint still
reports the rule the user configured.

Split the description presence check from the uniqueness check. The
presence pass returns the blocks that declare a description, which is
the only input the uniqueness pass needs, so the boolean no longer
gates half a function body.
Adds cases for descriptions that differ only in case or trailing
whitespace, pinning exact comparison, and for an undocumented block
declared alongside a duplicated pair, where both kinds of issue are
emitted together.

Drops the explicit `unique = false` case, which asserts nothing the
default case does not. Always passes .tflint.hcl to the test runner,
matching the other configurable rule tests.
Uses template.tf and includes the Reference line, as the surrounding
examples do. States that descriptions are compared exactly, and why
duplicated descriptions are worth catching.
@bendrucker bendrucker changed the title feat: implement description uniqueness check add uniqueness check for variables, outputs Sep 9, 2026
@bendrucker
bendrucker merged commit ca9c22f into terraform-linters:main Sep 9, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants