-
-
Notifications
You must be signed in to change notification settings - Fork 345
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
Added .clang-tidy file #660
Conversation
-readability-redundant-member-init, | ||
-readability-redundant-string-init, | ||
-readability-identifier-length, | ||
CheckOptions: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also added naming checks, so we all use the same naming conventions. I chose these based on what we currently use most often.
Let me know if any of these need to change.
This looks very promising! Can I test this locally? If so, what commands should I use exactly? |
In vscode, with the 2023-12-09.15-01-41.mp4You can hover over the warning and most of the time there is an automatic fix you can apply. You can also manually run clang-tidy in a terminal:
You need to install clang-tidy on your system (using your package installer of choice) |
The VSCode integration looks neat!
Thanks, but I think that's probably not the "right way" to do it? Because I'm getting a lot of errors running it that way, including nonsensical ones like:
|
You can pass the compile_commands.json file:
It's a lot slower when doing this, though, because it has to parse all included Qt header files as well. But it looks a lot better. For example, in
I also see this error in vscode. |
Alright, so I didn't know how to generate that file, but simply invoking CMake with Perhaps we can add it to
It too a while to finish, indeed, but the amount of warnings and errors I got at the end still seem too high...?
Or is that expected? |
This should indeed be added to CMakeLists.txt by default. I think the vscode CMake Tools extension already does that for me when I configure, which is why I didn't notice it wasn't included. |
I also get roughly that amount of warnings, but it doesn't stop with According to this stackoverflow thread: https://stackoverflow.com/questions/64360160/what-does-clang-tidy-suppressed-x-warnings-mean, those warnings are (supposed to be) suppressed because they come from external code (standard library, qt sources, other libraries, etc.). We should try to find a way to skip checking those files (if possible), I think it'll run a lot faster. |
Nevermind, I do get the |
@guihkx Found two ways to make it much faster:
It still outputs the warning counts like:
but you can disable that with The command then becomes: run-clang-tidy -p ./build/ -config-file ./.clang-tidy $(find ./src -regex '.*\.\(cpp\|hpp\|h\|c\)$') -quiet New output: clang-tidy-warnings2.txt Either way, clang-tidy is not really supposed to be used like this, you're supposed to set up your IDE with clang as a language server and then enable clang-tidy in the clang options. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either way, clang-tidy is not really supposed to be used like this, you're supposed to set up your IDE with clang as a language server and then enable clang-tidy in the clang options.
Yeah, using it like that makes more sense. But it's still nice to know there's a way to run with only a command.
I also added this for the Waybar repo (see discussion here for more info on what it is).
Later we could also add a GitHub action that checks whether new code adheres to these clang-tidy checks (I'm testing this here: https://github.com/zjeffer/Waybar/pull/1/files)