Closed olsson-s closed 4 years ago
Hi @olsson-s,
Please read:
gcc reports filenames in diagnostics in the same form they are specified on the command line, so if you specify them as full pathnames in the command you'll get them that way in the diagnostics.
Hope that helps.
Regards,
Thanks @guwirth.
OK, I had read those documents before, but some of it sinks in more as I read it again. I think I've done the Compiler part correctly. The path separator is the problem. I guess in my C++ makefile, I could find a way to force the full path of the filename being compiled somehow. The gcc will then use this full path name instead of relative to the directory where the warnings were found (e.g. my build_component.log file).
As another option, for example, if I add all my source directories to sonar.sources= directive, would that help my situation? Right now I use:
sonar.sources=.
I've already added all the sonar.cxx.includeDirectories set to a full list of my include locations so maybe I just need to do the same for sources?
Or that wouldn't help? Somehow forcing gcc to provide a full path or path relative to ProjectDir is the only way?
-Sten
Hi @olsson-s,
SQ read reports always in two steps:
In case of absolute paths, the paths must exactly match.
In case of relative paths in the report the path is made absolute relative to the root folder.
Root folder is where sonar-project.properties
is or https://docs.sonarqube.org/latest/analysis/scan/sonarscanner/.
Other settings are only to narrow the focus: https://docs.sonarqube.org/latest/project-administration/narrowing-the-focus/
After the sensor made the path absolute the path must match with the indexed path.
Regards,
Thank you, @guwirth. I think the issue must be closed then. It seems like there will be no easy way to import the filenames. I'm building 350 components with thousands of source files and I was hoping there would be a way to configure the tool instead of changing how the builds are done. I understand this is a difference in my config though and others that build with absolute filenames or filenames relative to the root folder don't have this problem.
I have an idea how to fix it. After I build all the software, I can run perl or python script on all my build_component.log(s) and swap the file name for it's absolute location.
Thanks again for your help. Please close this issue. -Sten
Looks like I can close it :)
Hi @olsson-s,
I’m not familiar with gcc and cmake but I’m quite sure there is a solution. Please ask in a cmake forum how to setup cmake to get absolute paths or path relative to root.
Regards,
I'm not sure if this is a sonar-cxx issue or a general sonar issue. The problem occurs when using the sonar.cxx directives.
The debug info in the log file could help to solve or locate the issue.
Description
When I try to import GCC compiler warnings, I get the following error for every C++ file with warnings that is in my build:
I believe the problem is that although sonar finds the log file in /skyline/workspace/SP7_Pipeline_Inspection_Branch_Tester/adapt_classes/rdp_classes/src/build_component.log, it does not check that same directory or its DB for the source file associated with the warning. In the case above, _message_brokerproduct.cpp is in _/skyline/workspace/SP7_Pipeline_Inspection_Branch_Tester/adapt_classes/rdpclasses/src/, but the plugin doesn't look there for it, or check the sonar-scanner DB for the source file with that name.
It looks like sonar requires absolute path names in the warnings, but from what I found, GCC can't provide absolute paths. Maybe there is some way to workaround this in sonar-cxx?
Steps to reproduce the problem
Expected behavior
Based on the sonar-project.properties, I hoped that sonar gcc compiler warnings parser would be able to find my cpp files and provide these warnings in Sonarqube website.
Actual behavior
Sonar GCC compiler warnings parser does not find the cpp files
Known workarounds
None that I know of, but since it appears to be a path issue, I guess I could copy also source files to the base of the project, but I don't think that will help me in the end.
LOG file
I listed the warnings above and attached DEBUG below. Here is my full sonar-project.properties file and my command line arguments for sonar-scanner which adds several other properties via command-line.
Command Line arguments:
Related information