Can't analysis for Java code with the sonarlint plugin (intellij) linked to sonarqube

I can’t analysis for Java code with the sonarlint plugin (intellij) linked to sonarqube.

  • versions used (SonarQube, Scanner, language analyzer)
  • Intellj :
    image

  • sonarlint : 4.12

  • SonarQube
    Version : 8.4.1.35646
    java.runtime.version : 11.0.6+10

  • sonarlint log

  • sonarlint report
    On SonarQube, various issues are checked in java code, but not visible in sonarlint.
    image

I tried lowering the runtime java version of Intellij to 1.8, but only Intellij became unstable.

Hello, welcome to the community!

There are a number of possible causes for this.

From the log extract, it seems that 59 Java source + 7 Java test files have been analyze - this eliminates any configuration that excludes them from analysis.

Now, if 66 analyzed files do not generate any issue, my main hypothesis is that types are not resolved correctly, e.g due do class path issues.

Could you please enable both “Analysis logs” and “Verbose output” in the SonarLint log tab and trigger a new analysis?

As an example here is what I get in connected mode on a package of SonarLint for IntelliJ itself - the part I am interested in is just below Starting analysis with configuration: - in the extraProperties member, the sonar.java.libraries property lists all detected class path entries.

Trigger: ACTION
[Action] 10 file(s) submitted
Configuring analysis with org.sonarlint.intellij.analysis.JavaAnalysisConfigurator
Using connection 'Next' for project 'org.sonarsource.sonarlint.intellij:sonarlint-intellij'
Analysing 10 files...
Starting analysis with configuration:
[
  projectKey: org.sonarsource.sonarlint.intellij:sonarlint-intellij
  baseDir: /opt/Dev/SonarSource/sonarlint-intellij
  extraProperties: {sonar.java.target=1.8, sonar.java.source=8, sonar.java.libraries=/opt/idea/idea-IU-201.6668.121/lib/istack-commons-runtime-3.0.7.jar,<... snip long list of JAR files ...>,/home/mith/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/19.0.0/efbff6752f67a7c9de3e4251c086a88e23591dfd/annotations-19.0.0.jar}
  inputFiles: [
    file:///opt/Dev/SonarSource/sonarlint-intellij/src/main/java/org/sonarlint/intellij/util/SonarLintUtils.java (UTF-8)
    file:///opt/Dev/SonarSource/sonarlint-intellij/src/main/java/org/sonarlint/intellij/util/ProjectLogOutput.java (UTF-8)
    file:///opt/Dev/SonarSource/sonarlint-intellij/src/main/java/org/sonarlint/intellij/util/GlobalLogOutput.java (UTF-8)
    file:///opt/Dev/SonarSource/sonarlint-intellij/src/main/java/org/sonarlint/intellij/util/SonarLintSeverity.java (UTF-8)
    file:///opt/Dev/SonarSource/sonarlint-intellij/src/main/java/org/sonarlint/intellij/util/CompoundIcon.java (UTF-8)
    file:///opt/Dev/SonarSource/sonarlint-intellij/src/main/java/org/sonarlint/intellij/util/SonarLintActions.java (UTF-8)
    file:///opt/Dev/SonarSource/sonarlint-intellij/src/main/java/org/sonarlint/intellij/util/package-info.java (UTF-8)
    file:///opt/Dev/SonarSource/sonarlint-intellij/src/main/java/org/sonarlint/intellij/util/GlobalLogOutputImpl.java (UTF-8)
    file:///opt/Dev/SonarSource/sonarlint-intellij/src/main/java/org/sonarlint/intellij/util/SonarLintAppUtils.java (UTF-8)
    file:///opt/Dev/SonarSource/sonarlint-intellij/src/main/java/org/sonarlint/intellij/util/TaskProgressMonitor.java (UTF-8)
  ]
]

Start analysis
Index files
Language of file 'file:///opt/Dev/SonarSource/sonarlint-intellij/src/main/java/org/sonarlint/intellij/util/SonarLintUtils.java' is detected to be 'Java'
Language of file 'file:///opt/Dev/SonarSource/sonarlint-intellij/src/main/java/org/sonarlint/intellij/util/ProjectLogOutput.java' is detected to be 'Java'
Language of file 'file:///opt/Dev/SonarSource/sonarlint-intellij/src/main/java/org/sonarlint/intellij/util/GlobalLogOutput.java' is detected to be 'Java'
Language of file 'file:///opt/Dev/SonarSource/sonarlint-intellij/src/main/java/org/sonarlint/intellij/util/SonarLintSeverity.java' is detected to be 'Java'
Language of file 'file:///opt/Dev/SonarSource/sonarlint-intellij/src/main/java/org/sonarlint/intellij/util/CompoundIcon.java' is detected to be 'Java'
Language of file 'file:///opt/Dev/SonarSource/sonarlint-intellij/src/main/java/org/sonarlint/intellij/util/SonarLintActions.java' is detected to be 'Java'
Language of file 'file:///opt/Dev/SonarSource/sonarlint-intellij/src/main/java/org/sonarlint/intellij/util/package-info.java' is detected to be 'Java'
Language of file 'file:///opt/Dev/SonarSource/sonarlint-intellij/src/main/java/org/sonarlint/intellij/util/GlobalLogOutputImpl.java' is detected to be 'Java'
Language of file 'file:///opt/Dev/SonarSource/sonarlint-intellij/src/main/java/org/sonarlint/intellij/util/SonarLintAppUtils.java' is detected to be 'Java'
Language of file 'file:///opt/Dev/SonarSource/sonarlint-intellij/src/main/java/org/sonarlint/intellij/util/TaskProgressMonitor.java' is detected to be 'Java'
10 files indexed
Available languages:
  * Python => "py"
  * Kotlin => "kotlin"
  * Ruby => "ruby"
  * Scala => "scala"
  * Java => "java"
  * HTML => "web"
  * JSP => "jsp"
  * XML => "xml"
  * PHP => "php"
  * Swift => "swift"
