SensorContext.newAnalysisError() method


(Gilles Querret) #1

Hello,

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 ?

Thanks,

Gilles


(Julien Henry) #2

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.


(Gilles Querret) #3

Hi Julien,

This makes perfect sense, thanks a lot !

Gilles