You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by pa...@apache.org on 2020/07/30 11:33:18 UTC

[ofbiz-plugins] branch trunk updated: Improved: Inconsistent String Comparisons(OFBIZ-9254)

This is an automated email from the ASF dual-hosted git repository.

pawan pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-plugins.git


The following commit(s) were added to refs/heads/trunk by this push:
     new b7ef54d  Improved: Inconsistent String Comparisons(OFBIZ-9254)
b7ef54d is described below

commit b7ef54d494e0c05d9ea8e1a013df3690f60696a4
Author: Pawan Verma <pa...@hotwaxsystems.com>
AuthorDate: Thu Jul 30 17:02:52 2020 +0530

    Improved: Inconsistent String Comparisons(OFBIZ-9254)
    
    There are some inconsistencies in the code for string comparison statusId.equals(PRUN_COMPLETED) whereas it should be written as PRUN_COMPLETED.equals(statusId) cause the former can throw NullPointerException if the variable found to be NULL.
    
    Thanks: Devanshu for your contribution.
---
 birt/groovyScripts/order/CheckReportBy.groovy      | 24 +++++++++++-----------
 .../order/NetBeforeOverheadReport.groovy           |  4 ++--
 .../store/PrepareProductListing.groovy             |  2 +-
 ebaystore/groovyScripts/store/SoldAction.groovy    |  2 +-
 .../org/apache/ofbiz/ebaystore/EbayEvents.java     |  2 +-
 .../java/org/apache/ofbiz/ebaystore/EbayStore.java |  2 +-
 .../ofbiz/ebaystore/EbayStoreAutoPreferences.java  |  4 ++--
 scrum/groovyScripts/EditDailyHourReport.groovy     |  6 +++---
 scrum/groovyScripts/FindBacklogItem.groovy         | 14 ++++++-------
 .../ListScrumPreferenceSecurityGroup.groovy        |  4 ++--
 scrum/groovyScripts/ListUnplanBacklog.groovy       |  2 +-
 scrum/groovyScripts/QuickAddBacklog.groovy         |  2 +-
 scrum/groovyScripts/SprintBacklogListItems.groovy  |  2 +-
 13 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/birt/groovyScripts/order/CheckReportBy.groovy b/birt/groovyScripts/order/CheckReportBy.groovy
index fd6a040..cdb4cf1 100644
--- a/birt/groovyScripts/order/CheckReportBy.groovy
+++ b/birt/groovyScripts/order/CheckReportBy.groovy
@@ -27,12 +27,12 @@ if (!parameters.fromDate) {
     return "error"
 }
 
