android.text.TextUtils.isEmpty methods should be hardcoded

Existing rule squid:S2637 cares about

In Android SDK there is similar method [android.text.TextUtils.isEmpty](https://developer.android.com/reference/android/text/TextUtils#isEmpty(java.lang.CharSequence)) which I propose to add and check also

Code example

import android.text.TextUtils;

...

public void test(String param1) {
    if (TextUtils.isEmpty(param1)) {
        return;
    }

    System.out.println(param1.length()); // currently it's false positive, after fix it must not warn
}

Type: Code Smell

I have tried to report the issue to https://jira.sonarsource.com but no success what is the next step? if someone can point me to right git repo I can prepare PR by my own

Hello Alexander,

I analyzed your reproducer on SonarCloud that is running in the background SonarJava 5.7 and I’m not able to reproduce your FP.

Can you try to do the same so we work together with the same context?

Thanks

Hi,

I am experiencing same problem on Android. SonarCloud insists “@NonNull” values should not be set to null". Even tho I check it with “TextUtils.isEmpty(value)”. I’ve also tried creating my own function to duplicate TextUtils, but result is the same

1 Like