Browse Source

SONAR-12181 Improve the error message when using sonar.branch.name on Community Edition

tags/7.8
Duarte Meneses 4 years ago
parent
commit
4c080d0e9e

+ 5
- 4
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorValidator.java View File

@@ -45,6 +45,7 @@ import static org.sonar.core.config.ScannerProperties.PULL_REQUEST_KEY;

/**
* This class aims at validating project reactor
*
* @since 3.6
*/
public class ProjectReactorValidator {
@@ -95,8 +96,8 @@ public class ProjectReactorValidator {
private void validateBranchParamsWhenPluginAbsent(List<String> validationMessages) {
for (String param : Arrays.asList(BRANCH_NAME, BRANCH_TARGET)) {
if (isNotEmpty(settings.get(param).orElse(null))) {
validationMessages.add(format("To use the property \"%s\", the branch plugin is required but not installed. "
+ "See the documentation of branch support: %s.", param, BRANCHES_DOC_LINK));
validationMessages.add(format("To use the property \"%s\" and analyze branches, Developer Edition or above is required. "
+ "See %s for more information.", param, BRANCHES_DOC_LINK));
}
}
}
@@ -104,8 +105,8 @@ public class ProjectReactorValidator {
private void validatePullRequestParamsWhenPluginAbsent(List<String> validationMessages) {
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\", the branch plugin is required but not installed. "
+ "See the documentation of branch support: %s.", param, BRANCHES_DOC_LINK)));
.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)));
}

private static void validateModuleIssuesMode(ProjectDefinition moduleDef, List<String> validationMessages) {

+ 5
- 5
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectReactorValidatorTest.java View File

@@ -149,7 +149,7 @@ public class ProjectReactorValidatorTest {
when(settings.get(eq(ScannerProperties.BRANCH_NAME))).thenReturn(Optional.of("feature1"));

thrown.expect(MessageException.class);
thrown.expectMessage("the branch plugin is required but not installed");
thrown.expectMessage("To use the property \"sonar.branch.name\" and analyze branches, Developer Edition or above is required");

underTest.validate(reactor);
}
@@ -162,7 +162,7 @@ public class ProjectReactorValidatorTest {
when(settings.get(eq(ScannerProperties.BRANCH_TARGET))).thenReturn(Optional.of("feature1"));

thrown.expect(MessageException.class);
thrown.expectMessage("the branch plugin is required but not installed");
thrown.expectMessage("To use the property \"sonar.branch.target\" and analyze branches, Developer Edition or above is required");

underTest.validate(reactor);
}
@@ -175,7 +175,7 @@ public class ProjectReactorValidatorTest {
when(settings.get(eq(ScannerProperties.PULL_REQUEST_KEY))).thenReturn(Optional.of("#1984"));

thrown.expect(MessageException.class);
thrown.expectMessage("the branch plugin is required but not installed");
thrown.expectMessage("To use the property \"sonar.pullrequest.key\" and analyze pull requests, Developer Edition or above is required");

underTest.validate(reactor);
}
@@ -188,7 +188,7 @@ public class ProjectReactorValidatorTest {
when(settings.get(eq(ScannerProperties.PULL_REQUEST_BRANCH))).thenReturn(Optional.of("feature1"));

thrown.expect(MessageException.class);
thrown.expectMessage("the branch plugin is required but not installed");
thrown.expectMessage("To use the property \"sonar.pullrequest.branch\" and analyze pull requests, Developer Edition or above is required");

underTest.validate(reactor);
}
@@ -201,7 +201,7 @@ public class ProjectReactorValidatorTest {
when(settings.get(eq(ScannerProperties.PULL_REQUEST_BASE))).thenReturn(Optional.of("feature1"));

thrown.expect(MessageException.class);
thrown.expectMessage("the branch plugin is required but not installed");
thrown.expectMessage("To use the property \"sonar.pullrequest.base\" and analyze pull requests, Developer Edition or above is required");

underTest.validate(reactor);
}

Loading…
Cancel
Save