From 82bd685c0d79dc683a118fbcf2c3e38340f49f8e Mon Sep 17 00:00:00 2001 From: Xianpeng Shen <3353385+shenxianpeng@users.noreply.github.com> Date: Mon, 9 Nov 2026 20:27:27 +0000 Subject: [PATCH 1/3] test: cpp-linter v2 preview for cpp-linter-rs README --- .github/workflows/v2-preview.yml | 47 ++++++++++++++++++++++++++++++++ src/demo.cpp | 11 +++++++- 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/v2-preview.yml diff --git a/.github/workflows/v2-preview.yml b/.github/workflows/v2-preview.yml new file mode 100644 index 0000000..19d6bb4 --- /dev/null +++ b/.github/workflows/v2-preview.yml @@ -0,0 +1,47 @@ +# Temporary: produces the cpp-linter v2 (cpp-linter-rs) preview screenshots +# for the cpp-linter-rs README. Remove after the screenshots are taken. +name: v2 preview + +on: + pull_request: + branches: [master] + +permissions: + contents: read + pull-requests: write + +jobs: + cpp-linter: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + with: + persist-credentials: false + + - name: Install cpp-linter v2 + env: + GH_TOKEN: ${{ github.token }} + run: >- + gh release download cpp-linter/v2.0.0-rc.25 + -R cpp-linter/cpp-linter-rs + --pattern cpp-linter-x86_64-unknown-linux-gnu.tar.gz + --output - | tar xz -C "$RUNNER_TEMP" + + - name: Generate compilation database + run: cmake -Bbuild src + + - name: Run cpp-linter + id: linter + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: >- + "$RUNNER_TEMP/cpp-linter" + --style=file + --version=21 + --ignore=build + --database=build + --extra-arg="-std=c++14 -Wall" + --thread-comments=update + --pr-review=true + --file-annotations=true + --step-summary=true diff --git a/src/demo.cpp b/src/demo.cpp index 0c1db60..eafa219 100644 --- a/src/demo.cpp +++ b/src/demo.cpp @@ -6,12 +6,21 @@ // using size_t from cstddef size_t dummyFunc(size_t i) { return i; } +namespace { +int scale(int value) +{ + if (value > 0) + return value * 3; + return 0; +} +} // namespace + int main() { for (;;) break; - printf("Hello world!\n"); + printf("Hello world! %d\n", scale(14)); return 0; } From 465b595d6e3b106dcf5240cd9b87b69aeabe476c Mon Sep 17 00:00:00 2001 From: Xianpeng Shen <3353385+shenxianpeng@users.noreply.github.com> Date: Mon, 9 Nov 2026 20:44:39 +0000 Subject: [PATCH 2/3] test: add a format issue inside the clang-tidy fix --- .github/workflows/v2-preview.yml | 2 +- src/demo.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/v2-preview.yml b/.github/workflows/v2-preview.yml index 19d6bb4..e384741 100644 --- a/.github/workflows/v2-preview.yml +++ b/.github/workflows/v2-preview.yml @@ -12,7 +12,7 @@ permissions: jobs: cpp-linter: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v7 with: diff --git a/src/demo.cpp b/src/demo.cpp index eafa219..9d82922 100644 --- a/src/demo.cpp +++ b/src/demo.cpp @@ -10,7 +10,7 @@ namespace { int scale(int value) { if (value > 0) - return value * 3; + return value*3; return 0; } } // namespace From afcd83f11ea80d86108a3b3804f97d30ad4965f9 Mon Sep 17 00:00:00 2001 From: Xianpeng Shen <3353385+shenxianpeng@users.noreply.github.com> Date: Mon, 9 Nov 2026 20:46:32 +0000 Subject: [PATCH 3/3] test: use the repo's .clang-tidy and one-line fixes --- .github/workflows/v2-preview.yml | 1 + src/demo.cpp | 10 ++++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/v2-preview.yml b/.github/workflows/v2-preview.yml index e384741..3347d25 100644 --- a/.github/workflows/v2-preview.yml +++ b/.github/workflows/v2-preview.yml @@ -37,6 +37,7 @@ jobs: run: >- "$RUNNER_TEMP/cpp-linter" --style=file + --tidy-checks="" --version=21 --ignore=build --database=build diff --git a/src/demo.cpp b/src/demo.cpp index 9d82922..c83a545 100644 --- a/src/demo.cpp +++ b/src/demo.cpp @@ -7,11 +7,9 @@ size_t dummyFunc(size_t i) { return i; } namespace { -int scale(int value) +bool hasName(const char* name) { - if (value > 0) - return value*3; - return 0; + return name; } } // namespace @@ -20,7 +18,7 @@ int main() for (;;) break; - printf("Hello world! %d\n", scale(14)); + printf("Hello world!\n"); - return 0; + return hasName("demo") ? 0 : 42; }