Skip to content

Resolve NullSafeMutableLiveData Lint Errors - #16647

Merged
oguzkocer merged 34 commits into
update/nav-component-version-to-2.4.2from
lint/resolve-null-safe-mutable-live-data-lint-errors
May 31, 2022
Merged

oguzkocer merged 34 commits into
update/nav-component-version-to-2.4.2from
lint/resolve-null-safe-mutable-live-data-lint-errors

Conversation

@ParaskP7

@ParaskP7 ParaskP7 commented May 26, 2022 •

Copy link
Copy Markdown
Contributor

Related to #16632

This PR deals with the NullSafeMutableLiveData Lint errors as they suddenly started appearing within the Navigation Component 2.4.2 update PR.

Some of these NullSafeMutableLiveData were fixed, while others suppressed. You will find all the details you need in the commit messages themselves as to how a specific NullSafeMutableLiveData got resolved. As such, I recommend reviewing this PR commit-by-commit.

PS: You will find more info about the decision behind this PR within this conversation.

To test:

All the changes were pretty straightforward and as such don't necessary require much testing. However, I would anyway recommend a quick smoke testing on the below screens and/or functionalities:

  • Site Creation
  • Stats
  • Stats (Tabs)
  • Selected Date (from Stats)
  • Posts
  • Posts (Search)
  • Pages
  • Pages (Search)
  • Publish Settings (from Posts)
  • Media Picker (from Post)
  • Photo Picker (from Post)
  • Register Domain (from Menu)
  • Plans (from Menu)
  • Plugins (from Menu)
  • Categories (from Site Settings)
  • What's New Announcement

Regression Notes

  1. Potential unintended areas of impact

N/A

  1. What I did to test those areas of impact (or what existing automated tests I relied on)

See To test section above.

  1. What automated tests I added (or what prevented me from doing so)

N/A

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

ParaskP7 added 26 commits May 26, 2022 12:34
There are currently 32 errors related to 'NullSafeMutableLiveData'. All
those will get resolved or suppressed locally in subsequent commits.
The 'mutableSnackbarMessage' mutable live data value is set to null
during 'onCleared()' and as such it needs to be declared as nullable.

Then, using 'let' on the 'snackbarMessage' live data this can be guarded
against so that to avoid a null pointer exception.
The 'showErrorMessage' mutable live data value is set to
'event.error.message' on multiple occasions. However, 'event.error' can
be nullable and as such the 'event.error.message' itself.

There is an 'if (event.isError) { ... }' statement above to guard from
that ever happening, but the compiler is not smart enough to understand
that. Maybe with 'Kotlin Contracts' this problem would have been
avoided, but this feature is a separate discussion of its own.

Thus, by guarding this with 'let' before setting this 'showErrorMessage'
mutable live data is the best that can be done at this point of time.
The 'supportedStates' mutable live data value is set to null during
'onCountrySelected(...)' and can be also set to null via the
'OnDomainSupportedStatesFetched.supportedStates' from within the
'SiteStore' as it is actually defined as nullable. As such, the
'supportedStates' itself needs to be declared as nullable.
The 'currentFeatureAnnouncement' mutable live data can be set to null
during 'loadFeatures()' and via
'FeatureAnnouncementProvider.getLatestFeatureAnnouncement(...)' which
might produce a nullable 'FeatureAnnouncement'. As such, the
'currentFeatureAnnouncement' itself needs to be declared as nullable.

The rest of the changes are propagated due to the above change and are
mainly guarding the rest of the functionality that depends on that with
'let' and '?' scope functions.
This 'LiveDataExtensions' is not used anywhere within the codebase and
as such can be safely remove. If at any point in the future it will be
needed again, engineers should either bring it back, with a more model
version of it, or use another utility from the 'LiveData' library
itself, which will serve the same purpose.

This also solves two 'NullSafeMutableLiveData' lint errors related to
this function.
Suppress this 'NullSafeMutableLiveData' instead of changing this
'LiveData.mapAsync(...)' extension function and as such its signature
seems to be the safest choice at the moment since this extension
function is being utilized in extension places.
The 'selectedIds' mutable live data can be set to null during the
'start(...)' and via its 'selectedIds' parameter which is nullable. As
such, the 'selectedIds' itself needs to be declared as nullable.
The 'selectedIds' mutable live data can be set to null during the
'start(...)' and via its 'selectedIds' parameter which is nullable. As
such, the 'selectedIds' itself needs to be declared as nullable.

