-
Type:
Bug
-
Status: Closed
-
Resolution: Fixed
-
Affects Version/s: 7.0.X EE, Master
-
Fix Version/s: 7.0.0 DXP FP23, 7.0.X EE, 7.0.4 CE GA5, 7.1.X, Master
-
Component/s: Sites Administration > Sites
-
Branch Version/s:7.0.x
-
Backported to Branch:Committed
-
Fix Priority:1
-
Git Pull Request:
Description
In the GroupLocalServiceImpl#doSearch method, there is a pointless conditional that is just wasting space and making the code harder to read.
This issue is not testable by QA
Explanation
At the beginning of the GroupLocalServiceImpl#doSearch method, we have the following code:
boolean parentGroupIdEquals = true; if (parentGroupId == GroupConstants.ANY_PARENT_GROUP_ID) { parentGroupIdEquals = false; }
Essentially, we're setting parentGroupIdEquals to false if parentGroupId is -1, and true otherwise. The parentGroupIdEquals variable never gets modified after this, nor does the parentGroupId variable, which is passed in as an argument, ever get modified.
Later on in the method, when filtering out groups by their parent group, we have the following code:
long groupParentGroupId = group.getParentGroupId(); if ((parentGroupIdEquals && (groupParentGroupId != parentGroupId)) || (!parentGroupIdEquals && (groupParentGroupId == parentGroupId))) { iterator.remove(); continue; }
However, the second half of that OR statement is pointless. If parentGroupIdEquals is false, then we know from the bolded statement above that parentGroupId is -1. However, no group will ever have their parentGroupId set to -1. Therefore, the following condition will never be true:
(!parentGroupIdEquals && (groupParentGroupId == parentGroupId)
Therefore, it should be removed from the source code to improve readability.