]> source.dussan.org Git - sonarqube.git/commitdiff
Sample: remove the quality profile and rule repository extensions
authorsimonbrandhof <simon.brandhof@gmail.com>
Tue, 17 May 2011 06:40:32 +0000 (08:40 +0200)
committersimonbrandhof <simon.brandhof@gmail.com>
Tue, 17 May 2011 06:40:32 +0000 (08:40 +0200)
samples/standard-plugin/src/main/java/com/mycompany/sonar/standard/SamplePlugin.java
samples/standard-plugin/src/main/java/com/mycompany/sonar/standard/rules/SampleQualityProfile.java [deleted file]
samples/standard-plugin/src/main/java/com/mycompany/sonar/standard/rules/SampleRuleRepository.java [deleted file]

index f530e6b38b43bbc3d08d890931d42043b5454857..7622e032bd02d6226582d2fc7e5a6bcc41d59fa9 100644 (file)
@@ -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 (file)
index ac6e981..0000000
+++ /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 (file)
index 4bd909a..0000000
+++ /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<Rule> 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");
-  }
-}