Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint suggesting removing Null/Empty Message #389

Open
jaqxues opened this issue Apr 16, 2020 · 1 comment
Open

Lint suggesting removing Null/Empty Message #389

jaqxues opened this issue Apr 16, 2020 · 1 comment

Comments

@jaqxues
Copy link

jaqxues commented Apr 16, 2020

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants