From 4bf16089679b6bb48c9b812e60510fe0f55e48b0 Mon Sep 17 00:00:00 2001 From: Edwin Kempin Date: Wed, 7 Aug 2019 14:00:29 +0200 Subject: [PATCH] PrologRuleEvaluator: Remove unneeded check for closed changes PrologRuleEvaluator#evaluate() is only used from PrologRule#evaluate(ChangeData, SubmitRuleOptions) which implements the SubmitRule interface. SubmitRules are only invoked from SubmitRuleEvaluator. SubmitRuleEvaluator checks the change state and whether closed changes are allowed before invoking the submit rules. If closed changes are not allowed and the change is closed SubmitRuleEvaluator returns a submit record with status SubmitRecord.Status.CLOSED and the submit rules are not invoked. This means PrologRuleEvaluator#evaluate() doesn't need to the same check again as it is never invoked if this is the case. If this check would be needed all other implementations of SubmitRule would need to do the same, but none of them does. This is part of an effort to eliminate the passing of SubmitRuleOptions into the submit rules. The SubmitRuleOptions contain mostly Prolog-specific settings and are only used by the PrologRule. All other implementation of SubmitRule ignore the options, hence it would be cleaner to remove them from the SubmitRule interface. Signed-off-by: Edwin Kempin Change-Id: I453b575b6aaf22b335cd3d7fa89df662208abf3b --- .../com/google/gerrit/server/rules/PrologRuleEvaluator.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/java/com/google/gerrit/server/rules/PrologRuleEvaluator.java b/java/com/google/gerrit/server/rules/PrologRuleEvaluator.java index c036c86fc7..4fbde637b8 100644 --- a/java/com/google/gerrit/server/rules/PrologRuleEvaluator.java +++ b/java/com/google/gerrit/server/rules/PrologRuleEvaluator.java @@ -159,12 +159,6 @@ public class PrologRuleEvaluator { return ruleError("Error looking up change " + cd.getId(), e); } - if (!opts.allowClosed() && change.isClosed()) { - SubmitRecord rec = new SubmitRecord(); - rec.status = SubmitRecord.Status.CLOSED; - return Collections.singletonList(rec); - } - List results; try { results =