Open ananta-code opened 1 year ago
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:
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
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=
.
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 .