diff options
author | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-10-26 15:57:35 +0400 |
---|---|---|
committer | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-10-26 21:48:18 +0400 |
commit | 0515a6312bccac7e56dd409e0c906a8bb825a014 (patch) | |
tree | b94177ee7b39edd64ee562f63930424b4ff21245 | |
parent | 911c66cab3137ba840b856a4750088ea6709064f (diff) | |
download | sonarqube-0515a6312bccac7e56dd409e0c906a8bb825a014.tar.gz sonarqube-0515a6312bccac7e56dd409e0c906a8bb825a014.zip |
Fix violations
4 files changed, 6 insertions, 2 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/EventPersister.java b/sonar-batch/src/main/java/org/sonar/batch/index/EventPersister.java index a36255b6065..26d9763f891 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/index/EventPersister.java +++ b/sonar-batch/src/main/java/org/sonar/batch/index/EventPersister.java @@ -22,7 +22,6 @@ package org.sonar.batch.index; import org.sonar.api.batch.Event; import org.sonar.api.database.DatabaseSession; import org.sonar.api.database.model.Snapshot; -import org.sonar.api.resources.Project; import org.sonar.api.resources.Resource; import java.util.Collections; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/WildcardPattern.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/WildcardPattern.java index 66e7a745aa1..e6bb142a5c2 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/WildcardPattern.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/WildcardPattern.java @@ -62,6 +62,7 @@ import org.apache.commons.lang.StringUtils; public class WildcardPattern { private static final Map<String, WildcardPattern> CACHE = new HashMap<String, WildcardPattern>(); + private static final String SPECIAL_CHARS = "()[]^$.{}+|"; private Pattern pattern; private String stringRepresentation; @@ -82,7 +83,7 @@ public class WildcardPattern { while (i < antPattern.length()) { final char ch = antPattern.charAt(i); - if (ch == '(' || ch == ')' || ch == '[' || ch == ']' || ch == '^' || ch == '$' || ch == '.' || ch == '{' || ch == '}' || ch == '+' || ch == '|') { + if (SPECIAL_CHARS.indexOf(ch) != -1) { // Escape regexp-specific characters sb.append('\\').append(ch); } else if (ch == '*') { diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/WildcardPatternTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/WildcardPatternTest.java index 2cde1e5964b..8e2ccbb172b 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/WildcardPatternTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/WildcardPatternTest.java @@ -147,6 +147,8 @@ public class WildcardPatternTest { assertFalse(match("[ab]", "a")); assertTrue(match("[ab]", "[ab]")); + + assertTrue("all regexp-specific characters", match("()[]^$.{}+|", "()[]^$.{}+|")); } @Test diff --git a/sonar-squid/src/main/java/org/sonar/squid/text/StringArrayReader.java b/sonar-squid/src/main/java/org/sonar/squid/text/StringArrayReader.java index 66c82baa972..054327d51e3 100644 --- a/sonar-squid/src/main/java/org/sonar/squid/text/StringArrayReader.java +++ b/sonar-squid/src/main/java/org/sonar/squid/text/StringArrayReader.java @@ -59,6 +59,8 @@ public class StringArrayReader extends Reader { case CR_PLUS_LF: content.append("\r\n"); break; + default: + throw new IllegalStateException(); // should never happen } } } |