Open gennartan opened 1 month ago
Hi @gennartan,
thanks for your question.
First of all the documentation for the current functionality:
But I think you saw already the sonar.projectBaseDir
option.
About your feature request:
It is relatively common to generate the report with external tools and possibly with different paths on other computers. So far, most customers patch the reports via scripts and replace the paths or parts of them. This is an extra step as part of the creation of the reports before they forward it to the SQ scanner.
We have already thought about it to support this as part of the plugin, but have not yet found a generic solution (or people told us, some line of Python are the easier solution). You have already described with baseDir
that it can be quite complex and difficult in detail.
What is your opinion on this?
Regards,
Hi @gennartan,
a possible solution with XLST could be with fn:replace
:
Never tried it, but maybe you can have a look …
Regards,
Hello, Thank you for your answer.
To me, the fact that most customers are using a script to convert the path is a proof that this feature would be welcome to this plugin. As you said, a generic solution should be found, otherwise it wouldn't make sense.
I haven't really undertood the part about XLST. So, it is a plugin that allows to replace fields in XML file following specific rules ? And this plugin can be run as a pre-job of the sonarqube analysis to replace all the "wrong" paths in the reports ? If yes, this could mean that we should only complete the documentation to explain it.
Regards,
Hello @gennartan,
I haven't really understood the part about XLST
XSLT (Extensible Stylesheet Language Transformations) is a language originally designed for transforming XML documents into other XML documents => https://en.wikipedia.org/wiki/XSLT. One possible transformation is Replace
: https://www.educba.com/xslt-replace/
And this plugin can be run as a pre-job of the sonarqube analysis
Yes sonar.cxx.xslt
is a pre-job, see https://github.com/SonarOpenCommunity/sonar-cxx/wiki/sonar.cxx.xslt
Regards,
Is your feature request related to a problem? Please describe.
My project is built with the command
make -C <subdir> ...
. When I run thescan-build
command for external analyser with clang, it reports all the paths the in the plist file relative to the<subdir>
. Then, when running the sonar scanner, it correctly parses the plist files, but is unable to find the files with reported errors. (*)(*) The error shows "file
/usr/src/lib/mylib.h
not found" while the file is located at/usr/src/<subdir>/lib/mylib.h
Describe the solution you'd like
Add a parameter
sonar.cxx.clangsa.baseDir
to specify the base directory of the clang analysis. The ideal solution is probably not as simple as this, since it should be possible to add multiplereportPaths
, it should also be possible to add multiplebaseDir
in case the current project is composed of multiple subdirectory to be analysed / build separately. And in this case, eachbaseDir
should be linked to areportPaths
in some way.Describe alternatives you've considered
Currently, I changed the
sonar.projectBaseDir
variable to match the base directory of the clang reports. But it is just a workaround as some of the files from my project root directory have now been excluded from the analysis.