Simplify boolean condition
Extracting to a method the remaining inline conditional improves code
readability.
Change-Id: I0bdb6e4c5dbe88611c291521d08012a4f7e1cd16
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/base/its/ItsConfig.java b/src/main/java/com/googlesource/gerrit/plugins/its/base/its/ItsConfig.java
index 2f06f8b..de22f9c 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/base/its/ItsConfig.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/base/its/ItsConfig.java
@@ -98,17 +98,8 @@
projectNK.get());
return false;
}
-
- if (isEnforcedByAnyParentProject(refName, projectState)) {
- return true;
- }
-
- return !"false"
- .equals(
- pluginCfgFactory
- .getFromProjectConfigWithInheritance(projectState, pluginName)
- .getString("enabled", "false"))
- && isEnabledForBranch(projectState, refName);
+ return isEnforcedByAnyParentProject(refName, projectState)
+ || (isEnabledForProject(projectState) && isEnabledForBranch(projectState, refName));
}
private boolean isEnforcedByAnyParentProject(String refName, ProjectState projectState) {
@@ -122,6 +113,14 @@
return false;
}
+ private boolean isEnabledForProject(ProjectState projectState) {
+ return !"false"
+ .equals(
+ pluginCfgFactory
+ .getFromProjectConfigWithInheritance(projectState, pluginName)
+ .getString("enabled", "false"));
+ }
+
private boolean isEnabledForBranch(ProjectState project, String refName) {
String[] refPatterns =
pluginCfgFactory