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;
public List getExtensions() {
return Arrays.asList(
// Definitions
- SampleRuleRepository.class, SampleMetrics.class, SampleQualityProfile.class,
+ SampleMetrics.class,
// Batch
SampleSensor.class, RandomDecorator.class,
+++ /dev/null
-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;
- }
-}
+++ /dev/null
-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");
- }
-}