The following code:
dynamic "rule" {
for_each = concat(local.default_firewall_rules.open_tcp_ports, var.extra_firewall_rules.open_tcp_ports)
content {
direction = "in"
protocol = "tcp"
port = "${rule.value}"
source_ips = ["0.0.0.0/0"]
}
}
Is formatted to the following by the plugin:
dynamic "rule" {
for_each = concat(local.default_firewall_rules.open_tcp_ports, var.extra_firewall_rules.open_tcp_ports)
content {
direction = "in"
protocol = "tcp"
port = rule.value
source_ips = ["0.0.0.0/0"]
}
}
Note that "${rule.value}" got unpacked into just rule.value. The resulting code however has different semantics as here it is intended to be used as an alternative for tostring().
Arguments made that one should use tostrings() instead, but it is fundamentally important property of a formatter to not change the semantics of the code.
If one would want such a change to be done automatically in some fashion, it would be a linter's job, behind an --unsafe-fixes (or vice-versa) option.
The following code:
Is formatted to the following by the plugin:
Note that
"${rule.value}"got unpacked into justrule.value. The resulting code however has different semantics as here it is intended to be used as an alternative fortostring().Arguments made that one should use
tostrings()instead, but it is fundamentally important property of a formatter to not change the semantics of the code.If one would want such a change to be done automatically in some fashion, it would be a linter's job, behind an
--unsafe-fixes(or vice-versa) option.