Custom plugin and PR support

Hello,

I already have a custom plugin which analyses a custom language. It works fine, report issues as expected.

The only issue is it’s not Pull Request compliant. On each PR, it analysis the full repository. The expected behavior is to only scan files modified in the PR.

I’m already aware of the InputFile.Status.SAME (seen here Plugin Development - Sonar Community) but as far as I can tell, none of the sensor provided by Sonar uses it (Java, PHP, XML, etc…)

How do you make a Sensor work for both PR and full repo analysis ?
(I don’t have access to the source code at the moment so I cannot paste what I have)
Is it somehow already filtered when you use context.fileSystem.inputFiles(...) ?

Is using the check against InputFile.Status the way to go ? It seems it will change in the near future…

In my pull request analysis log, when analyzing Java code, I see the line SCM Publisher 8 source files to be analyzed (https://github.com/SonarSource/sonarqube/blob/f50873318397d4bf7ba6a5c2b194dfa02492bdae/sonar-scanner-engine/src/main/java/org/sonar/scanner/scm/DefaultBlameOutput.java#L71).
How can I make my plugin use only the files filtered by the ScmPublisher ?

Thank you

For reference, I’m using (again, source code not available atm) on the latest
Sonar: latest LTS 9.9
plugin-api: around 9.14
SCM: Github
CI: Jenkins

Hey there.

I’m not an expert here, but it seems you could draw inspiration from many of our open source analyzers that take advantage of caching.

PHP - https://github.com/search?q=repo%3ASonarSource%2Fsonar-php+InputFile.Status.SAME&type=code
Java - https://github.com/search?q=repo%3ASonarSource%2Fsonar-java+InputFile.Status.SAME&type=code
Python - https://github.com/search?q=repo%3ASonarSource%2Fsonar-python+InputFile.Status.SAME&type=code