diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2017-06-21 11:18:26 +0200 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2017-06-29 17:23:19 +0200 |
commit | a624a9cc04c37176e311c39cf250f5ff19e6cf42 (patch) | |
tree | 4c853fc820b5257f0f6069ab96c17602c6c63286 /tests/plugins/foo-plugin-v2/src | |
parent | e5eb765a319edacb43ab7cfa5714659deb1fcad0 (diff) | |
download | sonarqube-a624a9cc04c37176e311c39cf250f5ff19e6cf42.tar.gz sonarqube-a624a9cc04c37176e311c39cf250f5ff19e6cf42.zip |
SONAR-9442 Add details of added/updated/disabled rules in notification
Diffstat (limited to 'tests/plugins/foo-plugin-v2/src')
-rw-r--r-- | tests/plugins/foo-plugin-v2/src/main/java/org/sonar/foo/rule/FooBasicProfile.java | 27 | ||||
-rw-r--r-- | tests/plugins/foo-plugin-v2/src/main/java/org/sonar/foo/rule/FooRulesDefinition.java | 6 |
2 files changed, 29 insertions, 4 deletions
diff --git a/tests/plugins/foo-plugin-v2/src/main/java/org/sonar/foo/rule/FooBasicProfile.java b/tests/plugins/foo-plugin-v2/src/main/java/org/sonar/foo/rule/FooBasicProfile.java index 1c2d051f7cf..aceb76331e2 100644 --- a/tests/plugins/foo-plugin-v2/src/main/java/org/sonar/foo/rule/FooBasicProfile.java +++ b/tests/plugins/foo-plugin-v2/src/main/java/org/sonar/foo/rule/FooBasicProfile.java @@ -21,7 +21,9 @@ package org.sonar.foo.rule; import org.sonar.api.profiles.ProfileDefinition; import org.sonar.api.profiles.RulesProfile; -import org.sonar.api.rules.Rule; +import org.sonar.api.rules.ActiveRule; +import org.sonar.api.rules.RuleFinder; +import org.sonar.api.rules.RulePriority; import org.sonar.api.utils.ValidationMessages; import static org.sonar.api.rules.RulePriority.MAJOR; @@ -31,12 +33,29 @@ import static org.sonar.foo.rule.FooRulesDefinition.FOO_REPOSITORY; public class FooBasicProfile extends ProfileDefinition { + private final RuleFinder ruleFinder; + + public FooBasicProfile(RuleFinder ruleFinder) { + this.ruleFinder = ruleFinder; + } + @Override public RulesProfile createProfile(ValidationMessages validation) { final RulesProfile profile = RulesProfile.create("Basic", KEY); - profile.activateRule(Rule.create(FOO_REPOSITORY, "UnchangedRule"), MAJOR); - profile.activateRule(Rule.create(FOO_REPOSITORY, "ChangedRule"), MINOR); - profile.activateRule(Rule.create(FOO_REPOSITORY, "NewRule"), MAJOR); + activateRule(profile, FOO_REPOSITORY, "UnchangedRule", MAJOR); + activateRule(profile, FOO_REPOSITORY, "ChangedRule", MINOR); + activateRule(profile, FOO_REPOSITORY, "NewRule", MAJOR); + activateRule(profile, FOO_REPOSITORY, "RuleWithUnchangedParameter", MAJOR); + // Update of the default value of a parameter is not taken into account in quality profile as long as it's not also explicitly set in the quality profile + // TODO Remove the parameter value when SONAR_9475 will be fixed + activateRule(profile, FOO_REPOSITORY, "RuleWithChangedParameter", MAJOR).setParameter("toBeChanged", "20"); + activateRule(profile, FOO_REPOSITORY, "RuleWithRemovedParameter", MAJOR); + activateRule(profile, FOO_REPOSITORY, "RuleWithAddedParameter", MAJOR); return profile; } + + private ActiveRule activateRule(RulesProfile profile, String repo, String key, RulePriority severity) { + return profile.activateRule(ruleFinder.findByKey(repo, key), severity); + } + } diff --git a/tests/plugins/foo-plugin-v2/src/main/java/org/sonar/foo/rule/FooRulesDefinition.java b/tests/plugins/foo-plugin-v2/src/main/java/org/sonar/foo/rule/FooRulesDefinition.java index aacc2335262..a0ef0ccbdf7 100644 --- a/tests/plugins/foo-plugin-v2/src/main/java/org/sonar/foo/rule/FooRulesDefinition.java +++ b/tests/plugins/foo-plugin-v2/src/main/java/org/sonar/foo/rule/FooRulesDefinition.java @@ -36,6 +36,12 @@ public class FooRulesDefinition implements RulesDefinition { createRule(repo, "UnchangedRule"); createRule(repo, "ChangedRule"); createRule(repo, "NewRule"); + createRule(repo, "ToBeDeactivatedRule"); + createRule(repo, "RuleWithUnchangedParameter").createParam("unchanged").setDefaultValue("10"); + // Update of the default value of a parameter is not taken into account in quality profile as long as it's not also explicitly set in the quality profile + createRule(repo, "RuleWithChangedParameter").createParam("toBeChanged").setDefaultValue("20"); + createRule(repo, "RuleWithRemovedParameter"); + createRule(repo, "RuleWithAddedParameter").createParam("added").setDefaultValue("10"); repo.done(); } |