#244 Unreachable code in "Clean" and "DOMDocumentImpl"

open
nobody
None
5
2012-10-08
2011-02-03
No

Eclipse detects the following unreachable code, which should be cleaned up:

In Clean.cleanWord2000() at line 2159, the following can be removed:

                if (node == null)
                {
                    break;
                }

In DOMDocumentImpl.createElement()
In DOMDocumentImpl.createTextNode()
In DOMDocumentImpl.createComment()
In DOMDocumentImpl.createAttribute()

objects are created using "new", then tested for non-nullness. This seems to be something that comes from literal translation from C. For example:

public org.w3c.dom.Attr createAttribute(String name) throws DOMException
{
    AttVal av = new AttVal(null, null, '"', name, null);
    if (av != null)
    {
        av.dict = AttributeTable.getDefaultAttributeTable().findAttribute(av);
        return av.getAdapter();
    }

    return null;
}

Can be shortened to

public org.w3c.dom.Attr createAttribute(String name) throws DOMException
{
    AttVal av = new AttVal(null, null, '"', name, null);
    av.dict = AttributeTable.getDefaultAttributeTable().findAttribute(av);
    return av.getAdapter();
}

Discussion


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks