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

Pylint analyzer

usage: universum_pylint [-h] [--files FILE_LIST [FILE_LIST ...]]
                        [--rcfile RCFILE] [--python-version {2,3}]
                        [--result-file RESULT_FILE]

Named Arguments

--files
 Python files and Python packages for Pylint.
--rcfile
 Specify a configuration file.
--python-version
 

Possible choices: 2, 3

Version of Python

Default: “3”

--result-file
 File for storing json results of Universum run. Set it to “${CODE_REPORT_FILE}” for running from Universum, variable will be handled during run. If you run this script separately from Universum, just name the result file or leave it empty.

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:

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

Svace

Svace analyzer

usage: universum_svace [-h] [--build-cmd BUILD_CMD [BUILD_CMD ...]]
                       [--lang {JAVA,CXX}] [--project-name PROJECT_NAME]
                       [--result-file RESULT_FILE]

Named Arguments

--build-cmd
 Relative path to build script or command itself
--lang
 

Possible choices: JAVA, CXX

Language to analyze

--project-name
 Svace project name defined on server
--result-file
 File for storing json results of Universum run. Set it to “${CODE_REPORT_FILE}” for running from Universum, variable will be handled during run. If you run this script separately from Universum, just name the result file or leave it empty.

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:

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

Uncrustify

Uncrustify analyzer

usage: universum_uncrustify [-h] [--files [FILE_NAMES [FILE_NAMES ...]]]
                            [--file-list [FILE_LISTS [FILE_LISTS ...]]]
                            [--cfg-file CFG_FILE]
                            [--filter-regex [PATTERN_FORM [PATTERN_FORM ...]]]
                            [--output-directory OUTPUT_DIRECTORY]
                            [--result-file RESULT_FILE]

Named Arguments

--files, -f
 File or directory to check; accepts multiple values; all files specified by both ‘–files’ and ‘–file-list’ are gathered into one combined list of files
--file-list, -fl
 Text file with list of files or directories to check; can be used with ‘–files’; accepts multiple values; all files specified by both ‘–files’ and ‘–file-list’ are gathered into one combined list of files
--cfg-file, -cf
 Name of the configuration file of Uncrustify; can also be set via ‘UNCRUSTIFY_CONFIG’ env. variable
--filter-regex, -r
 (optional) Python 2.7 regular expression filter to apply to combined list of files to check
--output-directory, -od
 Directory to store fixed files, generated by Uncrustify and HTML files with diff; the default value is ‘uncrustify’
--result-file
 File for storing json results of Universum run. Set it to “${CODE_REPORT_FILE}” for running from Universum, variable will be handled during run. If you run this script separately from Universum, just name the result file or leave it empty.

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:

$ ./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}]