Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/v2-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# 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-24.04
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
--tidy-checks=""
--version=21
--ignore=build
--database=build
--extra-arg="-std=c++14 -Wall"
--thread-comments=update
--pr-review=true
--file-annotations=true
--step-summary=true
9 changes: 8 additions & 1 deletion src/demo.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/** This is a very ugly test code (doomed to fail linting) */
#include "demo.hpp"
#include <cstdio>
Expand All @@ -6,12 +6,19 @@
// using size_t from cstddef
size_t dummyFunc(size_t i) { return i; }

namespace {
bool hasName(const char* name)
{
return name;

Check warning on line 12 in src/demo.cpp

View workflow job for this annotation

GitHub Actions / cpp-linter

src/demo.cpp:12:13 [readability-implicit-bool-conversion]

implicit conversion 'const char *' -> 'bool'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy diagnostic(s)

Suggested change
return name;
return name != nullptr;

}
} // namespace

int main()
{
for (;;)
break;

printf("Hello world!\n");

return 0;
return hasName("demo") ? 0 : 42;

Check warning on line 23 in src/demo.cpp

View workflow job for this annotation

GitHub Actions / cpp-linter

src/demo.cpp:23:34 [readability-magic-numbers]

42 is a magic number; consider replacing it with a named constant

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy diagnostic

src/demo.cpp:23:34 warning: [readability-magic-numbers]

42 is a magic number; consider replacing it with a named constant

   23 |     return hasName("demo") ? 0 : 42;
      |                                  ^

}