Report issue only once in include files


The language I’m analyzing relies on include files, and this means that some issues can be reported multiple times exactly at the same location (for example, an unused variable in an include file used in 10 “main” procedures). In many cases (but not all), it doesn’t make any sense to report an issue more than once.
Is it possible to query the SensorContext object before calling SensorContext#newIssue(), and see if a specific issue has already been raised at a given location ? I would like to avoid having to duplicate the list of issues in each rule.

Thanks !


Hi Gilles,

For performance reasons (and for simplicity of API changes) we have progressively removed most “read” APIs. Sensor are only able to “push” data, without the ability to read them back.

So you’ll have to find your own strategy to deduplicate issues.

For example the strategy used by SonarC# is to keep an in-memory set:

It makes sense to have a clean and simple API. I’ll include the code in my rules, thanks a lot for your answer !