-if (exportType == "pdf") {
-    if (reportBy == "day") {
+if ("pdf" == exportType) {
+    if ("day" == reportBy) {
         return "dayPDF"
-    } else if (reportBy == "week") {
+    } else if ("week" == reportBy) {
         return "weekPDF"
-    } else if (reportBy == "month") {
+    } else if ("month" == reportBy) {
         return "monthPDF"
     } else {
         request.setAttribute("_ERROR_MESSAGE_", "Please select Report By.")
@@ -40,12 +40,12 @@ if (exportType == "pdf") {
     }
 }
 
-if (exportType == "excel") {
-    if (reportBy == "day") {
+if ("excel" == exportType) {
+    if ("day" == reportBy) {
         return "dayExcel"
-    } else if (reportBy == "week") {
+    } else if ("week" == reportBy) {
         return "weekExcel"
-    } else if (reportBy == "month") {
+    } else if ("month" == reportBy) {
         return "monthExcel"
     } else {
         request.setAttribute("_ERROR_MESSAGE_", "Please select Report By.")
@@ -53,12 +53,12 @@ if (exportType == "excel") {
     }
 }
 
-if (exportType == "html") {
-    if (reportBy == "day") {
+if ("html" == exportType) {
+    if ("day" == reportBy) {
         return "dayHTML"
-    } else if (reportBy == "week") {
+    } else if ("week" == reportBy) {
         return "weekHTML"
-    } else if (reportBy == "month") {
+    } else if ("month"== reportBy) {
         return "monthHTML"
     } else {
         request.setAttribute("_ERROR_MESSAGE_", "Please select Report By.")
diff --git a/birt/groovyScripts/order/NetBeforeOverheadReport.groovy b/birt/groovyScripts/order/NetBeforeOverheadReport.groovy
index 7b45b4f..3d41252 100644
--- a/birt/groovyScripts/order/NetBeforeOverheadReport.groovy
+++ b/birt/groovyScripts/order/NetBeforeOverheadReport.groovy
@@ -26,11 +26,11 @@ DateDay = DateStr.substring(0,10)
 DateMonth = DateStr.substring(5,7)
 DateYear = DateStr.substring(0,4)
 
-if (DateMonth == "01"||DateMonth == "03"||DateMonth == "05"||DateMonth == "07"||DateMonth == "08"||DateMonth == "10"||DateMonth == "12")
+if ("01" == DateMonth||"03" == DateMonth||"05" == DateMonth||"07" == DateMonth||"08" == DateMonth||"10" == DateMonth||"12" == DateMonth)
 {
     NunberDate = 31
 }
-else if (DateMonth == "02")
+else if ("02" == DateMonth)
 {
     NunberDate = 29
 }
diff --git a/ebaystore/groovyScripts/store/PrepareProductListing.groovy b/ebaystore/groovyScripts/store/PrepareProductListing.groovy
index c043733..aff905a 100644
--- a/ebaystore/groovyScripts/store/PrepareProductListing.groovy
+++ b/ebaystore/groovyScripts/store/PrepareProductListing.groovy
@@ -53,7 +53,7 @@
          content.product = product
          contents.add(content)
 
-         if (addItemMap.isVerify == "Y") {
+         if ("Y" == addItemMap.isVerify) {
              isExportValid = "true"
          } else {
              isExportValid = "false"
diff --git a/ebaystore/groovyScripts/store/SoldAction.groovy b/ebaystore/groovyScripts/store/SoldAction.groovy
index 942f376..a1766ad 100644
--- a/ebaystore/groovyScripts/store/SoldAction.groovy
+++ b/ebaystore/groovyScripts/store/SoldAction.groovy
@@ -22,7 +22,7 @@ import org.apache.ofbiz.base.util.*
 actionList = []
 hasAction = false
 //Unpaid Item Dispute
-if (unpaidItemStatus == null && paidTime == null && checkoutStatus != "CheckoutComplete") {
+if (unpaidItemStatus == null && paidTime == null && "CheckoutComplete" != checkoutStatus) {
     inMap = [:]
     inMap.put("action","openUnpaid")
     inMap.put("actionName","Open Unpaid")
diff --git a/ebaystore/src/main/java/org/apache/ofbiz/ebaystore/EbayEvents.java b/ebaystore/src/main/java/org/apache/ofbiz/ebaystore/EbayEvents.java
index 29133d4..add6d4d 100644
--- a/ebaystore/src/main/java/org/apache/ofbiz/ebaystore/EbayEvents.java
+++ b/ebaystore/src/main/java/org/apache/ofbiz/ebaystore/EbayEvents.java
@@ -869,7 +869,7 @@ public class EbayEvents {
                                 String facilityId = ebayProductStore.getString("facilityId");
                                 BigDecimal atp = ebayProductStore.getBigDecimal("availableToPromiseListing");
                                 int intAtp = atp.intValue();
-                                if ((facilityId != "")  && (intAtp != 0)) {
+                                if (("" != facilityId)  && (intAtp != 0)) {
                                     int newAtp = intAtp - 1;
                                     Map<String, Object> inMap = new HashMap<>();
                                     inMap.put("productStoreId", productStoreId);
diff --git a/ebaystore/src/main/java/org/apache/ofbiz/ebaystore/EbayStore.java b/ebaystore/src/main/java/org/apache/ofbiz/ebaystore/EbayStore.java
index 4449587..99800ab 100644
--- a/ebaystore/src/main/java/org/apache/ofbiz/ebaystore/EbayStore.java
+++ b/ebaystore/src/main/java/org/apache/ofbiz/ebaystore/EbayStore.java
@@ -1632,7 +1632,7 @@ public class EbayStore {
                 }
             }
             if (UtilValidate.isNotEmpty(ProductsExportToEbay.getProductExportSuccessMessageList())) {
-                if ((facilityId != "")  && (intAtp != 0)) {
+                if (("" != facilityId)  && (intAtp != 0)) {
                     int newAtp = intAtp - 1;
                     Map<String, Object> inMap = new HashMap<>();
                     inMap.put("productStoreId", context.get("productStoreId").toString());
diff --git a/ebaystore/src/main/java/org/apache/ofbiz/ebaystore/EbayStoreAutoPreferences.java b/ebaystore/src/main/java/org/apache/ofbiz/ebaystore/EbayStoreAutoPreferences.java
index 64ed121..c0b6658 100644
--- a/ebaystore/src/main/java/org/apache/ofbiz/ebaystore/EbayStoreAutoPreferences.java
+++ b/ebaystore/src/main/java/org/apache/ofbiz/ebaystore/EbayStoreAutoPreferences.java
@@ -570,7 +570,7 @@ public class EbayStoreAutoPreferences {
                     Date paidTime = (Date) item.get("paidTime");
                     String unpaidItemStatus = (String) item.get("unpaidItemStatus");
                     int checkDays = UtilDateTime.getIntervalInDays(UtilDateTime.toTimestamp(creationTime), UtilDateTime.nowTimestamp());
-                    if (checkDays > afterDays && "CheckoutIncomplete".equals(checkoutStatus) && unpaidItemStatus == null && paidTime == null && checkoutStatus != "CheckoutComplete") {
+                    if (checkDays > afterDays && "CheckoutIncomplete".equals(checkoutStatus) && unpaidItemStatus == null && paidTime == null && "CheckoutComplete" != checkoutStatus) {
                         itemsToDispute.add(item);
                     }
                 }
@@ -643,7 +643,7 @@ public class EbayStoreAutoPreferences {
                     Date paidTime = (Date) item.get("paidTime");
                     String unpaidItemStatus = (String) item.get("unpaidItemStatus");
                     int checkDays = UtilDateTime.getIntervalInDays(UtilDateTime.toTimestamp(creationTime), UtilDateTime.nowTimestamp());
-                    if (checkDays > afterDays && unpaidItemStatus == null && paidTime == null && checkoutStatus == "CheckoutComplete") {
+                    if (checkDays > afterDays && unpaidItemStatus == null && paidTime == null && "CheckoutComplete" == checkoutStatus) {
                         itemsToDispute.add(item);
                     }
                 }
diff --git a/scrum/groovyScripts/EditDailyHourReport.groovy b/scrum/groovyScripts/EditDailyHourReport.groovy
index 5c23f16..bf9b177 100644
--- a/scrum/groovyScripts/EditDailyHourReport.groovy
+++ b/scrum/groovyScripts/EditDailyHourReport.groovy
@@ -151,7 +151,7 @@ void retrieveWorkEffortData() {
         entry.acualTotal = taskTotal
         entry.planTotal = planTotal
         //Drop Down Lists
-        if (entry.checkComplete != "Y") {
+        if ("Y" != entry.checkComplete) {
             if (aHours > 0.00)
                 entries.add(entry)
         } else {
@@ -216,7 +216,7 @@ void retrieveEmplLeaveData() {
                 leaveEntry.plannedHours = result.hours
                 leaveEntry.planHours =  result.hours
             }
-            if (lastEmplLeaveEntry.leaveStatus == "LEAVE_APPROVED") {
+            if ("LEAVE_APPROVED" == lastEmplLeaveEntry.leaveStatus) {
                 leaveEntry.checkComplete = "Y"
             }
             leaveEntry.partyId = lastEmplLeaveEntry.partyId
@@ -447,7 +447,7 @@ projectSprintBacklogAndTaskList.each { projectSprintBacklogAndTaskMap ->
 projectSprintBacklogAndTaskList = UtilMisc.sortMaps(projectSprintBacklogAndTaskList, ["-projectName","sprintName","-taskTypeId","custRequestId"])
 projectSprintBacklogAndTaskList.each { projectSprintBacklogAndTaskMap ->
 	blTypeId = projectSprintBacklogAndTaskMap.custRequestTypeId
-	if (blTypeId == "RF_PROD_BACKLOG"){
+	if ("RF_PROD_BACKLOG" == blTypeId){
 		taskList.add(0,projectSprintBacklogAndTaskMap)
 	}
 }
diff --git a/scrum/groovyScripts/FindBacklogItem.groovy b/scrum/groovyScripts/FindBacklogItem.groovy
index 7800458..871c43d 100644
--- a/scrum/groovyScripts/FindBacklogItem.groovy
+++ b/scrum/groovyScripts/FindBacklogItem.groovy
@@ -43,25 +43,25 @@ custRequestList.each { custRequestListMap ->
             taskId = taskBacklogMap.workEffortId
             
             task = from("WorkEffort").where("workEffortId", taskId).queryOne()
-            if (task.workEffortTypeId == "SCRUM_TASK_IMPL") {
+            if ("SCRUM_TASK_IMPL" == task.workEffortTypeId) {
                 countImplTask+=1
-                if ( task.currentStatusId == "STS_COMPLETED" || task.currentStatusId == "STS_CANCELLED") {
+                if ( "STS_COMPLETED" == task.currentStatusId || "STS_CANCELLED" == task.currentStatusId) {
                     countImplTaskComplete+=1
                 }
             }
-            else if (task.workEffortTypeId == "SCRUM_TASK_INST") {
+            else if ("SCRUM_TASK_INST" == task.workEffortTypeId) {
                 countInstallTask+=1
-                if ( task.currentStatusId == "STS_COMPLETED" || task.currentStatusId == "STS_CANCELLED") {
+                if ( "STS_COMPLETED" == task.currentStatusId || "STS_CANCELLED" == task.currentStatusId) {
                     countInstallTaskComplete+=1
                 }
             }
-            else if (task.workEffortTypeId == "SCRUM_TASK_ERROR") {
+            else if ("SCRUM_TASK_ERROR" == task.workEffortTypeId) {
                 countErrTask+=1
-                if ( task.currentStatusId == "STS_COMPLETED" || task.currentStatusId == "STS_CANCELLED") {
+                if ( "STS_COMPLETED" == task.currentStatusId || "STS_CANCELLED" == task.currentStatusId) {
                     countErrTaskComplete+=1
                 }
             }
-            else if (task.workEffortTypeId == "SCRUM_TASK_TEST" || task.currentStatusId == "STS_CANCELLED") {
+            else if ("SCRUM_TASK_TEST" == task.workEffortTypeId || "STS_CANCELLED" == task.currentStatusId) {
                 countTestTask+=1
             }
         }
diff --git a/scrum/groovyScripts/ListScrumPreferenceSecurityGroup.groovy b/scrum/groovyScripts/ListScrumPreferenceSecurityGroup.groovy
index 7e82aca..9aed616 100644
--- a/scrum/groovyScripts/ListScrumPreferenceSecurityGroup.groovy
+++ b/scrum/groovyScripts/ListScrumPreferenceSecurityGroup.groovy
@@ -48,13 +48,13 @@ userPreferenceList = []
 userPreferenceOutList = []
 if (scrumUserLoginSecurityGroupList) {
     scrumUserLoginSecurityGroupList.each { scrumUserLoginSecurityGroupMap ->
-        if (scrumUserLoginSecurityGroupMap.groupId == "SCRUM_PRODUCT_OWNER") {
+        if ("SCRUM_PRODUCT_OWNER" == scrumUserLoginSecurityGroupMap.groupId) {
             ownerCond = []
             ownerCond.add(EntityCondition.makeCondition("enumTypeId", EntityOperator.EQUALS, "SCRUM_PREFERENCE"))
             ownerCond.add(EntityCondition.makeCondition("enumId", EntityOperator.NOT_EQUAL, "MASTER_NOTIFY"))
             ownerConds = EntityCondition.makeCondition(ownerCond, EntityOperator.AND)
             userPreferenceList = from("Enumeration").where(ownerConds).queryList()
-        } else if (scrumUserLoginSecurityGroupMap.groupId == "SCRUM_MASTER") {
+        } else if ("SCRUM_MASTER" == scrumUserLoginSecurityGroupMap.groupId) {
             masterCond = []
             masterCond.add(EntityCondition.makeCondition("enumTypeId", EntityOperator.EQUALS, "SCRUM_PREFERENCE"))
             masterCond.add(EntityCondition.makeCondition("enumId", EntityOperator.EQUALS, "MASTER_NOTIFY"))
diff --git a/scrum/groovyScripts/ListUnplanBacklog.groovy b/scrum/groovyScripts/ListUnplanBacklog.groovy
index b317b27..a9d61e9 100644
--- a/scrum/groovyScripts/ListUnplanBacklog.groovy
+++ b/scrum/groovyScripts/ListUnplanBacklog.groovy
@@ -24,7 +24,7 @@ taskStatusId = null
 paraBacklogStatusId = backlogStatusId
 
 orStsExprs = []
-    if (backlogStatusId != "Any") {
+    if ("Any" != backlogStatusId) {
         taskStatusId = "STS_CREATED"
         orStsExprs.add(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "CRQ_REVIEWED"))
     } else {
diff --git a/scrum/groovyScripts/QuickAddBacklog.groovy b/scrum/groovyScripts/QuickAddBacklog.groovy
index 34526d9..823c764 100644
--- a/scrum/groovyScripts/QuickAddBacklog.groovy
+++ b/scrum/groovyScripts/QuickAddBacklog.groovy
@@ -29,7 +29,7 @@ try{
                projectList = from("WorkEffortAndProduct").where("workEffortId", workEffortParentId).queryList()
                projectMap = projectList[0]
                // make sure that project dose not closed
-               if (projectMap.currentStatusId != "SPJ_CLOSED") {
+               if ("SPJ_CLOSED" != projectMap.currentStatusId) {
                    productMap = from("Product").where("productId", projectMap.productId).queryOne()
                    workEffortMap.productId = productMap.productId
                    workEffortMap.internalName = returnNameAsString(productMap.internalName,30)
diff --git a/scrum/groovyScripts/SprintBacklogListItems.groovy b/scrum/groovyScripts/SprintBacklogListItems.groovy
index e60ab21..c6fecdc 100644
--- a/scrum/groovyScripts/SprintBacklogListItems.groovy
+++ b/scrum/groovyScripts/SprintBacklogListItems.groovy
@@ -29,7 +29,7 @@ currentStatus = sprintStatus.currentStatusId
 if ("SPRINT_CLOSED".equals(currentStatus)) {
     backlogStatusId = null
 } else {
-    if (backlogStatusId == "Any") {
+    if ("Any" == backlogStatusId) {
         backlogStatusId = null
     } else {
         backlogStatusId = "CRQ_REVIEWED"