File tree Expand file tree Collapse file tree
continuous_integration/scripts Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,6 +10,22 @@ permissions:
1010env :
1111 OTB_RELEASE : 9.1.0
1212jobs :
13+ quality :
14+ runs-on : ubuntu-22.04
15+ steps :
16+ - uses : actions/checkout@v4
17+ - name : setup python 3.10
18+ uses : actions/setup-python@v3
19+ with :
20+ python-version : " 3.10"
21+ - name : install quality deps
22+ run : |
23+ pip install pylint mccabe
24+ - name : code quality
25+ run : |
26+ pylint --disable=all --fail-under=10 --enable=too-many-statements .
27+ pylint --disable=all --fail-under=10 --enable=too-many-nested-blocks .
28+ ./continuous_integration/scripts/check_mccabe_complexity.sh 25 .
1329 test :
1430 runs-on : ubuntu-22.04
1531 steps :
2743 source /opt/otb/otbenv.profile
2844 sh /opt/otb/recompile_bindings.sh
2945 python -m pip install --upgrade pip
30- pip install flake8 pytest
46+ pip install pytest pytest-cov
3147 if [ -f docker/requirements.txt ]; then pip install -r docker/requirements.txt; fi
3248 - name : pytest
3349 run : |
4359 export OTB_INSTALL_DIR=/opt/otb
4460 export LC_NUMERIC=C
4561
46- pytest -s
62+ pytest -s --cov-fail-under=65
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ if [ -z " $1 " ] || [ -z " $2 " ]; then
4+ echo " Error: You must specify a McCabe threshold and a directory to analyze."
5+ echo " Usage: $0 <threshold> <directory>"
6+ exit 1
7+ fi
8+
9+ threshold=$1
10+ directory=$2
11+
12+ if [ ! -d " $directory " ]; then
13+ echo " Error: The directory '$directory ' does not exist."
14+ exit 1
15+ fi
16+
17+ all_files_ok=true
18+ for file in $( find " $directory " -name " *.py" ) ; do
19+ echo " Analyzing $file ..."
20+ output=$( python -m mccabe --min " $threshold " " $file " )
21+
22+ if [ -n " $output " ]; then
23+ echo " Error: McCabe complexity too high in $file "
24+ echo " $output "
25+ all_files_ok=false
26+ fi
27+ done
28+
29+ if $all_files_ok ; then
30+ echo " ✅ All files have McCabe scores less than or equal to $threshold . ✅"
31+ else
32+ echo " ❌ Some files have a complexity higher than $threshold ❌"
33+ exit 1
34+ fi
35+
36+ exit 0
You can’t perform that action at this time.
0 commit comments