Check attributes order and separation #2107
janschumann
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
My client would like to ensure the order and separation of attributes and blocks for specific resources for the sake of readability.
Examples
good
bad
good
bad
good
bad
While writing a ruleset to report those kind of issues, I stumbled upon the following:
The
hcl.Range
of a validation block always contains the same line asStart
andEnd
attribute, so that a check if there is an empty line between validation blocks is not possible. (As a workaround, I expand the validation block attributes and add +1 to the last attribute to find the end of the validation block)Empty lines between attributes are not reported
Consider the following variable definition:
My check uses the
hcl.Range.Start
of the first attribute and thehcl.Range.End
of the last attribute to emit the issue:As you can see, the empty line (3) is ignored.
And as a result, no
fixFunc func(f Fixer) error
can be used to remove the empty line.Wouldn't it be great to accomplish such a ruleset with a fix?
Here is the repo I am testing with: https://github.com/schumann-it/tflint-ruleset-terraform-ext
I would be happy if someone could share their thoughts!
Beta Was this translation helpful? Give feedback.
All reactions