premium-minds / sonar-postgres-plugin

Sonar plugin to analyze issues with Postgresql SQL scripts
MIT License
0 stars 0 forks source link

PLUGINAPI-5 deprecate support of markdown for rule descriptions #13

Open froque opened 1 year ago

froque commented 1 year ago
froque commented 8 months ago
❯ git diff                                                    
diff --git a/src/main/java/com/premiumminds/sonar/postgres/PostgresSqlRulesDefinition.java b/src/main/java/com/premiumminds/sonar/postgres/PostgresSqlRulesDefinition.java
index 422cbe4..0a35c50 100644
--- a/src/main/java/com/premiumminds/sonar/postgres/PostgresSqlRulesDefinition.java
+++ b/src/main/java/com/premiumminds/sonar/postgres/PostgresSqlRulesDefinition.java
@@ -28,8 +28,15 @@ import com.premiumminds.sonar.postgres.visitors.VisitorCheck;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.rule.Severity;
 import org.sonar.api.rules.RuleType;
+import org.sonar.api.server.rule.RuleDescriptionSection;
 import org.sonar.api.server.rule.RulesDefinition;

+import static org.sonar.api.server.rule.RuleDescriptionSection.RuleDescriptionSectionKeys.ASSESS_THE_PROBLEM_SECTION_KEY;
+import static org.sonar.api.server.rule.RuleDescriptionSection.RuleDescriptionSectionKeys.HOW_TO_FIX_SECTION_KEY;
+import static org.sonar.api.server.rule.RuleDescriptionSection.RuleDescriptionSectionKeys.INTRODUCTION_SECTION_KEY;
+import static org.sonar.api.server.rule.RuleDescriptionSection.RuleDescriptionSectionKeys.RESOURCES_SECTION_KEY;
+import static org.sonar.api.server.rule.RuleDescriptionSection.RuleDescriptionSectionKeys.ROOT_CAUSE_SECTION_KEY;
+
 public class PostgresSqlRulesDefinition implements RulesDefinition {

     public static final String REPOSITORY = "postgres-repository";
@@ -73,6 +80,26 @@ public class PostgresSqlRulesDefinition implements RulesDefinition {
         repository.createRule(RULE_PREFER_ROBUST_STMTS.rule())
                 .setName("prefer-robust-stmts rule")
                 .setType(RuleType.BUG)
+                .addDescriptionSection(RuleDescriptionSection.builder()
+                        .sectionKey(INTRODUCTION_SECTION_KEY)
+                        .htmlContent("INTRODUCTION_SECTION_KEY: Generates an issue when Postgres SQL is not valid and fails to parse 2")
+                        .build())
+                .addDescriptionSection(RuleDescriptionSection.builder()
+                        .sectionKey(ROOT_CAUSE_SECTION_KEY)
+                        .htmlContent("ROOT_CAUSE_SECTION_KEY: Generates an issue when Postgres SQL is not valid and fails to parse 2")
+                        .build())
+                .addDescriptionSection(RuleDescriptionSection.builder()
+                        .sectionKey(ASSESS_THE_PROBLEM_SECTION_KEY)
+                        .htmlContent("ASSESS_THE_PROBLEM_SECTION_KEY: Generates an issue when Postgres SQL is not valid and fails to parse 2")
+                        .build())
+                .addDescriptionSection(RuleDescriptionSection.builder()
+                        .sectionKey(HOW_TO_FIX_SECTION_KEY)
+                        .htmlContent("HOW_TO_FIX_SECTION_KEY: Generates an issue when Postgres SQL is not valid and fails to parse 2")
+                        .build())
+                .addDescriptionSection(RuleDescriptionSection.builder()
+                        .sectionKey(RESOURCES_SECTION_KEY)
+                        .htmlContent("RESOURCES_SECTION_KEY: Generates an issue when Postgres SQL is not valid and fails to parse 2")
+                        .build())
                 .setMarkdownDescription(getClass().getResource("prefer-robust-stmts.md"));

         repository.createRule(RULE_CONCURRENTLY.rule())

image

froque commented 8 months ago

Wait for more plugins to provide better examples.