JakeWharton / timber

A logger with a small, extensible API which provides utility on top of Android's normal Log class.
https://jakewharton.github.io/timber/docs/5.x/
Apache License 2.0
10.46k stars 962 forks source link

Lint suggesting removing Null/Empty Message #389

Open jaqxues opened 4 years ago

jaqxues commented 4 years ago

Similar to #270 and #205 (both fixed apparently)

This happens with local vals (and vars) and using the when (and if) expressions in Kotlin.

Example:

return try {
    val clazz = classLoader.loadClass(className) as Class<out M>
    val constructor = clazz.getConstructor(Parameter::class.java)

    constructor.newInstance(arg)
} catch (t: Throwable) {
    val message = when(t) {
        is ClassNotFoundException -> "Class ($className) not found"
        is NoSuchMethodException -> "Matching constructor not found."
        is InvocationTargetException -> "Constructor Invocation failed"
        else -> "Unknown Error while instantiating Class"
    }

    // Use single-argument log method instead of null/empty message
    Timber.e(t, message)
    throw ReflectionException(message, t)
}
quibi-jlk commented 4 years ago

+1 also seeing this false positive with a local val.