for file in "${FILES[@]}"
do
tflint "${ARGS[@]}" --chdir "$(dirname "$file")" --filter "$(basename "$file")"
done
tflint runs for each file and then shows only the issues in that file. However some issues don't reference specific files, namely those issues where something is missing, like a missing required_version or provider declaration.
To Reproduce
Run the hook with a terraform file like this:
terraform {
# required_version = "~>1.6.6"
}
which should find this issue
1 issue(s) found:
Warning: terraform "required_version" attribute is required (terraform_required_version)
on line 0:
(source code not available)
Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.5.0/docs/rules/terraform_required_version.md
but this is filtered out, because it does not reference a specific source code file.
Expected behavior
The issue should be found and the hook should fail.
Additional context
Finding issues like this requires that tflint no longer runs for each changed file, but for all files at once.
I think this trade-off should be taken in order to find all issues.
Describe the bug The
--filter
argument totflint
is too restrictive.This is the relevant code:
tflint
runs for each file and then shows only the issues in that file. However some issues don't reference specific files, namely those issues where something is missing, like a missingrequired_version
orprovider
declaration.To Reproduce Run the hook with a terraform file like this:
which should find this issue
but this is filtered out, because it does not reference a specific source code file.
Expected behavior The issue should be found and the hook should fail.
Additional context Finding issues like this requires that
tflint
no longer runs for each changed file, but for all files at once. I think this trade-off should be taken in order to find all issues.