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

[Nullability Annotations to Java Classes] Add Missing Nullability Annotations to Discovery Network Client Classes (safe) #2872

Merged

Conversation

ParaskP7
Copy link
Contributor

@ParaskP7 ParaskP7 commented Oct 17, 2023

Parent #2798

This PR adds any missing nullability annotation to DiscoveryWPAPIRestClient.java and DiscoveryXMLRPCClient.java, all its related response classes and anything in between (ie. AccountStore, SiteWPAPIRestClient).

FYI.1: This change is safe, meaning that there shouldn't be any (major) compile-time changes associated with this change. Having said that, testing is highly recommended since the changes in this PR can affect one or more clients (ie. JP/WPAndroid, WCAndroid, etc)

FYI.2: An analysis on AccountStore, SiteWPAPIRestClient and their usages with our main clients suggests that this store is being utilizing by both, the JP/WPAndroid and WCAndroid clients.


PS.1: @hichamboushaba I added you as the main reviewer, randomly so, since I just wanted someone from the WooCommerce mobile team to be aware of and sign-off on that change for both. Feel free to merge this PR directly yourself if you deem so.

PS.2: @irfano I am also adding you as an extra reviewer, randomly so, since I want someone from the Jetpack/WordPress mobile team to be aware of this change as well. However, there is no need for you to review it as well, thus duplicating the review work. Having one team member from either of the mobile teams reviewing and testing this change is enough for this change.


Nullability Annotation List:

  1. Add missing n-a to discover base url on discovery rest client
  2. Add missing n-a to verify support on discovery rest client
  3. Add missing n-a to get response on discovery xmlrpc client
  4. Add missing n-a to list methods on discovery xmlrpc client
  5. Add missing nn-a to dispatcher field on sh ep finder
  6. Add missing nn-a to xmlrpc client field on sh ep finder
  7. Add missing nn-a to rest client field on sh ep finder
  8. Add missing n-a to discovery exception on sh ep finder
  9. Add missing n-a to find endpoint on sh ep finder
  10. Add missing n-a to ordered verify urls to try on sh ep finder
  11. Add missing n-a to rsd metal tag href regex on sh ep finder
  12. Add missing n-a to sanitize site url on sh ep finder
  13. Add missing n-a to check xmlrpc ep validity on sh ep finder
  14. Add missing n-a to discovery result payload on sh ep finder
  15. Add missing n-a to strip known paths on discovery utils
  16. Add missing n-a to validate lm response on discovery utils
  17. Add missing n-a to is http auth em on discovery utils
  18. Add missing n-a to get xmlrpc api link on discovery utils
  19. Add missing n-a to get xmlrpc pingback on discovery utils
  20. Add missing n-a on discovery xmlrpc request
  21. Add missing n-a on discovery request
  22. Add missing n-a on wp api head request

Nullability Checks List:

  1. Guard usages of response namespaces on discovery rest client
  2. Guard usages of response headers on wp api head request

Warnings Resolutions List:

  1. Remove discovery exception from discover base url throws list
  2. Change type of request to root wp api rest response
  3. Remove discovery exception from rsd url based throws list

Warnings Suppression List:

  1. Suppress commented out code on discovery rest client

Refactor List:

  1. Reformat discovery wp api rest client
  2. Reformat discovery xmlrpc client
  3. Reformat self hosted endpoint finder
  4. Replace anonymous classes with lambda
  5. Move static rsd link field to top of sh ep finder

Docs List:

  1. Fix typo with perform on discovery xmlrpc client
  2. Fix typo with perform on discovery utils

Associated Clients

It is highly recommending that this change is being tested on the below associated clients:


To Test (REST):

  • Smoke test the FluxC Example app via the SIGN IN & FETCH SITES, SIGH OUT & SIGNED OUT ACTIONS screens. Verify everything is working as expected.
  • In addition to the above, using local-builds.gradle on JP/WPAndroid, smoke test any login/out and fetch site related functionality on both, the WordPress and Jetpack apps, and see if everything is working as expected.
  • Furthermore, using local-builds.gradle on WCAndroid, smoke test any login/out and fetch site related functionality and see if everything is working as expected.