Although the initial logic was different and what I am describing above,
and setting the 'selectedIds' was guarded with 'let' I chose to update
this logic and align that with the 'MediaPickerViewModel' logic and the
update I did there with my previous commit. Actually, this makes sense
as this view model and its associated fragment is treating this
'selectedIds' live data value as nullable already and guarding against
it accordingly.
The live data 'cachedPlans' is only utilized from within the view model
and as such can be replaced with the '_cachedPlans' mutable live data.

This change will make 'cachedPlans' intention much more straightforward.
The 'plans' and 'cachedPlans' mutable live data value can be set to null
during 'onPlanOffersFetched(...)' because of the
'OnPlanOffersFetched.planOffers' from within the
'PlansOfferStore' as it is actually defined as nullable. As such, the
'plans' and 'cachedPlans' themselves need to be declared as nullable.
Defaulting to an empty title is enough for this use case.
The 'searchQuery' mutable live data is set to null during
'clearSearch()'. As such, the 'searchQuery' itself needs to be declared
as nullable.

Also, this view model's associated fragment and activity screens are
treating this 'searchQuery' live data value as nullable already and use
it as such accordingly.
The 'navigateBack' mutable live data can be set to null during
'cleanupAndFinish()'. As such, the 'navigateBack' itself needs to be
declared as nullable.

Also, this view model's associated fragment is treating this
'navigateBack' live data value as nullable already and guards against it
accordingly.
The 'onNotificationTime' mutable live data can be set to null during
'onNotificationCreated()'. As such, the 'onNotificationTime' itself
needs to be declared as nullable.

Also, this view model's associated fragment is treating this
'onNotificationTime' live data value as nullable already and guards
against it accordingly.
The 'selectedDateChanged' mutable live data is set to null during the
'clear(...)' functions. As such, the 'selectedDateChanged' itself
needs to be declared as nullable.

Also, this view model's associated fragments are treating this
'selectedDateChanged' live data value as nullable already and guard
against it accordingly.
The 'onIntentSelected' mutable live data can be set to null during
'onCustomVerticalSelected()' because of the 'IntentsUiState.searchQuery'
as it is actually defined as nullable. As such, the 'onIntentSelected'
itself needs to be declared as nullable.

However, this view model's associated activity, main view model and
interface were expecting a non-nullable intent. But, this can actually
change easily and the interface intent can be defined and used as
nullable as well. It ends us anyway being using within the
'SiteCreationMainVM.onSiteIntentSelected(...)', which can accept a
nullable intent without any problems.
Suppress this 'NullSafeMutableLiveData' instead of changing this
'LiveData.observeEvent(...)' extension function and as such its
signature seems to be the safest choice at the moment since this
extension function is being utilized in extension places.

For more info see 'StatsFragment' and the usage of
'viewModel.siteChanged.observeEvent(...)' which prevents us from
changing this easily.
Also, this change moves this 'showSnackbarMessage' backing field closer
to it equivalent and associated public live data field.
Suppress this 'NullSafeMutableLiveData' instead of changing this
'LiveData.observeEvent(...)' extension function and as such its
signature seems to be the safest choice at the moment since this
extension function is being utilized in extension places.

For more info see 'StatsViewAllFragment' and the usage of
'viewModel.showSnackbarMessage.observeEvent(...)' which prevents us from
changing this easily.
For these classes in this commit the 'NullSafeMutableLiveData' Lint
error is suppressed are false positive. It is false positive because the
nullability of the variable is already checked before it is assigned to
the mutable live data field, but it is anyway ignored as being
potentially null and thus reported.
@ParaskP7 ParaskP7 added the Lint label May 26, 2022
@ParaskP7 ParaskP7 added this to the 20.0 milestone May 26, 2022
@ParaskP7
ParaskP7 requested review from ashiagr and oguzkocer May 26, 2022 14:05
@ParaskP7 ParaskP7 self-assigned this May 26, 2022
@peril-wordpress-mobile

peril-wordpress-mobile Bot commented May 26, 2022 •

Copy link
Copy Markdown

You can trigger optional UI/connected tests for these changes by visiting CircleCI here.

@ParaskP7 ParaskP7 changed the title Lint NullSafeMutableLiveData Lint Errors Resolve NullSafeMutableLiveData Lint Errors May 26, 2022
@peril-wordpress-mobile

