Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FragmentStrictMode] Detect calls to Fragment#setTargetFragment #139

Conversation

simonschiller
Copy link
Contributor

Proposed Changes

  • Detect calls to Fragment#setTargetFragment

Testing

Test: See FragmentStrictModeTest#detectSetTargetFragment

Issues Fixed

Fixes: 153737745

@google-cla google-cla bot added the cla: yes label Mar 12, 2021
@simonschiller
Copy link
Contributor Author

Right now, this check only detects calls to Fragment#setTargetFragment. We could also extend it to detect calls to Fragment#getTargetFragment and Fragment#getTargetRequestCode, as those methods belong to the same category. What do you think?

@jbw0033
Copy link

jbw0033 commented Mar 15, 2021

We should do all of the methods.

The long term goal for strict mode is to remove any APIs that cause violations. So if you have strict mode on and your app has no problems, then when you upgrade to say Fragment 2.0 where all the APIs that cause violations have been removed, it should be like a no-op. So although, calling the getters without the setter is not very useful, we should make sure we are actually catching those calls and reporting them as violations.

@simonschiller
Copy link
Contributor Author

Makes sense, I adapted the PR (as well as #140).

@simonschiller simonschiller deleted the feature/set-target-fragment branch March 23, 2021 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants