mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-23 00:02:38 -05:00
Add a test to ensure consistency of class names
This commit is contained in:
parent
a39b5df615
commit
778f7de452
8
.github/workflows/code_layout.yml
vendored
8
.github/workflows/code_layout.yml
vendored
@ -72,6 +72,14 @@ jobs:
|
||||
- name: Run Banned Keywords Test
|
||||
run: ./tests/code_layout/test_banned_keywords.sh
|
||||
|
||||
class_name_check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Run class naming conventions check
|
||||
run: ./tests/code_layout/test_class_names.sh
|
||||
|
||||
def_window_title_check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
@ -9,6 +9,7 @@ if(WITH_ASTYLE)
|
||||
endif()
|
||||
|
||||
add_qgis_test_script(qgis_banned_keywords tests/code_layout/test_banned_keywords.sh)
|
||||
add_qgis_test_script(qgis_class_names tests/code_layout/test_class_names.sh)
|
||||
add_qgis_test_script(qgis_licenses tests/code_layout/test_licenses.sh)
|
||||
add_qgis_test_script(qgis_spelling scripts/spell_check/spell_test.sh)
|
||||
add_qgis_test_script(qgis_defwindowtitle tests/code_layout/test_defwindowtitle.sh)
|
||||
|
37
tests/code_layout/test_class_names.sh
Executable file
37
tests/code_layout/test_class_names.sh
Executable file
@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# This test checks for use of non-compliant class names
|
||||
|
||||
declare -a KEYWORDS=()
|
||||
declare -a HINTS=()
|
||||
|
||||
KEYWORDS[0]="^\s*class[^:]*Qgs\S*3d"
|
||||
HINTS[0]="Use '3D' capitalisation in class names instead of '3d'"
|
||||
|
||||
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' | sed -n 's/.*\(Qgs\w*\).*/\1/p' | sort -u)
|
||||
|
||||
if [[ ${FOUND} ]]; then
|
||||
echo "Found classes with non-standard names!"
|
||||
echo " -> ${HINTS[$i]}"
|
||||
echo
|
||||
echo "${FOUND}"
|
||||
echo
|
||||
RES=1
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
popd > /dev/null || exit
|
||||
|
||||
if [ $RES ]; then
|
||||
echo " *** Found non-compliant class names"
|
||||
exit 1
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user