gruntwork-io / pre-commit

A collection of pre-commit hooks used by Gruntwork tools
https://gruntwork.io/
Apache License 2.0
484 stars 155 forks source link

Trying to set chdir so only scans certain folders is not working #90

Open balq60 opened 1 year ago

balq60 commented 1 year ago

Describe the bug I want to be able to scan folders. I have tried these settings. All of these settings fail to scan JUST the folder I set:

EXAMPLE 1

EXAMPLE 2

EXAMPLE 3

EXAMPLE 4

This fails as well

To Reproduce Terraform version 1.3.9


// paste code snippets here
To Trip the linter I added this in my IaC/environments/1-test folder

variable "not_used" {
  description = "To trip linters"
  type        = string
  default     = null
}

tflint...................................................................Failed
- hook id: tflint
- exit code: 2

1 issue(s) found:

Warning: variable "not_used" is declared but not used (terraform_unused_declarations)

  on IaC/environments/1-test/compute-priv-variables.tf line 183:
 183: variable "not_used" {

Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.2.2/docs/rules/terraform_unused_declarations.md

**Expected behavior**
Since I am setting a chdir argument to scan the IaC/environments/2-staging/ folder (I tried without the trailing slash, fails as well)

I would NOT expect the linter to find the issue in the IaC/environments/1-test folder.

I would expect no errors reported

**Nice to have**
- [ ] Terminal output
- [ ] Screenshots

**Additional context**
I want to be able to set different exclusion per environment.  I want production to have all rules applied with lower environments I want the ability to exclude rules.  I cannot do that, since chdir is not being honored.  I submitted this bug in the tflint repo, they it was not their issue.