Commit 7376b114 by Calen Pennington

Don't re-run pylint or pep8 when generating diffquality reports

parent 8c35e3d8
...@@ -74,7 +74,7 @@ def find_fixme(options): ...@@ -74,7 +74,7 @@ def find_fixme(options):
print "Number of pylint fixmes: " + str(num_fixme) print "Number of pylint fixmes: " + str(num_fixme)
def _get_pylint_violations(systems=ALL_SYSTEMS.split(','), errors_only=False): def _get_pylint_violations(systems=ALL_SYSTEMS.split(','), errors_only=False, clean=True):
""" """
Runs pylint. Returns a tuple of (number_of_violations, list_of_violations) Runs pylint. Returns a tuple of (number_of_violations, list_of_violations)
where list_of_violations is a list of all pylint violations found, separated where list_of_violations is a list of all pylint violations found, separated
...@@ -97,19 +97,20 @@ def _get_pylint_violations(systems=ALL_SYSTEMS.split(','), errors_only=False): ...@@ -97,19 +97,20 @@ def _get_pylint_violations(systems=ALL_SYSTEMS.split(','), errors_only=False):
apps_list = ' '.join(top_python_dirs(system)) apps_list = ' '.join(top_python_dirs(system))
sh( system_report = report_dir / 'pylint.report'
"pylint {flags} --output-format=parseable {apps} " if clean or not system_report.exists():
"> {report_dir}/pylint.report".format( sh(
flags=" ".join(flags), "pylint {flags} --output-format=parseable {apps} "
apps=apps_list, "> {report_dir}/pylint.report".format(
report_dir=report_dir flags=" ".join(flags),
), apps=apps_list,
ignore_error=True, report_dir=report_dir
) ),
ignore_error=True,
)
report = "{report_dir}/pylint.report".format(report_dir=report_dir) num_violations += _count_pylint_violations(system_report)
num_violations += _count_pylint_violations(report) with open(system_report) as report_contents:
with open(report) as report_contents:
violations_list.extend(report_contents) violations_list.extend(report_contents)
# Print number of violations to log # Print number of violations to log
...@@ -203,24 +204,25 @@ def _count_pylint_violations(report_file): ...@@ -203,24 +204,25 @@ def _count_pylint_violations(report_file):
return num_violations_report return num_violations_report
def _get_pep8_violations(): def _get_pep8_violations(clean=True):
""" """
Runs pep8. Returns a tuple of (number_of_violations, violations_string) Runs pep8. Returns a tuple of (number_of_violations, violations_string)
where violations_string is a string of all pep8 violations found, separated where violations_string is a string of all pep8 violations found, separated
by new lines. by new lines.
""" """
report_dir = (Env.REPORT_DIR / 'pep8') report_dir = (Env.REPORT_DIR / 'pep8')
report_dir.rmtree(ignore_errors=True) if clean:
report_dir.rmtree(ignore_errors=True)
report_dir.makedirs_p() report_dir.makedirs_p()
report = report_dir / 'pep8.report'
# Make sure the metrics subdirectory exists # Make sure the metrics subdirectory exists
Env.METRICS_DIR.makedirs_p() Env.METRICS_DIR.makedirs_p()
sh('pep8 . | tee {report_dir}/pep8.report -a'.format(report_dir=report_dir)) if not report.exists():
sh('pep8 . | tee {} -a'.format(report))
violations_list = _pep8_violations( violations_list = _pep8_violations(report)
"{report_dir}/pep8.report".format(report_dir=report_dir)
)
return (len(violations_list), violations_list) return (len(violations_list), violations_list)
...@@ -737,7 +739,7 @@ def run_quality(options): ...@@ -737,7 +739,7 @@ def run_quality(options):
return ''.join(lines) return ''.join(lines)
# Run pep8 directly since we have 0 violations on master # Run pep8 directly since we have 0 violations on master
(count, violations_list) = _get_pep8_violations() (count, violations_list) = _get_pep8_violations(clean=False)
# Print number of violations to log # Print number of violations to log
print _lint_output('pep8', count, violations_list) print _lint_output('pep8', count, violations_list)
...@@ -753,7 +755,7 @@ def run_quality(options): ...@@ -753,7 +755,7 @@ def run_quality(options):
# If pylint reports exist, use those # If pylint reports exist, use those
# Otherwise, `diff-quality` will call pylint itself # Otherwise, `diff-quality` will call pylint itself
(count, violations_list) = _get_pylint_violations() (count, violations_list) = _get_pylint_violations(clean=False)
# Print number of violations to log # Print number of violations to log
print _lint_output('pylint', count, violations_list, limit=6100) print _lint_output('pylint', count, violations_list, limit=6100)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment