From: Simon Brandhof Date: Tue, 15 Apr 2014 12:11:36 +0000 (+0200) Subject: Fix some quality flaws X-Git-Tag: 4.3~23 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=aecea1b85e37f20794e6cddf3e9bc4697041e762;p=sonarqube.git Fix some quality flaws --- diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ExclusionFilters.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ExclusionFilters.java index 7b8297ea062..ced596ed9dd 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ExclusionFilters.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ExclusionFilters.java @@ -61,15 +61,18 @@ public class ExclusionFilters implements BatchComponent { } public boolean accept(InputFile inputFile, InputFile.Type type) { - PathPattern[] inclusionPatterns = null; - PathPattern[] exclusionPatterns = null; + PathPattern[] inclusionPatterns; + PathPattern[] exclusionPatterns; if (InputFile.Type.MAIN == type) { inclusionPatterns = mainInclusions; exclusionPatterns = mainExclusions; } else if (InputFile.Type.TEST == type) { inclusionPatterns = testInclusions; exclusionPatterns = testExclusions; + } else { + throw new IllegalArgumentException("Unknown file type: " + type); } + if (inclusionPatterns.length > 0) { boolean matchInclusion = false; for (PathPattern pattern : inclusionPatterns) { diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileIndexer.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileIndexer.java index b4afd35d7d2..3d09990018e 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileIndexer.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileIndexer.java @@ -110,12 +110,9 @@ public class FileIndexer implements BatchComponent { Collection files = FileUtils.listFiles(dirToIndex, FILE_FILTER, DIR_FILTER); for (File file : files) { DefaultInputFile inputFile = inputFileBuilder.create(file); - if (inputFile != null) { - if (exclusionFilters.accept(inputFile, type)) { - indexFile(inputFileBuilder, fileSystem, status, inputFile, type); - } + if (inputFile != null && exclusionFilters.accept(inputFile, type)) + indexFile(inputFileBuilder, fileSystem, status, inputFile, type); } - } } private void indexFile(InputFileBuilder inputFileBuilder, DefaultModuleFileSystem fs,