From 040cba63ba4af5bed76846f0edb63c853b009da9 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 16 Feb 2015 16:41:01 +0000
Subject: [PATCH] AutoRefactor: no assignment in if statement

---
 opendj-server-legacy/src/main/java/org/opends/server/config/JMXMBean.java                             |    4 
 opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/TargetAttr.java         |   15 ++--
 opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/UserAttr.java           |    8 +-
 opendj-server-legacy/src/main/java/org/opends/server/controls/GetEffectiveRightsRequestControl.java   |   11 +--
 opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/Permission.java         |    4 
 opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/ParentInheritance.java  |   11 ++-
 opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/TargAttrFilterList.java |   16 ++---
 opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/TargetAttrTestCase.java |   10 +-
 opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/PatternDN.java          |   16 ++--
 opendj-server-legacy/src/main/java/org/opends/server/schema/AttributeTypeSyntax.java                  |    4 
 opendj-server-legacy/src/main/java/org/opends/server/types/DN.java                                    |   32 +++++-----
 opendj-server-legacy/src/main/java/org/opends/admin/ads/ADSContext.java                               |    8 +-
 opendj-server-legacy/src/main/java/org/opends/server/extensions/SASLContext.java                      |    3 
 opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciListenerManager.java |    8 +-
 14 files changed, 73 insertions(+), 77 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/admin/ads/ADSContext.java b/opendj-server-legacy/src/main/java/org/opends/admin/ads/ADSContext.java
index 1592a1f..83fd2f6 100644
--- a/opendj-server-legacy/src/main/java/org/opends/admin/ads/ADSContext.java
+++ b/opendj-server-legacy/src/main/java/org/opends/admin/ads/ADSContext.java
@@ -1552,9 +1552,9 @@
    */
   private static LdapName makeDNFromServerProperties(
       Map<ServerProperty, Object> serverProperties) throws ADSContextException
-      {
-    String serverID ;
-    if ( (serverID = getServerID(serverProperties)) != null )
+  {
+    String serverID = getServerID(serverProperties) ;
+    if (serverID != null)
     {
       return makeDNFromServerUniqueId(serverID);
     }
@@ -1570,7 +1570,7 @@
       ServerDescriptor s = ServerDescriptor.createStandalone(serverProperties);
       return makeDNFromServerUniqueId(s.getHostPort(true));
     }
-      }
+  }
 
   /**
    * This method returns the DN of the entry that corresponds to the given
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciListenerManager.java b/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciListenerManager.java
index e0214aa..dd8030e 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciListenerManager.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciListenerManager.java
@@ -243,11 +243,9 @@
     private void doPostAdd(Entry addedEntry)
     {
       // This entry might have both global and aci attribute types.
-      boolean hasAci, hasGlobalAci = false;
-      if ((hasAci = addedEntry
-          .hasOperationalAttribute(AciHandler.aciType))
-          || (hasGlobalAci = addedEntry
-              .hasAttribute(AciHandler.globalAciType)))
+      boolean hasAci = addedEntry.hasOperationalAttribute(AciHandler.aciType);
+      boolean hasGlobalAci = addedEntry.hasAttribute(AciHandler.globalAciType);
+      if (hasAci || hasGlobalAci)
       {
         // Ignore this list, the ACI syntax has already passed and it
         // should be empty.
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/ParentInheritance.java b/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/ParentInheritance.java
index 4604514..99f5915 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/ParentInheritance.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/ParentInheritance.java
@@ -226,11 +226,12 @@
      * @return The attribute type.
      */
     public AttributeType getAttributeType() {
-      AttributeType attrType;
-      if((attrType =
-           DirectoryServer.getAttributeType(attrTypeStr.toLowerCase())) == null)
-        attrType=
-             DirectoryServer.getDefaultAttributeType(attrTypeStr.toLowerCase());
+      final String attrName = attrTypeStr.toLowerCase();
+      AttributeType attrType = DirectoryServer.getAttributeType(attrName);
+      if(attrType == null)
+      {
+        attrType = DirectoryServer.getDefaultAttributeType(attrName);
+      }
       return attrType;
     }
 
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/PatternDN.java b/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/PatternDN.java
index 4f8c9b1..583db64 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/PatternDN.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/PatternDN.java
@@ -995,8 +995,8 @@
 
       int namePos = 0;
       int nameLength = attributeName.length();
