You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 as Start and End 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:
variable "example" {
description = "description"
type = string
}
My check uses the hcl.Range.Start of the first attribute and the hcl.Range.End of the last attribute to emit the issue:
tflint
1 issue(s) found:
Error: No empty line is expected between attributes (terraform_variable_attribute_separation)
on variables.tf line 2:
2: description = "The name of this content rewrite policy."
4: type = string
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?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
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