aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine/src
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2019-01-14 15:05:49 +0100
committersonartech <sonartech@sonarsource.com>2019-01-16 09:43:14 +0100
commit2a1bb3adb010fdb65468808551fc7cc45fae4579 (patch)
treed809740461f3fdf6af5587976fb1b23867da714e /sonar-scanner-engine/src
parenta670f22ca1ea07f1f24d3e89d5c0b1220c8185c2 (diff)
downloadsonarqube-2a1bb3adb010fdb65468808551fc7cc45fae4579.tar.gz
sonarqube-2a1bb3adb010fdb65468808551fc7cc45fae4579.zip
SONAR-11606 Stop excluding directories starting with a dot
Diffstat (limited to 'sonar-scanner-engine/src')
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/ProjectFileIndexer.java24
1 files changed, 17 insertions, 7 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/ProjectFileIndexer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/ProjectFileIndexer.java
index 788ee0d5887..9c13d0c2e1d 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/ProjectFileIndexer.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/ProjectFileIndexer.java
@@ -25,8 +25,10 @@ import java.nio.file.FileVisitOption;
import java.nio.file.FileVisitResult;
import java.nio.file.FileVisitor;
import java.nio.file.Files;
+import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.attribute.BasicFileAttributes;
+import java.nio.file.attribute.DosFileAttributes;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
@@ -35,6 +37,7 @@ import java.util.Optional;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.SystemUtils;
import org.sonar.api.batch.fs.InputFile.Type;
import org.sonar.api.batch.fs.internal.DefaultInputModule;
import org.sonar.api.batch.fs.internal.InputModuleHierarchy;
@@ -190,12 +193,7 @@ public class ProjectFileIndexer {
@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
- Path fileName = dir.getFileName();
-
- if (fileName != null && fileName.toString().length() > 1 && fileName.toString().charAt(0) == '.') {
- return FileVisitResult.SKIP_SUBTREE;
- }
- if (Files.isHidden(dir)) {
+ if (isHidden(dir)) {
return FileVisitResult.SKIP_SUBTREE;
}
return FileVisitResult.CONTINUE;
@@ -223,6 +221,18 @@ public class ProjectFileIndexer {
public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
return FileVisitResult.CONTINUE;
}
- }
+ private boolean isHidden(Path path) throws IOException {
+ if (SystemUtils.IS_OS_WINDOWS) {
+ try {
+ DosFileAttributes dosFileAttributes = Files.readAttributes(path, DosFileAttributes.class, LinkOption.NOFOLLOW_LINKS);
+ return dosFileAttributes.isHidden();
+ } catch (UnsupportedOperationException e) {
+ return path.toFile().isHidden();
+ }
+ } else {
+ return Files.isHidden(path);
+ }
+ }
+ }
}