svn commit: r1858350 - in /ofbiz/ofbiz-plugins/trunk: pricat/src/main/java/org/apache/ofbiz/pricat/AbstractPricatParser.java pricat/src/main/java/org/apache/ofbiz/pricat/sample/SamplePricatParser.java solr/src/main/java/org/apache/ofbiz/solr/SolrUtil.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1858350 - in /ofbiz/ofbiz-plugins/trunk: pricat/src/main/java/org/apache/ofbiz/pricat/AbstractPricatParser.java pricat/src/main/java/org/apache/ofbiz/pricat/sample/SamplePricatParser.java solr/src/main/java/org/apache/ofbiz/solr/SolrUtil.java

jleroux@apache.org
Author: jleroux
Date: Mon Apr 29 09:09:20 2019
New Revision: 1858350

URL: http://svn.apache.org/viewvc?rev=1858350&view=rev
Log:
Improved: Refactor boolean returns from methods
(OFBIZ-10725)

I was wondering if we should close. I just had a look and using this regexp:

if \(.*\) \{\R.*return true;

 I found
* 60 matches in applications
* 138 in framework
* 4 in plugins
I only checked the 1st two in applications and they really match

While at it this improves 3 of the 4 in plugins (the other is in a loop)

Modified:
    ofbiz/ofbiz-plugins/trunk/pricat/src/main/java/org/apache/ofbiz/pricat/AbstractPricatParser.java
    ofbiz/ofbiz-plugins/trunk/pricat/src/main/java/org/apache/ofbiz/pricat/sample/SamplePricatParser.java
    ofbiz/ofbiz-plugins/trunk/solr/src/main/java/org/apache/ofbiz/solr/SolrUtil.java

Modified: ofbiz/ofbiz-plugins/trunk/pricat/src/main/java/org/apache/ofbiz/pricat/AbstractPricatParser.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/pricat/src/main/java/org/apache/ofbiz/pricat/AbstractPricatParser.java?rev=1858350&r1=1858349&r2=1858350&view=diff
==============================================================================
--- ofbiz/ofbiz-plugins/trunk/pricat/src/main/java/org/apache/ofbiz/pricat/AbstractPricatParser.java (original)
+++ ofbiz/ofbiz-plugins/trunk/pricat/src/main/java/org/apache/ofbiz/pricat/AbstractPricatParser.java Mon Apr 29 09:09:20 2019
@@ -614,10 +614,8 @@ public abstract class AbstractPricatPars
             return false;
         }
         File file = FileUtil.getFile(tempFilesFolder + userLoginId + "/" + sequenceNum + ".xlsx");
-        if (file.exists()) {
-            return true;
-        }
-        return false;
+
+        return file.exists();
     }
 
     protected void cleanupLogAndCommentedExcel() {

Modified: ofbiz/ofbiz-plugins/trunk/pricat/src/main/java/org/apache/ofbiz/pricat/sample/SamplePricatParser.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/pricat/src/main/java/org/apache/ofbiz/pricat/sample/SamplePricatParser.java?rev=1858350&r1=1858349&r2=1858350&view=diff
==============================================================================
--- ofbiz/ofbiz-plugins/trunk/pricat/src/main/java/org/apache/ofbiz/pricat/sample/SamplePricatParser.java (original)
+++ ofbiz/ofbiz-plugins/trunk/pricat/src/main/java/org/apache/ofbiz/pricat/sample/SamplePricatParser.java Mon Apr 29 09:09:20 2019
@@ -346,20 +346,20 @@ public class SamplePricatParser extends
     public boolean isFacilityOk(XSSFRow row, String facilityName, String facilityId) {
         if (!facilities.containsKey(facilityId)) {
             if (UtilValidate.isEmpty(facilityId) && facilities.keySet().size() == 1) {
-                if (UtilValidate.isEmpty(facilityName)) {
-                    return true;
-                } else {
-                    String theFacilityId = (String) facilities.keySet().toArray()[0];
-                    String name = facilities.get(theFacilityId)[0];
-                    if (!name.equals(facilityName)) {
-                        String errorMessage = UtilProperties.getMessage(resource, "FacilityNameNotMatchId", new Object[]{theFacilityId, name, facilityName}, locale);
-                        report.println();
-                        report.print(errorMessage, InterfaceReport.FORMAT_ERROR);
-                        XSSFCell cell = row.getCell(0);
-                        errorMessages.put(new CellReference(cell), errorMessage);
-                        return false;
-                    }
+
+                return UtilValidate.isEmpty(facilityName);
+
+                String theFacilityId = (String) facilities.keySet().toArray()[0];
+                String name = facilities.get(theFacilityId)[0];
+                if (!name.equals(facilityName)) {
+                    String errorMessage = UtilProperties.getMessage(resource, "FacilityNameNotMatchId", new Object[]{theFacilityId, name, facilityName}, locale);
+                    report.println();
+                    report.print(errorMessage, InterfaceReport.FORMAT_ERROR);
+                    XSSFCell cell = row.getCell(0);
+                    errorMessages.put(new CellReference(cell), errorMessage);
+                    return false;
                 }
+
             } else {
                 String errorMessage = UtilProperties.getMessage(resource, "FacilityNotBelongToYou", new Object[]{facilityName, facilityId}, locale);
                 report.println();

Modified: ofbiz/ofbiz-plugins/trunk/solr/src/main/java/org/apache/ofbiz/solr/SolrUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/solr/src/main/java/org/apache/ofbiz/solr/SolrUtil.java?rev=1858350&r1=1858349&r2=1858350&view=diff
==============================================================================
--- ofbiz/ofbiz-plugins/trunk/solr/src/main/java/org/apache/ofbiz/solr/SolrUtil.java (original)
+++ ofbiz/ofbiz-plugins/trunk/solr/src/main/java/org/apache/ofbiz/solr/SolrUtil.java Mon Apr 29 09:09:20 2019
@@ -114,10 +114,7 @@ public final class SolrUtil {
     }
 
     private static boolean getTrustSelfSignedCert() {
-        if ("true".equals(trustSelfSignedCertString)) {
-            return true;
-        }
-        return false;
+        return "true".equals(trustSelfSignedCertString);
     }
 
     public static boolean isSolrEcaEnabled() {