-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
clang-tidy warning: do not use "using namespace" from GENERATE macro in user code #1799
Comments
The workaround to put NOLINT around the GENERATE macros feels like the right answer. I don't agree with the idea that the Even the clang-tidy check allows them, but only for specially blessed namespaces. I think this shows an unwarranted bias towards treating the standard library as special. What about all the other libraries in the world that define UDLs, like In the case of the |
I mostly agree although my (personal) issue with
vs hypothetical:
Yeah I may have saved 7 key strokes in the first case but now readers of the code will wonder if the Anyhow, I solved it for myself with NOLINT and if the public stuff in |
On the other hand, consider a more complex usage: const auto data = GENERATE(Catch::take(100,
Catch::filter([](int i) { return i % 2 == 1; },
Catch::random(-100, 100)))); where the namespacing starts to introduce a lot of noise. Anyway, for the v2 branch, the solution will definitely be to just suppress the lint. For further development, I'll think about adding a special namespace for the generator helpers, but explicitly listing all the helpers with |
Describe the bug
The specific check link is here: https://releases.llvm.org/8.0.0/tools/clang/tools/extra/docs/clang-tidy/checks/google-build-using-namespace.html The reasons why this is not good is clear I think as it is approximately never you want to import everything from a namespace to your current namespace.
In this particular case I think the better alternative would be another macro like CATCH_GENERATE_USING that would contain all symbols that make sense withing the call to GENERATE, like:
Not only will that do away with the warning but it will also help in IDE where it will show only relevant symbols and not literally everything in namespace Catch::Generators (which is a lot).
Expected behavior
"using namespace" is not used.
Reproduction steps
Run clan-tidy with
google-build-using-namespace
enabled or use IDE integration that performs such static analysis in real time and that includes that check (I am using Qt Creator).Platform information:
Additional context
A workaround is to append
//NOLINT(google-build-using-namespace)
after the definitions of the GENERATE macro lines. That suppresses the warning.The text was updated successfully, but these errors were encountered: