mebigfatguy / fb-contrib

a FindBugs/SpotBugs plugin for doing static code analysis for java code bases
http://fb-contrib.sf.net
GNU Lesser General Public License v2.1
157 stars 45 forks source link

`FII_USE_FUNCTION_IDENTITY` false-positive #469

Open boris-petrov opened 8 months ago

boris-petrov commented 8 months ago

RxJava has its own concept of Function. And has functions that use it. We can't use java.util.Function.identity() there unfortunately. But fb-contrib gives a warning.

mebigfatguy commented 1 month ago

can you cook up a small example?

boris-petrov commented 1 month ago
import java.util.concurrent.Callable;

import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.core.Single;

public class Test {
    public static <T> Observable<T> lazilyGetObservable(Callable<Observable<T>> callable) {
        return Single
            .fromCallable(callable)
            .flatMapObservable(observable -> observable);
    }
}

P.S. That needs the io.reactivex.rxjava3:rxjava:3.1.9 library.