From bfc11bdefa88f5a7efb0ae67d87d976655a7747b Mon Sep 17 00:00:00 2001 From: OrlovAlexander Date: Mon, 3 Jun 2024 10:55:32 +0200 Subject: [PATCH] SONAR-22224 Correctly Override Inherited rule --- .../sonar/server/qualityprofile/builtin/RuleActivator.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/builtin/RuleActivator.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/builtin/RuleActivator.java index f2f8db8ed15..325171b819e 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/builtin/RuleActivator.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/builtin/RuleActivator.java @@ -25,6 +25,7 @@ import java.util.Collection; import java.util.Date; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -191,7 +192,8 @@ public class RuleActivator { /** * Update severity, prioritizedRule and params */ - private void applySeverityAndPrioritizedRuleAndParamToChange(RuleActivation request, RuleActivationContext context, ActiveRuleChange change) { + private void applySeverityAndPrioritizedRuleAndParamToChange(RuleActivation request, RuleActivationContext context, + ActiveRuleChange change) { RuleWrapper rule = context.getRule(); ActiveRuleWrapper activeRule = context.getActiveRule(); ActiveRuleWrapper parentActiveRule = context.getParentActiveRule(); @@ -575,6 +577,9 @@ public class RuleActivator { if (!StringUtils.equals(change.getSeverity(), parentActiveRule.get().getSeverityString())) { return false; } + if (!(Objects.equals(change.isPrioritizedRule(), parentActiveRule.get().isPrioritizedRule()))) { + return false; + } for (Map.Entry entry : change.getParameters().entrySet()) { if (entry.getValue() != null && !entry.getValue().equals(parentActiveRule.getParamValue(entry.getKey()))) { return false; -- 2.39.5