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] Enable and Configure UnknownNullness Android Lint Check #2823

Merged
merged 4 commits into from
Sep 4, 2023

Conversation

ParaskP7
Copy link
Contributor

@ParaskP7 ParaskP7 commented Aug 31, 2023

Parent #2795
Closes #2822

This PR enabled and configures the extra interop related UnknownNullness Android Lint check to help detect and flag some of the nullability related interoperability issues, that is, issues in Java for Kotlin consumption.

For more info see:


To test:

  • There is nothing much to test here, verifying that all the CI checks are successful should be enough
    • Focus more on the Lint related ones.
  • You could also check that the Interoperability:Kotlin Interoperability related section on the Lint report is shown and reporting some few thousand of warnings (fluxc + plugins:woocommerce + example).
    • For example, locally, running Lint on the fluxc + debug variant, I got 2152 such warnings, configured to be informational only so that they don't fail the build, see screenshot below:

image

It doesn't seem that this 'lint.xml' file is being within the 'fluxc'
module, or anywhere for that matter. Thus, this is now being removed so
as to avoid having to worry about this unused file, thinking that it has
some kind of effect on this project's current Lint configuration.
It doesn't seem that this Lint related warning configuration for the
'InvalidPackage' check is necessary for the 'example' module. It is
better to remove that and have Lint being configured as straightforward
as possible.

FYI: This unnecessary Lint configuration was added as part of this very
first commit on this repo back on October 27th, 2015:
78b37f9
With that change the extra interop related 'UnknownNullness' Android
Lint check gets enabled, which helps detect and flag some of the
nullability interoperability issues for this project.

For more info see:
- Docs: https://developer.android.com/kotlin/interop#supported_checks
- Check: https://googlesamples.github.io/android-custom-lint-rules/
checks/UnknownNullness.md.html
The default severity for 'UnknownNullness' is 'Warning'. This change
updates that to 'Informational'. This is done in order to treat this
kind of warnings as informational only, a light typo like of a warning
in AS.
@ParaskP7 ParaskP7 requested a review from mkevins August 31, 2023 12:50
@ParaskP7 ParaskP7 self-assigned this Aug 31, 2023
@ParaskP7 ParaskP7 changed the title [Nullability Annotations to Java Classes] Enable and Configure UnknownNullness Android Lint Check [Nullability Annotations to Java Classes] Enable and Configure UnknownNullness Android Lint Check Aug 31, 2023
Copy link
Contributor

@mkevins mkevins left a comment

Choose a reason for hiding this comment

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

Nice! This is working as well for me. Similar to the WordPress-Android, the informational highlights did not show up in the editor until enabling them with an extra setting (similar to what is described here: wordpress-mobile/WordPress-Android#19116 (review)):

diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
index 4e2b427ce..4e4b694ab 100644
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -1,6 +1,7 @@
 <component name="InspectionProjectProfileManager">
   <profile version="1.0">
     <option name="myName" value="Project Default" />
+    <inspection_tool class="AndroidLintUnknownNullness" enabled="true" level="WARNING" enabled_by_default="true" />
     <inspection_tool class="ClassName" enabled="true" level="WEAK WARNING" enabled_by_default="true">
       <scope name="Tests" level="INFORMATION" enabled="true" />
     </inspection_tool>

Feel free to merge as is, or if it makes sense, include this config as well. 🤷‍♂️

@ParaskP7
Copy link
Contributor Author

ParaskP7 commented Sep 1, 2023

👋 @mkevins and thanks for the review! 🙇 ❤️ 🚀

Nice! This is working as well for me. Similar to the WordPress-Android, the informational highlights did not show up in the editor until enabling them with an extra setting (similar to what is described here: wordpress-mobile/WordPress-Android#19116 (review)):

Feel free to merge as is, or if it makes sense, include this config as well. 🤷‍♂️

Same response. 😊

@mkevins
Copy link
Contributor

mkevins commented Sep 3, 2023

As discussed on the similar WordPress-Android PR, no need to change any ./idea/ files, as we'll soon have our own rule enabled anyway. 👍

@ParaskP7
Copy link
Contributor Author

ParaskP7 commented Sep 4, 2023

As discussed on the similar WordPress-Android PR, no need to change any ./idea/ files, as we'll soon have our own rule enabled anyway. 👍

Awesome @mkevins , once more thanks for the excellent review and for always sharing great suggestions! 🥇

@ParaskP7 ParaskP7 merged commit 838d242 into trunk Sep 4, 2023
@ParaskP7 ParaskP7 deleted the analysis/enable-unknown-nullness-lint-check branch September 4, 2023 07:21
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.

Nullability Annotations to Java Classes - Enable and Configure UnknownNullness Android Lint Check
2 participants