Skip to content

Commit 0331592

Browse files
Use org.sonarsource.analyzer.commons.FileProvider
1 parent 1047f25 commit 0331592

File tree

5 files changed

+6
-149
lines changed

5 files changed

+6
-149
lines changed

sonar-python-plugin/src/main/java/org/sonar/plugins/python/DirectoryScanner.java

Lines changed: 0 additions & 60 deletions
This file was deleted.

sonar-python-plugin/src/main/java/org/sonar/plugins/python/PythonReportSensor.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
import org.sonar.api.batch.sensor.SensorContext;
2727
import org.sonar.api.batch.sensor.SensorDescriptor;
2828
import org.sonar.api.config.Configuration;
29-
import org.sonar.api.utils.WildcardPattern;
3029
import org.sonar.api.utils.log.Logger;
3130
import org.sonar.api.utils.log.Loggers;
3231
import org.sonar.plugins.python.warnings.AnalysisWarningsWrapper;
32+
import org.sonarsource.analyzer.commons.FileProvider;
3333

3434
public abstract class PythonReportSensor implements Sensor {
3535

@@ -69,23 +69,23 @@ public void execute(SensorContext context) {
6969
public static List<File> getReports(Configuration conf, String baseDirPath, String reportPathPropertyKey, String reportPath) {
7070
LOG.debug("Using pattern '{}' to find reports", reportPath);
7171

72-
DirectoryScanner scanner = new DirectoryScanner(new File(baseDirPath), WildcardPattern.create(reportPath));
73-
List<File> includedFiles = scanner.getIncludedFiles();
72+
FileProvider provider = new FileProvider(new File(baseDirPath), reportPath);
73+
List<File> matchingFiles = provider.getMatchingFiles();
7474

75-
if (includedFiles.isEmpty()) {
75+
if (matchingFiles.isEmpty()) {
7676
if (conf.hasKey(reportPathPropertyKey)) {
7777
// try absolute path
7878
File file = new File(reportPath);
7979
if (!file.exists()) {
8080
LOG.warn("No report was found for {} using pattern {}", reportPathPropertyKey, reportPath);
8181
} else {
82-
includedFiles.add(file);
82+
matchingFiles.add(file);
8383
}
8484
} else {
8585
LOG.debug("No report was found for {} using default pattern {}", reportPathPropertyKey, reportPath);
8686
}
8787
}
88-
return includedFiles;
88+
return matchingFiles;
8989
}
9090

9191
protected void processReports(SensorContext context, List<File> reports) throws javax.xml.stream.XMLStreamException {

sonar-python-plugin/src/test/java/org/sonar/plugins/python/DirectoryScannerTest.java

Lines changed: 0 additions & 83 deletions
This file was deleted.

sonar-python-plugin/src/test/resources/org/sonar/plugins/python/scanner/dir/f1.txt

Whitespace-only changes.

sonar-python-plugin/src/test/resources/org/sonar/plugins/python/scanner/dir/subdir/f1.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)