Skip to content

Commit

Permalink
JS-231 Deprecate the analyzer property sonar.nodejs.forceHost (#4823)
Browse files Browse the repository at this point in the history
  • Loading branch information
yassin-kammoun-sonarsource authored Sep 18, 2024
1 parent 0ad18cd commit 4a344fc
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,16 @@ private String locateNode(boolean isForceHost) throws IOException {
}

private static boolean isForceHost(Configuration configuration) {
return configuration.getBoolean(NODE_FORCE_HOST_PROPERTY).orElse(configuration.getBoolean(SKIP_NODE_PROVISIONING_PROPERTY).orElse(false));
var forceHost = configuration.getBoolean(NODE_FORCE_HOST_PROPERTY);
if (forceHost.isPresent()) {
LOG.warn(
"Property '{}' is deprecated and will be removed in a future version. Please use '{}' instead.",
NODE_FORCE_HOST_PROPERTY,
SKIP_NODE_PROVISIONING_PROPERTY
);
return forceHost.get();
}
return configuration.getBoolean(SKIP_NODE_PROVISIONING_PROPERTY).orElse(false);
}

private String locateNodeOnMac() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,25 @@ void test_skipping_nodejs_provisioning_property() throws Exception {
.contains("Forcing to use Node.js from the host.");
}

@Test
void test_node_force_host_property_deprecation() throws Exception {
var forceHostProp = "sonar.nodejs.forceHost";
var settings = new MapSettings();
settings.setProperty(forceHostProp, true);

builder()
.configuration(settings.asConfig())
.script("script.js")
.pathResolver(getPathResolver())
.build();

assertThat(logTester.logs(Level.WARN))
.contains(
"Property 'sonar.nodejs.forceHost' is deprecated and will be removed in a future version. " +
"Please use 'sonar.scanner.skipNodeProvisioning' instead."
);
}

private static String resourceScript(String script) throws URISyntaxException {
return new File(NodeCommandTest.class.getResource("/" + script).toURI()).getAbsolutePath();
}
Expand Down

0 comments on commit 4a344fc

Please sign in to comment.