False positive on "NullPointerException"

Running on Mac
Java code
installed via zip

I see a bunch of false positive failures with code like this.

public static Object toPageName(@Nullable String fragName) {
    if (TextUtils.isEmpty(fragName))
        return NONE;
    return fragName.replace("FragPage", "");    <--- flagged as possible NullPointerException on fragName

The scanner is flagging the fragName.replace as a possible NullPointerException.
But the line above is already checking for null, so not a real failure.

1 Like

Hello @landen, and welcome to the Sonar Community!

Iā€™m assuming the issue raised concerns rule S2259; can you confirm it? This rule has many False Positives because it relies on the symbolic execution engine which is not maintained. There is already a ticket to address this issue: [SONARJAVA-4273] - Jira.

I suggest you ignore this issue. This rule and all the others relying on symbolic execution will be re-implemented on a better engine.