From 8b8de24309ab91d2a3fa717366e48fc8431ed129 Mon Sep 17 00:00:00 2001 From: kminoda Date: Tue, 4 Jun 2024 15:45:55 +0900 Subject: [PATCH 01/29] ci: add cppcheck Signed-off-by: kminoda --- .cppcheck_suppressions | 57 ++++++++++++++++++++++++++++++++ .github/workflows/cpp-check.yaml | 34 +++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 .cppcheck_suppressions create mode 100644 .github/workflows/cpp-check.yaml diff --git a/.cppcheck_suppressions b/.cppcheck_suppressions new file mode 100644 index 0000000000000..e6ab3b74dba9f --- /dev/null +++ b/.cppcheck_suppressions @@ -0,0 +1,57 @@ +arrayIndexThenCheck +assignBoolToFloat +checkersReport +constParameterPointer +constParameterReference +constStatement +constVariable +constVariablePointer +constVariableReference +containerOutOfBounds +cstyleCast +ctuOneDefinitionRuleViolation +current_deleted_index +duplicateAssignExpression +duplicateBranch +duplicateBreak +duplicateCondition +duplicateExpression +funcArgNamesDifferent +functionConst +functionStatic +invalidPointerCast +knownConditionTrueFalse +missingInclude +missingIncludeSystem +multiCondition +noConstructor +noExplicitConstructor +noValidConfiguration +obstacle_cruise_planner +passedByValue +preprocessorErrorDirective +redundantAssignment +redundantContinue +redundantIfRemove +redundantInitialization +returnByReference +selfAssignment +shadowArgument +shadowFunction +shadowVariable +syntaxError +uninitMemberVar +unknownMacro +unpreciseMathCall +unreadVariable +unsignedLessThanZero +unusedFunction +unusedScopedObject +unusedStructMember +unusedVariable +useInitializationList +useStlAlgorithm +uselessCallsSubstr +uselessOverride +variableScope +virtualCallInConstructor diff --git a/.github/workflows/cpp-check.yaml b/.github/workflows/cpp-check.yaml new file mode 100644 index 0000000000000..1e5d8f0bc57d1 --- /dev/null +++ b/.github/workflows/cpp-check.yaml @@ -0,0 +1,34 @@ +name: cppcheck + +on: + pull_request: + +jobs: + cppcheck: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Install Cppcheck + run: | + sudo apt-get update + sudo apt-get install -y cppcheck + + - name: Get changed files + id: changed-files + run: | + git fetch origin ${{ github.base_ref }} --depth=1 + git diff --name-only FETCH_HEAD ${{ github.sha }} > changed_files.txt + cat changed_files.txt + + - name: Run Cppcheck on changed files + run: | + files=$(cat changed_files.txt | grep '\.cpp$\|\.h$' | tr '\n' ' ') + if [ -n "$files" ]; then + cppcheck --enable=warning,style,performance --error-exitcode=1 --xml $files 2> cppcheck-report.xml + else + echo "No C++ files changed." + fi + shell: bash From bf154e8cb300b84adb07faff290dfa9740502b31 Mon Sep 17 00:00:00 2001 From: kminoda Date: Tue, 4 Jun 2024 15:49:19 +0900 Subject: [PATCH 02/29] add more suppression Signed-off-by: kminoda --- .cppcheck_suppressions | 1 + 1 file changed, 1 insertion(+) diff --git a/.cppcheck_suppressions b/.cppcheck_suppressions index e6ab3b74dba9f..087d3cbfe9054 100644 --- a/.cppcheck_suppressions +++ b/.cppcheck_suppressions @@ -39,6 +39,7 @@ selfAssignment shadowArgument shadowFunction shadowVariable +stlFindInsert syntaxError uninitMemberVar unknownMacro From e57410b890d8b49186d05f04a34b6aaa3f678228 Mon Sep 17 00:00:00 2001 From: kminoda Date: Tue, 4 Jun 2024 15:50:06 +0900 Subject: [PATCH 03/29] update cppcheck version Signed-off-by: kminoda --- .github/workflows/cpp-check.yaml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cpp-check.yaml b/.github/workflows/cpp-check.yaml index 1e5d8f0bc57d1..fc34f78f7a4ac 100644 --- a/.github/workflows/cpp-check.yaml +++ b/.github/workflows/cpp-check.yaml @@ -11,10 +11,21 @@ jobs: - name: Checkout code uses: actions/checkout@v2 - - name: Install Cppcheck + - name: Install dependencies run: | sudo apt-get update - sudo apt-get install -y cppcheck + sudo apt-get install -y build-essential cmake git libpcre3-dev + + - name: Install Cppcheck from source + run: | + git clone https://github.com/danmar/cppcheck.git + cd cppcheck + git checkout 2.14.1 + mkdir build + cd build + cmake .. + make -j $(nproc) + sudo make install - name: Get changed files id: changed-files From 2e2cb235b26793c8dbe49f2c17abc7c340dbfe5d Mon Sep 17 00:00:00 2001 From: kminoda Date: Tue, 4 Jun 2024 15:52:55 +0900 Subject: [PATCH 04/29] update suppressions list Signed-off-by: kminoda --- .cppcheck_suppressions | 1 + 1 file changed, 1 insertion(+) diff --git a/.cppcheck_suppressions b/.cppcheck_suppressions index 087d3cbfe9054..5b140152e7f08 100644 --- a/.cppcheck_suppressions +++ b/.cppcheck_suppressions @@ -43,6 +43,7 @@ stlFindInsert syntaxError uninitMemberVar unknownMacro +unmatchedSuppression unpreciseMathCall unreadVariable unsignedLessThanZero From e7064d54ca4cf73e2f20af496a94b5458a62e825 Mon Sep 17 00:00:00 2001 From: kminoda Date: Tue, 4 Jun 2024 15:54:40 +0900 Subject: [PATCH 05/29] add two workflows Signed-off-by: kminoda --- .github/workflows/cpp-check-all.yaml | 38 +++++++++++++++++++ ...check.yaml => cpp-check-differential.yaml} | 0 2 files changed, 38 insertions(+) create mode 100644 .github/workflows/cpp-check-all.yaml rename .github/workflows/{cpp-check.yaml => cpp-check-differential.yaml} (100%) diff --git a/.github/workflows/cpp-check-all.yaml b/.github/workflows/cpp-check-all.yaml new file mode 100644 index 0000000000000..856c611c4ea1d --- /dev/null +++ b/.github/workflows/cpp-check-all.yaml @@ -0,0 +1,38 @@ +name: cppcheck + +on: + pull_request: + +jobs: + cppcheck: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y build-essential cmake git libpcre3-dev + + - name: Install Cppcheck from source + run: | + git clone https://github.com/danmar/cppcheck.git + cd cppcheck + git checkout 2.14.1 + mkdir build + cd build + cmake .. + make -j $(nproc) + sudo make install + + - name: Run Cppcheck on changed files + run: | + files=$(cat changed_files.txt | grep '\.cpp$\|\.h$' | tr '\n' ' ') + if [ -n "$files" ]; then + cppcheck --enable=warning,style,performance --error-exitcode=1 --xml . 2> cppcheck-report.xml + else + echo "No C++ files changed." + fi + shell: bash diff --git a/.github/workflows/cpp-check.yaml b/.github/workflows/cpp-check-differential.yaml similarity index 100% rename from .github/workflows/cpp-check.yaml rename to .github/workflows/cpp-check-differential.yaml From bd4b78ef9b4f280675029c15b4c2a6189b711866 Mon Sep 17 00:00:00 2001 From: kminoda Date: Tue, 4 Jun 2024 15:55:38 +0900 Subject: [PATCH 06/29] change name Signed-off-by: kminoda --- .github/workflows/{cpp-check-all.yaml => cppcheck-all.yaml} | 2 +- .../{cpp-check-differential.yaml => cppcheck-differential.yaml} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename .github/workflows/{cpp-check-all.yaml => cppcheck-all.yaml} (97%) rename .github/workflows/{cpp-check-differential.yaml => cppcheck-differential.yaml} (97%) diff --git a/.github/workflows/cpp-check-all.yaml b/.github/workflows/cppcheck-all.yaml similarity index 97% rename from .github/workflows/cpp-check-all.yaml rename to .github/workflows/cppcheck-all.yaml index 856c611c4ea1d..97b839d4f7660 100644 --- a/.github/workflows/cpp-check-all.yaml +++ b/.github/workflows/cppcheck-all.yaml @@ -1,4 +1,4 @@ -name: cppcheck +name: cppcheck-all on: pull_request: diff --git a/.github/workflows/cpp-check-differential.yaml b/.github/workflows/cppcheck-differential.yaml similarity index 97% rename from .github/workflows/cpp-check-differential.yaml rename to .github/workflows/cppcheck-differential.yaml index fc34f78f7a4ac..2f4a630edae9c 100644 --- a/.github/workflows/cpp-check-differential.yaml +++ b/.github/workflows/cppcheck-differential.yaml @@ -1,4 +1,4 @@ -name: cppcheck +name: cppcheck-differential on: pull_request: From 01739e265fcd403838713511d6939acef09bba4c Mon Sep 17 00:00:00 2001 From: kminoda Date: Tue, 4 Jun 2024 15:56:21 +0900 Subject: [PATCH 07/29] change timing of all ci Signed-off-by: kminoda --- .github/workflows/cppcheck-all.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/cppcheck-all.yaml b/.github/workflows/cppcheck-all.yaml index 97b839d4f7660..f6e8d133d9f7f 100644 --- a/.github/workflows/cppcheck-all.yaml +++ b/.github/workflows/cppcheck-all.yaml @@ -2,6 +2,9 @@ name: cppcheck-all on: pull_request: + schedule: + - cron: 0 0 * * * + workflow_dispatch: jobs: cppcheck: From d50d05dcbee650b9ca0466c3729107ed01afa78c Mon Sep 17 00:00:00 2001 From: kminoda Date: Tue, 4 Jun 2024 15:58:39 +0900 Subject: [PATCH 08/29] update Signed-off-by: kminoda --- .github/workflows/cppcheck-all.yaml | 2 +- .github/workflows/cppcheck-differential.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cppcheck-all.yaml b/.github/workflows/cppcheck-all.yaml index f6e8d133d9f7f..15b9a4f720386 100644 --- a/.github/workflows/cppcheck-all.yaml +++ b/.github/workflows/cppcheck-all.yaml @@ -34,7 +34,7 @@ jobs: run: | files=$(cat changed_files.txt | grep '\.cpp$\|\.h$' | tr '\n' ' ') if [ -n "$files" ]; then - cppcheck --enable=warning,style,performance --error-exitcode=1 --xml . 2> cppcheck-report.xml + cppcheck --enable=all --error-exitcode=1 --xml . 2> cppcheck-report.xml else echo "No C++ files changed." fi diff --git a/.github/workflows/cppcheck-differential.yaml b/.github/workflows/cppcheck-differential.yaml index 2f4a630edae9c..ef79e46b7d4ec 100644 --- a/.github/workflows/cppcheck-differential.yaml +++ b/.github/workflows/cppcheck-differential.yaml @@ -38,7 +38,7 @@ jobs: run: | files=$(cat changed_files.txt | grep '\.cpp$\|\.h$' | tr '\n' ' ') if [ -n "$files" ]; then - cppcheck --enable=warning,style,performance --error-exitcode=1 --xml $files 2> cppcheck-report.xml + cppcheck --enable=all --inconclusive --check-level=exhaustive --suppressions-list=.cppcheck_suppressions --xml $files 2> cppcheck-report.xml else echo "No C++ files changed." fi From de6f3e8c8029d6d4504ca0758040441127e67609 Mon Sep 17 00:00:00 2001 From: kminoda Date: Tue, 4 Jun 2024 15:59:09 +0900 Subject: [PATCH 09/29] update Signed-off-by: kminoda --- .github/workflows/cppcheck-all.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cppcheck-all.yaml b/.github/workflows/cppcheck-all.yaml index 15b9a4f720386..552b5a9f58d54 100644 --- a/.github/workflows/cppcheck-all.yaml +++ b/.github/workflows/cppcheck-all.yaml @@ -34,7 +34,7 @@ jobs: run: | files=$(cat changed_files.txt | grep '\.cpp$\|\.h$' | tr '\n' ' ') if [ -n "$files" ]; then - cppcheck --enable=all --error-exitcode=1 --xml . 2> cppcheck-report.xml + cppcheck --enable=all --inconclusive --check-level=exhaustive --xml . 2> cppcheck-report.xml else echo "No C++ files changed." fi From a89e8b60b4ee20a8dd74caaeb60940102cbc27dd Mon Sep 17 00:00:00 2001 From: kminoda Date: Tue, 4 Jun 2024 15:59:43 +0900 Subject: [PATCH 10/29] update Signed-off-by: kminoda --- .github/workflows/cppcheck-all.yaml | 2 +- .github/workflows/cppcheck-differential.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cppcheck-all.yaml b/.github/workflows/cppcheck-all.yaml index 552b5a9f58d54..2b331a4a4eb5a 100644 --- a/.github/workflows/cppcheck-all.yaml +++ b/.github/workflows/cppcheck-all.yaml @@ -32,7 +32,7 @@ jobs: - name: Run Cppcheck on changed files run: | - files=$(cat changed_files.txt | grep '\.cpp$\|\.h$' | tr '\n' ' ') + files=$(cat changed_files.txt | grep '\.cpp$\|\.hpp$' | tr '\n' ' ') if [ -n "$files" ]; then cppcheck --enable=all --inconclusive --check-level=exhaustive --xml . 2> cppcheck-report.xml else diff --git a/.github/workflows/cppcheck-differential.yaml b/.github/workflows/cppcheck-differential.yaml index ef79e46b7d4ec..9cf183aa5a6ab 100644 --- a/.github/workflows/cppcheck-differential.yaml +++ b/.github/workflows/cppcheck-differential.yaml @@ -36,7 +36,7 @@ jobs: - name: Run Cppcheck on changed files run: | - files=$(cat changed_files.txt | grep '\.cpp$\|\.h$' | tr '\n' ' ') + files=$(cat changed_files.txt | grep '\.cpp$\|\.hpp$' | tr '\n' ' ') if [ -n "$files" ]; then cppcheck --enable=all --inconclusive --check-level=exhaustive --suppressions-list=.cppcheck_suppressions --xml $files 2> cppcheck-report.xml else From 85c5036e51743aa46dc904b314d59f59bb8dfa27 Mon Sep 17 00:00:00 2001 From: kminoda Date: Tue, 4 Jun 2024 16:06:46 +0900 Subject: [PATCH 11/29] fix Signed-off-by: kminoda --- .github/workflows/cppcheck-all.yaml | 2 +- .github/workflows/cppcheck-differential.yaml | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/.github/workflows/cppcheck-all.yaml b/.github/workflows/cppcheck-all.yaml index 2b331a4a4eb5a..c9dc9a7589bc2 100644 --- a/.github/workflows/cppcheck-all.yaml +++ b/.github/workflows/cppcheck-all.yaml @@ -30,7 +30,7 @@ jobs: make -j $(nproc) sudo make install - - name: Run Cppcheck on changed files + - name: Run Cppcheck on all files run: | files=$(cat changed_files.txt | grep '\.cpp$\|\.hpp$' | tr '\n' ' ') if [ -n "$files" ]; then diff --git a/.github/workflows/cppcheck-differential.yaml b/.github/workflows/cppcheck-differential.yaml index 9cf183aa5a6ab..945f0d936d9dc 100644 --- a/.github/workflows/cppcheck-differential.yaml +++ b/.github/workflows/cppcheck-differential.yaml @@ -34,12 +34,7 @@ jobs: git diff --name-only FETCH_HEAD ${{ github.sha }} > changed_files.txt cat changed_files.txt - - name: Run Cppcheck on changed files + - name: Run Cppcheck on all files run: | - files=$(cat changed_files.txt | grep '\.cpp$\|\.hpp$' | tr '\n' ' ') - if [ -n "$files" ]; then - cppcheck --enable=all --inconclusive --check-level=exhaustive --suppressions-list=.cppcheck_suppressions --xml $files 2> cppcheck-report.xml - else - echo "No C++ files changed." - fi - shell: bash + cppcheck --enable=all --inconclusive --check-level=exhaustive --xml . 2> cppcheck-report.xml + shell: bash \ No newline at end of file From 4eb1d9c24bebeb10fc28e1657d907224a5e4dcc6 Mon Sep 17 00:00:00 2001 From: kminoda Date: Tue, 4 Jun 2024 16:11:05 +0900 Subject: [PATCH 12/29] update name Signed-off-by: kminoda --- .github/workflows/cppcheck-all.yaml | 2 +- .github/workflows/cppcheck-differential.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cppcheck-all.yaml b/.github/workflows/cppcheck-all.yaml index c9dc9a7589bc2..e8fbdb1aaa4d0 100644 --- a/.github/workflows/cppcheck-all.yaml +++ b/.github/workflows/cppcheck-all.yaml @@ -7,7 +7,7 @@ on: workflow_dispatch: jobs: - cppcheck: + cppcheck-all: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/cppcheck-differential.yaml b/.github/workflows/cppcheck-differential.yaml index 945f0d936d9dc..880f0ab3d491e 100644 --- a/.github/workflows/cppcheck-differential.yaml +++ b/.github/workflows/cppcheck-differential.yaml @@ -4,7 +4,7 @@ on: pull_request: jobs: - cppcheck: + cppcheck-differential: runs-on: ubuntu-latest steps: From e715115127f80e30480fab36434bc35395e718ab Mon Sep 17 00:00:00 2001 From: kminoda Date: Tue, 4 Jun 2024 16:11:45 +0900 Subject: [PATCH 13/29] fix mistake Signed-off-by: kminoda --- .github/workflows/cppcheck-all.yaml | 9 ++------- .github/workflows/cppcheck-differential.yaml | 11 ++++++++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/cppcheck-all.yaml b/.github/workflows/cppcheck-all.yaml index e8fbdb1aaa4d0..6d0b75242505c 100644 --- a/.github/workflows/cppcheck-all.yaml +++ b/.github/workflows/cppcheck-all.yaml @@ -32,10 +32,5 @@ jobs: - name: Run Cppcheck on all files run: | - files=$(cat changed_files.txt | grep '\.cpp$\|\.hpp$' | tr '\n' ' ') - if [ -n "$files" ]; then - cppcheck --enable=all --inconclusive --check-level=exhaustive --xml . 2> cppcheck-report.xml - else - echo "No C++ files changed." - fi - shell: bash + cppcheck --enable=all --inconclusive --check-level=exhaustive --xml . 2> cppcheck-report.xml + shell: bash \ No newline at end of file diff --git a/.github/workflows/cppcheck-differential.yaml b/.github/workflows/cppcheck-differential.yaml index 880f0ab3d491e..b18e92af47058 100644 --- a/.github/workflows/cppcheck-differential.yaml +++ b/.github/workflows/cppcheck-differential.yaml @@ -34,7 +34,12 @@ jobs: git diff --name-only FETCH_HEAD ${{ github.sha }} > changed_files.txt cat changed_files.txt - - name: Run Cppcheck on all files + - name: Run Cppcheck on changed files run: | - cppcheck --enable=all --inconclusive --check-level=exhaustive --xml . 2> cppcheck-report.xml - shell: bash \ No newline at end of file + files=$(cat changed_files.txt | grep '\.cpp$\|\.hpp$' | tr '\n' ' ') + if [ -n "$files" ]; then + cppcheck --enable=all --inconclusive --check-level=exhaustive --suppressions-list=.cppcheck_suppressions --xml $files 2> cppcheck-report.xml + else + echo "No C++ files changed." + fi + shell: bash From ed14e35c8be41743a16626fd7a16d38387a301b2 Mon Sep 17 00:00:00 2001 From: kminoda Date: Tue, 4 Jun 2024 16:17:16 +0900 Subject: [PATCH 14/29] add echo in diff Signed-off-by: kminoda --- .github/workflows/cppcheck-differential.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cppcheck-differential.yaml b/.github/workflows/cppcheck-differential.yaml index b18e92af47058..2cd5011834463 100644 --- a/.github/workflows/cppcheck-differential.yaml +++ b/.github/workflows/cppcheck-differential.yaml @@ -38,6 +38,7 @@ jobs: run: | files=$(cat changed_files.txt | grep '\.cpp$\|\.hpp$' | tr '\n' ' ') if [ -n "$files" ]; then + echo "Running Cppcheck on changed files: $files" cppcheck --enable=all --inconclusive --check-level=exhaustive --suppressions-list=.cppcheck_suppressions --xml $files 2> cppcheck-report.xml else echo "No C++ files changed." From 92316449121e58e82551b0573af3af42a60c2b45 Mon Sep 17 00:00:00 2001 From: kminoda Date: Tue, 4 Jun 2024 16:23:31 +0900 Subject: [PATCH 15/29] update regex Signed-off-by: kminoda --- .github/workflows/cppcheck-differential.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cppcheck-differential.yaml b/.github/workflows/cppcheck-differential.yaml index 2cd5011834463..efa44a66d9376 100644 --- a/.github/workflows/cppcheck-differential.yaml +++ b/.github/workflows/cppcheck-differential.yaml @@ -36,7 +36,7 @@ jobs: - name: Run Cppcheck on changed files run: | - files=$(cat changed_files.txt | grep '\.cpp$\|\.hpp$' | tr '\n' ' ') + files=$(cat changed_files.txt | grep -E '\.(cpp|hpp)$' || true) if [ -n "$files" ]; then echo "Running Cppcheck on changed files: $files" cppcheck --enable=all --inconclusive --check-level=exhaustive --suppressions-list=.cppcheck_suppressions --xml $files 2> cppcheck-report.xml From 4f102120ea990bd272fe30b4c2298b6509ca366d Mon Sep 17 00:00:00 2001 From: kminoda Date: Tue, 4 Jun 2024 16:41:31 +0900 Subject: [PATCH 16/29] add statistics for cppcheck-all Signed-off-by: kminoda --- .github/workflows/cppcheck-all.yaml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cppcheck-all.yaml b/.github/workflows/cppcheck-all.yaml index 6d0b75242505c..7e00229a91e59 100644 --- a/.github/workflows/cppcheck-all.yaml +++ b/.github/workflows/cppcheck-all.yaml @@ -33,4 +33,14 @@ jobs: - name: Run Cppcheck on all files run: | cppcheck --enable=all --inconclusive --check-level=exhaustive --xml . 2> cppcheck-report.xml - shell: bash \ No newline at end of file + shell: bash + + - name: Count errors by error ID and severity + run: | + #!/bin/bash + temp_file=$(mktemp) + grep -oP '(?<=id=")[^"]+" severity="[^"]+' cppcheck-report.xml | sed 's/" severity="/,/g' > "$temp_file" + echo "Error counts by error ID and severity:" + sort "$temp_file" | uniq -c + rm "$temp_file" + shell: bash From 2d3bbb3c80fa9909c1a58db22d012191acf0bbc0 Mon Sep 17 00:00:00 2001 From: kminoda Date: Tue, 4 Jun 2024 17:08:12 +0900 Subject: [PATCH 17/29] avoid checking cppcheck dir Signed-off-by: kminoda --- .github/workflows/cppcheck-all.yaml | 5 +++-- .github/workflows/cppcheck-differential.yaml | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cppcheck-all.yaml b/.github/workflows/cppcheck-all.yaml index 7e00229a91e59..18b5308dee9a5 100644 --- a/.github/workflows/cppcheck-all.yaml +++ b/.github/workflows/cppcheck-all.yaml @@ -21,8 +21,9 @@ jobs: - name: Install Cppcheck from source run: | - git clone https://github.com/danmar/cppcheck.git - cd cppcheck + mkdir /tmp/cppcheck + git clone https://github.com/danmar/cppcheck.git /tmp/cppcheck + cd /tmp/cppcheck git checkout 2.14.1 mkdir build cd build diff --git a/.github/workflows/cppcheck-differential.yaml b/.github/workflows/cppcheck-differential.yaml index efa44a66d9376..bc5aa2b7ac432 100644 --- a/.github/workflows/cppcheck-differential.yaml +++ b/.github/workflows/cppcheck-differential.yaml @@ -18,8 +18,9 @@ jobs: - name: Install Cppcheck from source run: | - git clone https://github.com/danmar/cppcheck.git - cd cppcheck + mkdir /tmp/cppcheck + git clone https://github.com/danmar/cppcheck.git /tmp/cppcheck + cd /tmp/cppcheck git checkout 2.14.1 mkdir build cd build From ba13741036667d0e4d325aae5311ab082908e6ec Mon Sep 17 00:00:00 2001 From: kminoda Date: Tue, 4 Jun 2024 20:57:41 +0900 Subject: [PATCH 18/29] error-exit Signed-off-by: kminoda --- .github/workflows/cppcheck-all.yaml | 8 +++++++- .github/workflows/cppcheck-differential.yaml | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cppcheck-all.yaml b/.github/workflows/cppcheck-all.yaml index 18b5308dee9a5..25e0a503aad7f 100644 --- a/.github/workflows/cppcheck-all.yaml +++ b/.github/workflows/cppcheck-all.yaml @@ -33,7 +33,7 @@ jobs: - name: Run Cppcheck on all files run: | - cppcheck --enable=all --inconclusive --check-level=exhaustive --xml . 2> cppcheck-report.xml + cppcheck --enable=all --inconclusive --check-level=exhaustive --error-exitcode=1 --xml . 2> cppcheck-report.xml shell: bash - name: Count errors by error ID and severity @@ -45,3 +45,9 @@ jobs: sort "$temp_file" | uniq -c rm "$temp_file" shell: bash + + - name: Upload Cppcheck report + uses: actions/upload-artifact@v2 + with: + name: latest-cppcheck-report + path: latest-cppcheck-report.xml diff --git a/.github/workflows/cppcheck-differential.yaml b/.github/workflows/cppcheck-differential.yaml index bc5aa2b7ac432..fb8bb2b251d52 100644 --- a/.github/workflows/cppcheck-differential.yaml +++ b/.github/workflows/cppcheck-differential.yaml @@ -40,7 +40,8 @@ jobs: files=$(cat changed_files.txt | grep -E '\.(cpp|hpp)$' || true) if [ -n "$files" ]; then echo "Running Cppcheck on changed files: $files" - cppcheck --enable=all --inconclusive --check-level=exhaustive --suppressions-list=.cppcheck_suppressions --xml $files 2> cppcheck-report.xml + cppcheck --enable=all --inconclusive --check-level=exhaustive --error-exitcode=1 --suppressions-list=.cppcheck_suppressions $files 2> cppcheck-report.txt + cat cppcheck-report.txt else echo "No C++ files changed." fi From e32bc67cbba09afb5dd982016fb9e70e5fd36dc3 Mon Sep 17 00:00:00 2001 From: kminoda Date: Tue, 4 Jun 2024 20:57:52 +0900 Subject: [PATCH 19/29] dummy test Signed-off-by: kminoda --- .github/workflows/cppcheck-all.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cppcheck-all.yaml b/.github/workflows/cppcheck-all.yaml index 25e0a503aad7f..4eb8e0a40bd7c 100644 --- a/.github/workflows/cppcheck-all.yaml +++ b/.github/workflows/cppcheck-all.yaml @@ -33,7 +33,7 @@ jobs: - name: Run Cppcheck on all files run: | - cppcheck --enable=all --inconclusive --check-level=exhaustive --error-exitcode=1 --xml . 2> cppcheck-report.xml + cppcheck --enable=all --inconclusive --check-level=exhaustive --error-exitcode=1 --xml perception/lidar_centerpoint 2> cppcheck-report.xml shell: bash - name: Count errors by error ID and severity From f2e97897a3a758f9aa06c4b80fe6be15f16c0d73 Mon Sep 17 00:00:00 2001 From: kminoda Date: Tue, 4 Jun 2024 21:01:44 +0900 Subject: [PATCH 20/29] upload file even if it fails Signed-off-by: kminoda --- .github/workflows/cppcheck-all.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/cppcheck-all.yaml b/.github/workflows/cppcheck-all.yaml index 4eb8e0a40bd7c..a1f961b69b88e 100644 --- a/.github/workflows/cppcheck-all.yaml +++ b/.github/workflows/cppcheck-all.yaml @@ -32,6 +32,8 @@ jobs: sudo make install - name: Run Cppcheck on all files + continue-on-error: true + id: cppcheck run: | cppcheck --enable=all --inconclusive --check-level=exhaustive --error-exitcode=1 --xml perception/lidar_centerpoint 2> cppcheck-report.xml shell: bash @@ -51,3 +53,7 @@ jobs: with: name: latest-cppcheck-report path: latest-cppcheck-report.xml + + - name: Fail the job if Cppcheck failed + if: steps.cppcheck.outcome == 'failure' + run: exit 1 From f64238b20aa47d8cba5a4aa2984e3203855685a4 Mon Sep 17 00:00:00 2001 From: kminoda Date: Tue, 4 Jun 2024 21:04:47 +0900 Subject: [PATCH 21/29] fix bug Signed-off-by: kminoda --- .github/workflows/cppcheck-all.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cppcheck-all.yaml b/.github/workflows/cppcheck-all.yaml index a1f961b69b88e..fc999b7f8bd4a 100644 --- a/.github/workflows/cppcheck-all.yaml +++ b/.github/workflows/cppcheck-all.yaml @@ -52,7 +52,7 @@ jobs: uses: actions/upload-artifact@v2 with: name: latest-cppcheck-report - path: latest-cppcheck-report.xml + path: cppcheck-report.xml - name: Fail the job if Cppcheck failed if: steps.cppcheck.outcome == 'failure' From c8f59cb6e53cf94e1a217ea8e725afeb445bd1b1 Mon Sep 17 00:00:00 2001 From: kminoda Date: Tue, 4 Jun 2024 21:08:38 +0900 Subject: [PATCH 22/29] revert unnecessary commit Signed-off-by: kminoda --- .github/workflows/cppcheck-all.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cppcheck-all.yaml b/.github/workflows/cppcheck-all.yaml index fc999b7f8bd4a..49969b7a5ddae 100644 --- a/.github/workflows/cppcheck-all.yaml +++ b/.github/workflows/cppcheck-all.yaml @@ -35,7 +35,7 @@ jobs: continue-on-error: true id: cppcheck run: | - cppcheck --enable=all --inconclusive --check-level=exhaustive --error-exitcode=1 --xml perception/lidar_centerpoint 2> cppcheck-report.xml + cppcheck --enable=all --inconclusive --check-level=exhaustive --error-exitcode=1 --xml . 2> cppcheck-report.xml shell: bash - name: Count errors by error ID and severity From 7923ce9310362e19e966614f515881694eb17df3 Mon Sep 17 00:00:00 2001 From: kminoda Date: Tue, 4 Jun 2024 21:09:42 +0900 Subject: [PATCH 23/29] minor fix Signed-off-by: kminoda --- .github/workflows/cppcheck-all.yaml | 2 +- .github/workflows/cppcheck-differential.yaml | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cppcheck-all.yaml b/.github/workflows/cppcheck-all.yaml index 49969b7a5ddae..94f04d2a02f22 100644 --- a/.github/workflows/cppcheck-all.yaml +++ b/.github/workflows/cppcheck-all.yaml @@ -51,7 +51,7 @@ jobs: - name: Upload Cppcheck report uses: actions/upload-artifact@v2 with: - name: latest-cppcheck-report + name: cppcheck-report path: cppcheck-report.xml - name: Fail the job if Cppcheck failed diff --git a/.github/workflows/cppcheck-differential.yaml b/.github/workflows/cppcheck-differential.yaml index fb8bb2b251d52..01223628eb895 100644 --- a/.github/workflows/cppcheck-differential.yaml +++ b/.github/workflows/cppcheck-differential.yaml @@ -36,6 +36,8 @@ jobs: cat changed_files.txt - name: Run Cppcheck on changed files + continue-on-error: true + id: cppcheck run: | files=$(cat changed_files.txt | grep -E '\.(cpp|hpp)$' || true) if [ -n "$files" ]; then @@ -46,3 +48,13 @@ jobs: echo "No C++ files changed." fi shell: bash + + - name: Upload Cppcheck report + uses: actions/upload-artifact@v2 + with: + name: cppcheck-report + path: cppcheck-report.txt + + - name: Fail the job if Cppcheck failed + if: steps.cppcheck.outcome == 'failure' + run: exit 1 From 7a029619dc29b354f35dbab47ae50e870b0083e9 Mon Sep 17 00:00:00 2001 From: kminoda Date: Tue, 4 Jun 2024 21:10:30 +0900 Subject: [PATCH 24/29] dummy test Signed-off-by: kminoda --- perception/lidar_centerpoint/lib/centerpoint_trt.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/perception/lidar_centerpoint/lib/centerpoint_trt.cpp b/perception/lidar_centerpoint/lib/centerpoint_trt.cpp index 2804e172b73fa..b2b456b12da50 100644 --- a/perception/lidar_centerpoint/lib/centerpoint_trt.cpp +++ b/perception/lidar_centerpoint/lib/centerpoint_trt.cpp @@ -86,6 +86,8 @@ void CenterPointTRT::initPtr() // host points_.resize(CAPACITY_POINT * config_.point_feature_size_); + int hoge = 1; + // device voxels_d_ = cuda::make_unique(voxels_size_); coordinates_d_ = cuda::make_unique(coordinates_size_); From 8c7d41c88007b2184afe4954f1400728985f7139 Mon Sep 17 00:00:00 2001 From: kminoda Date: Tue, 4 Jun 2024 21:13:57 +0900 Subject: [PATCH 25/29] dummy test Signed-off-by: kminoda --- .github/workflows/cppcheck-all.yaml | 1 + .github/workflows/cppcheck-differential.yaml | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cppcheck-all.yaml b/.github/workflows/cppcheck-all.yaml index 94f04d2a02f22..2730befcb0124 100644 --- a/.github/workflows/cppcheck-all.yaml +++ b/.github/workflows/cppcheck-all.yaml @@ -19,6 +19,7 @@ jobs: sudo apt-get update sudo apt-get install -y build-essential cmake git libpcre3-dev + # cppcheck from apt does not yet support --check-level args, and thus install from source - name: Install Cppcheck from source run: | mkdir /tmp/cppcheck diff --git a/.github/workflows/cppcheck-differential.yaml b/.github/workflows/cppcheck-differential.yaml index 01223628eb895..4939135ffe1b5 100644 --- a/.github/workflows/cppcheck-differential.yaml +++ b/.github/workflows/cppcheck-differential.yaml @@ -16,6 +16,7 @@ jobs: sudo apt-get update sudo apt-get install -y build-essential cmake git libpcre3-dev + # cppcheck from apt does not yet support --check-level args, and thus install from source - name: Install Cppcheck from source run: | mkdir /tmp/cppcheck @@ -42,7 +43,8 @@ jobs: files=$(cat changed_files.txt | grep -E '\.(cpp|hpp)$' || true) if [ -n "$files" ]; then echo "Running Cppcheck on changed files: $files" - cppcheck --enable=all --inconclusive --check-level=exhaustive --error-exitcode=1 --suppressions-list=.cppcheck_suppressions $files 2> cppcheck-report.txt + cppcheck --enable=all --inconclusive --check-level=exhaustive --error-exitcode=1 $files 2> cppcheck-report.txt + # cppcheck --enable=all --inconclusive --check-level=exhaustive --error-exitcode=1 --suppressions-list=.cppcheck_suppressions $files 2> cppcheck-report.txt cat cppcheck-report.txt else echo "No C++ files changed." From 330ceb8a9e72b47e6410db71cecb36efa6e2274c Mon Sep 17 00:00:00 2001 From: kminoda Date: Tue, 4 Jun 2024 21:20:05 +0900 Subject: [PATCH 26/29] modify to show cppcheck result even when failure Signed-off-by: kminoda --- .github/workflows/cppcheck-differential.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cppcheck-differential.yaml b/.github/workflows/cppcheck-differential.yaml index 4939135ffe1b5..fb8ad384f3885 100644 --- a/.github/workflows/cppcheck-differential.yaml +++ b/.github/workflows/cppcheck-differential.yaml @@ -45,11 +45,15 @@ jobs: echo "Running Cppcheck on changed files: $files" cppcheck --enable=all --inconclusive --check-level=exhaustive --error-exitcode=1 $files 2> cppcheck-report.txt # cppcheck --enable=all --inconclusive --check-level=exhaustive --error-exitcode=1 --suppressions-list=.cppcheck_suppressions $files 2> cppcheck-report.txt - cat cppcheck-report.txt else echo "No C++ files changed." + touch cppcheck-report.txt fi shell: bash + + - name: Show cppcheck-report result + run: | + cat cppcheck-report.txt - name: Upload Cppcheck report uses: actions/upload-artifact@v2 From b8829a498ad2bbf0b1215ac3aab0faa1484e36f9 Mon Sep 17 00:00:00 2001 From: kminoda Date: Tue, 4 Jun 2024 21:22:38 +0900 Subject: [PATCH 27/29] finalize PR Signed-off-by: kminoda --- .github/workflows/cppcheck-differential.yaml | 3 +-- perception/lidar_centerpoint/lib/centerpoint_trt.cpp | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/cppcheck-differential.yaml b/.github/workflows/cppcheck-differential.yaml index fb8ad384f3885..fef435bd91f5f 100644 --- a/.github/workflows/cppcheck-differential.yaml +++ b/.github/workflows/cppcheck-differential.yaml @@ -43,8 +43,7 @@ jobs: files=$(cat changed_files.txt | grep -E '\.(cpp|hpp)$' || true) if [ -n "$files" ]; then echo "Running Cppcheck on changed files: $files" - cppcheck --enable=all --inconclusive --check-level=exhaustive --error-exitcode=1 $files 2> cppcheck-report.txt - # cppcheck --enable=all --inconclusive --check-level=exhaustive --error-exitcode=1 --suppressions-list=.cppcheck_suppressions $files 2> cppcheck-report.txt + cppcheck --enable=all --inconclusive --check-level=exhaustive --error-exitcode=1 --suppressions-list=.cppcheck_suppressions $files 2> cppcheck-report.txt else echo "No C++ files changed." touch cppcheck-report.txt diff --git a/perception/lidar_centerpoint/lib/centerpoint_trt.cpp b/perception/lidar_centerpoint/lib/centerpoint_trt.cpp index b2b456b12da50..2804e172b73fa 100644 --- a/perception/lidar_centerpoint/lib/centerpoint_trt.cpp +++ b/perception/lidar_centerpoint/lib/centerpoint_trt.cpp @@ -86,8 +86,6 @@ void CenterPointTRT::initPtr() // host points_.resize(CAPACITY_POINT * config_.point_feature_size_); - int hoge = 1; - // device voxels_d_ = cuda::make_unique(voxels_size_); coordinates_d_ = cuda::make_unique(coordinates_size_); From ac26f557877bb5c74fe0de831585f80b7ae804ea Mon Sep 17 00:00:00 2001 From: kminoda Date: Wed, 5 Jun 2024 09:45:12 +0900 Subject: [PATCH 28/29] fix pre-commit Signed-off-by: kminoda --- .github/workflows/cppcheck-differential.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cppcheck-differential.yaml b/.github/workflows/cppcheck-differential.yaml index fef435bd91f5f..dcb448f641ba0 100644 --- a/.github/workflows/cppcheck-differential.yaml +++ b/.github/workflows/cppcheck-differential.yaml @@ -49,7 +49,7 @@ jobs: touch cppcheck-report.txt fi shell: bash - + - name: Show cppcheck-report result run: | cat cppcheck-report.txt From 6948f0ba0626a39a642877e40accc09fd67e96e9 Mon Sep 17 00:00:00 2001 From: kminoda Date: Wed, 5 Jun 2024 10:05:15 +0900 Subject: [PATCH 29/29] fix pre-commit Signed-off-by: kminoda --- .github/workflows/cppcheck-all.yaml | 94 +++++++++---------- .github/workflows/cppcheck-differential.yaml | 96 ++++++++++---------- 2 files changed, 95 insertions(+), 95 deletions(-) diff --git a/.github/workflows/cppcheck-all.yaml b/.github/workflows/cppcheck-all.yaml index 2730befcb0124..db3bd5d259895 100644 --- a/.github/workflows/cppcheck-all.yaml +++ b/.github/workflows/cppcheck-all.yaml @@ -11,50 +11,50 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install -y build-essential cmake git libpcre3-dev - - # cppcheck from apt does not yet support --check-level args, and thus install from source - - name: Install Cppcheck from source - run: | - mkdir /tmp/cppcheck - git clone https://github.com/danmar/cppcheck.git /tmp/cppcheck - cd /tmp/cppcheck - git checkout 2.14.1 - mkdir build - cd build - cmake .. - make -j $(nproc) - sudo make install - - - name: Run Cppcheck on all files - continue-on-error: true - id: cppcheck - run: | - cppcheck --enable=all --inconclusive --check-level=exhaustive --error-exitcode=1 --xml . 2> cppcheck-report.xml - shell: bash - - - name: Count errors by error ID and severity - run: | - #!/bin/bash - temp_file=$(mktemp) - grep -oP '(?<=id=")[^"]+" severity="[^"]+' cppcheck-report.xml | sed 's/" severity="/,/g' > "$temp_file" - echo "Error counts by error ID and severity:" - sort "$temp_file" | uniq -c - rm "$temp_file" - shell: bash - - - name: Upload Cppcheck report - uses: actions/upload-artifact@v2 - with: - name: cppcheck-report - path: cppcheck-report.xml - - - name: Fail the job if Cppcheck failed - if: steps.cppcheck.outcome == 'failure' - run: exit 1 + - name: Checkout code + uses: actions/checkout@v2 + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y build-essential cmake git libpcre3-dev + + # cppcheck from apt does not yet support --check-level args, and thus install from source + - name: Install Cppcheck from source + run: | + mkdir /tmp/cppcheck + git clone https://github.com/danmar/cppcheck.git /tmp/cppcheck + cd /tmp/cppcheck + git checkout 2.14.1 + mkdir build + cd build + cmake .. + make -j $(nproc) + sudo make install + + - name: Run Cppcheck on all files + continue-on-error: true + id: cppcheck + run: | + cppcheck --enable=all --inconclusive --check-level=exhaustive --error-exitcode=1 --xml . 2> cppcheck-report.xml + shell: bash + + - name: Count errors by error ID and severity + run: | + #!/bin/bash + temp_file=$(mktemp) + grep -oP '(?<=id=")[^"]+" severity="[^"]+' cppcheck-report.xml | sed 's/" severity="/,/g' > "$temp_file" + echo "Error counts by error ID and severity:" + sort "$temp_file" | uniq -c + rm "$temp_file" + shell: bash + + - name: Upload Cppcheck report + uses: actions/upload-artifact@v2 + with: + name: cppcheck-report + path: cppcheck-report.xml + + - name: Fail the job if Cppcheck failed + if: steps.cppcheck.outcome == 'failure' + run: exit 1 diff --git a/.github/workflows/cppcheck-differential.yaml b/.github/workflows/cppcheck-differential.yaml index dcb448f641ba0..914abd7df86ea 100644 --- a/.github/workflows/cppcheck-differential.yaml +++ b/.github/workflows/cppcheck-differential.yaml @@ -8,58 +8,58 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v2 + - name: Checkout code + uses: actions/checkout@v2 - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install -y build-essential cmake git libpcre3-dev + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y build-essential cmake git libpcre3-dev - # cppcheck from apt does not yet support --check-level args, and thus install from source - - name: Install Cppcheck from source - run: | - mkdir /tmp/cppcheck - git clone https://github.com/danmar/cppcheck.git /tmp/cppcheck - cd /tmp/cppcheck - git checkout 2.14.1 - mkdir build - cd build - cmake .. - make -j $(nproc) - sudo make install + # cppcheck from apt does not yet support --check-level args, and thus install from source + - name: Install Cppcheck from source + run: | + mkdir /tmp/cppcheck + git clone https://github.com/danmar/cppcheck.git /tmp/cppcheck + cd /tmp/cppcheck + git checkout 2.14.1 + mkdir build + cd build + cmake .. + make -j $(nproc) + sudo make install - - name: Get changed files - id: changed-files - run: | - git fetch origin ${{ github.base_ref }} --depth=1 - git diff --name-only FETCH_HEAD ${{ github.sha }} > changed_files.txt - cat changed_files.txt + - name: Get changed files + id: changed-files + run: | + git fetch origin ${{ github.base_ref }} --depth=1 + git diff --name-only FETCH_HEAD ${{ github.sha }} > changed_files.txt + cat changed_files.txt - - name: Run Cppcheck on changed files - continue-on-error: true - id: cppcheck - run: | - files=$(cat changed_files.txt | grep -E '\.(cpp|hpp)$' || true) - if [ -n "$files" ]; then - echo "Running Cppcheck on changed files: $files" - cppcheck --enable=all --inconclusive --check-level=exhaustive --error-exitcode=1 --suppressions-list=.cppcheck_suppressions $files 2> cppcheck-report.txt - else - echo "No C++ files changed." - touch cppcheck-report.txt - fi - shell: bash + - name: Run Cppcheck on changed files + continue-on-error: true + id: cppcheck + run: | + files=$(cat changed_files.txt | grep -E '\.(cpp|hpp)$' || true) + if [ -n "$files" ]; then + echo "Running Cppcheck on changed files: $files" + cppcheck --enable=all --inconclusive --check-level=exhaustive --error-exitcode=1 --suppressions-list=.cppcheck_suppressions $files 2> cppcheck-report.txt + else + echo "No C++ files changed." + touch cppcheck-report.txt + fi + shell: bash - - name: Show cppcheck-report result - run: | - cat cppcheck-report.txt + - name: Show cppcheck-report result + run: | + cat cppcheck-report.txt - - name: Upload Cppcheck report - uses: actions/upload-artifact@v2 - with: - name: cppcheck-report - path: cppcheck-report.txt + - name: Upload Cppcheck report + uses: actions/upload-artifact@v2 + with: + name: cppcheck-report + path: cppcheck-report.txt - - name: Fail the job if Cppcheck failed - if: steps.cppcheck.outcome == 'failure' - run: exit 1 + - name: Fail the job if Cppcheck failed + if: steps.cppcheck.outcome == 'failure' + run: exit 1