From: Teryk Bellahsene Date: Mon, 21 Sep 2015 16:28:06 +0000 (+0200) Subject: Fix quality flaws X-Git-Tag: 5.2-RC1~167 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=806c04edb2169d2523225bf67e32729b20bf0ef2;p=sonarqube.git Fix quality flaws --- diff --git a/server/sonar-server/src/main/java/org/sonar/server/scanner/ProjectAction.java b/server/sonar-server/src/main/java/org/sonar/server/scanner/ProjectAction.java index 31a4973a53d..28777593040 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/scanner/ProjectAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/scanner/ProjectAction.java @@ -20,6 +20,7 @@ package org.sonar.server.scanner; +import java.util.Date; import java.util.HashMap; import java.util.Map; import org.sonar.api.server.ws.Request; @@ -93,8 +94,9 @@ public class ProjectAction implements ScannerWsAction { } private static void setLastAnalysisDate(WsProjectResponse.Builder response, ProjectRepositories data) { - if (data.lastAnalysisDate() != null) { - response.setLastAnalysisDate(data.lastAnalysisDate().getTime()); + Date lastAnalysisDate = data.lastAnalysisDate(); + if (lastAnalysisDate != null) { + response.setLastAnalysisDate(lastAnalysisDate.getTime()); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/scanner/ProjectDataLoader.java b/server/sonar-server/src/main/java/org/sonar/server/scanner/ProjectDataLoader.java index 313022d32c6..06ba815719e 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/scanner/ProjectDataLoader.java +++ b/server/sonar-server/src/main/java/org/sonar/server/scanner/ProjectDataLoader.java @@ -28,8 +28,6 @@ import java.util.Date; import java.util.List; import java.util.Map; import org.sonar.api.server.ServerSide; -import org.sonar.api.utils.log.Logger; -import org.sonar.api.utils.log.Loggers; import org.sonar.api.web.UserRole; import org.sonar.batch.protocol.input.FileData; import org.sonar.batch.protocol.input.ProjectRepositories; @@ -51,8 +49,6 @@ import static org.sonar.server.ws.WsUtils.checkFound; @ServerSide public class ProjectDataLoader { - private static final Logger LOG = Loggers.get(ProjectDataLoader.class); - private final DbClient dbClient; private final UserSession userSession; diff --git a/server/sonar-server/src/main/java/org/sonar/server/util/ObjectUtils.java b/server/sonar-server/src/main/java/org/sonar/server/util/ObjectUtils.java index 09b57e70df2..f5f7542b314 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/util/ObjectUtils.java +++ b/server/sonar-server/src/main/java/org/sonar/server/util/ObjectUtils.java @@ -21,9 +21,13 @@ package org.sonar.server.util; public class ObjectUtils { + private ObjectUtils() { + // static utility methods only + } /** * Taken from http://commons.apache.org/proper/commons-lang/javadocs/api-3.1/src-html/org/apache/commons/lang3/ObjectUtils.html#line.119 + * *

Returns the first value in the array which is not {@code null}. * If all the values are {@code null} or the array is {@code null} * or empty then {@code null} is returned.

diff --git a/sonar-batch/src/main/java/org/sonar/batch/repository/DefaultProjectRepositoriesLoader.java b/sonar-batch/src/main/java/org/sonar/batch/repository/DefaultProjectRepositoriesLoader.java index add0f3d157e..ab0f960c6a1 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/repository/DefaultProjectRepositoriesLoader.java +++ b/sonar-batch/src/main/java/org/sonar/batch/repository/DefaultProjectRepositoriesLoader.java @@ -21,8 +21,8 @@ package org.sonar.batch.repository; import javax.annotation.Nullable; import org.apache.commons.lang.mutable.MutableBoolean; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.sonar.api.utils.log.Logger; +import org.sonar.api.utils.log.Loggers; import org.sonar.batch.analysis.DefaultAnalysisMode; import org.sonar.batch.cache.WSLoader; import org.sonar.batch.cache.WSLoaderResult; @@ -32,7 +32,7 @@ import org.sonar.batch.util.BatchUtils; public class DefaultProjectRepositoriesLoader implements ProjectRepositoriesLoader { - private static final Logger LOG = LoggerFactory.getLogger(DefaultProjectRepositoriesLoader.class); + private static final Logger LOG = Loggers.get(DefaultProjectRepositoriesLoader.class); private static final String BATCH_PROJECT_URL = "/scanner/project"; private final WSLoader wsLoader; @@ -53,13 +53,12 @@ public class DefaultProjectRepositoriesLoader implements ProjectRepositoriesLoad } url += "&preview=" + analysisMode.isIssues(); - ProjectRepositories projectRepositories = load(url, fromCache); - return projectRepositories; + return load(url, fromCache); } private ProjectRepositories load(String resource, @Nullable MutableBoolean fromCache) { WSLoaderResult result = wsLoader.loadString(resource); - if(fromCache != null) { + if (fromCache != null) { fromCache.setValue(result.isFromCache()); } return ProjectRepositories.fromJson(result.get());