Skip to content

Commit

Permalink
JENKINS-64365: Resolve review comments 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Hofmann-Sobik committed Dec 10, 2020
1 parent c358019 commit 898615b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -91,7 +92,7 @@ public String getServerURL() {

@DataBoundSetter
public void setServerURL(String serverURL) {
this.serverURL = MoreObjects.firstNonNull(Util.fixEmptyAndTrim(serverURL), DescriptorImpl.SONAR_URL);
this.serverURL = Optional.ofNullable(serverURL).map(Util::fixEmptyAndTrim).orElse(DescriptorImpl.SONAR_URL);
}

public SubJobConfig getBaseConfig() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.jenkinsci.plugins.tokenmacro.TokenMacro;

import java.io.IOException;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
Expand All @@ -40,7 +41,7 @@ public class SonarConnector implements InspectionReportAdapter {

private static final Logger LOGGER = Logger.getLogger(SonarConnector.class.getName());

private static final int SECONDS_TO_WAIT = 15;
private static final Duration SECONDS_TO_WAIT = Duration.ofSeconds(15);

private final Run<?, ?> run;

Expand Down Expand Up @@ -91,7 +92,7 @@ private List<ReportInfo> fetchReportFromSonarQube(FilePath workspace) throws Int
StringCredentials credentials = sonarInstallation.getCredentials(run);

TaskListenerLogger.logMessage(listener, LOGGER, Level.FINE, "jenkins.plugin.sonar.issues.wait", SECONDS_TO_WAIT);
Thread.sleep(SECONDS_TO_WAIT * 1000);
Thread.sleep(SECONDS_TO_WAIT.getSeconds() * 1000);

try (SonarClient sonarClient = new SonarClient(sonarInstallation, credentials, listener)) {
Report report = sonarClient.fetchIssues(
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jenkins.plugin.issues.to.score=Issues to be involved in score calculation: %s
jenkins.plugin.sonar.start=Starting Sonar to Gerrit Publisher with analysis type %s
jenkins.plugin.sonar.fetch=Fetch issues from %s
jenkins.plugin.sonar.report=Report has %s issues
jenkins.plugin.sonar.issues.wait=Processing can take some time, so wait %s seconds ...
jenkins.plugin.sonar.issues.wait=Processing can take some time, so wait %s ...

# default values
jenkins.plugin.default.review.body=<severity> SonarQube violation:\n\n\n<message>\n\n\nRead more: <rule_url>
Expand Down

0 comments on commit 898615b

Please sign in to comment.