Fixed
Status Update
Comments
il...@google.com <il...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-main
commit 57ca221882695bd6a52549f4d9ea3b812e6fe87c
Author: Simon Schiller <simonschiller@users.noreply.github.com>
Date: Mon Mar 22 16:09:30 2021
[GH] [FragmentStrictMode] Detect <fragment> tag usage
## Proposed Changes
- Detect `<fragment>` tag usage inside XML layouts
## Testing
Test: See `FragmentStrictModeTest#detectFragmentTagUsage`
## Issues Fixed
Fixes: 153738235
This is an imported pull request fromhttps://github.com/androidx/androidx/pull/141 .
Resolves #141
Github-Pr-Head-Sha: 4ea052596e4341b9f11bcf335e2bc38045a91f19
GitOrigin-RevId: 62e7487aa4874eef6bb556490e193717cf937251
Change-Id: Iae48578e85e4e4897f806d7ade2e2a660adf9479
M fragment/fragment/api/public_plus_experimental_current.txt
M fragment/fragment/api/restricted_current.txt
M fragment/fragment/src/androidTest/java/androidx/fragment/app/strictmode/FragmentStrictModeTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentLayoutInflaterFactory.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentStrictMode.java
A fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentTagUsageViolation.java
https://android-review.googlesource.com/1649748
Branch: androidx-main
commit 57ca221882695bd6a52549f4d9ea3b812e6fe87c
Author: Simon Schiller <simonschiller@users.noreply.github.com>
Date: Mon Mar 22 16:09:30 2021
[GH] [FragmentStrictMode] Detect <fragment> tag usage
## Proposed Changes
- Detect `<fragment>` tag usage inside XML layouts
## Testing
Test: See `FragmentStrictModeTest#detectFragmentTagUsage`
## Issues Fixed
Fixes: 153738235
This is an imported pull request from
Resolves #141
Github-Pr-Head-Sha: 4ea052596e4341b9f11bcf335e2bc38045a91f19
GitOrigin-RevId: 62e7487aa4874eef6bb556490e193717cf937251
Change-Id: Iae48578e85e4e4897f806d7ade2e2a660adf9479
M fragment/fragment/api/public_plus_experimental_current.txt
M fragment/fragment/api/restricted_current.txt
M fragment/fragment/src/androidTest/java/androidx/fragment/app/strictmode/FragmentStrictModeTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentLayoutInflaterFactory.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentStrictMode.java
A fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentTagUsageViolation.java
la...@gmail.com <la...@gmail.com> #3
The reproducible part is already the two lines of code above. Anyway, attaching a project to further demonstrate the issue, with the first line further simplified to View view = null;
il...@google.com <il...@google.com>
ap...@google.com <ap...@google.com> #4
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 7ace325454f63cfd3d574ab30cf3f28b1d349df9
Author: Rahul Ravikumar <rahulrav@google.com>
Date: Mon Feb 24 16:18:59 2020
Fix for lint UseRequireInsteadOfGet false positives
* When checking for reference expressions, ignore local variables.
Test: Added unit tests.
Fixes: b/149891163
Change-Id: I636a6d059967064f6e0c9c435fdf2f3556b2ed00
M fragment/fragment-lint/src/main/java/androidx/fragment/lint/UseRequireInsteadOfGet.kt
M fragment/fragment-lint/src/test/java/androidx/fragment/lint/UseRequireInsteadOfGetTest.kt
https://android-review.googlesource.com/1242418
Branch: androidx-master-dev
commit 7ace325454f63cfd3d574ab30cf3f28b1d349df9
Author: Rahul Ravikumar <rahulrav@google.com>
Date: Mon Feb 24 16:18:59 2020
Fix for lint UseRequireInsteadOfGet false positives
* When checking for reference expressions, ignore local variables.
Test: Added unit tests.
Fixes:
Change-Id: I636a6d059967064f6e0c9c435fdf2f3556b2ed00
M fragment/fragment-lint/src/main/java/androidx/fragment/lint/UseRequireInsteadOfGet.kt
M fragment/fragment-lint/src/test/java/androidx/fragment/lint/UseRequireInsteadOfGetTest.kt
il...@google.com <il...@google.com> #5
We've fixed this internally and it'll be available in the upcoming Fragment 1.3.0-alpha01 release (and if we do a Fragment 1.2.3, it'll also be a part of that).
Description
Version used: 1.2.2
The UseRequireInsteadOfGet lint checks in androidx-fragment 1.2.2 can detect false positives. Consider the following Java code in a Fragment:
View view = getSomeCompletelyUnrelatedView();
Objects.requireNonNull(view);
results in the following lint error:
Error: Use requireView() instead of Objects.requireNonNull(view) [UseRequireInsteadOfGet]
which would be valid if view was the result of a getView() call but it isn't.
Workaround: Rename the view variable to some other name