Skip to content

Commit

Permalink
Remove S2814 (no-redeclare) for TypeScript (#4098)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilia-kebets-sonarsource authored Aug 25, 2023
1 parent d8c8c2f commit 74a17ae
Show file tree
Hide file tree
Showing 12 changed files with 1 addition and 105 deletions.

This file was deleted.

10 changes: 0 additions & 10 deletions its/ruling/src/test/expected/ts/ag-grid/typescript-S2814.json

This file was deleted.

This file was deleted.

47 changes: 0 additions & 47 deletions its/ruling/src/test/expected/ts/eigen/typescript-S2814.json

This file was deleted.

This file was deleted.

11 changes: 0 additions & 11 deletions its/ruling/src/test/expected/ts/vuetify/typescript-S2814.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@
import org.sonar.check.Rule;
import org.sonar.plugins.javascript.api.EslintBasedCheck;
import org.sonar.plugins.javascript.api.JavaScriptRule;
import org.sonar.plugins.javascript.api.TypeScriptRule;

@JavaScriptRule
@TypeScriptRule
@Rule(key = "S2814")
public class RedeclaredSymbolCheck implements EslintBasedCheck {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"scope": "Main",
"quickfix": "unknown",
"compatibleLanguages": [
"JAVASCRIPT",
"TYPESCRIPT"
"JAVASCRIPT"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ private static void createProfile(
keys
.stream()
.filter(activeKeysForBothLanguages::contains)
// deprecated for Typescript: https://github.com/SonarSource/SonarJS/issues/3580
.filter(key -> !TypeScriptLanguage.KEY.equals(language) || !"S2814".equals(key))
.forEach(key -> newProfile.activateRule(repositoryKey, key));

addSecurityRules(newProfile, language);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

import java.util.Collections;
import org.sonar.api.SonarRuntime;
import org.sonar.api.rule.RuleStatus;
import org.sonar.api.server.rule.RulesDefinition;
import org.sonar.javascript.checks.CheckList;
import org.sonar.plugins.javascript.JavaScriptProfilesDefinition;
Expand Down Expand Up @@ -57,10 +56,6 @@ public void define(Context context) {
NewRule commentRegularExpression = repository.rule("S124");
commentRegularExpression.setTemplate(true);

// deprecated for Typescript: https://github.com/SonarSource/SonarJS/issues/3580
NewRule redeclaredSymbol = repository.rule("S2814");
redeclaredSymbol.setStatus(RuleStatus.DEPRECATED);

repository.done();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ void sonar_way_js() {
assertThat(profile.name()).isEqualTo(JavaScriptProfilesDefinition.SONAR_WAY);
assertThat(profile.rules()).extracting("repoKey").containsOnly(CheckList.JS_REPOSITORY_KEY);
assertThat(profile.rules().size()).isGreaterThan(100);
assertThat(profile.rules())
.extracting(BuiltInQualityProfilesDefinition.BuiltInActiveRule::ruleKey)
.contains("S2814");

assertThat(deprecatedRulesInProfile(profile, deprecatedJsRules)).isEmpty();
}
Expand Down Expand Up @@ -118,9 +115,6 @@ void sonar_way_ts() {
assertThat(profile.rules())
.extracting(BuiltInQualityProfilesDefinition.BuiltInActiveRule::ruleKey)
.contains("S5122");
assertThat(profile.rules())
.extracting(BuiltInQualityProfilesDefinition.BuiltInActiveRule::ruleKey)
.doesNotContain("S2814");

assertThat(deprecatedRulesInProfile(profile, deprecatedTsRules)).isEmpty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.junit.jupiter.api.Test;
import org.sonar.api.SonarRuntime;
import org.sonar.api.internal.SonarRuntimeImpl;
import org.sonar.api.rule.RuleStatus;
import org.sonar.api.rules.RuleType;
import org.sonar.api.server.debt.DebtRemediationFunction.Type;
import org.sonar.api.server.rule.RulesDefinition.Param;
Expand Down Expand Up @@ -142,7 +141,6 @@ private void assertRuleProperties(Repository repository) {
assertThat(rule.debtRemediationFunction().type()).isEqualTo(Type.CONSTANT_ISSUE);
assertThat(rule.type()).isEqualTo(RuleType.BUG);
assertThat(repository.rule("S124").template()).isTrue();
assertThat(repository.rule("S2814").status()).isEqualTo(RuleStatus.DEPRECATED);
}

private void assertAllRuleParametersHaveDescription(Repository repository) {
Expand Down

0 comments on commit 74a17ae

Please sign in to comment.