Skip to content

[Compile Warnings As Errors] WordPress Module - Resolve Other Warnings#17293

Merged
zwarm merged 11 commits intotrunkfrom
analysis/wordpress-main-other-warnings
Oct 11, 2022
Merged

[Compile Warnings As Errors] WordPress Module - Resolve Other Warnings#17293
zwarm merged 11 commits intotrunkfrom
analysis/wordpress-main-other-warnings

Conversation

@ParaskP7
Copy link
Copy Markdown
Contributor

Parent: #17173
Partially Closes: #17181

This PR resolves one part of all Other related warnings for the WordPress module, and in this part, (mainly) specific to the main source:

Main Source (35):

  • 1 x This is a delicate API and its use requires care. Make sure you fully read and understand documentation of the declaration that is marked as a delicate API.
  • 17 x Parameter 'xyz' is never used
  • 9 x Parameter 'xyz' is never used, could be renamed to _
  • 2 x Name shadowed: xyz
  • 1 x Parcelize annotations from package 'kotlinx.android.parcel' are deprecated. Change package to 'kotlinx.parcelize'
  • 1 x Variable 'xyz' initializer is redundant
  • 1 x There is more than one label with such a name in this scope
  • 2 x Condition 'xyz' is always 'xyz'
  • 1 x Unreachable code

Test Source (5)

  • 3 x Parameter 'xyz' is never used
  • 2 x Variable 'xyz' is never used

Warnings Resolution List:

  1. Resolve global scope delicate coroutines api warnings.
  2. Resolve parameter is never and could be renamed to _ warnings.
  3. Resolve variable is never used test warnings.
  4. Resolve name shadowed warnings.
  5. Resolve parcelize annotations deprecated package warning.
  6. Resolve variable initializer is redundant warning.
  7. Resolve more than one label with such a name in scope warning.
  8. Resolve condition is always true warnings.
  9. Resolve unreachable code warning.

Warnings Suppression List:

  1. Suppress parameter is never used warnings.

Refactor List:

  1. Use suppress in favor of suppress warnings for kotlin classes.

PS: @zwarm I added you as the main reviewer, that is, in addition to @wordpress-mobile/apps-infrastructure team itself, but randomly, since I want someone from the WordPress Android team to primarily sign-off on that change. 🥇

FYI: I am going to randomly add more of you in those PRs that will follow, just so you become more aware of this change and how close we are on enabling allWarningsAsErrors by default everywhere. 🎉


To test:

  • There is nothing much to test here.
  • Verifying that all the CI checks are successful should be enough.
  • However, if you want to be thorough about reviewing this change, you could quickly smoke test both, the WordPress and Jetpack apps, and see if they are both working as expected.

Regression Notes

  1. Potential unintended areas of impact

N/A

  1. What I did to test those areas of impact (or what existing automated tests I relied on)

See To test section above.

  1. What automated tests I added (or what prevented me from doing so)

N/A


PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

Warning Message: "This is a delicate API and its use requires care.
Make sure you fully read and understand documentation of the declaration
that is marked as a delicate API."

Adding the '@OptIn(DelicateCoroutinesApi::class)' annotation for the
'retrieveCapability(...)' function is the recommended action to resolve
this 'GlobalScope' warning.
The Kotlin stdlib related '@Suppress' annotation is preferable to the
Java lang related '@SuppressWarnings' annotation, if not for anything,
even just for consistency purposes. As such, the '@SuppressWarnings' is
being replaced with '@Suppress' on all Kotlin classes, wherever it is
found.
Warning Message: "Parameter 'xyz' is never used"

Notice that for 'Event Bus' related functions this warning should be
suppressed instead. This is because this is how the 'Event bus'
mechanism works as it need the parameter to be present on a function,
even if that parameter is unused.
Warning Message: "Parameter 'xyz' is never used, could be renamed to _"

Renaming the parameter 'xyz' that is never used to '_' or removing it
completely is the recommended action to resolve this kind of warnings.
Warning Message: "Variable 'xyz' is never used"
Warning Message: "Name shadowed: xyz"

Renaming the shadowed and/or the shadowing 'xyz' name is the recommended
action to resolve this kind of deprecated warnings.
Warning Message: "Parcelize annotations from package
'kotlinx.android.parcel' are deprecated. Change package to
'kotlinx.parcelize'"
Warning Message: "Variable 'cursor' initializer is redundant"
Warning Message: "There is more than one label with such a name in this
scope"
Warning Message: "Condition 'xyz' is always 'xyz'"
Warning Message: "Unreachable code"
@wpmobilebot
Copy link
Copy Markdown
Contributor

WordPress📲 You can test these changes on WordPress by downloading wordpress-installable-build-pr17293-3060469.apk
💡 Scan this QR code with your Android phone to download and install the APK directly on it.
AppWordPress
Build FlavorJalapeno
Build TypeDebug
Commit3060469
Note: This installable build uses the JalapenoDebug build flavor, and does not support Google Login.

@wpmobilebot
Copy link
Copy Markdown
Contributor

Jetpack📲 You can test these changes on Jetpack by downloading jetpack-installable-build-pr17293-3060469.apk
💡 Scan this QR code with your Android phone to download and install the APK directly on it.
AppJetpack
Build FlavorJalapeno
Build TypeDebug
Commit3060469
Note: This installable build uses the JalapenoDebug build flavor, and does not support Google Login.

Copy link
Copy Markdown
Contributor

@zwarm zwarm left a comment

Choose a reason for hiding this comment

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

@ParaskP7 - I have taken the apps out for a spin. Nothing unusual, so 👍 . Thanks for including me a reviewer, it's been nice seeing the changes and helps me in the future. I left one question, non-PR related, so I'll be merging this PR.

🚢

): List<String> {
val contentDescriptions = mutableListOf<String>()
entries.forEachIndexed { index, bar ->
entries.forEachIndexed { _, bar ->
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@ParaskP7 - all is good with the change you made ... just questioning why the use of forEachIndexed without actually using the index. 🤷 What am I missing? And I don't expect a change for this, it's not part of the PR.

Copy link
Copy Markdown
Contributor Author

@ParaskP7 ParaskP7 Oct 11, 2022

Choose a reason for hiding this comment

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

Ha, yea, you are right @zwarm, this could have further improved to become a plain entries.forEach { bar -> ... }, the indexed version is not needed as the index ends up becoming unused. I am seeing this entries.forEachIndexed { index, bar -> ... } being actually used within getBarChartEntryContentDescriptions(...) above, and as such, I think this was just a copy-pasting overside at that point to create the getLineChartEntryContentDescriptions(...) below, which this time didn't have any need for that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

PS: I am going to fix that on my next PR. It would be just another refactoring commit on top of all the others commits! 🎉 Thanks for spotting it! 🙇 ❤️ 🌟

@zwarm zwarm merged commit 09a3984 into trunk Oct 11, 2022
@zwarm zwarm deleted the analysis/wordpress-main-other-warnings branch October 11, 2022 13:49
@ParaskP7
Copy link
Copy Markdown
Contributor Author

And again, thank you so much for reviewing, testing and merging this PR @zwarm, you are awesome! 🙇 ❤️ 🚀

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.

Compiler Warnings as Errors - WordPress Module

3 participants