Static_analysis_report.json has incorrect format if there is more than one code report step
i-keliukh opened this issue · 4 comments
Description
If multiple config steps are marked with code_report=True
, the Static_analysis_report.json file created by universum is not valid json.
Steps to reproduce
- Create config with at least two code report steps, for example:
from universum.configuration_support import Configuration, Step
configs = Configuration([Step(name='Run pylint', command=['python', '-m', 'universum.analyzers.pylint', '--result-file', '${CODE_REPORT_FILE}', '--files', 'source_file.py'], code_report=True)])
configs += Configuration([Step(name='Run mypy', command=['python', '-m', 'universum.analyzers.mypy', '--result-file', '${CODE_REPORT_FILE}', '--files', 'source_file.py'], code_report=True)])
- Create source file that fails checks of both analyzers, for example:
"Docstring."
s: int = "world"
print(f"Hello {s}.")
- Run the above config against the source file passing --no-finalize option to universum or check it on real code review system, such as Github or Gerrit
- If running locally, check the
Static_analysis_report.json
file inartifacts
directory
Expected result
- The
Static_analysis_report.json
must be the correct json file
Actual result
The Static_analysis_report.json
is not valid json: it is a concatenation of two json files with arrays, which is not valid.
Environment
- OS: Ubuntu 22.0.4
- Python version 3.10
- Universum version: 91afad6
Additional context
The bug is located here:
Universum/universum/modules/code_report_collector.py
Lines 88 to 96 in 57cacdf
shouldn't code reports be delivered via
self.reporter.code_report(path, message)
that is called later?
The issue is than write
doesn't clear the file and in the second and further iterations the file is not valid json
as far as I know, "Static_analysis_report.json" is not used and can be safely deleted. Actually, I would prefer if we removed it from Universum logic to prevent future confusion
we have reproduced an issue with multiple code reports not working together, trying to narrow down the issue