]> source.dussan.org Git - sonarqube.git/commitdiff
Revert "SONAR-16598 Populate Generic concepts from sonar-plugin api"
authorPierre <pierre.guillot@sonarsource.com>
Fri, 8 Jul 2022 12:20:28 +0000 (14:20 +0200)
committersonartech <sonartech@sonarsource.com>
Fri, 8 Jul 2022 20:02:47 +0000 (20:02 +0000)
This reverts commit 1d1feb6ab5dcf0d89f63ec0e1c67778f22da0978.

build.gradle
plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooRulesDefinition.java
server/sonar-webserver-core/src/main/java/org/sonar/server/rule/RegisterRules.java
server/sonar-webserver-core/src/test/java/org/sonar/server/rule/RegisterRulesTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/AddTagsActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/RemoveTagsActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SetTagsActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/rule/RuleTagHelperTest.java

index fd18ae77ed6a37e6230913feaa9183f2d6b9c8d7..d0d96d9824afcfdcfb8dc10b9606145108e59335 100644 (file)
@@ -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'
index 51ad8f121e11f57a10413aa22a8174fe4d3aed03..38ed2bad0bfad79d855635ae5569ade6db3d7d58 100644 (file)
@@ -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");
index b7324ab3a3ab04c44967e98b34587d03ef764e39..fc3463987b61d5fd93cb5ec6e0816d7b19099b46 100644 (file)
@@ -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<>();
index e42dc236273e68f7207edcad0989c641772de9b9..fb6fb316b6c6df8ec9abe04ed74d82a0edec7cfa 100644 (file)
@@ -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")
index e716d9b2e8ae5ff41ae631ab4edceabfdf2f7f0f..a7a75e6f2e07b7fb35ebe9de0a242681f38db728 100644 (file)
@@ -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, '+', '-', '#', '.'");
   }
 }
index 6c35531d6e4be023554449f1df530f6458e19db9..4a8d7573c6ba7d69752703289a10f612a81db69c 100644 (file)
@@ -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, '+', '-', '#', '.'");
   }
 }
index 9dfd0f41558e9e2f9bbb9ec9297fcdb01877f23b..b4585b5b519fe1bb64bf361d87be606960d1cbca 100644 (file)
@@ -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
index 77e12bf069b921252256481d708a0bc201c05013..ac40696249338d82f447c297199d0715b247f5e1 100644 (file)
@@ -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");
     }
   }