Quality profiles:
  * java: 'Default - SonarSource conventions' (465 rules)
  * jsp: 'Sonar way' (0 rules)
  * kotlin: 'Sonar way' (30 rules)
  * php: 'Sonar way' (123 rules)
  * py: 'Sonar way' (126 rules)
  * ruby: 'Sonar way' (29 rules)
  * scala: 'Sonar way' (28 rules)
  * swift: 'Sonar way' (61 rules)
  * web: 'Sonar way' (28 rules)
  * xml: 'Sonar way' (4 rules)
Execute Sensor: JavaSquidSensor
Configured Java source version (sonar.java.source): 8
JavaClasspath initialization
JavaClasspath initialization (done) | time=11ms
JavaTestClasspath initialization
JavaTestClasspath initialization (done) | time=8ms
Java Main Files AST scan
10 source files to be analyzed
[SE] Loaded 174 hardcoded method behaviors.
Initializing metadata of file file:///opt/Dev/SonarSource/sonarlint-intellij/src/main/java/org/sonarlint/intellij/util/SonarLintUtils.java
Initializing metadata of file file:///opt/Dev/SonarSource/sonarlint-intellij/src/main/java/org/sonarlint/intellij/util/CompoundIcon.java
Initializing metadata of file file:///opt/Dev/SonarSource/sonarlint-intellij/src/main/java/org/sonarlint/intellij/util/SonarLintActions.java
Initializing metadata of file file:///opt/Dev/SonarSource/sonarlint-intellij/src/main/java/org/sonarlint/intellij/util/GlobalLogOutputImpl.java
Java Main Files AST scan (done) | time=1757ms
10/10 source files have been analyzed
Java Test Files AST scan
0 source files to be analyzed
Java Test Files AST scan (done) | time=1ms
Java Generated Files AST scan
0 source files to be analyzed
Java Generated Files AST scan (done) | time=0ms
0/0 source files have been analyzed
0/0 source files have been analyzed
'Python Sensor' skipped because there is no related file in current project
'Kotlin Sensor' skipped because there is no related file in current project
'Ruby Sensor' skipped because there is no related file in current project
'Scala Sensor' skipped because there is no related file in current project
Execute Sensor: JavaXmlSensor
Execute Sensor: HTML
'XML Sensor' skipped because there is no related file in current project
'PHP sensor' skipped because there is no related file in current project
'Analyzer for "php.ini" files' skipped because there is no related file in current project
'SonarTS' skipped because there is no related file in current project
'SonarSwift' skipped because there is no related file in current project
Done in 1820ms

Processed 13 issues in 7 ms
Found 13 issues

Thank you for your answer.

I send the log file.
sonarlint_log.txt (103.3 KB)

And using “SonarQube Community” plugin, it was analyzed normally. (use inspection menu)

What is the problem?

I can’t say anything about the “SonarQube Community” plugin - it’s a community effort, not affiliated with SonarSource or SonarLint. I would not advise to use it concurrently with SonarLint, as they could interfere with each other.

I did not notice anything weird in your log file, it does seem to process your whole source directory and dependencies.

This could be an issue with the “report mode” that you used (right click > “SonarLint” > “Analyze with SonarLint”).

What happens if instead you open a Java file for which the server reports issues?

If everything is OK, you should see the same issues as reported by the server in the “Current file” tab of the “SonarLint” tool window.

Still can’t solve it.

Sonarlint (in intellj)

Current file Tab : No issues found in the current opened file
Report Tab : No issues found
image

SonarQube Server

Some Issues for “Application.java” are being reported in SonarQube Server.

Thank you for the SonarQube screenshot.

It looks to me that those issues are reported by the Findbugs plugin for SonarQube, which won’t be executed by SonarLint even in connected mode - SonarLint only executes analyzers from SonarSource and custom rule plugins based on those.

To confirm this, would it be possible that you share the activated rules from the Widerplanet Java Basic Profile quality profile? If you only have Findbugs rules enabled, that can explain why SonarLint does not report anything.

this is our basic java profjie. (xml)
widerplanetJavaBasicProfile.txt (67.8 KB)

Thank you for the file. I confirm that your quality profile only uses rules from Checkstyle, PMD and Findbugs + fb-contrib - and SonarLint won’t run those, since they depend on external tools.

At this point, if you want the same issues in the IDE than on the server, you can either replace this quality profile with the (arguably more precise and robust) matching ones from SonarQube’s Java analyzer, or use IntelliJ’s integration with each of these tools.

1 Like

Thank you so much.
I applied a new quality profile base on original sonarway. (at sonarqube server)
It’s works!
I can see the same analysis results on both SonarQube server and Sonarlint plugin (intellij).

However, the fact that various plugins are not available other than Sonaway seems to need improvement.
Thanks~

1 Like

Great, thanks for the heads up! I’m glad that you found a setup that works for you and your team.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.