diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2015-12-23 11:29:14 +0100 |
---|---|---|
committer | Duarte Meneses <duarte.meneses@sonarsource.com> | 2015-12-23 11:29:14 +0100 |
commit | 638244f43d7ee3f3a5e643d4b9fcc4456f63b59c (patch) | |
tree | daed64b8033a1ee8312d6d21b3b6e532c4c2239c /sonar-batch | |
parent | 7f5a8542ce2f3041ad476e91b702ea41815fce0c (diff) | |
download | sonarqube-638244f43d7ee3f3a5e643d4b9fcc4456f63b59c.tar.gz sonarqube-638244f43d7ee3f3a5e643d4b9fcc4456f63b59c.zip |
SONAR-2867 Standard copy-paste detection should happen within a project, not only within a module
Diffstat (limited to 'sonar-batch')
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/cpd/CpdExecutor.java | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/cpd/CpdExecutor.java b/sonar-batch/src/main/java/org/sonar/batch/cpd/CpdExecutor.java index 302035c3973..31fac6c17a8 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/cpd/CpdExecutor.java +++ b/sonar-batch/src/main/java/org/sonar/batch/cpd/CpdExecutor.java @@ -93,13 +93,25 @@ public class CpdExecutor { } InputFile inputFile = (InputFile) component.inputComponent(); - Predicate<CloneGroup> minimumTokensPredicate = DuplicationPredicates.numberOfUnitsNotLessThan(getMinimumTokens(inputFile.language())); - List<CloneGroup> filtered = from(duplications).filter(minimumTokensPredicate).toList(); + + List<CloneGroup> filtered; + if (!"java".equalsIgnoreCase(inputFile.language())) { + Predicate<CloneGroup> minimumTokensPredicate = DuplicationPredicates.numberOfUnitsNotLessThan(getMinimumTokens(inputFile.language())); + filtered = from(duplications).filter(minimumTokensPredicate).toList(); + } else { + filtered = duplications; + } saveDuplications(component, filtered); } @VisibleForTesting + /** + * Not applicable to Java, as the {@link BlockChunker} that it uses does not record start and end units of each block. + * Also, it uses statements instead of tokens. + * @param languageKey + * @return + */ int getMinimumTokens(String languageKey) { int minimumTokens = settings.getInt("sonar.cpd." + languageKey + ".minimumTokens"); if (minimumTokens == 0) { |