@task
@needs('pavelib.prereqs.install_python_prereqs')
@timed
def run_complexity():
 system_string = 'cms/ lms/ common/ openedx/'
 complexity_report_dir = (Env.REPORT_DIR / 'complexity')
 complexity_report = (complexity_report_dir / 'python_complexity.log')
 Env.METRICS_DIR.makedirs_p()
 _prepare_report_dir(complexity_report_dir)
 print '--> Calculating cyclomatic complexity of python files...'
 try:
  sh('radon cc {system_string} --total-average > {complexity_report}'.format(system_string=system_string, complexity_report=complexity_report))
  complexity_metric = _get_count_from_last_line(complexity_report, 'python_complexity')
  _write_metric(complexity_metric, (Env.METRICS_DIR / 'python_complexity'))
  print '--> Python cyclomatic complexity report complete.'
  print 'radon cyclomatic complexity score: {metric}'.format(metric=str(complexity_metric))
 except BuildFailure:
  print 'ERROR: Unable to calculate python-only code-complexity.'

@ task @ needs ( 'pavelib.prereqs.install_python_prereqs' ) @ timed def run_complexity ( ) : system_string = 'cms/ lms/ common/ openedx/' complexity_report_dir = ( Env . REPORT_DIR / 'complexity' ) complexity_report = ( complexity_report_dir / 'python_complexity.log' ) Env . METRICS_DIR . makedirs_p ( ) _prepare_report_dir ( complexity_report_dir ) print '--> Calculating cyclomatic complexity of python files...' try : sh ( 'radon cc {system_string} --total-average > {complexity_report}' . format ( system_string = system_string , complexity_report = complexity_report ) ) complexity_metric = _get_count_from_last_line ( complexity_report , 'python_complexity' ) _write_metric ( complexity_metric , ( Env . METRICS_DIR / 'python_complexity' ) ) print '--> Python cyclomatic complexity report complete.' print 'radon cyclomatic complexity score: {metric}' . format ( metric = str ( complexity_metric ) ) except BuildFailure : print 'ERROR: Unable to calculate python-only code-complexity.'
uses radon to examine cyclomatic complexity .