android.text.TextUtils.isEmpty methods should be hardcoded

java

(Alexander Bobrikovich) #1

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


(Alexander Bobrikovich) #4

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


(Alexandre Gigleux) #5

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