peril-wordpress-mobile Bot commented May 26, 2022 •

Copy link
Copy Markdown

You can test the changes on this Pull Request by downloading the APKs:

@ParaskP7
ParaskP7 marked this pull request as draft May 26, 2022 15:05
ParaskP7 added 6 commits May 27, 2022 10:29
As part of this update the below occurred:
- The 'lifecycle-extensions' artifact and APIs got removed as it has
been deprecated since '2.2.0' and it is no longer updated. The
recommendation nowadays is to instead add dependencies for the specific
lifecycle artifacts needed.
- Update 'ViewModelProvider.Factory.create(...)' signature to a non-null
'ViewModel' generic as it is now defined as such by the Java
factory interface.

The above were the only breaking change. Apart from that everything else
seems to be compiling and working as expected (did a quick smoke test).
However, this update added 10 new 'NullSafeMutableLiveData' lint errors
that will be fixed in subsequent commits.
The 'data' mediator live data is set to null during the 'onCleared()'.
As such, the 'data' itself needs to be declared as nullable. This use
case's associated view model is updated accordingly.

Also, this view model's associated fragment is treating this
'uiModel' live data value as nullable already.
The 'searchPages' mutable live data is set to null during
'clearSearch()'. As such, the 'searchPages' itself needs to be declared
as nullable.

Also, this view model's associated search view model is treating this
'searchPages' live data value as nullable already and guarding against
it accordingly.
The 'searchPages' mutable live data is set to null during
'clearSearch()'. As such, the 'searchPages' itself needs to be declared
as nullable.

Also, this view model's associated search view model is treating this
'searchPages' live data value as nullable already and guarding against
it accordingly.
Suppress all 'NullSafeMutableLiveData' instead of changing this
'mergeNotNull(...)' implementation and as such 'showSnackbarMessage'
field's signature. This seems to be the safest choice for now.
@wpmobilebot

Copy link
Copy Markdown
Contributor

Found 1 violations:

The PR caused the following dependency changes:

 +--- com.automattic:about:0.0.5
 |    +--- androidx.core:core-ktx:1.7.0
 |    |    \--- androidx.core:core:1.7.0
-|    |         \--- androidx.lifecycle:lifecycle-runtime:2.3.1
-|    |              +--- androidx.arch.core:core-runtime:2.1.0
-|    |              |    +--- androidx.annotation:annotation:1.1.0 -> 1.2.0
-|    |              |    \--- androidx.arch.core:core-common:2.1.0
-|    |              |         \--- androidx.annotation:annotation:1.1.0 -> 1.2.0
-|    |              +--- androidx.lifecycle:lifecycle-common:2.3.1
-|    |              |    \--- androidx.annotation:annotation:1.1.0 -> 1.2.0
-|    |              +--- androidx.arch.core:core-common:2.1.0 (*)
-|    |              \--- androidx.annotation:annotation:1.1.0 -> 1.2.0
+|    |         \--- androidx.lifecycle:lifecycle-runtime:2.3.1 -> 2.4.1
+|    |              +--- androidx.arch.core:core-runtime:2.1.0
+|    |              |    +--- androidx.annotation:annotation:1.1.0 -> 1.2.0
+|    |              |    \--- androidx.arch.core:core-common:2.1.0
+|    |              |         \--- androidx.annotation:annotation:1.1.0 -> 1.2.0
+|    |              +--- androidx.lifecycle:lifecycle-common:2.4.1
+|    |              |    +--- androidx.annotation:annotation:1.1.0 -> 1.2.0
+|    |              |    \--- androidx.lifecycle:lifecycle-common-java8:2.4.1 (c)
+|    |              +--- androidx.arch.core:core-common:2.1.0 (*)
+|    |              \--- androidx.annotation:annotation:1.1.0 -> 1.2.0
 |    +--- com.google.android.material:material:1.4.0 -> 1.6.0-alpha01
 |    |    +--- androidx.appcompat:appcompat:1.1.0 -> 1.3.1
 |    |    |    +--- androidx.activity:activity:1.2.4 -> 1.3.1
