Issue is reported twice when scanning multi module project



I make breakpoint in my sensor. It is triggered twice

fs = context.fileSystem()

“” can be gotten when handling ModuleB. I check context.fileSystem(), its baseDir is Root/ModuleB. Why files in ModuleA can be gotten in ModuleB?

How can I only get the files in the current module?


Would be interesting to share a few more details:

  • the version of SonarQube you are testing your plugin with
  • the exact interface your Sensor is implementing (ProjectSensor, Sensor, …).
  • the Sensor descriptor
  • possibly the entire code of your Sensor
  • analysis logs in verbose mode

FYI Global/project sensors are called once per project, but “normal” sensors are called once per module. In theory the module sensors should only “see” files of the module.

sonarqube version: Enterprise and Community 6.7.3
sonar-scanner: and
demo project:
analysis log:

public class G11nSensor implements Sensor {
    public void describe(SensorDescriptor descriptor) {
                .onlyWhenConfiguration(x->x.getBoolean(Constants.StringIssueEnableKey).orElse(false) || x.getBoolean(Constants.ResourceIssueEnableKey).orElse(true))
                .name("G11n Sensor")
    public void execute(SensorContext context) {
        FileSystem fs = context.fileSystem();
        FilePredicate predicate = fs.predicates().hasExtension("java");
        Iterable<InputFile> inputFiles = fs.inputFiles(predicate);
        for (InputFile inputFile : inputFiles) {
            ... ...

the issue occurs just using “fs.predicates().hasExtension”.
“fs.predicates().matchesPathPattern” works correctly.

Thanks for all the details. Unfortunately the predicates hasFilename or hasExtension are broken for multi-module projects (they will return files from all modules, not limited to the current module the Sensor is running for). I created a ticket:

If your goal is to query all Java files, I suggest you query directly by language:
This is more correct because it will handle custom user extensions (even if I admit this is not common in Java to have file extension different than .java).

fs.predicates().hasLanguage("java"); depends on the original java plugin which declares java language.
So if customers don’t install java plugin, my plugin will not work. It isn’t acceptable.
So far, I feel the workaround solution is to compare path prefix to filter files before your jira issues would be done.

Another option is to use a ProjectSensor, if you don’t need to deal with modules. ProjectSensor were introduced in SQ 7.6, so if you want to support older versions, you can use normal Sensors, but with the attribute “global”, to make them behave almost like ProjectSensors:

Project/global Sensors are executed only once for the entire project, and FS queries are executed on the entire list of files.