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

Update function usage in SSR and remove need for commons-io #13073

Merged
merged 9 commits into from
Dec 11, 2024

Conversation

hafizrahman
Copy link
Contributor

@hafizrahman hafizrahman commented Dec 5, 2024

Description

While looking at the Dependabot PR #13044 , I investigated a little bit and found that the dependency common-io was used just for a function in WCSSRModelExt. Then I found from Stack Overflow a function that can replace it without the need for the dependency:

https://stackoverflow.com/a/5599842

This PR adds that function and unit tests, replaces the usage, and removes the dependency.

Steps to reproduce

  • Make sure unit tests pass
  • Go to More Menu > Help & Support > System Status Report, and ensure these are showing correct values:
    • WordPress Environment > WP Memory Limit
    • Server Environment > PHP Post Max Size
    • Server Environment > Max Upload Size

Testing information

Nothing specific needed here.

The tests that have been performed

I checked the steps listed above.

Images/gif

n/a

  • I have considered if this change warrants release notes and have added them to RELEASE-NOTES.txt if necessary. Use the "[Internal]" label for non-user-facing changes.

Reviewer (or Author, in the case of optional code reviews):

Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement:

  • The PR is small and has a clear, single focus, or a valid explanation is provided in the description. If needed, please request to split it into smaller PRs.
  • Ensure Adequate Unit Test Coverage: The changes are reasonably covered by unit tests or an explanation is provided in the PR description.
  • Manual Testing: The author listed all the tests they ran, including smoke tests when needed (e.g., for refactorings). The reviewer confirmed that the PR works as expected on big (tablet) and small (phone) in case of UI changes, and no regressions are added.

@wpmobilebot
Copy link
Collaborator

Project dependencies changes

The following changes in project dependencies were detected (configuration vanillaReleaseRuntimeClasspath):

list
Removed Dependencies
commons-io:commons-io:2.11.0
tree
-\--- commons-io:commons-io:2.11.0

@hafizrahman hafizrahman marked this pull request as ready for review December 5, 2024 06:41
@hafizrahman hafizrahman added this to the 21.3 milestone Dec 5, 2024
@hafizrahman hafizrahman added feature: support Related to anything in the help & support section, including app logs and the Zendesk SDK. dependency update labels Dec 5, 2024
@hafizrahman hafizrahman changed the title Update function usage in SSR and remove need for commons:io Update function usage in SSR and remove need for commons-io Dec 5, 2024
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Dec 5, 2024

📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
App Name WooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commitc616faf
Direct Downloadwoocommerce-wear-prototype-build-pr13073-c616faf.apk

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Dec 5, 2024

📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.

App Name WooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Commitc616faf
Direct Downloadwoocommerce-prototype-build-pr13073-c616faf.apk

@codecov-commenter
Copy link

codecov-commenter commented Dec 5, 2024

Codecov Report

Attention: Patch coverage is 60.00000% with 4 lines in your changes missing coverage. Please review.

Project coverage is 40.41%. Comparing base (c891053) to head (c616faf).
Report is 10 commits behind head on trunk.

Files with missing lines Patch % Lines
...om/woocommerce/android/extensions/WCSSRModelExt.kt 0.00% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##              trunk   #13073   +/-   ##
=========================================
  Coverage     40.41%   40.41%           
  Complexity     6194     6194           
=========================================
  Files          1294     1294           
  Lines         74479    74485    +6     
  Branches      10188    10189    +1     
=========================================
+ Hits          30097    30103    +6     
  Misses        41771    41771           
  Partials       2611     2611           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@irfano irfano self-assigned this Dec 9, 2024
Copy link
Contributor

@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'm thinking if we should use com.zendesk.util.FileUtils.humanReadableFileSize.humanReadableFileSize() since we're already using this Zendes library for other purposes. This would save us from adding new code to the repository, but it would still use an unnecessary dependency. I wonder about your opinion.

@hafizrahman
Copy link
Contributor Author

I'm thinking if we should use com.zendesk.util.FileUtils.humanReadableFileSize.humanReadableFileSize() since we're already using this Zendes library for other purposes. This would save us from adding new code to the repository, but it would still use an unnecessary dependency. I wonder about your opinion.

Nice find, I did not know about that before. For this purpose I think it's better to not add dependency as it would save time in the future dealing with dependabot. I don't think the added new code will need a lot of maintenance, and it's also only used in one small part of the app. What do you think?

@hafizrahman hafizrahman requested a review from irfano December 10, 2024 07:54
Copy link
Contributor

@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.

For this purpose I think it's better to not add dependency as it would save time in the future dealing with dependabot. I don't think the added new code will need a lot of maintenance, and it's also only used in one small part of the app. What do you think?

I agree. Let’s proceed with adding this PR. I’ve approved it, but I won’t merge it yet to give you a chance to address the feedback I provided.

I noticed a bug in the current release. We're rounding 1.99 GB to 1 GB. We're also fixing it with this PR. I guess it's not a critical issue and no need to report it to HEs.

before after web
Screenshot 2024-12-10 at 18 13 11

@hafizrahman hafizrahman force-pushed the remove-need-for-common-io branch from b234134 to b451d03 Compare December 11, 2024 11:30
@hafizrahman
Copy link
Contributor Author

I noticed a bug in the current release. We're rounding 1.99 GB to 1 GB. We're also fixing it with this PR. I guess it's not a critical issue and no need to report it to HEs.

Great catch, thanks for testing so thoroughly! I think it's nothing we should announce, but great that it's fixed as a side effect.

@hafizrahman hafizrahman merged commit 385f8bb into trunk Dec 11, 2024
15 checks passed
@hafizrahman hafizrahman deleted the remove-need-for-common-io branch December 11, 2024 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependency update feature: support Related to anything in the help & support section, including app logs and the Zendesk SDK.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants