Skip to content

[Lifecycle] [Lint] fixes b/184830263 Lint should use check reference too - #161

Closed
kozaxinan wants to merge 3 commits into
androidx:androidx-mainfrom
kozaxinan:184830263
Closed

kozaxinan wants to merge 3 commits into
androidx:androidx-mainfrom
kozaxinan:184830263

Conversation

@kozaxinan

@kozaxinan kozaxinan commented Apr 17, 2021

Copy link
Copy Markdown
Contributor

Proposed Changes

  • Fix NonNullableMutableLiveDataDetector for different cases. It is possible to only set type reference and omit call's generic argument.
  • Added check for generic values because default upper bound of generic (if none specified) is Any?. If generic is not specified as <T : Any>, T can be defined null at call site. https://kotlinlang.org/docs/generics.html#upper-bounds

Testing

Test: Run NonNullableMutableLiveDataDetectorTest with new edge cases.
nullLiteralFailMultipleFields : Added type reference
justKotlinObject : Add additional test to prevent ArrayIndexOutOfBoundsException. It is fixed in 428f0ec but not tested. It is reported here with b/184830262
genericParameterDefinition : Generics are assumed as nullable, lint should ignore.

Issues Fixed

Fixes: The bug on b/184830263 being fixed
Fixes: Tests b/184830262

@googlebot

Copy link
Copy Markdown
Collaborator

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

1 similar comment
@google-cla

google-cla Bot commented Apr 17, 2021

Copy link
Copy Markdown

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@kozaxinan

Copy link
Copy Markdown
Contributor Author

@googlebot I signed it!

@googlebot

Copy link
Copy Markdown
Collaborator

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

1 similar comment
@google-cla

google-cla Bot commented Apr 17, 2021

Copy link
Copy Markdown

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@jbw0033
jbw0033 self-requested a review April 19, 2021 17:25
@kozaxinan

Copy link
Copy Markdown
Contributor Author

@jbw0033 Is there anything I can add to this PR?
This lint blocks us to update latest version of lifecycle.

@kozaxinan
kozaxinan requested a review from jbw0033 May 3, 2021 16:41
@kozaxinan
kozaxinan requested a review from jbw0033 May 5, 2021 09:02
@jbw0033

jbw0033 commented May 5, 2021

Copy link
Copy Markdown

From our internal lint:

lifecycle/lifecycle-livedata-core-ktx-lint/src/test/java/androidx/lifecycle/lint/NonNullableMutableLiveDataDetectorTest.kt
#202
Patchset 1
9:08 AM
Lint 🤖
Please remove the trailing whitespace.

#794
Patchset 1
9:08 AM
Lint 🤖
Please remove the trailing whitespace.

@kozaxinan

kozaxinan commented May 5, 2021

Copy link
Copy Markdown
Contributor Author

From our internal lint:

lifecycle/lifecycle-livedata-core-ktx-lint/src/test/java/androidx/lifecycle/lint/NonNullableMutableLiveDataDetectorTest.kt
#202
Patchset 1
9:08 AM
Lint 🤖
Please remove the trailing whitespace.

#794
Patchset 1
9:08 AM
Lint 🤖
Please remove the trailing whitespace.

I deleted whitespaces. When I run ./gradlew buildOnServer some unrelated lints fails, is that expected? (even on main branch)

@copybara-service copybara-service Bot closed this in 655e08d May 6, 2021
@kozaxinan
kozaxinan deleted the 184830263 branch May 6, 2021 16:02
@jbw0033

jbw0033 commented May 6, 2021

Copy link
Copy Markdown

Thank you for the pull request!

harryzz pushed a commit to harryzz/compose-multiplatform-core that referenced this pull request Jul 28, 2026
…ence too

## Proposed Changes

  - Fix NonNullableMutableLiveDataDetector for  [different cases](https://issuetracker.google.com/issues/184830263). It is possible to only set type reference and omit call's generic argument.
  -  Added check for generic values because default upper bound of generic (if none specified) is Any?.  If generic is not specified as `<T : Any>`, `T` can be defined null at call site. https://kotlinlang.org/docs/generics.html#upper-bounds

## Testing

Test: Run NonNullableMutableLiveDataDetectorTest with new edge cases.
`nullLiteralFailMultipleFields` : Added type reference
`justKotlinObject` : Add additional test to prevent ArrayIndexOutOfBoundsException. It is fixed in androidx@1ebd7bc but not tested. It is reported here with [b/184830262](https://issuetracker.google.com/issues/184830262)
`genericParameterDefinition` : Generics are assumed as nullable, lint should ignore.

## Issues Fixed

Fixes: The bug on [b/184830263](https://issuetracker.google.com/issues/184830263) being fixed
Fixes: Tests [b/184830262](https://issuetracker.google.com/issues/184830263)

This is an imported pull request from androidx#161.

Resolves JetBrains#161
Github-Pr-Head-Sha: e96b4a8
GitOrigin-RevId: eb21c2e
Change-Id: Id6cd01e9ec6b79a3f14b569b53d79627c79b9866
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants