Option to generate cppcheck reports as xml file
osechet opened this issue · 2 comments
It would be nice to have an option to generate ccpcheck reports as an xml file. When calling cppcheck, using the --xml --output-file=<output_file>
arguments forces cppcheck to output its report to the given file.
My version of cppcheck (1.82 on Ubuntu 18.04) does not document the --output-file
parameter. However, the parameter is usable and your suggestion is reasonable.
What I would want to discuss are actual implementation details.
(1) You suggest to add a cmake option. I wonder if such option would toggle the xml-output for all health checks or just for cppcheck. More specifically, would such an option be called OPTION_XML_REPORTS
or OPTION_CPPCHECK_XML_REPORTS
.
(2) Alternative approaches are the ability to extend the command-line arguments passed to cppcheck at a more visible location in the setup.
Example:
set(CPPCHECK_FLAGS "--enable=all --verbose --suppress=missingIncludeSystem
--xml --output-file="\\${CMAKE_CURRENT_BINARY_DIR}/cppcheck-\\${target}.xml")
(3) What I currently test is the addition of more cmake targets where their names encode the output to xml.
An example of the current health check targets:
- check-all
- check-baselib
- check-fiblib
- cppcheck-baselib
- cppcheck-fiblib
- clang-tidy-baselib
- clang-tidy-fiblib
I'm thinking of adding these additional cmake targets:
- check-all-xml
- check-baselib-xml
- check-fiblib-xml
- cppcheck-baselib-xml
- cppcheck-fiblib-xml
- clang-tidy-baselib-xml
- clang-tidy-fiblib-xml
The 3 solutions seem interesting. My personal need is only about cppcheck so a OPTION_CPPCHECK_XML_REPORTS
would be good. However I agree it would be better to have a more general mechanism.
For that reason, the OPTION_XML_REPORTS
could be interesting but what happens if a future health tool cannot generate an XML report?
I don't really like the 2nd suggestion. It forces people to know the arguments. It isn't very flexible neither. When manually building the project, I may want to get normal cppcheck reports and only generate the XML reports when running CI/CD.
I like the 3rd option but I'm afraid it would make the project more and more complex if new health tools are added in the future.