mirror of
https://github.com/SonarSource/sonarqube.git
synced 2024-08-03 08:18:00 +02:00
SONAR-2303 "Architectural constraint" rule should work for patterns with spaces
This commit is contained in:
parent
9380e275b3
commit
6f4124e680
@ -29,7 +29,12 @@ public final class PatternUtils {
|
||||
}
|
||||
|
||||
public static WildcardPattern[] createPatterns(String patterns) {
|
||||
return WildcardPattern.create(StringUtils.split(StringUtils.replace(patterns, ".", "/"), ','));
|
||||
String[] p = StringUtils.split(patterns, ',');
|
||||
WildcardPattern[] result = new WildcardPattern[p.length];
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
result[i] = WildcardPattern.create(StringUtils.trim(StringUtils.replace(p[i], ".", "/")));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -36,4 +36,16 @@ public class PatternUtilsTest {
|
||||
assertThat(patterns[0].match("org/sonar/Foo"), is(true));
|
||||
assertThat(patterns[1].match("javax/Bar"), is(true));
|
||||
}
|
||||
|
||||
/**
|
||||
* See http://jira.codehaus.org/browse/SONAR-2303
|
||||
*/
|
||||
@Test
|
||||
public void shouldTrim() {
|
||||
WildcardPattern[] patterns = PatternUtils.createPatterns("org.foo.*,\n org.bar.*");
|
||||
|
||||
assertThat(patterns[0].match("org/foo/Foo"), is(true));
|
||||
assertThat(patterns[1].match("org/bar/Bar"), is(true));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user