mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-17 00:04:02 -04:00
[ci] Add unit test for banned keywords
Flags use of keywords representing deprecated or other "to be avoided" methods, e.g. use of DBL_MAX instead of the type-safe std::numeric_limits<double>::max() method.
This commit is contained in:
parent
a4c8386e88
commit
ce6fc8fe96
@ -2,6 +2,7 @@ IF(WITH_ASTYLE)
|
||||
ADD_TEST(qgis_indentation ${CMAKE_SOURCE_DIR}/scripts/verify-indentation.sh)
|
||||
ENDIF(WITH_ASTYLE)
|
||||
|
||||
ADD_TEST(qgis_banned_keywords ${CMAKE_SOURCE_DIR}/tests/code_layout/test_banned_keywords.sh)
|
||||
ADD_TEST(qgis_licenses ${CMAKE_SOURCE_DIR}/tests/code_layout/test_licenses.sh)
|
||||
ADD_TEST(qgis_spelling ${CMAKE_SOURCE_DIR}/scripts/spell_check/spell_test.sh)
|
||||
|
||||
|
43
tests/code_layout/test_banned_keywords.sh
Executable file
43
tests/code_layout/test_banned_keywords.sh
Executable file
@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# This test checks for use of deprecated/outdated methods and suggests their replacement
|
||||
|
||||
declare -a KEYWORDS=()
|
||||
declare -a HINTS=()
|
||||
|
||||
KEYWORDS[0]="DBL_MAX"
|
||||
HINTS[0]="Use the type-safe method std::numeric_limits<double>::max() instead"
|
||||
|
||||
KEYWORDS[1]="DBL_MIN"
|
||||
HINTS[1]="Use the type-safe method std::numeric_limits<double>::lowest() instead"
|
||||
|
||||
KEYWORDS[2]="DBL_EPSILON"
|
||||
HINTS[2]="Use the type-safe method std::numeric_limits<double>::epsilon() instead"
|
||||
|
||||
RES=
|
||||
DIR=$(git rev-parse --show-toplevel)
|
||||
|
||||
pushd "${DIR}" > /dev/null || exit
|
||||
|
||||
for i in "${!KEYWORDS[@]}"
|
||||
do
|
||||
FOUND=$(git grep "${KEYWORDS[$i]}" -- 'src/*.h' 'src/*.cpp')
|
||||
|
||||
if [[ ${FOUND} ]]; then
|
||||
echo "Found source files with banned keyword: ${KEYWORDS[$i]}!"
|
||||
echo " -> ${HINTS[$i]}"
|
||||
echo
|
||||
echo "${FOUND}"
|
||||
echo
|
||||
RES=1
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
popd > /dev/null || exit
|
||||
|
||||
if [ $RES ]; then
|
||||
echo " *** Found banned keywords"
|
||||
exit 1
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user