From 3e47f8df06becff4f6936434f7211be8d0ef599b Mon Sep 17 00:00:00 2001 From: Anja Kleebaum Date: Thu, 28 Jun 2018 15:03:42 +0200 Subject: [PATCH] ConDec-71: Improve code quality --- .../jira/config/SettingsOfSingleProject.java | 10 ++++------ .../jira/persistence/ConfigPersistence.java | 10 ++-------- .../resources/js/controller/decdoc.rest.client.js | 2 +- src/main/resources/js/view/decdoc.accordion.editor.js | 4 ++-- src/main/resources/js/view/decdoc.context.menu.js | 11 ++++++----- src/main/resources/js/view/decdoc.treant.js | 2 +- 6 files changed, 16 insertions(+), 23 deletions(-) diff --git a/src/main/java/de/uhd/ifi/se/decision/documentation/jira/config/SettingsOfSingleProject.java b/src/main/java/de/uhd/ifi/se/decision/documentation/jira/config/SettingsOfSingleProject.java index 40ce8c0728..97b4102db6 100644 --- a/src/main/java/de/uhd/ifi/se/decision/documentation/jira/config/SettingsOfSingleProject.java +++ b/src/main/java/de/uhd/ifi/se/decision/documentation/jira/config/SettingsOfSingleProject.java @@ -20,7 +20,8 @@ import de.uhd.ifi.se.decision.documentation.jira.persistence.ConfigPersistence; /** - * @description Renders the administration page to change the plug-in configuration of a single project + * @description Renders the administration page to change the plug-in + * configuration of a single project */ public class SettingsOfSingleProject extends AbstractSettingsServlet { @@ -29,7 +30,7 @@ public class SettingsOfSingleProject extends AbstractSettingsServlet { @Inject public SettingsOfSingleProject(@ComponentImport UserManager userManager, - @ComponentImport LoginUriProvider loginUriProvider, @ComponentImport TemplateRenderer renderer) { + @ComponentImport LoginUriProvider loginUriProvider, @ComponentImport TemplateRenderer renderer) { super(userManager, loginUriProvider, renderer); } @@ -37,10 +38,7 @@ protected boolean isValidUser(HttpServletRequest request) { String projectKey = request.getParameter("projectKey"); String username = userManager.getRemoteUsername(request); - if (isProjectAdmin(username, projectKey)) { - return true; - } - return false; + return isProjectAdmin(username, projectKey); } private boolean isProjectAdmin(String username, String projectKey) { diff --git a/src/main/java/de/uhd/ifi/se/decision/documentation/jira/persistence/ConfigPersistence.java b/src/main/java/de/uhd/ifi/se/decision/documentation/jira/persistence/ConfigPersistence.java index d13d9b98ce..31e92df2b9 100644 --- a/src/main/java/de/uhd/ifi/se/decision/documentation/jira/persistence/ConfigPersistence.java +++ b/src/main/java/de/uhd/ifi/se/decision/documentation/jira/persistence/ConfigPersistence.java @@ -19,10 +19,7 @@ public Object doInTransaction() { return settings.get(pluginStorageKey + ".isIssueStrategy"); } }); - if (isIssueStrategy instanceof String && isIssueStrategy.equals("true")) { - return true; - } - return false; + return isIssueStrategy instanceof String && "true".equals(isIssueStrategy); } public static void setIssueStrategy(String projectKey, boolean isIssueStrategy) { @@ -37,10 +34,7 @@ public Object doInTransaction() { return settings.get(pluginStorageKey + ".isActivated"); } }); - if (isActivated instanceof String && isActivated.equals("true")) { - return true; - } - return false; + return isActivated instanceof String && "true".equals(isActivated); } public static void setActivated(String projectKey, boolean isActivated) { diff --git a/src/main/resources/js/controller/decdoc.rest.client.js b/src/main/resources/js/controller/decdoc.rest.client.js index 718382f209..5bab01be17 100644 --- a/src/main/resources/js/controller/decdoc.rest.client.js +++ b/src/main/resources/js/controller/decdoc.rest.client.js @@ -109,7 +109,7 @@ function getLinkedDecisionComponents(id, callback) { function getUnlinkedDecisionComponents(id, callback) { getJSON(AJS.contextPath() + "/rest/decisions/latest/decisions/getUnlinkedDecisionComponents.json?projectKey=" + getProjectKey() + "&id=" + id, function(error, unlinkedDecisionComponents) { - if (error == null) { + if (error === null) { callback(unlinkedDecisionComponents); } else { showFlag("error", diff --git a/src/main/resources/js/view/decdoc.accordion.editor.js b/src/main/resources/js/view/decdoc.accordion.editor.js index c7cd247080..8978dc7d60 100644 --- a/src/main/resources/js/view/decdoc.accordion.editor.js +++ b/src/main/resources/js/view/decdoc.accordion.editor.js @@ -61,7 +61,7 @@ function showDetailsOfChildren(parentId) { function showDetailsOfSingleChild(decisionKnowledgeElement) { var type = decisionKnowledgeElement.type; for (var i = 0; i < simpleKnowledgeTypes.length; i++) { - if (simpleKnowledgeTypes[i].toLocaleLowerCase() == type.toLocaleLowerCase()) { + if (simpleKnowledgeTypes[i].toLocaleLowerCase() === type.toLocaleLowerCase()) { document.getElementById(simpleKnowledgeTypes[i]).insertAdjacentHTML( 'beforeend', '