empty-list-equality
What it does
Section titled “What it does”Reports a comparison with an empty list, x == [] or x != []. It is false for an empty set or a tuple of another type.
Why it matters
Section titled “Why it matters”[] is a tuple, and Terraform compares values of different types as not equal, so the comparison is false for an empty set or an empty list of another type, and the condition silently does the wrong thing.
To fix, compare the length: length(x) == 0.
Example
Section titled “Example”a = var.l == []b = var.l != []c = [] == var.ld = length(var.l) == 0e = var.l == [] && var.mf = var.l == [1]Configuration
Section titled “Configuration”hcl: lint: rules: empty-list-equality: warn # off, warn (default), errorEnabled by the presets: hcl/tflint-recommended.
Suppress one line with sudsy-disable-next-line empty-list-equality in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| tflint | terraform_empty_list_equality |
full |