From 535c17f85daa59f4573bf12c4aa161d50d1ecd57 Mon Sep 17 00:00:00 2001 From: Lindsay Stewart Date: Fri, 27 Oct 2023 00:08:54 -0700 Subject: [PATCH] Try again to fix inconsistency --- .github/workflows/ci_linting.yml | 11 ++--------- codebuild/bin/cppcheck_suppressions.txt | 7 +++++++ codebuild/bin/run_cppcheck.sh | 6 +----- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci_linting.yml b/.github/workflows/ci_linting.yml index 20315db2f94..b82b8058d07 100644 --- a/.github/workflows/ci_linting.yml +++ b/.github/workflows/ci_linting.yml @@ -44,15 +44,8 @@ jobs: if: steps.cache.outputs.cache-hit != 'true' run: ./codebuild/bin/install_cppcheck.sh "$CPPCHECK_INSTALL_DIR" - # There are inconsistences between cppcheck with and without a cached build-dir. - # For example, cppcheck can't check for unusedFunction when run initially, - # but will detect unusedFunction when run again with the cached build-dir. - # To avoid inconsistent results, run cppcheck twice. - # The second run should be very fast. - - name: Initialize cppcheck results - run: JOBS=8 ./codebuild/bin/run_cppcheck.sh "$CPPCHECK_INSTALL_DIR" - - name: Update cppcheck results - run: JOBS=1 ./codebuild/bin/run_cppcheck.sh "$CPPCHECK_INSTALL_DIR" + - name: Check + run: ./codebuild/bin/run_cppcheck.sh "$CPPCHECK_INSTALL_DIR" copyright: runs-on: ubuntu-latest diff --git a/codebuild/bin/cppcheck_suppressions.txt b/codebuild/bin/cppcheck_suppressions.txt index c85c4bd9514..7981c041aaa 100644 --- a/codebuild/bin/cppcheck_suppressions.txt +++ b/codebuild/bin/cppcheck_suppressions.txt @@ -1,3 +1,10 @@ +// Message: unusedFunction check can't be used with '-j' option. Disabling unusedFunction check. +// Reason: cppcheck can't detect unusedFunction with -j and a missing / empty build-dir. +// But that means that if we run cppcheck twice with the --cppcheck-build-dir argument, +// the second run will detect unusedFunction. For now, just completely disable unusedFunction +// for consistency with previous behavior and across CI runs. +unusedFunction + // Message: (style:variableScope) The scope of the variable 'text' can be reduced. // Reason: Don't error for being able to reduce scope of variables in tests variableScope:tests/unit/* diff --git a/codebuild/bin/run_cppcheck.sh b/codebuild/bin/run_cppcheck.sh index 04258809165..a789bd96b77 100755 --- a/codebuild/bin/run_cppcheck.sh +++ b/codebuild/bin/run_cppcheck.sh @@ -30,17 +30,13 @@ if [ -n "$CPPCHECK_CACHE_DIR" ]; then BUILD_DIR_ARG="--cppcheck-build-dir=$CPPCHECK_CACHE_DIR" fi -if [-z "$JOBS" ]; then - JOBS=1 -fi - INSTALL_DIR=$1 CPPCHECK_EXECUTABLE=${INSTALL_DIR}/cppcheck FAILED=0 $CPPCHECK_EXECUTABLE --version -$CPPCHECK_EXECUTABLE --std=c99 --error-exitcode=-1 --quiet --force -j ${JOBS} \ +$CPPCHECK_EXECUTABLE --std=c99 --error-exitcode=-1 --quiet --force -j 8 \ --enable=all --template='[{file}:{line}]: ({severity}:{id}) {message}' \ ${BUILD_DIR_ARG} \ --inline-suppr --suppressions-list=codebuild/bin/cppcheck_suppressions.txt \