-|    |    |    |    +--- androidx.lifecycle:lifecycle-runtime:2.3.1 (*)
+|    |    |    |    +--- androidx.lifecycle:lifecycle-runtime:2.3.1 -> 2.4.1 (*)
-|    |    |    |    +--- androidx.lifecycle:lifecycle-viewmodel:2.3.1
-|    |    |    |    |    \--- androidx.annotation:annotation:1.1.0 -> 1.2.0
+|    |    |    |    +--- androidx.lifecycle:lifecycle-viewmodel:2.3.1 -> 2.4.1
+|    |    |    |    |    +--- androidx.annotation:annotation:1.1.0 -> 1.2.0
+|    |    |    |    |    \--- org.jetbrains.kotlin:kotlin-stdlib:1.5.30 -> 1.6.10 (*)
 |    |    |    |    +--- androidx.savedstate:savedstate:1.1.0
-|    |    |    |    |    \--- androidx.lifecycle:lifecycle-common:2.0.0 -> 2.3.1 (*)
+|    |    |    |    |    \--- androidx.lifecycle:lifecycle-common:2.0.0 -> 2.4.1 (*)
 |    |    |    |    \--- androidx.lifecycle:lifecycle-viewmodel-savedstate:2.3.1
-|    |    |    |         +--- androidx.lifecycle:lifecycle-livedata-core:2.3.1
-|    |    |    |         |    +--- androidx.arch.core:core-common:2.1.0 (*)
-|    |    |    |         |    +--- androidx.arch.core:core-runtime:2.1.0 (*)
-|    |    |    |         |    \--- androidx.lifecycle:lifecycle-common:2.3.1 (*)
+|    |    |    |         +--- androidx.lifecycle:lifecycle-livedata-core:2.3.1 -> 2.4.1
+|    |    |    |         |    +--- androidx.arch.core:core-common:2.1.0 (*)
+|    |    |    |         |    +--- androidx.arch.core:core-runtime:2.1.0 (*)
+|    |    |    |         |    \--- androidx.lifecycle:lifecycle-common:2.4.1 (*)
-|    |    |    |         \--- androidx.lifecycle:lifecycle-viewmodel:2.3.1 (*)
+|    |    |    |         \--- androidx.lifecycle:lifecycle-viewmodel:2.3.1 -> 2.4.1 (*)
 |    |    |    +--- androidx.fragment:fragment:1.3.6 -> 1.4.1
 |    |    |    |    +--- androidx.loader:loader:1.0.0
-|    |    |    |    |    +--- androidx.lifecycle:lifecycle-livedata:2.0.0 -> 2.2.0
-|    |    |    |    |    |    +--- androidx.arch.core:core-runtime:2.1.0 (*)
-|    |    |    |    |    |    +--- androidx.lifecycle:lifecycle-livedata-core:2.2.0 -> 2.3.1 (*)
-|    |    |    |    |    |    \--- androidx.arch.core:core-common:2.1.0 (*)
+|    |    |    |    |    +--- androidx.lifecycle:lifecycle-livedata:2.0.0 -> 2.4.1
+|    |    |    |    |    |    +--- androidx.arch.core:core-common:2.1.0 (*)
+|    |    |    |    |    |    +--- androidx.arch.core:core-runtime:2.1.0 (*)
+|    |    |    |    |    |    \--- androidx.lifecycle:lifecycle-livedata-core:2.4.1 (*)
-|    |    |    |    |    \--- androidx.lifecycle:lifecycle-viewmodel:2.0.0 -> 2.3.1 (*)
+|    |    |    |    |    \--- androidx.lifecycle:lifecycle-viewmodel:2.0.0 -> 2.4.1 (*)
-|    |    |    |    +--- androidx.lifecycle:lifecycle-livedata-core:2.3.1 (*)
+|    |    |    |    +--- androidx.lifecycle:lifecycle-livedata-core:2.3.1 -> 2.4.1 (*)
-|    |    |    |    \--- androidx.lifecycle:lifecycle-viewmodel:2.3.1 (*)
+|    |    |    |    \--- androidx.lifecycle:lifecycle-viewmodel:2.3.1 -> 2.4.1 (*)
-|    |    |    +--- androidx.lifecycle:lifecycle-runtime:2.3.1 (*)
+|    |    |    +--- androidx.lifecycle:lifecycle-runtime:2.3.1 -> 2.4.1 (*)
-|    |    |    \--- androidx.lifecycle:lifecycle-viewmodel:2.3.1 (*)
+|    |    |    \--- androidx.lifecycle:lifecycle-viewmodel:2.3.1 -> 2.4.1 (*)
-|    |    \--- androidx.lifecycle:lifecycle-runtime:2.0.0 -> 2.3.1 (*)
+|    |    \--- androidx.lifecycle:lifecycle-runtime:2.0.0 -> 2.4.1 (*)
 |    +--- androidx.compose.ui:ui:1.0.5 -> 1.1.0-beta04
