Run one specific clang-tidy check on your entire codebase

Recently I did a major refactor on a piece of code that involved thousands of lines of code which were in one way or another related to string handling. All of the code handled `char*` (C style character pointer arrays) and the concept of `const` or ownership was literally unknown in that part of the codebase. The refactored code uses `std::string`'s, but due to the legacy nature, a large number of methods returned `nullptr`'s instead of empty strings. I understand why this was done, but finding all those instances and the fact it only gives a runtime error was a bit of a bummer.
Luckily `clang-tidy` is here to save the day. In my IDE, CLion, it gives a warning when you return a `nullptr`. It however does that only in the file you're currently editing, and since we're talking millions of files, I wasn't going to open them by hand. You can run `clang-tidy` easily on one file, and it's not hard to run it on an entire codebase as well, using the script ``, provided in their packages.
This snippet shows you how to run one specific `clang-tidy` check, in my case, `bugprone-string-constructor`, on a (cmake and C++) codebase.

Top News