-
Notifications
You must be signed in to change notification settings - Fork 922
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
Refactor render_social_share_buttons helper #5415
Comments
We have enough unused code in helpers. For example |
First of all, thank you for taking the time to do this post-merge review @gravitystorm . I wish these points had been raised earlier so I could have reassessed and addressed them before merging. I completely agree with your observations. As mentioned earlier, I drew some inspiration from the rails library mentioned in the issue. The I noticed that @tomhughes has already opened #5417 to address this. I wish i was active at the time issue was raised to do it instead. Never the less, I appreciate the feedback and will keep this in mind as we refactor and finalize social sharing functionality. |
Fixed by #5417
Yes, there's lots of other code to fix too, of course. We can work through each thing you mention individually.
No worries, there's plenty more work for everyone! |
The implementation of render_social_share_buttons can be refactored in a number of ways:
html_safe
must not be used. It does not convert strings to a safe representation, it is an assertion that the string is always safe given every possible input. This method is probably too complex for us to assert this today, and certainly not to ensure that everything involved is perfectly safe when features are added or removed from the helper in future. See e.g.opengraph_tags
helper for the use ofsafe_join
to combine tags in loop.render_
prefix in helper methods. See e.g.opengraph_tags
helperopts
ever used in the method,:title
and:url
. Since there are only two, it would be better to call the method with these explicitly, ideally as keyword arguments so that the order doesn't matter.filter_allowed_sites
method behaves surprisingly. If you pass it some sites, it will only return a subset of those sites. However, if you pass an empty set, instead of an empty list you instead get a full list of sites that were not requested. However, it's probably unlikely to be important, because...filter_allowed_sites
method is unnecessary and unused code. It should be removed, since unnecessary and used code is both a source of bugs, and also makes it harder for new developers in future, who need to read and understand it. Personally I've spent time trying to review how it works and what it's trying to do, before realising that it's not used anywhere.The text was updated successfully, but these errors were encountered: