The following analysing modules (analysers) are currently added to Universum:
Analysers are separate scripts, fully compatible with Universum. It is possible to use them as independent Python modules.
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.
Running analysers from Universum config, 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, without code_report=True
and result file may be called any name, as it won't be processed according to the rules defined for analysers. Such step will be marked as Failed
if any analysis issues are found.
Do note that you can also directly submit results generated by static analyzers, which are not supported by the Universum. Provided data shall be parsed and found issues shall be processed and reported, given that file conforms to the following pylint-like json schema:
"issues": {
"type": "array",
"items": {
"type": "object",
"required": [ "path", "line", "message", "symbol" ],
"properties": {
"path": { "type": "string" },
"line": { "type": "number" },
"message": { "type": "string" },
"symbol": { "type": "string" }
}
}
}
Alternatively, report file can conform to SARIF schema: https://docs.oasis-open.org/sarif/sarif/v2.0/sarif-v2.0.html To provide such report directly, you need to place/copy the pre-formatted file in "${CODE_REPORT_FILE}"
location.
from universum.configuration_support import Configuration, Step
- configs = Configuration([Step(name="Direct report", code_report=True, report_artifacts='${CODE_REPORT_FILE}',
command=f"cp /my_path/my_report.json ${{CODE_REPORT_FILE}}")])
Note
When using Universum, if a 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.
Config example for universum.analyzers.pylint
:
from universum.configuration_support import Configuration, Step
- configs = Configuration([Step(name="pylint", code_report=True, command=[
"{python}", "-m", "universum.analyzers.pylint", "--python-version", "2.7", "--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("$ ./.universum.py") print(configs.dump())
$ ./.universum.py [{'name': 'pylint', 'code_report': True, 'command': '{python} -m universum.analyzers.pylint --python-version 2.7 --result-file ${CODE_REPORT_FILE} --files *.py examples/'}]
Config example for universum.analyzers.mypy
:
from universum.configuration_support import Configuration, Step
- configs = Configuration([Step(name="mypy", code_report=True, command=[
"{python}", "-m", "universum.analyzers.mypy", "--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("$ ./.universum.py") print(configs.dump())
$ ./.universum.py [{'name': 'mypy', 'code_report': True, 'command': '{python} -m universum.analyzers.mypy --python-version 3 --result-file ${CODE_REPORT_FILE} --files *.py examples/'}]
Config example for universum.analyzers.uncrustify
:
from universum.configuration_support import Configuration, Step
- configs = Configuration([Step(name="uncrustify", code_report=True, command=[
"{python}", "-m", "universum.analyzers.uncrustify", "--files", "/home/user/workspace/temp/*.c", "--cfg-file", "file_name.cfg", "--result-file", "${CODE_REPORT_FILE}", "--output-directory", "uncrustify"
])])
- if __name__ == '__main__':
print(configs.dump())
will produce this list of configurations:
print("$ ./.universum.py") print(configs.dump())
$ ./.universum.py [{'name': 'uncrustify', 'code_report': True, 'command': '{python} -m universum.analyzers.uncrustify --files /home/user/workspace/temp/*.c --cfg-file file_name.cfg --result-file ${CODE_REPORT_FILE} --output-directory uncrustify'}]
Config example for universum.analyzers.clang_format
:
from universum.configuration_support import Configuration, Step
- configs = Configuration([Step(name="clang-format", code_report=True, command=[
"{python}", "-m", "universum.analyzers.clang-format", "--files", "/home/user/workspace/temp/*.c", "--result-file", "${CODE_REPORT_FILE}", "--output-directory", "clang-format", "-e", "clang-format-15",
])])
- if __name__ == '__main__':
print(configs.dump())
will produce this list of configurations:
print("$ ./.universum.py") print(configs.dump())
$ ./.universum.py [{'name': 'clang-format', 'code_report': True, 'command': '{python} -m universum.analyzers.clang-format --files /home/user/workspace/temp/*.c --result-file ${CODE_REPORT_FILE} --output-directory clang-format -e clang-format-15'}]