From: simonbrandhof Date: Tue, 17 May 2011 06:40:32 +0000 (+0200) Subject: Sample: remove the quality profile and rule repository extensions X-Git-Tag: 2.8~8 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=095ff83bb255b37cd31d60a12e8716af196b9fa0;p=sonarqube.git Sample: remove the quality profile and rule repository extensions --- diff --git a/samples/standard-plugin/src/main/java/com/mycompany/sonar/standard/SamplePlugin.java b/samples/standard-plugin/src/main/java/com/mycompany/sonar/standard/SamplePlugin.java index f530e6b38b4..7622e032bd0 100644 --- a/samples/standard-plugin/src/main/java/com/mycompany/sonar/standard/SamplePlugin.java +++ b/samples/standard-plugin/src/main/java/com/mycompany/sonar/standard/SamplePlugin.java @@ -2,8 +2,6 @@ package com.mycompany.sonar.standard; import com.mycompany.sonar.standard.batch.RandomDecorator; import com.mycompany.sonar.standard.batch.SampleSensor; -import com.mycompany.sonar.standard.rules.SampleQualityProfile; -import com.mycompany.sonar.standard.rules.SampleRuleRepository; import com.mycompany.sonar.standard.ui.SampleFooter; import com.mycompany.sonar.standard.ui.SampleRubyWidget; import org.sonar.api.SonarPlugin; @@ -20,7 +18,7 @@ public final class SamplePlugin extends SonarPlugin { public List getExtensions() { return Arrays.asList( // Definitions - SampleRuleRepository.class, SampleMetrics.class, SampleQualityProfile.class, + SampleMetrics.class, // Batch SampleSensor.class, RandomDecorator.class, diff --git a/samples/standard-plugin/src/main/java/com/mycompany/sonar/standard/rules/SampleQualityProfile.java b/samples/standard-plugin/src/main/java/com/mycompany/sonar/standard/rules/SampleQualityProfile.java deleted file mode 100644 index ac6e981085b..00000000000 --- a/samples/standard-plugin/src/main/java/com/mycompany/sonar/standard/rules/SampleQualityProfile.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.mycompany.sonar.standard.rules; - -import org.sonar.api.profiles.ProfileDefinition; -import org.sonar.api.profiles.RulesProfile; -import org.sonar.api.resources.Java; -import org.sonar.api.rules.Rule; -import org.sonar.api.rules.RulePriority; -import org.sonar.api.utils.ValidationMessages; - -public class SampleQualityProfile extends ProfileDefinition { - - private SampleRuleRepository ruleRepository; - - // The component ruleRepository is injected at runtime - public SampleQualityProfile(SampleRuleRepository ruleRepository) { - this.ruleRepository = ruleRepository; - } - - @Override - public RulesProfile createProfile(ValidationMessages validation) { - RulesProfile profile = RulesProfile.create("Sample profile", Java.KEY); - profile.activateRule(ruleRepository.getRule1(), RulePriority.MAJOR); - profile.activateRule(ruleRepository.getRule2(), null); - profile.activateRule(Rule.create("checkstyle", "com.puppycrawl.tools.checkstyle.checks.coding.CovariantEqualsCheck", null), null); - return profile; - } -} diff --git a/samples/standard-plugin/src/main/java/com/mycompany/sonar/standard/rules/SampleRuleRepository.java b/samples/standard-plugin/src/main/java/com/mycompany/sonar/standard/rules/SampleRuleRepository.java deleted file mode 100644 index 4bd909a3b11..00000000000 --- a/samples/standard-plugin/src/main/java/com/mycompany/sonar/standard/rules/SampleRuleRepository.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.mycompany.sonar.standard.rules; - -import org.sonar.api.resources.Java; -import org.sonar.api.rules.Rule; -import org.sonar.api.rules.RulePriority; -import org.sonar.api.rules.RuleRepository; - -import java.util.Arrays; -import java.util.List; - -/** - * This class declares rules. It is not the engine used to execute rules during project analysis. - */ -public class SampleRuleRepository extends RuleRepository { - - public static final String REPOSITORY_KEY = "sample"; - - public SampleRuleRepository() { - super(REPOSITORY_KEY, Java.KEY); - setName("Sample"); - } - - @Override - public List createRules() { - // This method is called when server is started. It's used to register rules into database. - // Definition of rules can be loaded from any sources, like XML files. - return Arrays.asList( - getRule1(), - getRule2()); - } - - public Rule getRule1() { - return Rule.create(REPOSITORY_KEY, "fake1", "Fake one").setSeverity(RulePriority.CRITICAL); - } - - public Rule getRule2() { - return Rule.create(REPOSITORY_KEY, "fake2", "Fake two").setDescription("Description of fake two"); - } -}