Skip to content

Latest commit

 

History

History
135 lines (88 loc) · 4.2 KB

code_report.rst

File metadata and controls

135 lines (88 loc) · 4.2 KB

Code report

The following analysing modules (analysers) are installed by default: universum_pylint, universum_svace, universum_uncrustify. Analysers are separate scripts, fully compatible with Universum. It is possible to use them independently from command line.

All analysers must have an argument for JSON file with analysis results. If you run code report independently, the name must conform to file name standards. If argument is not provided, output will be written to console.

Running analysers from Universum, you need to add code_report=True and result file argument mandatory must be set to "${CODE_REPORT_FILE}". "${CODE_REPORT_FILE}" is a pseudo-variable that will be replaced with the file name during execution. Also, you are able not to add code_report=True option and name file as you wish, in this case result file won't be processed according to the rules defined for analysers and step will be marked as Failed if there are analysis issues found.

Note

When using Universum, if file with analysis results is not added to artifacts, it will be deleted along with other build sources and results.

When using via Universum code_report=True step, use --report-to-review functionality to comment on any found issues to code review system.

Pylint

Config example for universum_pylint:

from _universum.configuration_support import Variations

configs = Variations([dict(name="pylint", code_report=True, command=["universum_pylint",

"--python-version", "3", "--result-file", "${CODE_REPORT_FILE}", "--files", "*.py", "examples/"])

])

if __name__ == '__main__':

print configs.dump()

This file will get us the following list of configurations:

print "$ ./configs.py" print configs.dump()

$ ./configs.py [{'command': 'universum_pylint --python-version 3 --result-file ${CODE_REPORT_FILE} --files *.py examples/', 'name': 'pylint', 'code_report': True}]

Svace

Config example for universum_svace:

from _universum.configuration_support import Variations

configs = Variations([dict(name="svace", code_report=True, command=["universum_svace",

"--build-cmd", "make", "--lang", "CXX", "--result-file", "${CODE_REPORT_FILE}"])

])

if __name__ == '__main__':

print configs.dump()

will produce this list of configurations:

print "$ ./configs.py" print configs.dump()

$ ./configs.py [{'command': 'universum_svace --build-cmd make --lang CXX --result-file ${CODE_REPORT_FILE}', 'name': 'svace', 'code_report': True}]

Uncrustify

Config example for universum_uncrustify:

from _universum.configuration_support import Variations

configs = Variations([dict(name="uncrustify", code_report=True, command=["universum_uncrustify",

"--files", "project_root_directory", "--cfg-file", "file_name.cfg", "--filter-regex", ".*//.(?:c|cpp)", "--result-file", "${CODE_REPORT_FILE}", "--output-directory", "uncrustify"])

])

if __name__ == '__main__':

print configs.dump()

will produce this list of configurations:

print "$ ./configs.py" print configs.dump()

$ ./configs.py [{'command': 'universum_uncrustify --files project_root_directory --cfg-file file_name.cfg --filter-regex .*//.(?:c|cpp) --result-file ${CODE_REPORT_FILE} --output-directory uncrustify', 'name': 'uncrustify', 'code_report': True}]