From f58ba515a6fd5e30501e4f54e0d4e51fcd89b2ff Mon Sep 17 00:00:00 2001 From: Tibor Blenessy Date: Thu, 16 Feb 2023 17:32:14 +0100 Subject: [PATCH] Fix backwards incompatible change in SonarLint metadata file (#3712) --- .../plugins/javascript/utils/RulesMetadataForSonarLint.java | 3 +-- .../javascript/utils/RulesMetadataForSonarLintTest.java | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/sonar-javascript-plugin/src/main/java/org/sonar/plugins/javascript/utils/RulesMetadataForSonarLint.java b/sonar-javascript-plugin/src/main/java/org/sonar/plugins/javascript/utils/RulesMetadataForSonarLint.java index 97d3906cf1e..cb5eb8474fe 100644 --- a/sonar-javascript-plugin/src/main/java/org/sonar/plugins/javascript/utils/RulesMetadataForSonarLint.java +++ b/sonar-javascript-plugin/src/main/java/org/sonar/plugins/javascript/utils/RulesMetadataForSonarLint.java @@ -49,7 +49,6 @@ import org.sonar.plugins.javascript.JavaScriptLanguage; import org.sonar.plugins.javascript.JavaScriptProfilesDefinition; import org.sonar.plugins.javascript.api.EslintBasedCheck; -import org.sonar.plugins.javascript.api.JavaScriptCheck; import org.sonar.plugins.javascript.css.CssProfileDefinition; import org.sonar.plugins.javascript.css.CssRules; import org.sonar.plugins.javascript.css.CssRulesDefinition; @@ -175,7 +174,7 @@ static class Rule { private RuleStatus status = RuleStatus.defaultStatus(); private Set tags; private List params; - private List defaultParams; + private List defaultParams = Collections.emptyList(); private RuleScope scope; private String eslintKey; private boolean activatedByDefault; diff --git a/sonar-javascript-plugin/src/test/java/org/sonar/plugins/javascript/utils/RulesMetadataForSonarLintTest.java b/sonar-javascript-plugin/src/test/java/org/sonar/plugins/javascript/utils/RulesMetadataForSonarLintTest.java index f004ecfd170..fc5d6c6ae1e 100644 --- a/sonar-javascript-plugin/src/test/java/org/sonar/plugins/javascript/utils/RulesMetadataForSonarLintTest.java +++ b/sonar-javascript-plugin/src/test/java/org/sonar/plugins/javascript/utils/RulesMetadataForSonarLintTest.java @@ -32,12 +32,10 @@ import org.sonar.javascript.checks.StringLiteralsQuotesCheck; import org.sonar.plugins.javascript.JavaScriptProfilesDefinition; import org.sonar.plugins.javascript.css.CssProfileDefinition; -import org.sonar.plugins.javascript.css.CssRules; import org.sonar.plugins.javascript.css.CssRulesDefinition; import org.sonar.plugins.javascript.css.rules.AtRuleNoUnknown; import org.sonar.plugins.javascript.rules.JavaScriptRulesDefinition; -import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; class RulesMetadataForSonarLintTest { @@ -156,6 +154,8 @@ void test_all() throws Exception { .map(element -> element.getAsJsonObject().get("scope").getAsString()) .collect(Collectors.toSet()); assertThat(scopes).isEqualTo(Set.of("ALL", "MAIN", "TEST")); + + assertThat(jsonArray).extracting(j -> j.getAsJsonObject().get("defaultParams")).doesNotContainNull(); } }