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

Merge some of the WordPress lint rules, to reduce number of reported issues #21256

Merged
merged 11 commits into from
Nov 7, 2024

Conversation

wzieba
Copy link
Contributor

@wzieba wzieba commented Sep 24, 2024

Description

This PR disables UnkownNullness lint check, to not duplicate lint warnings of the same type we get from WordPress-Lint.

Testing

Not necessary.

Related: wordpress-mobile/WordPress-Lint-Android#20

@dangermattic
Copy link
Collaborator

dangermattic commented Sep 24, 2024

1 Warning
⚠️ PR is not assigned to a milestone.

Generated by 🚫 Danger

Copy link

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Sep 24, 2024

Jetpack📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack Jetpack
FlavorJalapeno
Build TypeDebug
Versionpr21256-ffb9840
Commitffb9840
Direct Downloadjetpack-prototype-build-pr21256-ffb9840.apk
Note: Google Login is not supported on these builds.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Sep 24, 2024

WordPress📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress WordPress
FlavorJalapeno
Build TypeDebug
Versionpr21256-ffb9840
Commitffb9840
Direct Downloadwordpress-prototype-build-pr21256-ffb9840.apk
Note: Google Login is not supported on these builds.

@@ -79,4 +79,6 @@

<!-- TODO: https://github.com/wordpress-mobile/WordPress-Android/issues/21065 -->
<issue id="UsingMaterialAndMaterial3Libraries" severity="warning" />
<!-- We rely on more granural checks from WordPress-Lint-Android -->
<issue id="UnknownNullness" severity="ignore" />
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion (💡): Instead of ignoring UnknownNullness I actually recommend we revert #19116 and remove all the configuration related to that, effectively removing it, not ignoring. 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you @ParaskP7 ! I've applied your suggestion and rebranded this PR to not introduce changed WordPress Lint checks. I don't have capacity to work on this now, but I think PR in this shape will also be useful to merge!

@wzieba wzieba added the Core label Nov 1, 2024
@wzieba wzieba marked this pull request as ready for review November 1, 2024 16:06
@wzieba wzieba requested a review from ParaskP7 November 1, 2024 16:07
Copy link
Contributor

@ParaskP7 ParaskP7 left a comment

Choose a reason for hiding this comment

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

👋 @wzieba !

I have reviewed this PR as per the instructions, everything works as expected, good job! 🌟


I have left one suggestion (💡) for you to consider. I am going to approve this PR anyway, since none is blocking. I am NOT going to merge this PR yet to give you some time to apply any of my suggestions. However, feel free to ignore them and merge the PR yourself.

@@ -18,7 +18,6 @@ android {
buildConfig true
}
lint {
enable += 'UnknownNullness'
disable 'UseTomlInstead'
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion (💡): I understand that we could remove this here too, now that all dependencies within this module are migrated to version catalogs. And then get rid of the whole lint { ... } block, just like you did for the rest of the modules.

PS: We could potentially do the same for the fluxc module, but we would first need to migrate the below two dependencies to version catalogs (however, I am not sure about the IgnoreWithoutReason):

    api "com.goterl:lazysodium-android:5.0.2@aar"
    api "net.java.dev.jna:jna:5.15.0@aar"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

PS: We could potentially do the same for the fluxc module, but we would first need to migrate the below two dependencies to version catalogs

This is not easy to do though, because of the aar specification not working as intended. This is needed, because both of these dependencies offer both aar and jar and one of them even defaults to jar. This seems to be a known issue at Gradle (gradle/gradle#21267) but not yet fixed.

But regarding the login module, I agree, I'll fix this in a sec!

Copy link
Contributor

@ParaskP7 ParaskP7 Nov 4, 2024

Choose a reason for hiding this comment

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

But regarding the login module, I agree, I'll fix this in a sec!

Thanks @wzieba ! 🙏

This seems to be a known issue at Gradle (gradle/gradle#21267) but not yet fixed.

Yea, true, I tried really quick myself and couldn't get it working (the right way), but I didn't thought this would be such a blocker, interesting, thanks for sharing this issue... 🤔

I guess, in the meanwhile, we could do the following, adding a TODO comment point to the issue you shared:

libs.version.toml

...
[versions]
terl-lazysodium-android = '5.0.2@aar'
jna = '5.15.0@aar'
...
[libraries]
terl-lazysodium-android = { module = "com.goterl:lazysodium-android", version.ref = "terl-lazysodium-android" }
jna = { module = "net.java.dev.jna:jna", version.ref = "jna" }
...

build.gradle

api(libs.terl.lazysodium.android.get().toString()) // TODO: https://github.com/gradle/gradle/issues/21267
api(libs.jna.get().toString()) // TODO: https://github.com/gradle/gradle/issues/21267

Wdyt? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This looks neat, but I'm unable to verify that aar instead of jar is actually used.

Let's take the JNA dependency for the example: it offers both aar and jar. The default artifact specified in the pom file is jar: https://mvnrepository.com/artifact/net.java.dev.jna/jna/5.15.0

When I applied your suggestion and when I run :WordPress:dependencyInsight --dependency net.java.dev.jna:jna --configuration wordpressWasabiDebugRuntimeClasspath, it seems that jar is used. You can compare this result to result of any other dependency, e.g. :WordPress:dependencyInsight --dependency androidx.credentials:credentials --configuration wordpressWasabiDebugRuntimeClasspath which prints usage of aar.

But what's strange, when I run the dependency insight for JNA on trunk, I also see that jar is requested 😕 .

For this reason, as I'm not entirely sure how it all work, I'd postpone changing this dependencies to version catalog as I'm not sure what would be the effect. Happy to hear your thoughts - maybe there's a way to make sure aar is used?

Copy link
Contributor

Choose a reason for hiding this comment

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

@wzieba , I did a simple println(...) to verify the exact string that is used. In the end, using this .get().toString() trick should give us exactly what we had before, a simple string, there shouldn't be any more magic involved, not having version catalogs choosing between aar and jar whatsoever (🤔). This is my assumption at least. 🤞

println("LazySodium: ${libs.terl.lazysodium.android.get().toString()}")
println("JNA: ${libs.jna.get().toString()}")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gotcha 👍 when I removed @aar the project won't compile, and with the code you suggested, build is complete so I think we're all good 👍

I've also applied changed to remove IgnoreWithoutReason from disabled rules.

@wzieba wzieba enabled auto-merge November 7, 2024 11:55
Copy link

sonarqubecloud bot commented Nov 7, 2024

@wzieba wzieba merged commit 0fe0421 into trunk Nov 7, 2024
22 of 23 checks passed
@wzieba wzieba deleted the bump_android_lint branch November 7, 2024 12:17
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.

4 participants