10.4.1: NullPointerException: Unable to run check class

  • Operating system: MacOS Sonoma 14.4.1
  • SonarLint plugin version:10.4.1.77998
  • Programming language you’re coding in: Java
  • Is connected mode used:
    • Connected to SonarQube (Community Edition Version 9.9.4 (build 87374)):

I get this Exception:

Unable to run check class fr.greencodeinitiative.java.checks.AvoidMultipleIfElseStatement - EC2 on file ‘[uri=file:///xxxxxxxxxxxxxxxxxxxx.java]’, To help improve the SonarSource Java Analyzer, please report this problem to SonarSource: see https://community.sonarsource.com/

java.lang.NullPointerException: Cannot invoke "java.util.Map.get(Object)" because "variablesParentLevelMap" is null
	at fr.greencodeinitiative.java.checks.AvoidMultipleIfElseStatement$VariablesPerLevelDataStructure.internalGetVariableUsageOfNearestParent(AvoidMultipleIfElseStatement.java:308)
	at fr.greencodeinitiative.java.checks.AvoidMultipleIfElseStatement$VariablesPerLevelDataStructure.internalIncrementVariableUsage(AvoidMultipleIfElseStatement.java:289)
	at fr.greencodeinitiative.java.checks.AvoidMultipleIfElseStatement$VariablesPerLevelDataStructure.incrementVariableUsageForLevelForCurrentIfStruct(AvoidMultipleIfElseStatement.java:345)
	at fr.greencodeinitiative.java.checks.AvoidMultipleIfElseStatement.computeVariables(AvoidMultipleIfElseStatement.java:196)
	at fr.greencodeinitiative.java.checks.AvoidMultipleIfElseStatement.computeConditionVariables(AvoidMultipleIfElseStatement.java:175)
	at fr.greencodeinitiative.java.checks.AvoidMultipleIfElseStatement.computeIfVariables(AvoidMultipleIfElseStatement.java:146)
	at fr.greencodeinitiative.java.checks.AvoidMultipleIfElseStatement.visitIfNode(AvoidMultipleIfElseStatement.java:115)
	at fr.greencodeinitiative.java.checks.AvoidMultipleIfElseStatement.visitNodeContent(AvoidMultipleIfElseStatement.java:95)
	at fr.greencodeinitiative.java.checks.AvoidMultipleIfElseStatement.visitElseNode(AvoidMultipleIfElseStatement.java:218)
	at fr.greencodeinitiative.java.checks.AvoidMultipleIfElseStatement.visitIfNode(AvoidMultipleIfElseStatement.java:127)
	at fr.greencodeinitiative.java.checks.AvoidMultipleIfElseStatement.visitIfNode(AvoidMultipleIfElseStatement.java:129)
	at fr.greencodeinitiative.java.checks.AvoidMultipleIfElseStatement.visitNodeContent(AvoidMultipleIfElseStatement.java:95)
	at fr.greencodeinitiative.java.checks.AvoidMultipleIfElseStatement.visitNode(AvoidMultipleIfElseStatement.java:75)
	at org.sonar.java.model.VisitorsBridge$IssuableSubscriptionVisitorsRunner.lambda$visit$6(VisitorsBridge.java:452)
	at org.sonar.java.model.VisitorsBridge$IssuableSubscriptionVisitorsRunner.lambda$forEach$9(VisitorsBridge.java:468)
	at org.sonar.java.model.VisitorsBridge.runScanner(VisitorsBridge.java:265)
	at org.sonar.java.model.VisitorsBridge$IssuableSubscriptionVisitorsRunner.forEach(VisitorsBridge.java:468)
	at org.sonar.java.model.VisitorsBridge$IssuableSubscriptionVisitorsRunner.visit(VisitorsBridge.java:454)
	at org.sonar.java.model.VisitorsBridge$IssuableSubscriptionVisitorsRunner.visitChildren(VisitorsBridge.java:438)
	at org.sonar.java.model.VisitorsBridge$IssuableSubscriptionVisitorsRunner.visit(VisitorsBridge.java:458)
	at org.sonar.java.model.VisitorsBridge$IssuableSubscriptionVisitorsRunner.visitChildren(VisitorsBridge.java:438)
	at org.sonar.java.model.VisitorsBridge$IssuableSubscriptionVisitorsRunner.visit(VisitorsBridge.java:458)
	at org.sonar.java.model.VisitorsBridge$IssuableSubscriptionVisitorsRunner.scanFile(VisitorsBridge.java:416)
	at org.sonar.java.model.VisitorsBridge.lambda$runScanner$1(VisitorsBridge.java:260)
	at org.sonar.java.model.VisitorsBridge.runScanner(VisitorsBridge.java:265)
	at org.sonar.java.model.VisitorsBridge.runScanner(VisitorsBridge.java:260)
	at org.sonar.java.model.VisitorsBridge.visitFile(VisitorsBridge.java:243)
	at org.sonar.java.ast.JavaAstScanner.simpleScan(JavaAstScanner.java:132)
	at org.sonar.java.ast.JavaAstScanner.lambda$scan$0(JavaAstScanner.java:92)
	at org.sonar.java.model.JParserConfig$FileByFile.parse(JParserConfig.java:274)
	at org.sonar.java.model.JParserConfig$FileByFile.parse(JParserConfig.java:249)
	at org.sonar.java.ast.JavaAstScanner.scan(JavaAstScanner.java:89)
	at org.sonar.java.JavaFrontend.scanAndMeasureTask(JavaFrontend.java:412)
	at org.sonar.java.JavaFrontend.scan(JavaFrontend.java:164)
	at org.sonar.plugins.java.JavaSensor.execute(JavaSensor.java:113)
	at org.sonarsource.sonarlint.core.analysis.container.analysis.sensor.SensorsExecutor.executeSensor(SensorsExecutor.java:95)
	at org.sonarsource.sonarlint.core.analysis.container.analysis.sensor.SensorsExecutor.executeSensors(SensorsExecutor.java:86)
	at org.sonarsource.sonarlint.core.analysis.container.analysis.sensor.SensorsExecutor.execute(SensorsExecutor.java:76)
	at org.sonarsource.sonarlint.core.analysis.container.analysis.AnalysisContainer.doAfterStart(AnalysisContainer.java:122)
	at org.sonarsource.sonarlint.core.plugin.commons.container.SpringComponentContainer.startComponents(SpringComponentContainer.java:182)
	at org.sonarsource.sonarlint.core.plugin.commons.container.SpringComponentContainer.execute(SpringComponentContainer.java:161)
	at org.sonarsource.sonarlint.core.analysis.container.module.ModuleContainer.analyze(ModuleContainer.java:71)
	at org.sonarsource.sonarlint.core.analysis.command.AnalyzeCommand.execute(AnalyzeCommand.java:58)
	at org.sonarsource.sonarlint.core.analysis.command.AnalyzeCommand.execute(AnalyzeCommand.java:32)
	at org.sonarsource.sonarlint.core.analysis.AnalysisEngine$AsyncCommand.execute(AnalysisEngine.java:153)
	at org.sonarsource.sonarlint.core.analysis.AnalysisEngine.executeQueuedCommands(AnalysisEngine.java:71)
	at java.base/java.lang.Thread.run(Thread.java:840)

Hello @jwvmarkus,

Apologies for the late response to your issue. By looking at the stack trace, it seems the NPE comes from a 3rd party code and it would be best to raise the issue directly with the maintainers as there isn’t much we can do on the SonarLint side.

Best,

Vojech from :sonarlint: