mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-22 00:06:12 -05:00
Add a test to ensure consistency of class names
This commit is contained in:
parent
a39b5df615
commit
778f7de452
10
.github/workflows/code_layout.yml
vendored
10
.github/workflows/code_layout.yml
vendored
@ -20,7 +20,7 @@ jobs:
|
||||
- name: Set up Python 3.10
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.10'
|
||||
python-version: '3.10'
|
||||
- name: Install requirements
|
||||
run: |
|
||||
wget https://www.doxygen.nl/files/doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz
|
||||
@ -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