-|    |    +--- androidx.lifecycle:lifecycle-common-java8:2.3.0
-|    |    |    +--- androidx.lifecycle:lifecycle-common:2.3.0 -> 2.3.1 (*)
-|    |    |    \--- androidx.annotation:annotation:1.1.0 -> 1.2.0
+|    |    +--- androidx.lifecycle:lifecycle-common-java8:2.3.0 -> 2.4.1
+|    |    |    +--- androidx.lifecycle:lifecycle-common:2.4.1 (*)
+|    |    |    \--- androidx.annotation:annotation:1.1.0 -> 1.2.0
-|    |    +--- androidx.lifecycle:lifecycle-runtime:2.3.0 -> 2.3.1 (*)
+|    |    +--- androidx.lifecycle:lifecycle-runtime:2.3.0 -> 2.4.1 (*)
-|    |    +--- androidx.lifecycle:lifecycle-viewmodel:2.3.0 -> 2.3.1 (*)
+|    |    +--- androidx.lifecycle:lifecycle-viewmodel:2.3.0 -> 2.4.1 (*)
 |    |    \--- androidx.profileinstaller:profileinstaller:1.1.0-beta04
-|    |         \--- androidx.startup:startup-runtime:1.0.0
+|    |         \--- androidx.startup:startup-runtime:1.0.0 -> 1.1.1
 |    +--- androidx.compose.ui:ui-tooling:1.0.5
 |    |    +--- androidx.compose.material:material:1.0.5 -> 1.1.0-beta04
-|    |    |    +--- androidx.lifecycle:lifecycle-runtime:2.3.0 -> 2.3.1 (*)
+|    |    |    +--- androidx.lifecycle:lifecycle-runtime:2.3.0 -> 2.4.1 (*)
-|    |    |    \--- androidx.lifecycle:lifecycle-viewmodel:2.3.0 -> 2.3.1 (*)
+|    |    |    \--- androidx.lifecycle:lifecycle-viewmodel:2.3.0 -> 2.4.1 (*)
 |    |    \--- androidx.activity:activity-compose:1.3.1
 |    |         \--- androidx.activity:activity-ktx:1.3.1
-|    |              +--- androidx.lifecycle:lifecycle-runtime-ktx:2.3.1
-|    |              |    +--- androidx.lifecycle:lifecycle-runtime:2.3.1 (*)
-|    |              |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.4.20 -> 1.6.10 (*)
-|    |              |    +--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1 -> 1.5.2 (*)
-|    |              |    \--- androidx.annotation:annotation:1.0.0 -> 1.2.0
+|    |              +--- androidx.lifecycle:lifecycle-runtime-ktx:2.3.1 -> 2.4.1
+|    |              |    +--- androidx.lifecycle:lifecycle-runtime:2.4.1 (*)
+|    |              |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.5.30 -> 1.6.10 (*)
+|    |              |    +--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0 -> 1.5.2 (*)
+|    |              |    \--- androidx.annotation:annotation:1.0.0 -> 1.2.0
-|    |              \--- androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1
-|    |                   +--- androidx.lifecycle:lifecycle-viewmodel:2.3.1 (*)
-|    |                   +--- org.jetbrains.kotlin:kotlin-stdlib:1.4.20 -> 1.6.10 (*)
-|    |                   \--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1 -> 1.5.2 (*)
+|    |              \--- androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1 -> 2.4.1
+|    |                   +--- androidx.lifecycle:lifecycle-viewmodel:2.4.1 (*)
+|    |                   +--- org.jetbrains.kotlin:kotlin-stdlib:1.5.30 -> 1.6.10 (*)
+|    |                   \--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0 -> 1.5.2 (*)
 |    \--- androidx.navigation:navigation-compose:2.4.0-beta02
 |         +--- androidx.lifecycle:lifecycle-viewmodel-compose:2.4.0-rc01
-|         |    \--- androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.0 -> 2.3.1 (*)
+|         |    \--- androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.0 -> 2.4.1 (*)
 |         \--- androidx.navigation:navigation-runtime-ktx:2.4.0-beta02 -> 2.4.2
 |              \--- androidx.navigation:navigation-runtime:2.4.2
 |                   +--- androidx.navigation:navigation-common:2.4.2
