-
Notifications
You must be signed in to change notification settings - Fork 64
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
Class ClangTidyCmd disregards its args
parameter
#46
Comments
Submitted a PR #47 |
Thank you so much for this detailed issue and PR. I should have time later this month. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I noticed this issue with
ClangTidyCmd
but it it is an issue for all the other similar concrete classes (CppcheckCmd
,CpplintCmd
,IncludeWhatYouUseCmd
, etc.).I am working on a cross-platform C++ repo that has windows/ and linux/ subfolders for implementations on a specific OS. I'm setting up linting. Clang-tidy, as expected, can only process the code for the current system (Linux / Windows). e.g. if I am on Linux and run your hooks with the command
pre-commit run --all-files clang-tidy
, it will try to parse the Windows files and error out.Because pre-commit-config.yaml does not take variables, I created a shim script that filters out any files from the wrong folder. For example, if I am on Linux and pre-commit passes some file named
foo/windows/bar.cpp
in argv, the shim will create a new list without that file and call your hook..pre-commit-config.yaml:
scripts/pocc-shim.py:
The issue is that this doesn't work. Clang-tidy is still failing on files shouldn't have been passed to it.
I had a look at utils.py and saw that
Command.get_added_files
is reading directly fromsys.argv
instead of theargs
variable passed in.My current workaround is to just set sys.argv.
scripts/pocc-shim.py:
After this, the hook passes on both systems, properly ignoring files from the excluded folders.
I find this workaround distasteful, but it works fine and is acceptable for my purposes.
However, the underlying issue should still be addressed.
Repro
You can see my code here akfreed/CppSocketsXPlatform@df8ac58. At the moment it is easier to reproduce on Linux. You will need clang-tidy version 13 (I installed with brew).
OS: Ubuntu 20
Toolchain: (All Ubuntu 20 apt default versions except clang-tidy)
Expected result
Actual result
it fails on a file under the windows folder
The text was updated successfully, but these errors were encountered: