JakeWharton / JakeWharton/timber

Lint suggesting removing Null/Empty Message

Open
#389 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
10.9k
Forks
994
Avg merge
17h 16m
Merged PRs (30d)
17

Description

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

This happens with local `val`s (and `var`s) and using the `when` (and `if`) expressions in Kotlin.

Example:
```kt
return try {
val clazz = classLoader.loadClass(className) as Class
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)
}
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the Kotlin example with local val/var variables inside when or if expressions and record the lint diagnostic. Compare the behavior with issues #270 and #205, then verify the diagnostic no longer incorrectly suggests removing the null or empty message in the shown Timber.e call.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.