-|                   |    +--- androidx.lifecycle:lifecycle-runtime-ktx:2.3.1 (*)
+|                   |    +--- androidx.lifecycle:lifecycle-runtime-ktx:2.3.1 -> 2.4.1 (*)
-|                   |    \--- androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1 (*)
+|                   |    \--- androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1 -> 2.4.1 (*)
-|                   +--- androidx.lifecycle:lifecycle-runtime-ktx:2.3.1 (*)
+|                   +--- androidx.lifecycle:lifecycle-runtime-ktx:2.3.1 -> 2.4.1 (*)
-|                   \--- androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1 (*)
+|                   \--- androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1 -> 2.4.1 (*)
 +--- com.automattic:stories:1.3.0
 |    +--- androidx.navigation:navigation-fragment-ktx:2.0.0 -> 2.4.2
 |    |    \--- androidx.navigation:navigation-fragment:2.4.2
 |    |         \--- androidx.fragment:fragment-ktx:1.4.1
-|    |              +--- androidx.lifecycle:lifecycle-livedata-core-ktx:2.3.1
-|    |              |    +--- androidx.lifecycle:lifecycle-livedata-core:2.3.1 (*)
-|    |              |    \--- org.jetbrains.kotlin:kotlin-stdlib:1.4.20 -> 1.6.10 (*)
+|    |              +--- androidx.lifecycle:lifecycle-livedata-core-ktx:2.3.1 -> 2.4.1
+|    |              |    +--- androidx.lifecycle:lifecycle-livedata-core:2.4.1 (*)
+|    |              |    \--- org.jetbrains.kotlin:kotlin-stdlib:1.5.30 -> 1.6.10 (*)
-|    |              \--- androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1 (*)
+|    |              \--- androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1 -> 2.4.1 (*)
 |    +--- com.automattic.stories:photoeditor:1.3.0
 |    |    \--- androidx.camera:camera-core:1.0.0-alpha06
-|    |         +--- androidx.lifecycle:lifecycle-livedata:2.1.0 -> 2.2.0 (*)
+|    |         +--- androidx.lifecycle:lifecycle-livedata:2.1.0 -> 2.4.1 (*)
-|    |         \--- androidx.lifecycle:lifecycle-common:2.1.0 -> 2.3.1 (*)
+|    |         \--- androidx.lifecycle:lifecycle-common:2.1.0 -> 2.4.1 (*)
-|    +--- androidx.lifecycle:lifecycle-common-java8:2.2.0 -> 2.3.0 (*)
+|    +--- androidx.lifecycle:lifecycle-common-java8:2.2.0 -> 2.4.1 (*)
-|    +--- androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0 -> 2.3.1 (*)
+|    +--- androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0 -> 2.4.1 (*)
-|    \--- androidx.lifecycle:lifecycle-livedata-ktx:2.2.0
-|         +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.50 -> 1.6.10 (*)
-|         +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0 -> 1.5.2 (*)
-|         +--- androidx.lifecycle:lifecycle-livedata:2.2.0 (*)
-|         \--- androidx.lifecycle:lifecycle-livedata-core-ktx:2.2.0 -> 2.3.1 (*)
+|    \--- androidx.lifecycle:lifecycle-livedata-ktx:2.2.0 -> 2.4.1
+|         +--- androidx.lifecycle:lifecycle-livedata:2.4.1 (*)
+|         +--- androidx.lifecycle:lifecycle-livedata-core-ktx:2.4.1 (*)
+|         +--- org.jetbrains.kotlin:kotlin-stdlib:1.5.30 -> 1.6.10 (*)
+|         \--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0 -> 1.5.2 (*)
 +--- project :libs:image-editor:ImageEditor
