Reputation: 163
I started development of my own plugin and have a trouble about FileSystem:
My Sensor implementation like a sonar-reference-plugin:
public class PLPlusCodeSensor implements Sensor {
private final Logger log = LoggerFactory.getLogger(this.getClass());
private final FileSystem filesystem;
private final Settings settings;
public PLPlusCodeSensor(Settings settings, FileSystem filesystem) {
this.filesystem = filesystem;
this.settings = settings;
}
@Override
public boolean shouldExecuteOnProject(Project project) {
return true;
}
@Override
public void analyse(Project project, SensorContext sensorContext) {
for(InputFile file : filesystem.inputFiles(filesystem.predicates().all())) {
log.info("Processing file " + file.absolutePath());
Measure measure = new Measure(PLPlusMetrics.LineLength, 85d);
sensorContext.saveMeasure(file, measure);
}
}
@Override
public String toString() {
return this.getClass().getName();
}
}
but there is no output about any file in source dir:
18:04:27.707 INFO - Sensor com.sbt.tools.sonarqube.plplus.PLPlusCodeSensor
18:04:27.707 INFO - Sensor com.sbt.tools.sonarqube.plplus.PLPlusCodeSensor (done) | time=0ms
here is my sonar-project.properties flie:
sonar.projectKey=plplus-test
sonar.projectName=PLPlus Test Analysis
sonar.projectVersion=1.0
sonar.sources=c:/dev/plplus/src
here is content of src dir:
C:\dev\plplus\src>dir
Том в устройстве C имеет метку Windows7_OS
Серийный номер тома: 18DB-13C8
Содержимое папки C:\dev\plplus\src
23.12.2015 17:59 <DIR> .
23.12.2015 17:59 <DIR> ..
23.12.2015 15:54 0 test.plp
1 файлов 0 байт
2 папок 98 023 743 488 байт свободно
C:\dev\plplus\src>
Please, help me to understand, why filesystem.inputFiles(filesystem.predicates().all()) returns an empty iterator?
Upvotes: 2
Views: 165
Reputation: 10833
In order to get a file from fileSystem api it has to be indexed. In order to do so, you have to either define a language that will declare the extension you are looking for or import all source files using sonar.import_unknown_files=true
(with SQ 5.1+)
Upvotes: 1