-
Notifications
You must be signed in to change notification settings - Fork 46
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
Animalsniffer check #771
Animalsniffer check #771
Conversation
# Conflicts: # settings.gradle.kts
Also supersedes #768 |
@@ -1,58 +0,0 @@ | |||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oof, I guess this was cruft just left over from a previous rename?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The convention configs for animalsniffer checks on plain Java libs are slightly different than for Android libs, for a moment I thought about adding all that config in a separate convention file and so on, but then I realized that the plain Java lib conventions aren't used anywhere right now, so it seems like it's better to just remove them instead of making this PR bigger by adding all that other config that's not needed right now.
@@ -77,7 +78,15 @@ public static int replacementForContentLength(URLConnection connection) { | |||
} | |||
|
|||
public static long replacementForContentLengthLong(URLConnection connection) { | |||
return replace(connection, () -> connection.getContentLengthLong()); | |||
return replace( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, did this catch one already then!?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the method getContentLengthLong() is available starting from API 24 so animalsniffer complains about it because our min is 21. However, for this particular case, this method is guaranteed to be called on apps with at least min API 24 so there's no need to address it, so to disable animalsniffer for this case only we have to annotate the class/method/field with @RequiresApi
where this call is made, and I tried first to annotate the parent method replacementForContentLengthLong
, though that didn't work, because the call to getContentLengthLong()
was made in a lambda and it seems like animalsniffer doesn't check those scenarios, so for it to work I had to turn the lambda into an anonymous class and then annotate the actual method inside where the call to getContentLengthLong()
is made.
Closes #770
Follow-up for #701