To Test (XMLRPC):

  • Create a new self-hosted WordPress site for XMLRPC testing purposes (jurassic.ninja).
  • Smoke test the FluxC Example app via the SIGN IN & FETCH SITES, SIGH OUT & SIGNED OUT ACTIONS screens. Verify everything is working as expected.
  • In addition to the above, using local-builds.gradle on JP/WPAndroid, smoke test any login/out and fetch site related functionality on both, the WordPress and Jetpack apps, and see if everything is working as expected.
  • Furthermore, using local-builds.gradle on WCAndroid, smoke test any login/out and fetch site related functionality and see if everything is working as expected.

Warning: "Exception 'org.wordpress.android.fluxc.network.discovery
.SelfHostedEndpointFinder.DiscoveryException' is never thrown in the
method"
Warning: "Raw use of parameterized class 'WPAPIGsonRequest'"
Warnings: "Commented out code (7 lines)"

There exist a TODO related to both those commented-out code, which is
about adding support for HTTP AUTH and self-signed SSL WP-API sites.
FYI: 'n-a' stands for 'nullability annotations'.
FYI: 'n-a' stands for 'nullability annotations'.
FYI: 'n-a' stands for 'nullability annotations'.
FYI: 'n-a' stands for 'nullability annotations'.
Warning: "Exception 'org.wordpress.android.fluxc.network.discovery
.SelfHostedEndpointFinder.DiscoveryException' is never thrown in the
method"
FYI: 'nn-a' stands for 'non-null annotation'.
FYI: 'nn-a' stands for 'non-null annotation'.
FYI: 'nn-a' stands for 'non-null annotation'.
FYI: 'n-a' stands for 'nullability annotations'.
FYI: 'n-a' stands for 'nullability annotations'.
FYI: 'n-a' stands for 'nullability annotations'.
FYI: 'n-a' stands for 'nullability annotations'.
FYI: 'n-a' stands for 'nullability annotations'.
FYI: 'n-a' stands for 'nullability annotations'.
FYI: 'n-a' stands for 'nullability annotations'.
FYI: 'n-a' stands for 'nullability annotations'.
FYI: 'n-a' stands for 'nullability annotations'.
FYI: 'n-a' stands for 'nullability annotations'.
FYI: 'n-a' stands for 'nullability annotations'.
FYI: 'n-a' stands for 'nullability annotations'.
Warning: "Typo: In word 'begining'"
FYI: 'n-a' stands for 'nullability annotations'.
FYI: 'n-a' stands for 'nullability annotations'.
FYI: 'n-a' stands for 'nullability annotations'.
…ndroid into analysis/add-missing-nullability-annotations-to-discovery-clients
Copy link
Member

@hichamboushaba hichamboushaba left a comment

Choose a reason for hiding this comment

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

Nice work @ParaskP7, thanks for handling this.
I reviewed the code, and I tested the changes with WCAndroid, and there are no compile errors.

@ParaskP7
Copy link
Contributor Author

👋 @hichamboushaba and thanks so much for reviewing and testing this, you are awesome! 🙇 ❤️ 🚀

FYI: @irfano I'll be also waiting any input from you, else a quick 👍, that is before proceeding with merging this, just so that I know you are aware of this change merging into trunk before it happens.

Copy link
Member

@irfano irfano left a comment

Choose a reason for hiding this comment

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

I conducted smoke tests on signing in, signing out, and site-fetching screens for WordPress.com and a self-hosted site. Everything appears to be working fine 🟢.
I also skimmed the code changes; they all seem safe.

@irfano irfano merged commit 9344541 into trunk Oct 19, 2023
2 checks passed
@irfano irfano deleted the analysis/add-missing-nullability-annotations-to-discovery-clients branch October 19, 2023 14:57
@ParaskP7
Copy link
Contributor Author

Awesome, thank you so much for the skim review, testing and merging this @irfano , you rock! 🙇 ❤️ 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants