Skip to content

Commit

Permalink
static_checks: bugfixes, read exceptions from source directory
Browse files Browse the repository at this point in the history
  • Loading branch information
asherikov committed Apr 28, 2024
1 parent 3d06475 commit e0d86bf
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 9 deletions.
8 changes: 8 additions & 0 deletions .ccws/test_main.mk
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ test:
${MAKE} wstest PKG=staticoma EXEC_PROFILE="core_pattern valgrind"
# static checks & documentation
${MAKE} bp_install_build BUILD_PROFILE=static_checks
# must fail without exceptions
! ${MAKE} BUILD_PROFILE=static_checks
# must succeed with exceptions
cp -R examples/.ccws ./src/
${MAKE} BUILD_PROFILE=static_checks
# must succeed without package exceptions
rm ./src/.ccws/static_checks.exceptions.packages
cp -R examples/.ccws src/
${MAKE} BUILD_PROFILE=static_checks
${MAKE} bp_install_build BUILD_PROFILE=doxygen
${MAKE} PKG=staticoma BUILD_PROFILE=doxygen
Expand Down
1 change: 1 addition & 0 deletions examples/.ccws/static_checks.exceptions.packages
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
staticoma
2 changes: 2 additions & 0 deletions examples/.ccws/static_checks.exceptions.paths
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
staticoma/src/3rdparty
staticoma/src/3rdparty
9 changes: 9 additions & 0 deletions profiles/build/common/setup.bash
Original file line number Diff line number Diff line change
Expand Up @@ -335,3 +335,12 @@ umask u=rwx,g=rx,o=rx
DEBIAN_FRONTEND=noninteractive
export DEBIAN_FRONTEND

ccws_read_exceptions()
{
FILE="${CCWS_SOURCE_DIR}/.ccws/${BUILD_PROFILE}.exceptions.${1}"

if [ -f "${FILE}" ]
then
sed -e 's=^=:${CCWS_SOURCE_DIR}/=' < "${FILE}" | tr -d '\n'
fi
}
1 change: 1 addition & 0 deletions profiles/build/scan_build/setup.bash
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ set -o pipefail
BUILD_PROFILE=${BUILD_PROFILE:-"$(basename "$(dirname "${BASH_SOURCE[0]}")")"}
source "$(dirname "${BASH_SOURCE[0]}")/../${1:-"static_checks"}/setup.bash" "${@:2}" ""

CCWS_STATIC_DIR_EXCEPTIONS="${CCWS_STATIC_DIR_EXCEPTIONS}$(ccws_read_exceptions paths)"
EXCEPTIONS=$(echo "${CCWS_STATIC_DIR_EXCEPTIONS}" | sed "s/:/ --exclude /g")


Expand Down
4 changes: 2 additions & 2 deletions profiles/build/static_checks/setup.bash
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ source "$(dirname "${BASH_SOURCE[0]}")/../${1:-"common"}/setup.bash" "${@:2}" ""
#

# popl.hpp
CCWS_STATIC_DIR_EXCEPTIONS="${CCWS_STATIC_DIR_EXCEPTIONS}:${CCWS_SOURCE_DIR}/staticoma/src/3rdparty"
CCWS_STATIC_DIR_EXCEPTIONS="${CCWS_STATIC_DIR_EXCEPTIONS}$(ccws_read_exceptions paths)"
# shellcheck disable=SC2269
CCWS_STATIC_PKG_EXCEPTIONS="${CCWS_STATIC_PKG_EXCEPTIONS}"
CCWS_STATIC_PKG_EXCEPTIONS="${CCWS_STATIC_PKG_EXCEPTIONS}$(ccws_read_exceptions packages)"
export CCWS_STATIC_DIR_EXCEPTIONS CCWS_STATIC_PKG_EXCEPTIONS


Expand Down
20 changes: 13 additions & 7 deletions profiles/build/static_checks/targets.mk
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,20 @@ cppcheck:
# syntaxError -- has issues with templated methods and test fixtures.
# useInitializationList -- initialization in the body of the constructor is ok
# unknownMacro -- too much hassle
# useStlAlgorithm -- not always worth the effort
#
# --inconclusive -- can be used to catch some extra issues
# --error-exitcode=1 -- fails with no errors printed
mkdir -p ${WORKSPACE_DIR}/build/$@
#
# cppcheck does not check headers when their names are not provided explicitly
${MAKE} static_checks_generic_dir_filter TARGET=$@
find ${WORKSPACE_DIR}/src -type f -iname '*.hpp' -or -iname "*.cpp" -or -iname "*.h" > ${WORKSPACE_DIR}/build/$@/input
rm -f '${WORKSPACE_DIR}/build/$@/cppcheck.err'
bash -c "${SETUP_SCRIPT}; \
EXCEPTIONS=\$$(echo \$${CCWS_STATIC_DIR_EXCEPTIONS} | sed -e 's/:/ -i /g'); \
source ${WORKSPACE_DIR}/build/$@/filter > ${WORKSPACE_DIR}/build/$@/input.filtered; \
cat ${WORKSPACE_DIR}/build/$@/input.filtered | xargs --max-procs=${JOBS} --no-run-if-empty -I {} \
cppcheck \
${WORKSPACE_DIR}/src \
-j ${JOBS} \
-j 1 \
--relative-paths \
--quiet --verbose --force \
--template='[{file}:{line}] {severity} {id} {message}' \
Expand All @@ -73,9 +78,10 @@ cppcheck:
--suppress=syntaxError \
--suppress=useInitializationList \
--suppress=unknownMacro \
\$${EXCEPTIONS} \
--suppress=useStlAlgorithm \
3>&1 1>&2 2>&3 \
| tee '${WORKSPACE_DIR}/build/$@/cppcheck.err' "
{} \
| tee --append '${WORKSPACE_DIR}/build/$@/cppcheck.err' "
test ! -s '${WORKSPACE_DIR}/build/$@/cppcheck.err' || exit 1


Expand Down Expand Up @@ -153,7 +159,7 @@ catkin_lint:
pylint:
bash -c "${SETUP_SCRIPT}; \
DIR_EXCEPTIONS=\$$(echo \$${CCWS_STATIC_DIR_EXCEPTIONS} | sed -e 's/://' -e 's/:/,/g'); \
pylint --rcfile \$${CCWS_BUILD_PROFILE_DIR}/pylintrc --jobs ${JOBS} --ignore-paths \$${DIR_EXCEPTIONS} '${WORKSPACE_DIR}/src'"
pylint --rcfile \$${CCWS_BUILD_PROFILE_DIR}/pylintrc --jobs ${JOBS} --ignore-paths \"\$${DIR_EXCEPTIONS}\" '${WORKSPACE_DIR}/src'"

flake8:
bash -c "${SETUP_SCRIPT}; \
Expand Down

0 comments on commit e0d86bf

Please sign in to comment.