From 30291e7511b47b7e0d9b6f5eb2402c46dd1ed676 Mon Sep 17 00:00:00 2001 From: Ben Patterson Date: Thu, 26 Feb 2015 19:26:50 -0500 Subject: [PATCH 1/3] Add radon. --- requirements/edx/base.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements/edx/base.txt b/requirements/edx/base.txt index 49372b9b78..bbf0641adc 100644 --- a/requirements/edx/base.txt +++ b/requirements/edx/base.txt @@ -147,6 +147,7 @@ pep8==1.5.7 PyContracts==1.7.1 pylint==1.4.1 python-subunit==0.0.16 +radon==1.2 rednose==0.3 selenium==2.42.1 splinter==0.5.4 From 471bd2c0a878c70a5ae63df5030a0284a46e7eb4 Mon Sep 17 00:00:00 2001 From: Ben Patterson Date: Thu, 26 Feb 2015 20:29:32 -0500 Subject: [PATCH 2/3] Enable code complexity reporting. --- pavelib/quality.py | 19 +++++++++++++++++++ scripts/all-tests.sh | 1 + 2 files changed, 20 insertions(+) diff --git a/pavelib/quality.py b/pavelib/quality.py index a5c7eb4634..2f1584fede 100644 --- a/pavelib/quality.py +++ b/pavelib/quality.py @@ -173,6 +173,25 @@ def _count_pep8_violations(report_file): return num_lines +@task +@needs('pavelib.prereqs.install_python_prereqs') +def run_complexity(): + """ + Uses radon to examine cyclomatic complexity. + For additional details on radon, see http://radon.readthedocs.org/ + """ + system_string = 'cms/ lms/ common/ openedx/' + print "--> Calculating cyclomatic complexity of files..." + try: + sh( + "radon cc {system_string} --total-average".format( + system_string=system_string + ) + ) + except BuildFailure: + print "ERROR: Unable to calculate python-only code-complexity." + + @task @needs('pavelib.prereqs.install_python_prereqs') @cmdopts([ diff --git a/scripts/all-tests.sh b/scripts/all-tests.sh index 3767d10492..3a6ee2ec44 100755 --- a/scripts/all-tests.sh +++ b/scripts/all-tests.sh @@ -80,6 +80,7 @@ case "$TEST_SUITE" in # Run quality task. Pass in the 'fail-under' percentage to diff-quality paver run_quality -p 100 + paver run_complexity > code_complexity.log || echo "Unable to calculate code complexity. Ignoring error." # Need to create an empty test result so the post-build # action doesn't fail the build. mkdir -p reports From eb4f852916a0e5767fbd95ba23f71a2db1b6ef7e Mon Sep 17 00:00:00 2001 From: Ben Patterson Date: Mon, 2 Mar 2015 11:27:31 -0500 Subject: [PATCH 3/3] Pipe complexity report to reports dir. --- scripts/all-tests.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/all-tests.sh b/scripts/all-tests.sh index 3a6ee2ec44..5d3874f000 100755 --- a/scripts/all-tests.sh +++ b/scripts/all-tests.sh @@ -80,10 +80,10 @@ case "$TEST_SUITE" in # Run quality task. Pass in the 'fail-under' percentage to diff-quality paver run_quality -p 100 - paver run_complexity > code_complexity.log || echo "Unable to calculate code complexity. Ignoring error." + mkdir -p reports + paver run_complexity > reports/code_complexity.log || echo "Unable to calculate code complexity. Ignoring error." # Need to create an empty test result so the post-build # action doesn't fail the build. - mkdir -p reports cat > reports/quality.xml <