Skip to content
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

no files found from JSON Compilation Database on linux if project contains upper case file names #2691

Conversation

kragens
Copy link

@kragens kragens commented Jun 7, 2024

convert files in JSON Compilation Database to lower case because unifyPath() converted file names to lower case


This change is Reviewable

… case on linux

convert files in JSON Compilation Database to lower case because unifyPath() converted file names to lower case
@kragens kragens changed the title files found from JSON Compilation Database empty on linux if project contains upper case file names no files found from JSON Compilation Database on linux if project contains upper case file names Jun 7, 2024
@guwirth guwirth added the bug label Jul 4, 2024
@guwirth
Copy link
Collaborator

guwirth commented Jul 4, 2024

Hi @kragens,

thanks for providing this. This issues seems to be related to #2700?

Not sure if your fix works on all operating systems. Reading here https://github.com/SonarOpenCommunity/sonar-cxx/wiki/Troubleshooting-Reports#file-path-issues there are also case-sensitive operating systems where making all lower-case is not working?

Depending on the operating system and SonarQube Database settings paths can be case-sensitive (also on case-insensitive operating systems). Report sensors always try to restore the case-senitive path to avoid problems.

Have to check this.

Regards,

@guwirth guwirth self-requested a review July 4, 2024 06:26
@@ -400,7 +401,7 @@ private Iterable<InputFile> getInputFiles(SensorContext context, CxxSquidConfigu
// then analyze only the files contained in the db.
var inputFilesInConfig = squidConfig.getFiles();
var result = StreamSupport.stream(inputFiles.spliterator(), false)
.filter(f -> inputFilesInConfig.contains(Path.of(f.uri())))
.filter(f -> inputFilesInConfig.contains(Paths.get((Path.of(f.uri()).toString()).toLowerCase(Locale.getDefault()))))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depending on the operating system and SonarQube Database settings paths can be case-sensitive (also on case-insensitive operating systems). Think making it always lowercase does not work?

@guwirth
Copy link
Collaborator

guwirth commented Jul 8, 2024

Below the solution from the report sensors:

public InputFile getInputFileIfInProject(String path) {

private InputFile getInputFileTryRealPath(String path) {

@kragens
Copy link
Author

kragens commented Jul 11, 2024

thanks for providing this. This issues seems to be related to #2700?
I don't think so, because all files in compile_commands.json are lowercase in #2700

The problem here is that alle files in inputFilesInConfig were made lowercase by

return result.toLowerCase(Locale.getDefault());

@guwirth
Copy link
Collaborator

guwirth commented Jul 13, 2024

Hello @kragens, thx for the hint will have a look to it and try to find out why all is converted to lowercase …

guwirth added a commit to guwirth/sonar-cxx that referenced this pull request Aug 23, 2024
- the notation of paths in the db can deviate from the notation in the file system.
- restoring the spelling of paths from the file system
- close SonarOpenCommunity#2691
@guwirth guwirth closed this in 20c54bf Aug 27, 2024
@guwirth
Copy link
Collaborator

guwirth commented Aug 27, 2024

solved with #2725

@guwirth
Copy link
Collaborator

guwirth commented Aug 27, 2024

@kragens
Copy link
Author

kragens commented Mar 10, 2025

Tested successfully in release v2.2.0. thanks for fixing it @guwirth

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

2 participants