Skip to content

Commit

Permalink
Deprecate Node.js 12 support (#2927)
Browse files Browse the repository at this point in the history
  • Loading branch information
yassin-kammoun-sonarsource authored Jan 18, 2022
1 parent 41dfcde commit f8f44f0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public class NodeDeprecationWarning {

private static final Logger LOG = Loggers.get(NodeDeprecationWarning.class);
static final int MIN_NODE_VERSION = 10;
private static final int MIN_RECOMMENDED_NODE_VERSION = 12;
private static final List<Integer> SUPPORTED_NODE_VERSIONS = Arrays.asList(12, 14, 16);
private static final int MIN_RECOMMENDED_NODE_VERSION = 14;
private static final List<Integer> SUPPORTED_NODE_VERSIONS = Arrays.asList(14, 16);
private final AnalysisWarningsWrapper analysisWarnings;

public NodeDeprecationWarning(AnalysisWarningsWrapper analysisWarnings) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ key: javascript
## Prerequisites

In order to analyze JavaScript, TypeScript or CSS code, you need to have supported version of Node.js installed on the
machine running the scan. Supported versions are current LTS versions (v12, v14) and the latest version - v16. Odd
machine running the scan. Supported versions are previous LTS version v14 and the latest version - v16. Odd
(non LTS) versions might work, but are not actively tested. We recommend using the latest available LTS version
(v14 as of today) for optimal stability and performance. v10 is still supported, but it already reached end-of-life and
is deprecated.
(v16 as of today) for optimal stability and performance. v10 and v12 are still supported, but they already reached end-of-life and
are deprecated.

If `node` is not available in the PATH, you can use property `sonar.nodejs.executable` to set an absolute path to
Node.js executable.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@
import java.util.List;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.api.SonarEdition;
import org.sonar.api.SonarQubeSide;
import org.sonar.api.SonarRuntime;
import org.sonar.api.internal.SonarRuntimeImpl;
import org.sonar.api.utils.Version;
import org.sonar.api.utils.log.LogTesterJUnit5;
import org.sonar.api.utils.log.LoggerLevel;

Expand All @@ -37,7 +32,8 @@ public class NodeDeprecationWarningTest {

private static final String MSG = "You are using Node.js version 8, which reached end-of-life. Support for this version will be dropped in future release, please upgrade Node.js to more recent version.";
private static final String MSG_10 = "You are using Node.js version 10, which reached end-of-life. Support for this version will be dropped in future release, please upgrade Node.js to more recent version.";
private static final String UNSUPPORTED_MSG = "Node.js version 15 is not supported, you might experience issues. Please use a supported version of Node.js [12, 14, 16]";
private static final String MSG_12 = "You are using Node.js version 12, which reached end-of-life. Support for this version will be dropped in future release, please upgrade Node.js to more recent version.";
private static final String UNSUPPORTED_MSG = "Node.js version 15 is not supported, you might experience issues. Please use a supported version of Node.js [14, 16]";

@RegisterExtension
public final LogTesterJUnit5 logTester = new LogTesterJUnit5();
Expand All @@ -55,31 +51,39 @@ public void addUnique(String text) {
NodeDeprecationWarning deprecationWarning = new NodeDeprecationWarning(analysisWarnings);

@Test
public void test() {
void test() {
deprecationWarning.logNodeDeprecation(8);

assertThat(analysisWarnings.warnings).containsExactly(MSG);
assertThat(logTester.logs(LoggerLevel.WARN)).contains(MSG);
}

@Test
public void test_10() {
void test_10() {
deprecationWarning.logNodeDeprecation(10);

assertThat(analysisWarnings.warnings).containsExactly(MSG_10);
assertThat(logTester.logs(LoggerLevel.WARN)).contains(MSG_10);
}

@Test
public void test_good_version() {
void test_12() {
deprecationWarning.logNodeDeprecation(12);

assertThat(analysisWarnings.warnings).containsExactly(MSG_12);
assertThat(logTester.logs(LoggerLevel.WARN)).contains(MSG_12);
}

@Test
void test_good_version() {
deprecationWarning.logNodeDeprecation(14);

assertThat(analysisWarnings.warnings).isEmpty();
assertThat(logTester.logs(LoggerLevel.WARN)).isEmpty();
}

@Test
public void test_no_warnings() {
void test_no_warnings() {
// SonarLint doesn't provide AnalysisWarnings API
NodeDeprecationWarning deprecationWarning = new NodeDeprecationWarning(new AnalysisWarningsWrapper());
deprecationWarning.logNodeDeprecation(8);
Expand All @@ -88,7 +92,7 @@ public void test_no_warnings() {
}

@Test
public void test_unsupported_version() {
void test_unsupported_version() {
deprecationWarning.logNodeDeprecation(15);

assertThat(analysisWarnings.warnings).containsExactly(UNSUPPORTED_MSG);
Expand Down

0 comments on commit f8f44f0

Please sign in to comment.