-|    +--- androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0 -> 2.3.1 (*)
+|    +--- androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1 (*)
-|    \--- androidx.lifecycle:lifecycle-livedata-ktx:2.2.0 (*)
+|    \--- androidx.lifecycle:lifecycle-livedata-ktx:2.4.1 (*)
-+--- androidx.lifecycle:lifecycle-extensions:2.2.0
-|    +--- androidx.lifecycle:lifecycle-runtime:2.2.0 -> 2.3.1 (*)
-|    +--- androidx.arch.core:core-common:2.1.0 (*)
-|    +--- androidx.arch.core:core-runtime:2.1.0 (*)
-|    +--- androidx.fragment:fragment:1.2.0 -> 1.4.1 (*)
-|    +--- androidx.lifecycle:lifecycle-common:2.2.0 -> 2.3.1 (*)
-|    +--- androidx.lifecycle:lifecycle-livedata:2.2.0 (*)
-|    +--- androidx.lifecycle:lifecycle-process:2.2.0
-|    |    \--- androidx.lifecycle:lifecycle-runtime:2.2.0 -> 2.3.1 (*)
-|    +--- androidx.lifecycle:lifecycle-service:2.2.0
-|    |    \--- androidx.lifecycle:lifecycle-runtime:2.2.0 -> 2.3.1 (*)
-|    \--- androidx.lifecycle:lifecycle-viewmodel:2.2.0 -> 2.3.1 (*)
-+--- androidx.lifecycle:lifecycle-runtime-ktx:2.2.0 -> 2.3.1 (*)
++--- androidx.lifecycle:lifecycle-runtime-ktx:2.4.1 (*)
 +--- androidx.work:work-runtime:2.7.0
-|    +--- androidx.lifecycle:lifecycle-livedata:2.1.0 -> 2.2.0 (*)
+|    +--- androidx.lifecycle:lifecycle-livedata:2.1.0 -> 2.4.1 (*)
-|    +--- androidx.startup:startup-runtime:1.0.0 (*)
+|    +--- androidx.startup:startup-runtime:1.0.0 -> 1.1.1 (*)
-|    \--- androidx.lifecycle:lifecycle-service:2.1.0 -> 2.2.0 (*)
+|    \--- androidx.lifecycle:lifecycle-service:2.1.0
+|         \--- androidx.lifecycle:lifecycle-runtime:2.1.0 -> 2.4.1 (*)
-+--- androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0 -> 2.3.1 (*)
++--- androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1 (*)
-+--- androidx.lifecycle:lifecycle-livedata-ktx:2.2.0 (*)
++--- androidx.lifecycle:lifecycle-livedata-ktx:2.4.1 (*)
-+--- androidx.lifecycle:lifecycle-process:2.2.0 (*)
++--- androidx.lifecycle:lifecycle-process:2.4.1
+|    +--- androidx.lifecycle:lifecycle-runtime:2.4.1 (*)
+|    +--- androidx.startup:startup-runtime:1.1.1 (*)
+|    \--- androidx.annotation:annotation:1.2.0
 +--- com.automattic:Automattic-Tracks-Android:2.2.0
 |    \--- io.sentry:sentry-android -> 5.4.3
 |         \--- io.sentry:sentry-android-core:5.4.3
-|              +--- androidx.lifecycle:lifecycle-process:2.2.0 (*)
+|              +--- androidx.lifecycle:lifecycle-process:2.2.0 -> 2.4.1 (*)
-|              \--- androidx.lifecycle:lifecycle-common-java8:2.2.0 -> 2.3.0 (*)
+|              \--- androidx.lifecycle:lifecycle-common-java8:2.2.0 -> 2.4.1 (*)
 +--- com.google.dagger:dagger-android-support:2.41
-|    +--- androidx.lifecycle:lifecycle-common:2.3.1 (*)
+|    +--- androidx.lifecycle:lifecycle-common:2.3.1 -> 2.4.1 (*)
-|    \--- androidx.lifecycle:lifecycle-viewmodel:2.3.1 (*)
+|    \--- androidx.lifecycle:lifecycle-viewmodel:2.3.1 -> 2.4.1 (*)
 +--- com.google.dagger:hilt-android:2.41
-|    +--- androidx.lifecycle:lifecycle-common:2.3.1 (*)
+|    +--- androidx.lifecycle:lifecycle-common:2.3.1 -> 2.4.1 (*)
-|    \--- androidx.lifecycle:lifecycle-viewmodel:2.3.1 (*)
+|    \--- androidx.lifecycle:lifecycle-viewmodel:2.3.1 -> 2.4.1 (*)
 +--- org.wordpress:fluxc:{strictly trunk-e8d924793cb408ede0f016e68c5420af0688ff90} -> trunk-e8d924793cb408ede0f016e68c5420af0688ff90
 |    \--- androidx.paging:paging-runtime:2.1.2
