From 1493707a0c2acc5470adf281167eaeebb0272d50 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Tue, 15 Mar 2016 12:05:23 +0100 Subject: [PATCH] Fix quality flaws --- .../java/org/sonar/server/db/EmbeddedDatabaseFactory.java | 5 ++++- .../main/java/org/sonar/batch/report/ReportPublisher.java | 3 ++- .../src/main/java/org/sonar/batch/rule/QProfileVerifier.java | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/EmbeddedDatabaseFactory.java b/server/sonar-server/src/main/java/org/sonar/server/db/EmbeddedDatabaseFactory.java index 2a6a293e8aa..107dabad1aa 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/db/EmbeddedDatabaseFactory.java +++ b/server/sonar-server/src/main/java/org/sonar/server/db/EmbeddedDatabaseFactory.java @@ -20,10 +20,13 @@ package org.sonar.server.db; import com.google.common.annotations.VisibleForTesting; +import org.apache.commons.lang.StringUtils; import org.picocontainer.Startable; import org.sonar.api.config.Settings; import org.sonar.api.database.DatabaseProperties; +import static org.apache.commons.lang.StringUtils.startsWith; + public class EmbeddedDatabaseFactory implements Startable { private final Settings settings; private EmbeddedDatabase embeddedDatabase; @@ -36,7 +39,7 @@ public class EmbeddedDatabaseFactory implements Startable { public void start() { if (embeddedDatabase == null) { String jdbcUrl = settings.getString(DatabaseProperties.PROP_URL); - if (jdbcUrl.startsWith("jdbc:h2:tcp:")) { + if (startsWith(jdbcUrl, "jdbc:h2:tcp:")) { embeddedDatabase = getEmbeddedDatabase(settings); embeddedDatabase.start(); } diff --git a/sonar-batch/src/main/java/org/sonar/batch/report/ReportPublisher.java b/sonar-batch/src/main/java/org/sonar/batch/report/ReportPublisher.java index c62ccd63c56..4654892fb57 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/report/ReportPublisher.java +++ b/sonar-batch/src/main/java/org/sonar/batch/report/ReportPublisher.java @@ -52,6 +52,7 @@ import org.sonarqube.ws.WsCe; import org.sonarqube.ws.client.PostRequest; import org.sonarqube.ws.client.WsResponse; +import static org.apache.commons.lang.StringUtils.trimToEmpty; import static org.sonar.core.util.FileUtils.deleteQuietly; @BatchSide @@ -230,7 +231,7 @@ public class ReportPublisher implements Startable { * See https://jira.sonarsource.com/browse/SONAR-4239 */ private String publicUrl() { - String baseUrl = settings.getString(CoreProperties.SERVER_BASE_URL); + String baseUrl = trimToEmpty(settings.getString(CoreProperties.SERVER_BASE_URL)); if (baseUrl.equals(settings.getDefaultValue(CoreProperties.SERVER_BASE_URL))) { // crap workaround for https://jira.sonarsource.com/browse/SONAR-7109 // If server base URL was not configured in Sonar server then is is better to take URL configured on batch side diff --git a/sonar-batch/src/main/java/org/sonar/batch/rule/QProfileVerifier.java b/sonar-batch/src/main/java/org/sonar/batch/rule/QProfileVerifier.java index 00ecc85f700..6206a289f17 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/rule/QProfileVerifier.java +++ b/sonar-batch/src/main/java/org/sonar/batch/rule/QProfileVerifier.java @@ -28,6 +28,8 @@ import org.sonar.api.batch.fs.FileSystem; import org.sonar.api.config.Settings; import org.sonar.api.utils.MessageException; +import static org.apache.commons.lang.StringUtils.isNotEmpty; + @BatchSide public class QProfileVerifier { @@ -57,7 +59,7 @@ public class QProfileVerifier { logger.warn("No Quality profile found for language " + lang); } else { logger.info("Quality profile for {}: {}", lang, profile.getName()); - if (StringUtils.isNotBlank(defaultName) && defaultName.equals(profile.getName())) { + if (isNotEmpty(defaultName) && defaultName.equals(profile.getName())) { defaultNameUsed = true; } } -- 2.39.5