-      char ch = attributeName.charAt(0);
-      if ((ch == 'o') || (ch == 'O'))
+      char ch0 = attributeName.charAt(0);
+      if (ch0 == 'o' || ch0 == 'O')
       {
         if (nameLength <= 4)
         {
@@ -1004,11 +1004,11 @@
         }
         else
         {
-          if ((((ch = attributeName.charAt(1)) == 'i') ||
-               (ch == 'I')) &&
-              (((ch = attributeName.charAt(2)) == 'd') ||
-               (ch == 'D')) &&
-              (attributeName.charAt(3) == '.'))
+          char ch1 = attributeName.charAt(1);
+          char ch2 = attributeName.charAt(2);
+          if ((ch1 == 'i' || ch1 == 'I')
+              && (ch2 == 'd' || ch2 == 'D')
+              && attributeName.charAt(3) == '.')
           {
             attributeName.delete(0, 4);
             nameLength -= 4;
@@ -1022,7 +1022,7 @@
 
       while (validOID && (namePos < nameLength))
       {
-        ch = attributeName.charAt(namePos++);
+        char ch = attributeName.charAt(namePos++);
         if (isDigit(ch))
         {
           while (validOID && (namePos < nameLength) &&
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/Permission.java b/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/Permission.java
index d7581af..d00dbb3 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/Permission.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/Permission.java
@@ -74,8 +74,8 @@
      */
     private Permission(String accessType, String rights)
     throws AciException {
-        if ((this.accessType =
-            EnumAccessType.decode(accessType)) == null){
+        this.accessType = EnumAccessType.decode(accessType);
+        if (this.accessType == null){
             LocalizableMessage message =
                 WARN_ACI_SYNTAX_INVALID_ACCESS_TYPE_VERSION.get(accessType);
             throw new AciException(message);
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/TargAttrFilterList.java b/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/TargAttrFilterList.java
index b76250a..c8e4915 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/TargAttrFilterList.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/TargAttrFilterList.java
@@ -131,16 +131,15 @@
             if (semicolon != -1)
                 attributeName=attributeName.substring(0, semicolon);
             String filterString=matcher.group(filterPos);
-            AttributeType attributeType;
-            if((attributeType =
-                    DirectoryServer.getAttributeType(attributeName)) == null)
-                attributeType =
-                        DirectoryServer.getDefaultAttributeType(attributeName);
+            AttributeType attrType = DirectoryServer.getAttributeType(attributeName);
+            if (attrType == null) {
+                attrType = DirectoryServer.getDefaultAttributeType(attributeName);
+            }
             SearchFilter filter;
             //Check if it is a valid filter and add it to the list map if ok.
             try {
                filter = SearchFilter.createFilterFromString(filterString);
-               attrFilterList.put(attributeType, filter);
+               attrFilterList.put(attrType, filter);
             } catch (DirectoryException ex) {
                 LocalizableMessage er=ex.getMessageObject();
                 LocalizableMessage message =
@@ -149,9 +148,8 @@
                 throw new AciException(message);
             }
             //Verify the filter components. This check assures that each
-            //attribute type in the filter matches the provided attribute
-            //type.
-            verifyFilterComponents(filter, attributeType);
+            //attribute type in the filter matches the provided attribute type.
+            verifyFilterComponents(filter, attrType);
         }
         return new TargAttrFilterList(mask, attrFilterList);
     }
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/TargetAttr.java b/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/TargetAttr.java
index 423ec0d..de8e5e7 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/TargetAttr.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/TargetAttr.java
@@ -150,15 +150,14 @@
                     throw new AciException(message);
                 }
             } else {
-                AttributeType attributeType;
-                if((attributeType =
-                        DirectoryServer.getAttributeType(attribute)) == null)
-                    attributeType =
-                            DirectoryServer.getDefaultAttributeType(attribute);
-                if(attributeType.isOperational())
-                    opAttributes.add(attributeType);
+                AttributeType attrType = DirectoryServer.getAttributeType(attribute);
+                if (attrType == null) {
+                    attrType = DirectoryServer.getDefaultAttributeType(attribute);
+                }
+                if(attrType.isOperational())
+                    opAttributes.add(attrType);
                 else
-                    attributes.add(attributeType);
+                    attributes.add(attrType);
             }
         }
     }
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/UserAttr.java b/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/UserAttr.java
index ca94f85..91c6abc 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/UserAttr.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/UserAttr.java
@@ -201,8 +201,8 @@
     private EnumEvalResult evalVAL(AciEvalContext evalCtx) {
         EnumEvalResult matched= EnumEvalResult.FALSE;
         boolean undefined=false;
-        AttributeType attrType;
-        if((attrType = DirectoryServer.getAttributeType(attrStr)) == null) {
+        AttributeType attrType = DirectoryServer.getAttributeType(attrStr);
+        if (attrType == null) {
             attrType = DirectoryServer.getDefaultAttributeType(attrStr);
         }
         final SearchRequest request = newSearchRequest(evalCtx.getClientDN(), SearchScope.BASE_OBJECT);
@@ -232,8 +232,8 @@
     private EnumEvalResult evalURL(AciEvalContext evalCtx) {
         EnumEvalResult matched= EnumEvalResult.FALSE;
         boolean undefined=false;
-        AttributeType attrType;
-        if((attrType = DirectoryServer.getAttributeType(attrStr)) == null) {
+        AttributeType attrType = DirectoryServer.getAttributeType(attrStr);
+        if (attrType == null) {
             attrType = DirectoryServer.getDefaultAttributeType(attrStr);
         }
         List<Attribute> attrs=evalCtx.getResourceEntry().getAttribute(attrType);
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/config/JMXMBean.java b/opendj-server-legacy/src/main/java/org/opends/server/config/JMXMBean.java
index c856235..50aa49d 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/config/JMXMBean.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/config/JMXMBean.java
@@ -577,12 +577,12 @@
 
 
     AttributeList attrList = new AttributeList(attributes.length);
-    Attribute attr;
     for (String name : attributes)
     {
       try
       {
-        if ((attr = getJmxAttribute(name)) != null)
+        Attribute attr = getJmxAttribute(name);
+        if (attr != null)
         {
           attrList.add(attr);
           continue;
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/controls/GetEffectiveRightsRequestControl.java b/opendj-server-legacy/src/main/java/org/opends/server/controls/GetEffectiveRightsRequestControl.java
index e1f23cf..8d77c7e 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/controls/GetEffectiveRightsRequestControl.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/controls/GetEffectiveRightsRequestControl.java
@@ -112,18 +112,17 @@
           }
           //There is an sequence containing an attribute list, try to decode it.
           if(reader.hasNextElement()) {
-            AttributeType attributeType;
             attrs = new LinkedList<AttributeType>();
             reader.readStartSequence();
             while(reader.hasNextElement()) {
               //Decode as an octet string.
               String attrStr = reader.readOctetStringAsString();
+              AttributeType attrType = DirectoryServer.getAttributeType(attrStr);
               //Get an attribute type for it and add to the list.
-              if((attributeType =
-                  DirectoryServer.getAttributeType(attrStr)) == null)
-                attributeType =
-                    DirectoryServer.getDefaultAttributeType(attrStr);
-              attrs.add(attributeType);
+              if (attrType == null) {
+                attrType = DirectoryServer.getDefaultAttributeType(attrStr);
+              }
+              attrs.add(attrType);
             }
             reader.readEndSequence();
           }
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/extensions/SASLContext.java b/opendj-server-legacy/src/main/java/org/opends/server/extensions/SASLContext.java
index 595b1d5..6172058 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/extensions/SASLContext.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/extensions/SASLContext.java
@@ -724,7 +724,8 @@
       {
         try
         {
-          if ((authzEntry = DirectoryServer.getEntry(authzDN)) == null)
+          authzEntry = DirectoryServer.getEntry(authzDN);
+          if (authzEntry == null)
           {
             setCallbackMsg(ERR_SASL_AUTHZID_NO_SUCH_ENTRY.get(authzDN));
             callback.setAuthorized(false);
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/AttributeTypeSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/AttributeTypeSyntax.java
index ce735cf..bfaa102 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/AttributeTypeSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/AttributeTypeSyntax.java
@@ -711,8 +711,8 @@
             if (c == '}')
             {
               // The next character must be a space or a closing parenthesis.
-              if ((c = lowerStr.charAt(pos)) != ' '
-                      &&  (c = lowerStr.charAt(pos)) != ')')
+              c = lowerStr.charAt(pos);
+              if (c != ' ' && c != ')')
               {
                 LocalizableMessage message =
                   ERR_ATTR_SYNTAX_ATTRTYPE_ILLEGAL_CHAR_IN_NUMERIC_OID.get(valueStr, c, pos - 1);
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/types/DN.java b/opendj-server-legacy/src/main/java/org/opends/server/types/DN.java
index 269e2a1..a97afc5 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/types/DN.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/types/DN.java
@@ -1525,8 +1525,8 @@
 
       int namePos = 0;
       int nameLength = nameBytes.length();
-      byte ch = nameBytes.byteAt(0);
-      if ((ch == 'o') || (ch == 'O'))
+      byte ch0 = nameBytes.byteAt(0);
+      if (ch0 == 'o' || ch0 == 'O')
       {
         if (nameLength <= 4)
         {
@@ -1534,11 +1534,11 @@
         }
         else
         {
-          if ((((ch = nameBytes.byteAt(1)) == 'i') ||
-               (ch == 'I')) &&
-              (((ch = nameBytes.byteAt(2)) == 'd') ||
-               (ch == 'D')) &&
-              (nameBytes.byteAt(3) == '.'))
+          byte ch1 = nameBytes.byteAt(1);
+          byte ch2 = nameBytes.byteAt(1);
+          if ((ch1 == 'i' || ch1 == 'I')
+              && (ch2 == 'd' || ch2 == 'D')
+              && nameBytes.byteAt(3) == '.')
           {
             nameBytes = nameBytes.subSequence(4, nameBytes.length());
             nameLength -= 4;
@@ -1552,7 +1552,7 @@
 
       while (validOID && (namePos < nameLength))
       {
-        ch = nameBytes.byteAt(namePos++);
+        byte ch = nameBytes.byteAt(namePos++);
         if (isDigit((char)ch))
         {
           while (validOID && (namePos < nameLength) &&
@@ -1930,8 +1930,8 @@
 
       int namePos = 0;
       int nameLength = attributeName.length();
-      char ch = attributeName.charAt(0);
-      if ((ch == 'o') || (ch == 'O'))
+      char ch0 = attributeName.charAt(0);
+      if (ch0 == 'o' || ch0 == 'O')
       {
         if (nameLength <= 4)
         {
@@ -1939,11 +1939,11 @@
         }
         else
         {
-          if ((((ch = attributeName.charAt(1)) == 'i') ||
-               (ch == 'I')) &&
-              (((ch = attributeName.charAt(2)) == 'd') ||
-               (ch == 'D')) &&
-              (attributeName.charAt(3) == '.'))
+          char ch1 = attributeName.charAt(1);
+          char ch2 = attributeName.charAt(2);
+          if ((ch1 == 'i' || ch1 == 'I')
+              && (ch2 == 'd' || ch2 == 'D')
+              && attributeName.charAt(3) == '.')
           {
             attributeName.delete(0, 4);
             nameLength -= 4;
@@ -1957,7 +1957,7 @@
 
       while (validOID && (namePos < nameLength))
       {
-        ch = attributeName.charAt(namePos++);
+        char ch = attributeName.charAt(namePos++);
         if (isDigit(ch))
         {
           while (validOID && (namePos < nameLength) &&
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/TargetAttrTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/TargetAttrTestCase.java
index 9537313..325e012 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/TargetAttrTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/TargetAttrTestCase.java
@@ -411,11 +411,11 @@
   {
     EnumTargetOperator op = EnumTargetOperator.createOperator(eqOperator);
     TargetAttr targetAttr = TargetAttr.decode(op, targetAttrString);
-    AttributeType attributeType;
-    if((attributeType =
-          DirectoryServer.getAttributeType(attribute)) == null)
-      attributeType = DirectoryServer.getDefaultAttributeType(attribute);
-    Boolean res = TargetAttr.isApplicable(attributeType, targetAttr);
+    AttributeType attrType = DirectoryServer.getAttributeType(attribute);
+    if (attrType == null) {
+      attrType = DirectoryServer.getDefaultAttributeType(attribute);
+    }
+    Boolean res = TargetAttr.isApplicable(attrType, targetAttr);
     Assert.assertEquals(res, expectedResult);
   }
 }

--
Gitblit v1.10.0