aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2014-10-21 22:37:10 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2014-10-21 22:37:10 +0200
commit67e2a0659d60ff3825b6119539c0344f5ac80be7 (patch)
treed04beaea12d5ce4b9d536662849ec53acf5e41bf
parent23f009e251de91721c37dbfbfb67502839d9b9a3 (diff)
downloadsonarqube-67e2a0659d60ff3825b6119539c0344f5ac80be7.tar.gz
sonarqube-67e2a0659d60ff3825b6119539c0344f5ac80be7.zip
SONAR-5758 fix quality flaws
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/db/migrations/v451/DeleteUnescapedActivities.java14
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/db/migrations/v451/DeleteUnescapedActivitiesTest.java4
2 files changed, 13 insertions, 5 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v451/DeleteUnescapedActivities.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v451/DeleteUnescapedActivities.java
index 5f9866de881..c0bbe4fa71a 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v451/DeleteUnescapedActivities.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v451/DeleteUnescapedActivities.java
@@ -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;
diff --git a/server/sonar-server/src/test/java/org/sonar/server/db/migrations/v451/DeleteUnescapedActivitiesTest.java b/server/sonar-server/src/test/java/org/sonar/server/db/migrations/v451/DeleteUnescapedActivitiesTest.java
index 4f342cfe5a8..cb13eb73884 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/db/migrations/v451/DeleteUnescapedActivitiesTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/db/migrations/v451/DeleteUnescapedActivitiesTest.java
@@ -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();