Skip to content

Commit 9eb972f

Browse files
committed
get cppcheck suppressions file
Signed-off-by: ISP akm <[email protected]>
1 parent b50c213 commit 9eb972f

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: cppcheck-differential
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
cppcheck-differential:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v2
13+
14+
- name: Install dependencies
15+
run: |
16+
sudo apt-get update
17+
sudo apt-get install -y build-essential cmake git libpcre3-dev wget
18+
19+
# cppcheck from apt does not yet support --check-level args, and thus install from source
20+
- name: Install Cppcheck from source
21+
run: |
22+
mkdir /tmp/cppcheck
23+
git clone https://github.com/danmar/cppcheck.git /tmp/cppcheck
24+
cd /tmp/cppcheck
25+
git checkout 2.14.1
26+
mkdir build
27+
cd build
28+
cmake ..
29+
make -j $(nproc)
30+
sudo make install
31+
32+
# Download the cppcheck suppression file
33+
- name: Download cppcheck suppression file
34+
run: |
35+
wget https://raw.githubusercontent.com/autowarefoundation/autoware.universe/main/.cppcheck_suppressions -O .cppcheck_suppressions
36+
37+
- name: Get changed files
38+
id: changed-files
39+
run: |
40+
git fetch origin ${{ github.base_ref }} --depth=1
41+
git diff --name-only FETCH_HEAD ${{ github.sha }} > changed_files.txt
42+
cat changed_files.txt
43+
44+
- name: Run Cppcheck on changed files
45+
continue-on-error: true
46+
id: cppcheck
47+
run: |
48+
files=$(cat changed_files.txt | grep -E '\.(cpp|hpp)$' || true)
49+
if [ -n "$files" ]; then
50+
echo "Running Cppcheck on changed files: $files"
51+
cppcheck --enable=all --inconclusive --check-level=exhaustive --error-exitcode=1 --suppressions-list=.cppcheck_suppressions $files 2> cppcheck-report.txt
52+
else
53+
echo "No C++ files changed."
54+
touch cppcheck-report.txt
55+
fi
56+
shell: bash
57+
58+
- name: Show cppcheck-report result
59+
run: |
60+
cat cppcheck-report.txt
61+
62+
- name: Upload Cppcheck report
63+
uses: actions/upload-artifact@v4
64+
with:
65+
name: cppcheck-report
66+
path: cppcheck-report.txt
67+
68+
- name: Fail the job if Cppcheck failed
69+
if: steps.cppcheck.outcome == 'failure'
70+
run: exit 1

CARET_analyze_cpp_impl/src/iterator_base.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@
3434
Record & IteratorBase::get_record() const
3535
{
3636
throw std::exception();
37+
// NOLINTBEGIN(cppcheck-suppress[unreachableCode])
3738
static Record record;
3839
return record;
40+
// NOLINTEND(cppcheck-suppress[unreachableCode])
3941
}
4042

4143
void IteratorBase::next()
@@ -46,14 +48,18 @@ void IteratorBase::next()
4648
bool IteratorBase::has_next() const
4749
{
4850
throw std::exception();
51+
// NOLINTBEGIN(cppcheck-suppress[unreachableCode])
4952
return false;
53+
// NOLINTEND(cppcheck-suppress[unreachableCode])
5054
}
5155

5256
const Record & ConstIteratorBase::get_record() const
5357
{
5458
throw std::exception();
59+
// NOLINTBEGIN(cppcheck-suppress[unreachableCode])
5560
static Record record;
5661
return record;
62+
// NOLINTEND(cppcheck-suppress[unreachableCode])
5763
}
5864

5965
void ConstIteratorBase::next()

0 commit comments

Comments
 (0)