for (Integer unprocessedRuleId : buffer.unprocessedRuleIds) {
RuleDto ruleDto = buffer.rulesById.get(unprocessedRuleId);
boolean toBeRemoved = true;
- if (ruleDto.getParentId() != null && !ruleDto.getStatus().equals(Rule.STATUS_REMOVED)) {
+ // Update copy of template rules from template
+ if (ruleDto.getParentId() != null) {
RuleDto parent = buffer.rulesById.get(ruleDto.getParentId());
- if (parent != null) {
+ if (parent != null && !parent.getStatus().equals(Rule.STATUS_REMOVED)) {
// TODO merge params and tags ?
ruleDto.setLanguage(parent.getLanguage());
ruleDto.setStatus(parent.getStatus());
/**
* SONAR-4642
- *
+ * <p/>
* Remove active rules on repositories that still exists.
- *
+ * <p/>
* For instance, if the javascript repository do not provide anymore some rules, active rules related to this rules will be removed.
* But if the javascript repository do not exists anymore, then related active rules will not be removed.
- *
+ * <p/>
* The side effect of this approach is that extended repositories will not be managed the same way.
* If an extended repository do not exists anymore, then related active rules will be removed.
*/
private void removeActiveRulesOnStillExistingRepositories(List<RuleDto> removedRules, RuleDefinitions.Context context) {
List<String> repositoryKeys = newArrayList(Iterables.transform(context.repositories(), new Function<RuleDefinitions.Repository, String>() {
- @Override
- public String apply(RuleDefinitions.Repository input) {
- return input.key();
- }
+ @Override
+ public String apply(RuleDefinitions.Repository input) {
+ return input.key();
}
+ }
));
for (RuleDto rule : removedRules) {
}
@Test
- public void should_not_reactivate_disabled_template_rules() {
- setupData("should_not_reactivate_disabled_template_rules");
+ public void reactivate_disabled_template_rules() {
+ setupData("reactivate_disabled_template_rules");
task.start();
- checkTables("should_not_reactivate_disabled_template_rules", EXCLUDED_COLUMN_NAMES, "rules");
+ checkTables("reactivate_disabled_template_rules", EXCLUDED_COLUMN_NAMES, "rules");
}
@Test
--- /dev/null
+<dataset>
+
+ <rules id="1" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="config1" name="One" description="Description of One"
+ status="READY" priority="4" cardinality="SINGLE" parent_id="[null]" language="java"/>
+
+ <rules id="2" plugin_rule_key="user_rule" plugin_name="fake" plugin_config_key="[null]" name="User rule" description="[null]"
+ status="READY" priority="4" cardinality="SINGLE" parent_id="1" language="java"/>
+
+ <rules id="3" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="[null]" name="Two" description="Description of Two"
+ status="DEPRECATED" priority="0" cardinality="SINGLE" parent_id="[null]" language="java"/>
+
+</dataset>
--- /dev/null
+<dataset>
+
+ <rules id="1" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="config1" name="One" description="Description of One"
+ status="REMOVED" priority="4" cardinality="SINGLE" parent_id="[null]" language="java"/>
+
+ <rules id="2" plugin_rule_key="user_rule" plugin_name="fake" plugin_config_key="[null]" name="User rule" description="[null]"
+ status="REMOVED" priority="4" cardinality="SINGLE" parent_id="1" language="java"/>
+
+</dataset>
+++ /dev/null
-<dataset>
-
- <rules id="1" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="config1" name="One" description="Description of One"
- status="READY" priority="4" cardinality="SINGLE" parent_id="[null]" language="java"/>
-
- <rules id="2" plugin_rule_key="user_rule" plugin_name="fake" plugin_config_key="[null]" name="User rule" description="[null]"
- status="REMOVED" priority="4" cardinality="SINGLE" parent_id="1" language="java"/>
-
- <rules id="3" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="[null]" name="Two" description="Description of Two"
- status="DEPRECATED" priority="0" cardinality="SINGLE" parent_id="[null]" language="java"/>
-
-</dataset>
+++ /dev/null
-<dataset>
-
- <rules id="1" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="config1" name="One" description="Description of One"
- status="REMOVED" priority="4" cardinality="SINGLE" parent_id="[null]" language="java"/>
-
- <rules id="2" plugin_rule_key="user_rule" plugin_name="fake" plugin_config_key="[null]" name="User rule" description="[null]"
- status="REMOVED" priority="4" cardinality="SINGLE" parent_id="1" language="java"/>
-
-</dataset>