-
Notifications
You must be signed in to change notification settings - Fork 20
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
New Issues could not be mapped to files under review #37
Comments
Filename mapping is required as Gerrit and Sonar do not refer to the file the same way. |
I got this issue when the source code file is under a directory structure which contains a folder named "src" in this case all the structure before "src" folder is removed at the gerrit plugin side and used as the key, while the value still contains the full path. So when the plugin cross entries from sonarqube project and from gerrit patchset it fails because the path from sonarqube is bigger and the one retrieved from gerrit is altered due to the following: fileName.replaceFirst(MAVEN_ENTRY_REGEX, "src/") I'm not using git submodules or sonar branches. I'm checking if i can workaround this problem by changing the sonarqube project configuration. |
Hi Mildis, |
The regex was meant to match the name of the file being analyzed and the one returned bu Gerrit. |
I can't push anything reliable at this time. we will investigate more how it could be done without impact while supporting most of projects structures. Thank you a lot for your great plugin :) |
I’m trying to figure out how to solve this programmatically without adding too much overhead in the file-matching algorithm. |
sorry for delay, I'm using a snapshot of your plugin ( https://github.com/tech-advantage/sonar-gerrit-plugin/tree/840201d5fd5c38008d329862a749984b914a327b ) and sonarqube 5.2 By the way I have seen your recent commit, i will give them a try. |
I would add some informations. If you have this project: If you analyze the project from /, each file will contain the project folder (P1, P2, ..) : P1/src/... And the matching will not be done. Could you check if the analyzes are started from the same folder ? |
@greg7859 most of the time its started from the same folder. Quite recently we also run into other issues with this plugin on some C# projects, because there the sonarqube client for C# projects do more or less like the maven plugin (breaking down the application solution into modules) then whatever the location from which the analysis is executed the path of the file known and stored inside sonarqube will be always shorter than the path seen in Gerrit. Then it makes the mapping failing. In addition to that with those C# projects we don't have like under maven regular structure a "src/" folder to help the parsing and then the mapping. As we were running into a lot of issues on various type of projects, we added two additional ways of doing mapping into getFileNameFromInputPath.
|
I find out a case where new issues are identified by SonarQube but where the sonar-gerrit-plugin fails to map them to files under review.
this is when in the file path there is a "src" folder. The sonar-gerrit-plugin apparently use a shortened key for those files due to the following block of code:
protected String parseFileName(@NotNull String fileName) { return fileName.replaceFirst(MAVEN_ENTRY_REGEX, "src/"); }
If gerrit returns something like this:
{"/COMMIT_MSG":{"status":"A","lines_inserted":9},"a/b/c/src/x/y/z/a.source.file":{"lines_inserted":5}}
then it will keep in memory the following:
11:17:55.564 DEBUG - [GERRIT PLUGIN] Modified files in gerrit (keys) : [src/x/y/z/a.source.file] 11:17:55.564 DEBUG - [GERRIT PLUGIN] Modified files in gerrit (values): [a/b/c/src/x/y/z/a.source.file]
Which means that when later the plugin will check if a/b/c/src/x/y/z/a.source.file is under review it will not find it and will not post any comments:
11:17:55.615 DEBUG - [GERRIT PLUGIN] Decorate: a/b/c/src/x/y/z/a.source.file 11:17:55.615 DEBUG - [GERRIT PLUGIN] Start Sonar decoration for Gerrit 11:17:55.615 DEBUG - [GERRIT PLUGIN] Look for in Gerrit if the file was under review, name=a/b/c/src/x/y/z/a.source.file 11:17:55.615 DEBUG - [GERRIT PLUGIN] File a/b/c/src/x/y/z/a.source.file is not under review
Then is this parseFileName function really needed? is there cases when it should be done?
The text was updated successfully, but these errors were encountered: