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 check triggers on correct code #331

Open
BenoitDuffez opened this issue Aug 26, 2018 · 2 comments
Open

Lint check triggers on correct code #331

BenoitDuffez opened this issue Aug 26, 2018 · 2 comments
Labels

Comments

@BenoitDuffez
Copy link

BenoitDuffez commented Aug 26, 2018

I have this code:

val errorMessage: String = apiResponse.errorMessage(context)
if (errorMessage.isNotEmpty()) {
    Timber.e(Exception("Couldn't load more past replies"), errorMessage)
}

The timber call raises the following:

Use single-argument log method instead of null/empty message less... (⌘F1)
Explicitly including the exception message is redundant when supplying an exception to log. Issue id: TimberExceptionLogging

I don't see what's wrong: I have created an exception so that the error is sent to my bug reporting backend, which has a generic error description. Then as an argument I have added the full error message built by my API client: either a network error, or a server error, or just the error message returned by the backend. The error message is a non-null string, which may be empty.

errorMessage is a local variable so it can't be changed by other threads, so in the if block it is a non-empty string.

Just updated to 4.7.1 (kotlin 1.2.60) and the warning persists.

@JakeWharton
Copy link
Owner

We should come up with a failing test case to see whether the lint check still fails on master.

@jknair0
Copy link

jknair0 commented Aug 30, 2020

The warning is shown both in java and Kotlin. Although there is lint warning in IDE the lint test passes when expecting clean.

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

No branches or pull requests

3 participants