diff options
author | Evgeny Mandrikov <mandrikov@gmail.com> | 2012-05-07 18:16:48 +0600 |
---|---|---|
committer | Evgeny Mandrikov <mandrikov@gmail.com> | 2012-05-08 21:02:54 +0600 |
commit | 54ce0edc38605421e91a660ccbacd8765a8e2a6d (patch) | |
tree | c425901f0d5d11101512dca95840aba81899e7a2 /sonar-duplications | |
parent | c4136d4e4ae8bac0c30a0c0cef8b5b4688565642 (diff) | |
download | sonarqube-54ce0edc38605421e91a660ccbacd8765a8e2a6d.tar.gz sonarqube-54ce0edc38605421e91a660ccbacd8765a8e2a6d.zip |
SONAR-3182 Remove unused code
Diffstat (limited to 'sonar-duplications')
3 files changed, 0 insertions, 173 deletions
diff --git a/sonar-duplications/src/main/java/net/sourceforge/pmd/cpd/AbstractLanguage.java b/sonar-duplications/src/main/java/net/sourceforge/pmd/cpd/AbstractLanguage.java deleted file mode 100644 index 7237e68d2e1..00000000000 --- a/sonar-duplications/src/main/java/net/sourceforge/pmd/cpd/AbstractLanguage.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2012 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * Sonar is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ - -package net.sourceforge.pmd.cpd; - -import java.io.File; -import java.io.FilenameFilter; - -public abstract class AbstractLanguage implements Language { - private final Tokenizer tokenizer; - private final FilenameFilter fileFilter; - - public AbstractLanguage(Tokenizer tokenizer, String... extensions) { - this.tokenizer = tokenizer; - fileFilter = new ExtensionsFilter(extensions); - } - - /** - * @deprecated in 2.14, seems that not used in Sonar ecosystem - we don't scan directories. - */ - @Deprecated - public FilenameFilter getFileFilter() { - return fileFilter; - } - - public Tokenizer getTokenizer() { - return tokenizer; - } - - private static class ExtensionsFilter implements FilenameFilter { - private final String[] extensions; - - public ExtensionsFilter(String... extensions) { - this.extensions = new String[extensions.length]; - for (int i = 0; i < extensions.length; i++) { - this.extensions[i] = extensions[i].toUpperCase(); - } - } - - public boolean accept(File dir, String name) { - File file = new File(dir, name); - if (file.isDirectory()) { - return true; - } - String uppercaseName = name.toUpperCase(); - for (String extension : extensions) { - if (uppercaseName.endsWith(extension)) { - return true; - } - } - return false; - } - } -} diff --git a/sonar-duplications/src/main/java/net/sourceforge/pmd/cpd/Language.java b/sonar-duplications/src/main/java/net/sourceforge/pmd/cpd/Language.java deleted file mode 100644 index 8fb352cfe84..00000000000 --- a/sonar-duplications/src/main/java/net/sourceforge/pmd/cpd/Language.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2012 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * Sonar is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ - -/** - * BSD-style license; for more info see http://pmd.sourceforge.net/license.html - */ -package net.sourceforge.pmd.cpd; - -import java.io.FilenameFilter; - -public interface Language { - - Tokenizer getTokenizer(); - - FilenameFilter getFileFilter(); - -} diff --git a/sonar-duplications/src/test/java/net/sourceforge/pmd/cpd/AbstractLanguageTest.java b/sonar-duplications/src/test/java/net/sourceforge/pmd/cpd/AbstractLanguageTest.java deleted file mode 100644 index 404df716657..00000000000 --- a/sonar-duplications/src/test/java/net/sourceforge/pmd/cpd/AbstractLanguageTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2012 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * Sonar is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package net.sourceforge.pmd.cpd; - -import org.junit.Test; - -import java.io.File; -import java.io.FilenameFilter; - -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; - -/** - * We use modified version of {@link AbstractLanguage} in comparison with PMD - it doesn't use package "net.sourceforge.pmd.util.filter", - * so goal of this test is to verify that behavior wasn't changed: - * filter should always accept directories and files with a specified set of extensions (comparison is case insensitive). - */ -public class AbstractLanguageTest { - - @Test - public void shouldCreateCorrectFilenameFilterForExtensions() { - AbstractLanguage language = new AbstractLanguage(null, "java") { - }; - - FilenameFilter filter = language.getFileFilter(); - assertThat(filter.accept(new File("test-resources"), "org"), is(true)); - assertThat(filter.accept(new File("test-resources/org/sonar/duplications/cpd/CPDTest"), "CPDFile1.java"), is(true)); - assertThat(filter.accept(new File("test-resources/org/sonar/duplications/cpd/CPDTest"), "CPDFile1.cpp"), is(false)); - - language = new AbstractLanguage(null, "Java") { - }; - assertThat(filter.accept(new File("test-resources/org/sonar/duplications/cpd/CPDTest"), "CPDFile1.java"), is(true)); - - language = new AbstractLanguage(null, new String[] {}) { - }; - assertThat(filter.accept(new File("test-resources/org/sonar/duplications/cpd/CPDTest"), "CPDFile1.java"), is(true)); - } - - @Test(expected = NullPointerException.class) - public void shouldThrowException() { - new AbstractLanguage(null, (String) null) { - }; - } - - @Test(expected = NullPointerException.class) - public void shouldAlsoThrowException() { - new AbstractLanguage(null, (String[]) null) { - }; - } - -} |