Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix file arguments handling when using --chdir #1636

Merged
merged 1 commit into from Dec 29, 2022

Conversation

wata727
Copy link
Member

@wata727 wata727 commented Dec 29, 2022

Filtering issues by file arguments did not work properly with --chdir:

$ tree
.
└── subdir
    └── main.tf

1 directory, 1 file

$ tflint --chdir=subdir main.tf
Failed to parse CLI arguments; Failed to load `main.tf`: File not found

$ tflint --chdir=subdir subdir/main.tf
Cannot use --chdir and directory argument at the same time

This PR fixes this issue by parsing the arguments after the directory change. So tflint --chdir=subdir main.tf works.

This may seem counterintuitive at first glance, but in the current model where --chdir is applied first, it makes sense that the path is relative to the changed working directory.

To further prevent misunderstandings, file arguments will also be deprecated in the future. Instead, it provides an option like --filter, implying that the behavior is to filter issues after inspection of a directory, rather than inspecting only specific files.

@wata727 wata727 merged commit fcd0f8b into master Dec 29, 2022
@wata727 wata727 deleted the fix_file_args_handling_with_chdir branch December 29, 2022 16:25
@wata727 wata727 mentioned this pull request Dec 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant