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

Not getting consistent result while overriding clang-tidy check for an particular service #40

Open
ananta-code opened this issue Feb 1, 2023 · 1 comment

Comments

@ananta-code
Copy link

Hi ,

I have a global clang-tidy profile in our monorepo but in a particular service i dont want to use global configuration rather i have different set of checks.
i am getting surprising issues that is if i ran with local clang-tidy configuration and lets say the perticular CPP file dont have any issue then later when i try to run the same file with global config i am not getting any error because of the bazel cache .

@dan-cohn-sabre
Copy link

dan-cohn-sabre commented Feb 1, 2023

I am working with @ananta-code and can provide some additional information. I believe the rule behaves correctly, but the README is misleading for two reasons:

  1. If a .clang-tidy file exists in the root directory of the workspace, clang-tidy will use it regardless of what is specified in the clang_tidy_config. I'm referring to this logic: https://github.com/erenon/bazel_clang_tidy/blob/master/clang_tidy/run_clang_tidy.sh#L22

  2. If a .clang-tidy file also exists in the source code tree, clang-tidy will use it and will ignore the "global" .clang-tidy file, overriding what's specified in the clang_tidy_config. Refer to https://clang.llvm.org/extra/clang-tidy/ under "Configuration files:"

This results in unexpected behavior for users. First of all, it's unclear which .clang-tidy file will be used. The one referenced via clang_tidy_config may be ignored. Secondly, Bazel may not invalidate the cache when the local .clang-tidy file is changed. This is because Bazel is only aware of a single .clang-tidy file – the one referenced in the config. Changes to other config files in the source tree are hidden from Bazel, resulting in seemingly inconsistent behavior.

May I suggest updating the documentation (README) to explain which config will be used? In particular, the only time Bazel honors the clang_tidy_config is when there are no .clang-tidy config files present in source directory or any of its parent directories up to the workspace root. If any are present, they take precedence over whatever was specified through --@com_github_erenon_bazel_clang_tidy//:clang_tidy_config=.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants