Thank you very much for developing this Sonarlint upgrade. This is very useful to me.
I encountered an error while my Project Structure and Module files (.iml and more) are stored outside of the project code.
Example:
Intellij files -> C:/IdeaProjectName/
Source code (with .git) -> C:/ProjectName/
I struggled a bit to find out what was going wrong and found a fix :
in org.sonarlint.intellij.config.project.SonarLintProjectSettings.java
I changed :
return Optional.ofNullable(m.getModuleFile())
.orElseGet(() -> Arrays.stream(ModuleRootManager.getInstance(m).getContentRoots()).findFirst().orElse(null));
to :
return Optional.ofNullable(Arrays.stream(ModuleRootManager.getInstance(m).getContentRoots()).findFirst().orElse(null))
.orElseGet(() -> m.getModuleFile());
Because ProjectLevelVcsManager.getInstance(project).getVcsRootFor(virtualFile) will return null if virtualFile is the .iml file, when the content root will target the folder which is linked to VCS.
Hi !
Thank you very much for developing this Sonarlint upgrade. This is very useful to me.
I encountered an error while my Project Structure and Module files (.iml and more) are stored outside of the project code. Example: Intellij files -> C:/IdeaProjectName/ Source code (with .git) -> C:/ProjectName/
I struggled a bit to find out what was going wrong and found a fix :
in org.sonarlint.intellij.config.project.SonarLintProjectSettings.java
I changed : return Optional.ofNullable(m.getModuleFile()) .orElseGet(() -> Arrays.stream(ModuleRootManager.getInstance(m).getContentRoots()).findFirst().orElse(null)); to : return Optional.ofNullable(Arrays.stream(ModuleRootManager.getInstance(m).getContentRoots()).findFirst().orElse(null)) .orElseGet(() -> m.getModuleFile());
Because ProjectLevelVcsManager.getInstance(project).getVcsRootFor(virtualFile) will return null if virtualFile is the .iml file, when the content root will target the folder which is linked to VCS.