From 17573c17df66046c7905147d5f728ed9b7b1a5ab Mon Sep 17 00:00:00 2001 From: Dhruv Maroo Date: Tue, 23 Nov 2021 23:45:34 +0530 Subject: [PATCH] Use `clang-format-13` for linting * Update `linter.yml` to use `clang-format-13` * Update documentation for clang-format --- .github/workflows/linter.yml | 14 +++++++------- DEVELOPERS.md | 15 +++++++++++---- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index dd488521c4..de5a765925 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -67,21 +67,21 @@ jobs: - name: Checkout repository uses: actions/checkout@v2 - - name: Install wget - run: sudo apt --assume-yes install wget + - name: Install wget, software-properties-common, lsb-release (dependencies of LLVM install script) + run: sudo apt --assume-yes install wget software-properties-common lsb-release - - name: Install automatic llvm (stable branch) - run: sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" + - name: Install automatic LLVM 13 + run: wget https://apt.llvm.org/llvm.sh -O /tmp/llvm-install.sh; chmod +x /tmp/llvm-install.sh; sudo /tmp/llvm-install.sh 13 - - name: Install clang-format-11 - run: sudo apt --assume-yes install clang-format-11 + - name: Install clang-format-13 + run: sudo apt --assume-yes install clang-format-13 - name: Install gitpython run: sudo pip install gitpython - name: Run clang-format run: | - sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-11 110 + sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-13 130 clang-format --version python sys/clang-format.py --check --verbose diff --git a/DEVELOPERS.md b/DEVELOPERS.md index f9a25fa905..514ae6ad02 100644 --- a/DEVELOPERS.md +++ b/DEVELOPERS.md @@ -49,12 +49,13 @@ E.g.: `Bug fix did not change the general behavior of the function. No documenta In order to contribute with patches or plugins, we encourage you to use the same coding style as the rest of the code base. -* Use git-clang-format 11 to format your code. You should invoke it as below -(after making sure that your local copy of `dev` is up-to-date and your branch -is up-to-date with `dev`): +* Use git-clang-format 13 to format your code. If clang-format-13 is not available on + your Debian-based distribution, you can install it from https://apt.llvm.org/. + You should invoke it as below (after making sure that your local copy of `dev` + is up-to-date and your branch is up-to-date with `dev`): ```bash -git-clang-format-11 --extensions c,cpp,h,hpp,inc --style file dev +git-clang-format-13 --extensions c,cpp,h,hpp,inc --style file dev ``` * Lines should be at most 100 chars. A tab is considered as 8 chars. If it makes @@ -183,6 +184,12 @@ rz_core_wrap.cxx:32103:61: error: assigning to 'RzDebugReasonType' from incompat * Never ever use `%lld` or `%llx`. This is not portable. Always use the `PFMT64x` macros. Those are similar to the ones in GLIB. See all macroses in `librz/include/rz_types.h`. +* Add a single space after the `//` when writing inline comments: + +```c +int sum = 0; // set sum to 0 +``` + ### Shell Scripts * Use `#!/bin/sh`