Add Clang-Tidy and Clang-Format support
This MR proposes adding a standardized configuration for the Clang-Format and Clang-Tidy tools.
For the former, I have taken the official KDE configuration from the ECM module and customized it with two bits:
- changed the C++ standard since we use C++14
- changed the line length to not be as excessive
For the latter, during the past two years I've been building Krita with the configuration of @dragonmux in one of her repos: https://github.com/bad-alloc-heavy-industries/substrate/blob/main/.clang-tidy, and added some exclusion bits that pertain to our shared pointers and test suites.
This does not apply changes automatically. It merely makes you aware of bits you can improve in your code.
Test Plan
Build Krita with -DCMAKE_EXPORT_COMPILE_COMMANDS=ON and then have your IDE be aware of where the compile_commands.json
file is.
For instance, in Visual Studio Code, install the clangd extension, and set the following preference:
{
"clangd.arguments": [
"--clang-tidy",
"--enable-config",
"-j=<how many worker threads you want>",
"--compile-commands-dir=<root of the compile_commands.json file>",
],
}
Wait for clangd to build Krita, and
Formalities Checklist
-
I confirmed this builds. -
I confirmed Krita ran and the relevant functions work. -
I tested the relevant unit tests and can confirm they are not broken. (If not possible, don't hesitate to ask for help!) -
I made sure my commits build individually and have good descriptions as per KDE guidelines. -
I made sure my code conforms to the standards set in the HACKING file. -
I can confirm the code is licensed and attributed appropriately, and that unattributed code is mine, as per KDE Licensing Policy.