Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

terraform_unused_declarations: Make unused variable checks aware of validation blocks #133

Merged

Conversation

wata727
Copy link
Member

@wata727 wata727 commented Oct 1, 2023

Fixes #94

The terraform_unused_declarations rule recognizes unused variables by walking through all expressions and seeing if a variable reference exists. However, this way cannot recognize which block is being walked, so false negatives like #94 may occur.

This PR changes the rule so that if an expression reference is inside a variable validation block, it will not be marked as used.

Copy link
Member

@bendrucker bendrucker left a comment

Choose a reason for hiding this comment

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

🙌🏻

@wata727 wata727 merged commit 7cb0f65 into main Oct 8, 2023
2 checks passed
@wata727 wata727 deleted the make_unused_variable_check_aware_of_validation_blocks branch October 8, 2023 14:57
tpdownes added a commit to tpdownes/hpc-toolkit that referenced this pull request Dec 5, 2023
Use older release until we address the code changes required by
terraform-linters/tflint-ruleset-terraform#133
ek-nag pushed a commit to ek-nag/hpc-toolkit that referenced this pull request Dec 8, 2023
Use older release until we address the code changes required by
terraform-linters/tflint-ruleset-terraform#133
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.

false negative for variables used only in their own validation block
2 participants