Skip to content

Commit

Permalink
Try again to fix inconsistency
Browse files Browse the repository at this point in the history
  • Loading branch information
lrstewart committed Oct 27, 2023
1 parent e5f9e73 commit 535c17f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
11 changes: 2 additions & 9 deletions .github/workflows/ci_linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions codebuild/bin/cppcheck_suppressions.txt
Original file line number Diff line number Diff line change
@@ -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/*
Expand Down
6 changes: 1 addition & 5 deletions codebuild/bin/run_cppcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down

0 comments on commit 535c17f

Please sign in to comment.