]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5758 fix quality flaws
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 21 Oct 2014 20:37:10 +0000 (22:37 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 21 Oct 2014 20:37:10 +0000 (22:37 +0200)
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v451/DeleteUnescapedActivities.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v451/DeleteUnescapedActivitiesTest.java

index 5f9866de88124f340c539a0fb5b0d618eab5408f..c0bbe4fa71aca96081f706e3b0c2c8b708c4b35a 100644 (file)
@@ -26,6 +26,8 @@ import org.sonar.server.db.migrations.MassUpdate;
 import org.sonar.server.db.migrations.Select;
 import org.sonar.server.db.migrations.SqlStatement;
 
+import javax.annotation.Nullable;
+
 import java.sql.SQLException;
 
 /**
@@ -57,11 +59,13 @@ public class DeleteUnescapedActivities extends BaseDataChange {
     });
   }
 
-  static boolean isUnescaped(String csv) {
-    String[] splits = csv.split(";");
-    for (String split : splits) {
-      if (StringUtils.countMatches(split, "=") != 1) {
-        return true;
+  static boolean isUnescaped(@Nullable String csv) {
+    if (csv != null) {
+      String[] splits = StringUtils.split(csv, ';');
+      for (String split : splits) {
+        if (StringUtils.countMatches(split, "=") != 1) {
+          return true;
+        }
       }
     }
     return false;
index 4f342cfe5a8e3b40193a8cf5f32e1d1e070e49eb..cb13eb7388406e977e7c5e809b0ca4cf0c8de64d 100644 (file)
@@ -47,7 +47,11 @@ public class DeleteUnescapedActivitiesTest {
       "ruleKey=findbugs:PT_RELATIVE_PATH_TRAVERSAL;profileKey=java-findbugs-74105;severity=MAJOR;" +
         "key=java-findbugs-74105:findbugs:PT_RELATIVE_PATH_TRAVERSAL"))
       .isFalse();
+    assertThat(DeleteUnescapedActivities.isUnescaped(null)).isFalse();
+    assertThat(DeleteUnescapedActivities.isUnescaped("")).isFalse();
+    assertThat(DeleteUnescapedActivities.isUnescaped("foo=bar")).isFalse();
     assertThat(DeleteUnescapedActivities.isUnescaped("param_xpath=/foo/bar")).isFalse();
+
     assertThat(DeleteUnescapedActivities.isUnescaped("param_xpath=/foo/bar;foo;ruleKey=S001")).isTrue();
     assertThat(DeleteUnescapedActivities.isUnescaped("param_xpath=/foo=foo;ruleKey=S001")).isTrue();