aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine/src/main/java/org
diff options
context:
space:
mode:
authorAntoine Vinot <antoine.vinot@sonarsource.com>2023-05-31 14:08:29 +0200
committersonartech <sonartech@sonarsource.com>2023-05-31 20:02:50 +0000
commit977d49ebdcce0b576bd4f08fe93853c2e6a73721 (patch)
treebeaa9d30bdea485df3687136a7ee5cf1cd804984 /sonar-scanner-engine/src/main/java/org
parentb723c0ba6da5945178e24d28d3e2bdfc0e4d5a9b (diff)
downloadsonarqube-977d49ebdcce0b576bd4f08fe93853c2e6a73721.tar.gz
sonarqube-977d49ebdcce0b576bd4f08fe93853c2e6a73721.zip
SONAR-18213 - Make branches documentation link version sensitive in scanner logs
Diffstat (limited to 'sonar-scanner-engine/src/main/java/org')
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorValidator.java16
1 files changed, 10 insertions, 6 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorValidator.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorValidator.java
index b3d07425332..f9b24a60543 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorValidator.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorValidator.java
@@ -27,6 +27,7 @@ import org.sonar.api.batch.bootstrap.ProjectDefinition;
import org.sonar.api.batch.bootstrap.ProjectReactor;
import org.sonar.api.utils.MessageException;
import org.sonar.core.component.ComponentKeys;
+import org.sonar.core.documentation.DocumentationLinkGenerator;
import org.sonar.scanner.bootstrap.GlobalConfiguration;
import org.sonar.scanner.scan.branch.BranchParamsValidator;
import org.springframework.beans.factory.annotation.Autowired;
@@ -35,7 +36,7 @@ import static java.lang.String.format;
import static java.util.Objects.nonNull;
import static org.apache.commons.lang.StringUtils.isNotEmpty;
import static org.sonar.core.component.ComponentKeys.ALLOWED_CHARACTERS_MESSAGE;
-import static org.sonar.core.config.ScannerProperties.BRANCHES_DOC_LINK;
+import static org.sonar.core.config.ScannerProperties.BRANCHES_DOC_LINK_SUFFIX;
import static org.sonar.core.config.ScannerProperties.BRANCH_NAME;
import static org.sonar.core.config.ScannerProperties.PULL_REQUEST_BASE;
import static org.sonar.core.config.ScannerProperties.PULL_REQUEST_BRANCH;
@@ -53,15 +54,18 @@ public class ProjectReactorValidator {
@Nullable
private final BranchParamsValidator branchParamsValidator;
+ private final DocumentationLinkGenerator documentationLinkGenerator;
+
@Autowired(required = false)
- public ProjectReactorValidator(GlobalConfiguration settings, @Nullable BranchParamsValidator branchParamsValidator) {
+ public ProjectReactorValidator(GlobalConfiguration settings, @Nullable BranchParamsValidator branchParamsValidator, DocumentationLinkGenerator documentationLinkGenerator) {
this.settings = settings;
this.branchParamsValidator = branchParamsValidator;
+ this.documentationLinkGenerator = documentationLinkGenerator;
}
@Autowired(required = false)
- public ProjectReactorValidator(GlobalConfiguration settings) {
- this(settings, null);
+ public ProjectReactorValidator(GlobalConfiguration settings, DocumentationLinkGenerator documentationLinkGenerator) {
+ this(settings, null, documentationLinkGenerator);
}
public void validate(ProjectReactor reactor) {
@@ -87,7 +91,7 @@ public class ProjectReactorValidator {
private void validateBranchParamsWhenPluginAbsent(List<String> validationMessages) {
if (isNotEmpty(settings.get(BRANCH_NAME).orElse(null))) {
validationMessages.add(format("To use the property \"%s\" and analyze branches, Developer Edition or above is required. "
- + "See %s for more information.", BRANCH_NAME, BRANCHES_DOC_LINK));
+ + "See %s for more information.", BRANCH_NAME, documentationLinkGenerator.getDocumentationLink(BRANCHES_DOC_LINK_SUFFIX)));
}
}
@@ -95,7 +99,7 @@ public class ProjectReactorValidator {
Stream.of(PULL_REQUEST_KEY, PULL_REQUEST_BRANCH, PULL_REQUEST_BASE)
.filter(param -> nonNull(settings.get(param).orElse(null)))
.forEach(param -> validationMessages.add(format("To use the property \"%s\" and analyze pull requests, Developer Edition or above is required. "
- + "See %s for more information.", param, BRANCHES_DOC_LINK)));
+ + "See %s for more information.", param, documentationLinkGenerator.getDocumentationLink(BRANCHES_DOC_LINK_SUFFIX))));
}
private static void validateModule(ProjectDefinition projectDefinition, List<String> validationMessages) {