SensorContext.newAnalysisError() method


What is the use case of SensorContext.newAnalysisError() ? Based on the Javadoc, I’ve tried to use it to report parser issues for a new language, but it doesn’t seem to be doing anything (that I’m able to see). Any hint on what this is supposed to do ?



Hi Gilles,

Short answer: this API was created to help SonarLint integration. Since SonarLint doesn’t support third party analyzers, you can safely ignore it.

Long answer:

In SonarQube world, we assume that all the code that is analyzed is “valid”. If an analyzer face a parsing error, we will fail the scanner process, asking the user to either fix the setup, or to report the bug to us (could be an issue in our analyzer). There is no risk to wrongly report no issues on a file, that would close all existing issues on SQ server side.

In SonarLint world, this is quite different. Depending on the IDE, analysis could be triggered in the middle of editing the code. It means the analyzer may fail to parse, but we need to know that on IDE side, to not clear all reported issues (and loose the issue date).

So we added this API, that some of our analyzers use to report that they were unable to process a file.

1 Like

Hi Julien,

This makes perfect sense, thanks a lot !