Fixed
Status Update
Comments
br...@gmail.com <br...@gmail.com> #2
Here is a link to UnsafeRepeatOnLifecycleDetectorTest
:
sm...@gmail.com <sm...@gmail.com> #3
The same lint fails using:
viewLifecycleOwner.lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.XXX) {}
}
Doesn't matter which state the repeat is for, it is highlighted. I notice this on BumbleBee Beta5. However, the exact same code base on ArticFox Patch 4 works without flagging the issue so the issue might be Android Studio in some manner.
viewLifecycleOwner.lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.XXX) {}
}
Doesn't matter which state the repeat is for, it is highlighted. I notice this on BumbleBee Beta5. However, the exact same code base on ArticFox Patch 4 works without flagging the issue so the issue might be Android Studio in some manner.
am...@gmail.com <am...@gmail.com> #4
We are encountering this false positive too.
am...@gmail.com <am...@gmail.com> #5
To add some context, here is a short snippet that is causing the linter to fail:
viewLifecycleOwner.lifecycleScope.launch {
viewLifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
viewModel.repeatOnLifecycle()
}
}
- With AGP
7.1.0
, thelint
Gradle task fails. - Using Android Studio Bumblebee 2021.1.1, it will be marked as a linter error in the IDE, even when using AGP
7.0.4
.
jb...@google.com <jb...@google.com>
ap...@google.com <ap...@google.com> #6
Project: platform/frameworks/support
Branch: androidx-main
commit 1cd0ca9eaa3e3df91b32833ee387819b1c71506f
Author: Jeremy Woods <jbwoods@google.com>
Date: Mon Jul 18 16:20:46 2022
Fix UnsafeRepeat lint false positive
Fixing an error in the UnsafeRepeatOnLifecycleDetector lint rule that
would cause a false positive if they call to repeatOnLifecycle was not
done directly on the viewLifecycleOwner.
RelNote: "The `UnsafeRepeatOnLifecycle` lint warning will no longer
report a false positive when the `viewLifecycleOwner` calls
`repeatOnLifecycle()` indirectly."
Test: Added test
Bug: 209658963
Change-Id: Ibbbeb0c41e7d806b707af16e814b482847e19836
M fragment/fragment-lint/src/main/java/androidx/fragment/lint/UnsafeRepeatOnLifecycleDetector.kt
M fragment/fragment-lint/src/test/java/androidx/fragment/lint/UnsafeRepeatOnLifecycleDetectorTest.kt
https://android-review.googlesource.com/2159427
Branch: androidx-main
commit 1cd0ca9eaa3e3df91b32833ee387819b1c71506f
Author: Jeremy Woods <jbwoods@google.com>
Date: Mon Jul 18 16:20:46 2022
Fix UnsafeRepeat lint false positive
Fixing an error in the UnsafeRepeatOnLifecycleDetector lint rule that
would cause a false positive if they call to repeatOnLifecycle was not
done directly on the viewLifecycleOwner.
RelNote: "The `UnsafeRepeatOnLifecycle` lint warning will no longer
report a false positive when the `viewLifecycleOwner` calls
`repeatOnLifecycle()` indirectly."
Test: Added test
Bug: 209658963
Change-Id: Ibbbeb0c41e7d806b707af16e814b482847e19836
M fragment/fragment-lint/src/main/java/androidx/fragment/lint/UnsafeRepeatOnLifecycleDetector.kt
M fragment/fragment-lint/src/test/java/androidx/fragment/lint/UnsafeRepeatOnLifecycleDetectorTest.kt
jb...@google.com <jb...@google.com> #7
Along with this, we also made it so that this lint rule only runs in Fragment View lifecycle callbacks which is what was always attended.
This fix will be available in the Fragment 1.5.1
release.
Description
Component used: Fragment
Version used: 1.4.0
The following code will throw a lint error, but it should not:
Adding the following
TestConfig
toUnsafeRepeatOnLifecycleDetectorTest
will highlight the issue: