eygraber
04/04/2022, 6:43 PMUnnecessaryLet
for 1.20?
I got a lot of violations in my project after updating to RC2. Most of them are related to using an "out" parameter, but I'm not sure if there's anything detekt can do there, and removing the let
isn't terrible.
There are some others, and I got one like this, and I'm not sure why it's unnecessary:
fun View.postHideKeyboard(shouldClearFocus: Boolean = false) {
if(shouldClearFocus) {
clearFocus()
}
val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
rootView.windowToken.let { token -> <http://rootView.post|rootView.post> { imm.hideSoftInputFromWindow(token, 0) } }
}
eygraber
04/04/2022, 6:57 PMfun String.sha256(): String =
MessageDigest
.getInstance("SHA-256")
.also { it.update(toByteArray()) }
.digest()
.let { Base64.encodeToString(it, Base64.DEFAULT) }
.run { substring(0, length - 1) }
This seems a bit aggressivemkrussel
04/04/2022, 7:00 PMmkrussel
04/04/2022, 7:02 PMlet
outside of null handling.eygraber
04/04/2022, 7:21 PMlet
as a scoping function. So if I only wanted token
to be used in that scope within that function, I would think the let
was OK.mkrussel
04/04/2022, 7:23 PMeygraber
04/04/2022, 7:30 PMmkrussel
04/04/2022, 7:36 PMeygraber
04/04/2022, 9:03 PM