From 9e9c59ca9dd3c7faec5d5e44e7f42c78268d1b4f Mon Sep 17 00:00:00 2001 From: Markus Heberling Date: Wed, 12 Feb 2020 10:03:18 +0100 Subject: [PATCH] [GITLAB] don't fail, if no new coverage condition is provided Fixes #85 --- .../gitlab/GitlabServerPullRequestDecorator.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/gitlab/GitlabServerPullRequestDecorator.java b/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/gitlab/GitlabServerPullRequestDecorator.java index 2eadd60ac..84d1d4313 100644 --- a/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/gitlab/GitlabServerPullRequestDecorator.java +++ b/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/gitlab/GitlabServerPullRequestDecorator.java @@ -153,10 +153,10 @@ public void decorateQualityGateStatus(AnalysisDetails analysis, AlmSettingDto al } } - QualityGate.Condition newCoverageCondition = analysis.findQualityGateCondition(CoreMetrics.NEW_COVERAGE_KEY) - .orElseThrow(() -> new IllegalStateException("Could not find New Coverage Condition in analysis")); - String coverageValue = newCoverageCondition.getStatus().equals(QualityGate.EvaluationStatus.NO_VALUE) ? "0" : newCoverageCondition.getValue(); - + String coverageValue = analysis.findQualityGateCondition(CoreMetrics.NEW_COVERAGE_KEY) + .filter(condition -> condition.getStatus() != QualityGate.EvaluationStatus.NO_VALUE) + .map(QualityGate.Condition::getValue) + .orElse("0"); List openIssues = analysis.getPostAnalysisIssueVisitor().getIssues().stream().filter(i -> OPEN_ISSUE_STATUSES.contains(i.getIssue().getStatus())).collect(Collectors.toList());