SonarLint in IntelliJ showing "False Positive" and "Won't Fix" Issues

Hi

I’m using SonarLint in IntelliJ, binding to my remote SonarQube server.

  • IntelliJ 2019.1.1 Ultimate Edition; JVM: OpenJDK 64-bit Server VM by AdoptOpenJDK
  • SonarLint v4.0.2.3009

SonarLint shows issues marked as False Positive and Won't Fix on the server. We have seen this for both java and javascript. As you can see, those issues are noises to developers. Is there a way to not show them?

Thanks
Huan

Forgot to mention, the SonarQube version is 7.7.0.23042

An update.

We use sbt sub modules for our java project. Let’s say

  • parent-module

  • sub-module-1

  • sub-module-2

Behavior

  • On SonarQube server, we have one project parent-module. SonarLint in IntelliJ points to it.

  • Opening parent-module in IntelliJ, SonarLint does not displayed False Positive or Won't Fix issues. Good.

  • Opening sub-module-1 in IntelliJ, SonarLint does displayed False Positive or Won't Fix issues. Not so good.

We used to use SonarQube’s sub-project support to map our sub module layout, i.e. multiple sonar-project.properties files. We have combined them into one since SonarQube 7.6 deprecated sub-project.

I suspect SonarLint in sub-module-1 might have got the issue mapping wrong due to files on SonarQube server are relative to parent-module while in the IDE is relative to sub-module-1.

Hi,

If you open the ‘Project Structure’, go to ‘Modules’ and switch to the ‘SonarLint’ tab, you can find what is the prefixes used for the matching between local files and files in SonarQube for that module.

Thanks Duarte. I found the settings you listed. Both IDE path prefix: and SonarQube path prefix: are empty and read-only. How can do I configure them?

Hi,

I think there is an issue with the prefix computation. I was able to reproduce and we will investigate.
Here is the ticket:
https://jira.sonarsource.com/browse/SLI-330

Thanks Julien.

Hi @Huan_Ruan

I had some time to investigate, and I was not able to reproduce your issue. I tried using a sample sbt multi project, opening either the root project, or only a subproject, but each time it works fine.

When opening the sub project, ensure you rebind it, so that path prefix computation is correctly done.

If you still have the issue, maybe you could try to create a small reproducer that you could share with us.

Thanks

Hi @Julien_HENRY

This is still happening in my project. I will try and get a minimal reproducible case for you.

Huan

Hi @Julien_HENRY

Sorry for the delayed response.

I can see SonarQube path prefix: properly set up now, probably due to me running a full git clean -fdx to clean up all IntelliJ’s state and then updating the Sonar binding.

With sample code found in https://drive.google.com/drive/folders/1BTGPWK9yhMqULpMAnazDi1YPVDi6SMLm?usp=sharing (upload here doesn’t allow code), I have

  • sonar-parent-project depends on sub-module sonar-common-submodule and sonar-submodule-project.
  • sonar-submodule-project depends on sonar-common-submodule.
  • Two Sonar issues(TODO comment), both marked as Won't Fix in the Sonar server.
    • Issue 1 from a file in sonar-common-submodule.
    • Issue 2 from a file in sonar-submodule-project.
  • In IntelliJ
    • Opening sonar-parent-project, Issue 1 and Issue 2 are both invisible, good.
    • Opening sonar-submodule-project
      • Issue 2 is invisible, good.
      • Issue 1 is visible. Question This might be as designed since, from Sonar project’s standpoint, Issue 1 originates from a file living in a sibling sub-module, but can you please confirm that is the intention?

Thanks
Huan