Enforce coding style using clang-tidy#3603
Draft
PremadeS wants to merge 6 commits intorizinorg:devfrom
Draft
Conversation
wargio
reviewed
Apr 15, 2026
wargio
reviewed
Apr 15, 2026
notxvilka
approved these changes
Apr 15, 2026
wargio
approved these changes
Apr 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Your checklist for this pull request
Detailed description
Cutter has no concrete coding style, too many bad practices and magic numbers. This PR aims to enforce a coding style using
clang-tidyto fix those issuesWhat this PR adds:
1-
.clang-tidyconfig with the relevant checks2-
scripts/clang-tidy.pyfor runningclang-tidy3- ci workflow for
clang-tidy4- Header sorting fix in
_clang-format5- Coding style documentation update in
docs/source/contributing/code/development-guidelines.rstDetailed Explaination
Contains the following checks. All of them must pass in order for the CI to pass
cppcoreguidelines-non-private-member-variables-in-classes
cppcoreguidelines-prefer-member-initializer
cppcoreguidelines-pro-type-cstyle-cast
misc-const-correctness
misc-unused-parameters
modernize-loop-convert
modernize-use-auto
modernize-use-nullptr
readability-magic-numbers
readability-braces-around-statements
readability-identifier-naming
readability-make-member-function-const
performance-for-range-copy
performance-enum-size
performance-move-const-arg
performance-no-automatic-move
performance-noexcept-destructor
performance-noexcept-move-constructor
performance-noexcept-swap
performance-unnecessary-copy-initialization
performance-unnecessary-value-param
performance-use-std-move
performance-move-constructor-init
Similar to
scripts/clang-format.py- a python script for making it easier to run clang-tidyclang-tidywill only run on valid/necessary files (.h .hpp and .cpp) in thesrcdirectory. It will not run on files in the following directories:SKIP_LIST = ["themes", "bindings", "fonts", "img", "translations", "build", "_autogen"]Added in the
linter.ymlfile as a separate jobVerifies all of the checks defined in .clang-tidy config are passing. clang-tidy requires compile_commands.json so we have to configure cmake before running it.
CI performs the following tasks:
1- Install build dependencies for cutter
2- Install llvm-16
3- Install clang-tidy-16
4- Configure Cmake
5- Run Qt autogen tools for cutter
6- run clang-tidy on all valid/necessary files in
srcusing the providedrun-clang-tidy-16scriptFrom some testing the CI job takes around 15 minutes which is much less than the full build jobs, hence total time shouldn't be affected.
The code changes line is commented out on purpose (just for now)
_clang-format file had weird sorting for headers before:
I'm guessing these were either taken from somewhere or were the default options for the _clang-format generation script
These are updated to be:
This now aligns with what the Includes segment in Coding Style documentation which suggests:
1- Main header at the top
2- Followed by local includes. e.g:
#include "Cutter.h"3- Followed by Qt includes. e.g:
<QLabel>,<qlobal.h>`4- Lastly C++ standard headers or any other headers that don't fall into the above 3 groups
All of these 4 groups are separated by an empty line and entries in them are sorted in alphabetical order
Note that this will cause the clang-format check to fail
This new _clang-format file is generated via the modified
scripts/_clang-formatscript usingscripts/update_clang_format.shrunningclang-format-8Also in
scripts/clang-format.pythe description states "Clang format the rizin project" while I'm pretty sure it's for cutter not rizin :)See the changed doc file for updated coding conventions
Test plan (required)
Will add later, this PR is not done yet. Checks might be added/removed when doing the actual refactor of the codebase
Just need some opinions on this first
Closing issues