-|         +--- androidx.lifecycle:lifecycle-runtime:2.0.0 -> 2.3.1 (*)
+|         +--- androidx.lifecycle:lifecycle-runtime:2.0.0 -> 2.4.1 (*)
-|         \--- androidx.lifecycle:lifecycle-livedata:2.0.0 -> 2.2.0 (*)
+|         \--- androidx.lifecycle:lifecycle-livedata:2.0.0 -> 2.4.1 (*)

Please review and act accordingly

Suppress this 'NullSafeMutableLiveData' instead of changing this
'MutableLiveData.postOnUi(...)' extension function and as such its
signature seems to be the safest choice at the moment since this
extension function is being utilized in extension places.
@ParaskP7 ParaskP7 added Lint and removed Lint labels May 27, 2022
@ParaskP7
ParaskP7 marked this pull request as ready for review May 27, 2022 13:59
@ParaskP7

Copy link
Copy Markdown
Contributor Author

👋 @oguzkocer @ashiagr !

FYI: Just in case you missed my previous ping, this PR is now ready for review. 🎉

I updated lifecycle to 2.4.1 and resolved/suppressed those 10 new NullSafeMutableLiveData lint errors, which did the trick and now the PR is 🟢 on CI.

Please take a look at is and let me know how else I can help you. 🙏

@ashiagr ashiagr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋 @ParaskP7

I went through this discussion, and am really happy to see lifecycle updated to 2.4.1 with CI passing.

I was able to follow the changes by reading commit messages. I experienced no crashes while smoke testing mentioned areas. Overall I'm confident of approving the changes.

As always, thank you for your thorough work! 🙏

Feel free to merge when you're ready.

Comment thread build.gradle
swipeToRefresh = '1.1.0'
uCropVersion = '2.2.4'
lifecycleVersion = '2.2.0'
lifecycleVersion = '2.4.1'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥇 for this! 👏

@ParaskP7

ParaskP7 commented May 30, 2022 •

Copy link
Copy Markdown
Contributor Author
  1. @ashiagr Thank you so much for the review and for giving us the 🟢 light with these changes! 🥇
  2. @oguzkocer I am letting you merge this when and if you feel okay about it too so that we could then progress Update Navigation component version to 2.4.2 #16632 and ultimately Plugin DSL #15314 .

PS: As part of this PR review and test we should be able to merged #16632 straight to trunk or we could just close it and point this PR to trunk directly. 🎯

@AliSoftware

AliSoftware commented May 30, 2022 •

Copy link
Copy Markdown
Contributor

I'm moving this PR's milestone to 20.1 as I'm doing the code freeze for 20.0.

@oguzkocer I am letting you merge this when and if you feel okay about it too so that we could then progress #16632 and ultimately #15314 .

I was tempted to merge this as I saw this was approved, but given this comment + since the troubles Petros had on Friday's release finalization domino'd into postponing the finalization and thus the code freeze today, I'm now too late in my day to wait any further to give a chance for this to land before I start the freeze; but feel free to rebase to the release branch if you feel it's necessary)

@AliSoftware AliSoftware modified the milestones: 20.0, 20.1 May 30, 2022
@ParaskP7

Copy link
Copy Markdown
Contributor Author

👋 @AliSoftware !

I'm moving this PR's milestone to 20.1 as I'm doing the code freeze for 20.0.

Thank you for moving this to the new 20.1 milestone, this is correct.

I was tempted to merge this as I saw this was approved, but given this comment + since the troubles Petros had on Friday's release finalization domino'd into #16661, I'm now too late in my day to wait any further to give a chance for this to land before I start the freeze; but feel free to rebase to the release branch if you feel it's necessary)

Thanks for the communication and for NOT merging this. This indeed doesn't and wouldn't need to be included and rebased to the release branch, so all good from our side.

@oguzkocer

Copy link
Copy Markdown
Contributor

Thank you for the PR @ParaskP7 and thank you for the review @ashiagr 🙇‍♂️ I did a very quick look at it and it all makes sense to me. Note that I am not adding an explicit approval because I didn't do a proper review as I have a lot to catch up on and I don't want to block a PR that's already approved.

I also took a look at the release notes for lifecycle and as far as I can tell there are only a few minor behavioural changes, so it seems like a "safe" update, so 👍 for that as well.

@oguzkocer
oguzkocer merged commit 14e5729 into update/nav-component-version-to-2.4.2 May 31, 2022
@oguzkocer
oguzkocer deleted the lint/resolve-null-safe-mutable-live-data-lint-errors branch May 31, 2022 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants