False Positive on Java code in SonarLint for rule java:S1854

Hi @Petr_Nehez

Thanks @Quentin for the initial investigation. SonarLint for IntelliJ is supposed to provide the correct project classpath to the Java analyzer, so let’s investigate in this direction.

@Petr_Nehez could you please tell us if you are using connected mode with a SonarQube server (if yes, we will need the version of the Java analyzer installed on your SonarQube server)?
Then we will need a full analysis logs. Go to the SonarLint Tool Window, and enable verbose + analysis logs. Then reopen your offending file, and share the log with us. If you are concerned about privacy of paths and filenames, send it to me by private message.

This should look like this:

Trigger: EDITOR_OPEN
[Editor open] 1 file(s) submitted
Configuring analysis with org.sonarlint.intellij.analysis.JavaAnalysisConfigurator
Analysing 'SonarLintJob.java'...
Starting analysis with configuration:
[
  baseDir: /home/julien/Prog/Projects/sonar-intellij
  extraProperties: {sonar.java.target=1.8, sonar.java.libraries=/home/julien/.gradle/caches/modules-2/files-2.1/org.sonarsource.sonarlint.core/sonarlint-core/4.8.0.14729/f08fde1b1632c54876e578d147c4037e8c482099/sonarlint-core-4.8.0.14729.jar,/home/julien/.gradle/caches/modules-2/files-2.1/org.sonarsource.sonarlint.core/sonarlint-client-api/4.8.0.14729/65cd0d1ecfdc68c40e6d79bf2fe120971074467f/sonarlint-client-api-4.8.0.14729.jar,[...]}
  inputFiles: [
    file:///home/julien/Prog/Projects/sonar-intellij/src/main/java/org/sonarlint/intellij/analysis/SonarLintJob.java (UTF-8)
  ]
]

Available languages:
  * Java => "java"
[...]
Start analysis
Declared extensions of language Java were converted to java: **/*.java,**/*.jav
[...]
Index files
Language of file 'file:///home/julien/Prog/Projects/sonar-intellij/src/main/java/org/sonarlint/intellij/analysis/SonarLintJob.java' is detected to be 'java'
1 file indexed
Quality profiles:
  * java: 'Default - SonarSource conventions' (423 rules)
[...]
Execute Sensor: JavaSquidSensor
Configured Java source version (sonar.java.source): 8
JavaClasspath initialization
JavaClasspath initialization (done) | time=2ms
JavaTestClasspath initialization
JavaTestClasspath initialization (done) | time=3ms
----- Classpath analyzed by Squid:
/home/julien/Prog/Projects/sonar-intellij/out/production/classes
/home/julien/.gradle/caches/modules-2/files-2.1/org.sonarsource.sonarlint.core/sonarlint-core/4.8.0.14729/f08fde1b1632c54876e578d147c4037e8c482099/sonarlint-core-4.8.0.14729.jar
[...]
-----
----- Classpath analyzed by Squid:
/home/julien/Prog/Projects/sonar-intellij/out/production/classes
/home/julien/.gradle/caches/modules-2/files-2.1/org.sonarsource.sonarlint.core/sonarlint-core/4.8.0.14729/f08fde1b1632c54876e578d147c4037e8c482099/sonarlint-core-4.8.0.14729.jar
[...]
-----
Java Main Files AST scan
1 source files to be analyzed
Initializing metadata of file file:///home/julien/Prog/Projects/sonar-intellij/src/main/java/org/sonarlint/intellij/analysis/SonarLintJob.java
1/1 source files have been analyzed
Java Main Files AST scan (done) | time=394ms
[...]

Thanks

1 Like