Intellij Plugin not working when bound to SonarQube

Hi, I am using the IntelliJ SonarLint Plugin.
IntelliJ IDEA 2019.3 (Ultimate Edition)
SonarLint 4.3.0.3495

When connected to our SonarQube SonarLint never finds any issues.
When I remove the binding the default rules apply and corresponding errors are shown.

I made a test class:

import java.util.List;

public class SonarTest {

    private List<String> list;

    public int test(String str) {
        int x = -5;
        return x;
    }

    public List<String> getList() {
        return list;
    }
}

The IntelliJ logs do not show any errors or exceptions and neither does the plugin log.
The following log shows these steps:

  1. lint using the default rules
  2. update the server binding in the settings
  3. lint again
Analysing 'SonarTest.java'...
Found 2 issues
Downloaded settings in 72ms
Project '********:master' in server binding '****' updated
Clearing all issues because binding was updated
Using configuration of '********:master' in server '****'
Analysing 'SonarTest.java'...
Found 0 issues

Our server reports 4 errors for this file

  • squid:UndocumentedApi for the class
  • squid:UndocumentedApi for the method
  • squid:S1488 for the unneccessary local variable
  • squid:S2384 for not returning a (shallow readonly) copy from the getter

The rules are downloaded correctly from our server. At least they show up correctly in the Rules tab in the SonarLint general settings.

I found a similar issue (SonarLint ignores non-default quality profile on SonarQube server) but nieting the apparently fixed version nor the version before as suggested in the issue is working.

EDIT:

I found out that you can toggle verbose logging.
Here is the output:

-----
Java Main Files AST scan
1 source files to be analyzed
Unable to create symbol table for : ...\SonarTest.java
java.lang.IllegalArgumentException
	at org.objectweb.asm.ClassReader.<init>(ClassReader.java:160)
	at org.objectweb.asm.ClassReader.<init>(ClassReader.java:143)
	at org.sonar.java.resolve.BytecodeCompleter.loadClass(BytecodeCompleter.java:204)
	at org.sonar.java.resolve.Symbols.<init>(Symbols.java:176)
	at org.sonar.java.resolve.SemanticModel.createFor(SemanticModel.java:59)
	at org.sonar.java.model.VisitorsBridge.visitFile(VisitorsBridge.java:110)
	at org.sonar.java.ast.JavaAstScanner.simpleScan(JavaAstScanner.java:96)
	at org.sonar.java.ast.JavaAstScanner.scan(JavaAstScanner.java:68)
	at org.sonar.java.JavaSquid.scanSources(JavaSquid.java:120)
	at org.sonar.java.JavaSquid.scan(JavaSquid.java:114)
	at org.sonar.plugins.java.JavaSquidSensor.execute(JavaSquidSensor.java:91)
	at org.sonarsource.sonarlint.core.analyzer.sensor.SensorsExecutor.executeSensor(SensorsExecutor.java:81)
	at org.sonarsource.sonarlint.core.analyzer.sensor.SensorsExecutor.execute(SensorsExecutor.java:72)
	at org.sonarsource.sonarlint.core.container.analysis.AnalysisContainer.doAfterStart(AnalysisContainer.java:134)
	at org.sonarsource.sonarlint.core.container.ComponentContainer.startComponents(ComponentContainer.java:125)
	at org.sonarsource.sonarlint.core.container.ComponentContainer.execute(ComponentContainer.java:110)
	at org.sonarsource.sonarlint.core.container.storage.StorageAnalyzer.analyze(StorageAnalyzer.java:75)
	at org.sonarsource.sonarlint.core.container.storage.StorageContainerHandler.analyze(StorageContainerHandler.java:81)
	at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.lambda$analyze$0(ConnectedSonarLintEngineImpl.java:152)
	at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.withReadLock(ConnectedSonarLintEngineImpl.java:344)
	at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.withReadLock(ConnectedSonarLintEngineImpl.java:334)
	at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.analyze(ConnectedSonarLintEngineImpl.java:149)
	at org.sonarlint.intellij.core.ConnectedSonarLintFacade.analyze(ConnectedSonarLintFacade.java:74)
	at org.sonarlint.intellij.core.SonarLintFacade.startAnalysis(SonarLintFacade.java:63)
	at org.sonarlint.intellij.analysis.SonarLintAnalyzer.analyzeModule(SonarLintAnalyzer.java:97)
	at org.sonarlint.intellij.analysis.SonarLintTask.analyze(SonarLintTask.java:181)
	at org.sonarlint.intellij.analysis.SonarLintTask.run(SonarLintTask.java:105)
	at org.sonarlint.intellij.analysis.SonarLintUserTask.run(SonarLintUserTask.java:40)
	at org.sonarlint.intellij.analysis.SonarLintJobManager.lambda$runTask$1(SonarLintJobManager.java:120)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:163)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:585)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:531)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:59)
	at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:150)
	at org.sonarlint.intellij.analysis.SonarLintJobManager.lambda$runTask$2(SonarLintJobManager.java:120)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)

Java Main Files AST scan (done) | time=1ms
Java Test Files AST scan
0 source files to be analyzed
1/1 source files have been analyzed
0/0 source files have been analyzed
Java Test Files AST scan (done) | time=2ms
Execute Sensor: SonarJavaXmlFileSensor
Done in 96ms

Processed 0 issues in 1 ms
Found 0 issues
2 Likes

Same errors, I don’t know how to solve it and I changed previous sonarlint versions , it still not working .

Edit:

I found where cause this probleam, because sonarlint uses Intellij Idea enviorment JDK11 but sonarlint plugin contains a class that is ClassReader it does not support JDK11.

Blockquote
*/
public ClassReader(final byte b, final int off, final int len) {
this.b = b;
// checks the class version
if (readShort(off + 6) > Opcodes.V1_8) {
throw new IllegalArgumentException(); // here not support JDK
}
// parses the constant pool
items = new int[readUnsignedShort(off + 8)];
int n = items.length;
strings = new String[n];
int max = 0;
int index = off + 10;
for (int i = 1; i < n; ++i) {
items[i] = index + 1;
int size;
switch (b[index]) {
case ClassWriter.FIELD:
case ClassWriter.METH:

so , if you change IDEA working enviorment to JDK8 , it will work.

Thanks for your workaround, @winters, it is working!

But this is still a bug in the plugin then, isn’t it?

Hello, thank you both for your feedback.

The problem with ASM and Java 11 is not in SonarLint itself, but in the underlying Java analyzer.

In “recent” versions, the embedded ASM library used to load bytecode supports Java 11. The problem happens in connected mode, when the server version is older than the one embedded in SonarLint.

You might want to update the version of the Java analyzer on your SonarQube server, and if not possible then yes, you will have to resort to using a JDK8 to run IntelliJ.