Skip to content

style: clean-up ParselyTracker class #67

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

Merged
merged 11 commits into from
Sep 14, 2023
Merged

style: clean-up ParselyTracker class #67

merged 11 commits into from
Sep 14, 2023

Conversation

wzieba
Copy link
Collaborator

@wzieba wzieba commented Sep 12, 2023

Description

This PR contains a set of code quality improvements: removing unneeded checks or making fields final when there's no need for them to be mutable. It's not the complete set of improvements I could provide, but I try to limit the size of PRs.

Changes applied by IntelliJ "cleanup code" action. It adds `final`
keyword where it's apllicable and simplifies boolean expressions.
They don't change after initialization so let's keep them outside of the constructor to reduce its size.
`getStoredQueue` method could never return `null` so we mark this method as `@NonNull` and remove all nullability checks to improve code clarity
Comment on lines +507 to 508
@NonNull
private ArrayList<Map<String, Object>> getStoredQueue() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

getStoredQueue could never return null. Look lines 525-528. Also, IDE was smart enough to infer it

Screenshot 2023-09-12 at 10 46 31

That's why I explicitly added @NonNull annotation.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Praise (❤️): Kudos on making this change, it removes lots of unnecessary nullability checks! 🥇

@wzieba wzieba marked this pull request as ready for review September 12, 2023 13:05
@wzieba wzieba requested a review from ParaskP7 September 12, 2023 13:05
@ParaskP7 ParaskP7 self-assigned this Sep 13, 2023
Copy link
Collaborator

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

LGTM, thanks for this PR @wzieba ! 💯


I have left a few suggestions (💡) and one minor (🔍) comments 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.


EXTRAS:

  1. Suggestion (💡): Consider removing the unnecessary url == null check from the trackPageview(...), startEngagement(...) and trackPlay(...) methods. PS: Same applies to the videoMetadata == null check.
  2. Minor (🔍): Between commit 94a551e and c51a206, the later had extra changes related to the former on QUEUE_SIZE_LIMIT and STORAGE_SIZE_LIMIT within doInBackground(...). This made both commits harder to review in isolation. Consider rebasing next time to fix that and have each commit specific to the change it introduces.

private static final String STORAGE_KEY = "parsely-events.ser";
// emulator localhost
// private static final String ROOT_URL = "http://10.0.2.2:5001/";
private static final String ROOT_URL = "https://p1.parsely.com/";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggestion (💡): Consider using the below shorter alternative:

    private static final String ROOT_URL = "https://p1.parsely.com/"; // emulator localhost: http://10.0.2.2:5001/

@ParaskP7
Copy link
Collaborator

👋 @wzieba !

I just reviewed the new changes and everything LGTM, thank you so much for applying those suggestions, this class is getting cleaner and cleaner! 🙇 ❤️ 🚀

Feel free to merge this when you are ready! ✅

@wzieba wzieba merged commit 91c7922 into master Sep 14, 2023
@wzieba wzieba deleted the code_cleanup branch September 14, 2023 14:12
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.

2 participants