Redundant Null Check and Dead Code [message #1823098] |
Thu, 19 March 2020 13:30 |
Ed Merks Messages: 33218 Registered: July 2009 |
Senior Member |
|
|
I have code like this: protected void processObject(EObject object)
{
if (recordAnyTypeNSDecls && object instanceof AnyType)
{
FeatureMap featureMap = ((AnyType)object).getAnyAttribute();
for (Map.Entry<String, String> entry : helper.getAnyContentPrefixToURIMapping().entrySet())
{
Object uri = entry.getValue();
featureMap.add(extendedMetaData.demandFeature(ExtendedMetaData.XMLNS_URI, entry.getKey(), false), uri == null ? "" : uri);
}
}
if (object != null)
{
objects.push(object);
types.push(OBJECT_TYPE);
if (extendedMetaData != null)
{
EStructuralFeature mixedFeature = extendedMetaData.getMixedFeature(object.eClass());
if (mixedFeature != null)
{
mixedTargets.push((FeatureMap)object.eGet(mixedFeature));
}
else
{
mixedTargets.push(null);
}
}
else
{
mixedTargets.push(null);
}
}
else
{
types.push(ERROR_TYPE);
}
}
It claims that "object != null" is a redundant check. But I don't think it's redundant. As a result it also complains the the final else is dead code.
Is this a regression?
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06768 seconds