aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre <pierre.guillot@sonarsource.com>2022-07-08 14:20:28 +0200
committersonartech <sonartech@sonarsource.com>2022-07-08 20:02:47 +0000
commitbcf7cdd7569465198d9d0252b6aedcfc51c83474 (patch)
treef276aedb97a28c731fa8ca62bf70ad10f06a636a
parent184bc0a3836db2cc3fd7ec312b15663db42a4923 (diff)
downloadsonarqube-bcf7cdd7569465198d9d0252b6aedcfc51c83474.tar.gz
sonarqube-bcf7cdd7569465198d9d0252b6aedcfc51c83474.zip
Revert "SONAR-16598 Populate Generic concepts from sonar-plugin api"
This reverts commit 1d1feb6ab5dcf0d89f63ec0e1c67778f22da0978.
-rw-r--r--build.gradle2
-rw-r--r--plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooRulesDefinition.java3
-rw-r--r--server/sonar-webserver-core/src/main/java/org/sonar/server/rule/RegisterRules.java16
-rw-r--r--server/sonar-webserver-core/src/test/java/org/sonar/server/rule/RegisterRulesTest.java21
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/AddTagsActionTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/RemoveTagsActionTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SetTagsActionTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/rule/RuleTagHelperTest.java2
8 files changed, 16 insertions, 34 deletions
diff --git a/build.gradle b/build.gradle
index fd18ae77ed6..d0d96d9824a 100644
--- a/build.gradle
+++ b/build.gradle
@@ -178,7 +178,7 @@ subprojects {
dependency 'org.sonarsource.kotlin:sonar-kotlin-plugin:2.9.0.1147'
dependency 'org.sonarsource.slang:sonar-ruby-plugin:1.9.0.3429'
dependency 'org.sonarsource.slang:sonar-scala-plugin:1.9.0.3429'
- dependency 'org.sonarsource.api.plugin:sonar-plugin-api:9.8.0.184'
+ dependency 'org.sonarsource.api.plugin:sonar-plugin-api:9.7.0.160'
dependency 'org.sonarsource.xml:sonar-xml-plugin:2.5.0.3376'
dependency 'org.sonarsource.iac:sonar-iac-plugin:1.7.0.2012'
dependency 'org.sonarsource.text:sonar-text-plugin:1.1.0.282'
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooRulesDefinition.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooRulesDefinition.java
index 51ad8f121e1..38ed2bad0bf 100644
--- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooRulesDefinition.java
+++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooRulesDefinition.java
@@ -118,8 +118,7 @@ public class XooRulesDefinition implements RulesDefinition {
addHowToFixSectionsWithContexts(oneIssuePerLine);
oneIssuePerLine
.setDebtRemediationFunction(oneIssuePerLine.debtRemediationFunctions().linear("1min"))
- .setGapDescription("It takes about 1 minute to an experienced software craftsman to remove a line of code")
- .addGenericConceptKeys("defense_in_depth", "least_trust_principle");
+ .setGapDescription("It takes about 1 minute to an experienced software craftsman to remove a line of code");
NewRule oneQuickFixPerLine = repo.createRule(OneQuickFixPerLineSensor.RULE_KEY).setName("One Quick Fix Per Line")
.setTags("line");
diff --git a/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/RegisterRules.java b/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/RegisterRules.java
index b7324ab3a3a..fc3463987b6 100644
--- a/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/RegisterRules.java
+++ b/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/RegisterRules.java
@@ -396,8 +396,7 @@ public class RegisterRules implements Startable {
.setIsExternal(ruleDef.repository().isExternal())
.setIsAdHoc(false)
.setCreatedAt(system2.now())
- .setUpdatedAt(system2.now())
- .setGenericConcepts(ruleDef.genericConceptKeys());
+ .setUpdatedAt(system2.now());
if (isNotEmpty(ruleDef.htmlDescription())) {
ruleDto.setDescriptionFormat(Format.HTML);
@@ -443,8 +442,7 @@ public class RegisterRules implements Startable {
boolean debtDefinitionsMerged = mergeDebtDefinitions(ruleDef, ruleDto);
boolean tagsMerged = mergeTags(ruleDef, ruleDto);
boolean securityStandardsMerged = mergeSecurityStandards(ruleDef, ruleDto);
- boolean genericConceptsMerged = mergeGenericConcepts(ruleDef, ruleDto);
- return ruleMerged || debtDefinitionsMerged || tagsMerged || securityStandardsMerged || genericConceptsMerged;
+ return ruleMerged || debtDefinitionsMerged || tagsMerged || securityStandardsMerged;
}
private boolean mergeRule(RulesDefinition.Rule def, RuleDto dto) {
@@ -683,16 +681,6 @@ public class RegisterRules implements Startable {
return changed;
}
- private static boolean mergeGenericConcepts(RulesDefinition.Rule ruleDef, RuleDto dto) {
- boolean changed = false;
- if (dto.getGenericConcepts().size() != ruleDef.genericConceptKeys().size() ||
- !dto.getGenericConcepts().containsAll(ruleDef.genericConceptKeys())) {
- dto.setGenericConcepts(ruleDef.genericConceptKeys());
- changed = true;
- }
- return changed;
- }
-
private void processRemainingDbRules(RegisterRulesContext recorder, DbSession dbSession) {
// custom rules check status of template, so they must be processed at the end
List<RuleDto> customRules = new ArrayList<>();
diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/RegisterRulesTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/RegisterRulesTest.java
index e42dc236273..fb6fb316b6c 100644
--- a/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/RegisterRulesTest.java
+++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/RegisterRulesTest.java
@@ -244,7 +244,6 @@ public class RegisterRulesTest {
assertThat(rule.getType()).isEqualTo(RuleType.CODE_SMELL.getDbConstant());
assertThat(rule.getPluginKey()).isEqualTo(FAKE_PLUGIN_KEY);
assertThat(rule.isAdHoc()).isFalse();
- assertThat(rule.getGenericConcepts()).containsOnly("concept1", "concept2", "concept3");
}
@Test
@@ -414,7 +413,6 @@ public class RegisterRulesTest {
assertThat(rule1.getType()).isEqualTo(RuleType.BUG.getDbConstant());
assertThat(rule1.getCreatedAt()).isEqualTo(DATE1.getTime());
assertThat(rule1.getUpdatedAt()).isEqualTo(DATE2.getTime());
- assertThat(rule1.getGenericConcepts()).containsOnly("concept1","concept4");
}
@Test
@@ -665,7 +663,7 @@ public class RegisterRulesTest {
@DataProvider
public static Object[][] allRenamingCases() {
- return new Object[][]{
+ return new Object[][] {
{"repo1", "rule1", "repo1", "rule2"},
{"repo1", "rule1", "repo2", "rule1"},
{"repo1", "rule1", "repo2", "rule2"},
@@ -746,10 +744,10 @@ public class RegisterRulesTest {
system.setNow(DATE1.getTime());
RuleDescriptionSection section1context1 = createRuleDescriptionSection(HOW_TO_FIX_SECTION_KEY, "section1 ctx1 content", "CTX_1");
- RuleDescriptionSection section1context2 = createRuleDescriptionSection(HOW_TO_FIX_SECTION_KEY, "section1 ctx2 content", "CTX_2");
- RuleDescriptionSection section2context1 = createRuleDescriptionSection(RESOURCES_SECTION_KEY, "section2 content", "CTX_1");
- RuleDescriptionSection section3noContext = createRuleDescriptionSection(ASSESS_THE_PROBLEM_SECTION_KEY, "section3 content", null);
- RuleDescriptionSection section4noContext = createRuleDescriptionSection(ROOT_CAUSE_SECTION_KEY, "section4 content", null);
+ RuleDescriptionSection section1context2 = createRuleDescriptionSection(HOW_TO_FIX_SECTION_KEY,"section1 ctx2 content", "CTX_2");
+ RuleDescriptionSection section2context1 = createRuleDescriptionSection(RESOURCES_SECTION_KEY,"section2 content", "CTX_1");
+ RuleDescriptionSection section3noContext = createRuleDescriptionSection(ASSESS_THE_PROBLEM_SECTION_KEY,"section3 content", null);
+ RuleDescriptionSection section4noContext = createRuleDescriptionSection(ROOT_CAUSE_SECTION_KEY,"section4 content", null);
execute(context -> {
NewRepository repo = context.createRepository("fake", "java");
repo.createRule("rule")
@@ -1204,8 +1202,7 @@ public class RegisterRulesTest {
.setScope(RuleScope.ALL)
.setType(RuleType.CODE_SMELL)
.setStatus(RuleStatus.BETA)
- .setGapDescription("java.S115.effortToFix")
- .addGenericConceptKeys("concept1", "concept2", "concept3");
+ .setGapDescription("java.S115.effortToFix");
rule1.setDebtRemediationFunction(rule1.debtRemediationFunctions().linearWithOffset("5d", "10h"));
rule1.createParam("param1").setDescription("parameter one").setDefaultValue("default1");
@@ -1243,8 +1240,7 @@ public class RegisterRulesTest {
.setTags("tag1", "tag4")
.setType(RuleType.BUG)
.setStatus(READY)
- .setGapDescription("java.S115.effortToFix.v2")
- .addGenericConceptKeys("concept1", "concept4");
+ .setGapDescription("java.S115.effortToFix.v2");
rule1.setDebtRemediationFunction(rule1.debtRemediationFunctions().linearWithOffset("6d", "2h"));
rule1.createParam("param1").setDescription("parameter one v2").setDefaultValue("default1 v2");
rule1.createParam("param2").setDescription("parameter two v2").setDefaultValue("default2 v2");
@@ -1283,8 +1279,7 @@ public class RegisterRulesTest {
.setTags("tag1", "tag2", "tag3")
.setScope(RuleScope.ALL)
.setType(RuleType.CODE_SMELL)
- .setStatus(RuleStatus.BETA)
- .addGenericConceptKeys("concept1", "concept2", "concept3");
+ .setStatus(RuleStatus.BETA);
repo.createRule(EXTERNAL_HOTSPOT_RULE_KEY.rule())
.setName("Hotspot")
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/AddTagsActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/AddTagsActionTest.java
index e716d9b2e8a..a7a75e6f2e0 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/AddTagsActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/AddTagsActionTest.java
@@ -67,6 +67,6 @@ public class AddTagsActionTest {
underTest.execute(properties, context);
})
.isInstanceOf(IllegalArgumentException.class)
- .hasMessage("Entry 'th ag' is invalid. Rule tags accept only the characters: a-z, 0-9, '+', '-', '#', '.'");
+ .hasMessage("Tag 'th ag' is invalid. Rule tags accept only the characters: a-z, 0-9, '+', '-', '#', '.'");
}
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/RemoveTagsActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/RemoveTagsActionTest.java
index 6c35531d6e4..4a8d7573c6b 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/RemoveTagsActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/RemoveTagsActionTest.java
@@ -67,6 +67,6 @@ public class RemoveTagsActionTest {
action.execute(properties, context);
})
.isInstanceOf(IllegalArgumentException.class)
- .hasMessage("Entry 'th ag' is invalid. Rule tags accept only the characters: a-z, 0-9, '+', '-', '#', '.'");
+ .hasMessage("Tag 'th ag' is invalid. Rule tags accept only the characters: a-z, 0-9, '+', '-', '#', '.'");
}
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SetTagsActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SetTagsActionTest.java
index 9dfd0f41558..b4585b5b519 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SetTagsActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SetTagsActionTest.java
@@ -175,7 +175,7 @@ public class SetTagsActionTest {
assertThatThrownBy(() -> call(issueDto.getKey(), "pol op"))
.isInstanceOf(IllegalArgumentException.class)
- .hasMessage("Entries 'pol op' are invalid. Rule tags accept only the characters: a-z, 0-9, '+', '-', '#', '.'");
+ .hasMessage("Tags 'pol op' are invalid. Rule tags accept only the characters: a-z, 0-9, '+', '-', '#', '.'");
}
@Test
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/rule/RuleTagHelperTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/rule/RuleTagHelperTest.java
index 77e12bf069b..ac406962493 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/rule/RuleTagHelperTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/rule/RuleTagHelperTest.java
@@ -65,7 +65,7 @@ public class RuleTagHelperTest {
RuleTagHelper.applyTags(rule, Sets.newHashSet("Java Eight"));
fail();
} catch (IllegalArgumentException e) {
- assertThat(e.getMessage()).startsWith("Entry 'Java Eight' is invalid");
+ assertThat(e.getMessage()).startsWith("Tag 'Java Eight' is invalid");
}
}