-
Notifications
You must be signed in to change notification settings - Fork 363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve handling of relative file paths in report files #2747
Conversation
403cb38
to
0ccc7bb
Compare
The problem still exists when the file starts with ../../ (which I have seen). |
Hello @cmorve-te, thanks for your test. Can you provide a report file to reproduce the issue. With the unit tests it works? Like to understand what’s different. Regards, |
I guess anything starting with ../../ will fail. Which makes sense, it gets converted to ./../XXX, which is equivalent to ../XXX, which was the original problem.
fails with
Honestly, not even sure what I would write in the assertion. |
Hi @cmorve-te, you are right, I was not testing with relative path with more than one level like
This can also fail: In case In the meantime I tend to simply add the file name in case What do you think? |
Indeed.
That would work for me, but can you just add the filename? In general, that's something I would like from Sonar. Instead of hoping the warnings don't point to an (existing) file that's not in So your "simply add the file name" is probably the best option. If not possible, I guess I would just fallback to just drop any warnings that resolve to a null file in the same way they are dropped if the resolve to a valid file not in |
- Up to know we were stating in our [Wiki](https://github.com/SonarOpenCommunity/sonar-cxx/wiki/Troubleshooting-Reports): Relative paths in report files are always relative to the project base directory. Start relative paths always with .\ on Windows or ./ on Linux. - relative paths starting with '..' were resolved to null in the past. "No file" results in adding an issue on project level (project issue). In such a case we replace null with the filename. This leads at least to an error message an that and the issue is not added to the project because typically no such indexed file exists. - The real problem is that tools generate reports with relative paths without defining which base directory is referred to. This problem remains and must be solved via the CI/CD and tool configuration. - close SonarOpenCommunity#2741
Oh, you meant only the file, without any path, and only inside the CxxReportLocation constructor! |
…o if report is generated on the one and consumed on the other
@cmorve-te maybe you can give this a try: https://github.com/SonarOpenCommunity/sonar-cxx/actions/runs/10972510569/artifacts/1961586003 In case result is null try with filename only. This should avoid project issue generation and should give you a warning in the LOG file. |
Hi @cmorve-te, like to release V2.1.3 and add this one. Any feedback? |
Verified with my real output, it's all fine now. Again, unless the file name happens to match the name of a real file in the root of the project, I guess. My project doesn't have source files in the root of the project at all. |
@cmorve-te thanks for testing I know this is not a perfect solution but an improvement. |
This change is