From 3a09a52553ef62c734044f98aad384e3dabcc64d Mon Sep 17 00:00:00 2001 From: David Gageot Date: Fri, 5 Oct 2012 17:11:30 +0200 Subject: [PATCH] SONAR-3758 Test exclusion patterns --- .../src/main/java/org/sonar/plugins/core/CorePlugin.java | 3 ++- .../src/main/java/org/sonar/api/resources/JavaFile.java | 3 --- .../src/test/java/org/sonar/api/resources/JavaFileTest.java | 6 +++--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java index b65f646aa3a..5476f7eb6f7 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java @@ -185,7 +185,8 @@ import java.util.List; name = "Global test exclusions", description = "Exclude tests from code analysis. Applies to every project. Cannot be overriden. Changes will be applied during next code analysis.", multiValues = true, - category = CoreProperties.CATEGORY_EXCLUSIONS), + category = CoreProperties.CATEGORY_EXCLUSIONS, + defaultValue = "**/package-info.java"), @Property( key = CoreProperties.PROJECT_EXCLUSIONS_PROPERTY, name = "Exclusions", diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/JavaFile.java b/sonar-plugin-api/src/main/java/org/sonar/api/resources/JavaFile.java index cd142ae6ce2..fb4bde75189 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/resources/JavaFile.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/resources/JavaFile.java @@ -174,9 +174,6 @@ public class JavaFile extends Resource { */ @Override public boolean matchFilePattern(String antPattern) { - if (unitTest) { - return false; - } String fileKey = getKey(); if (!fileKey.endsWith(".java")) { fileKey += ".java"; diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/resources/JavaFileTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/resources/JavaFileTest.java index afe33c33f22..72187079486 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/resources/JavaFileTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/resources/JavaFileTest.java @@ -210,16 +210,16 @@ public class JavaFileTest { * See http://jira.codehaus.org/browse/SONAR-1449 */ @Test - public void doNotMatchAjPattern() { + public void doNotMatchAPattern() { JavaFile file = new JavaFile("org.sonar.commons.Foo"); assertFalse(file.matchFilePattern("**/*.aj")); assertTrue(file.matchFilePattern("**/*.java")); } @Test - public void doNotExcludeTestFiles() { + public void should_exclude_test_files() { JavaFile unitTest = new JavaFile("org.sonar.commons.FooTest", true); - assertFalse(unitTest.matchFilePattern("**/*")); + assertTrue(unitTest.matchFilePattern("**/*")); } private File newDir(String dirName) { -- 2.39.5