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

refactor(builder): remove unsafe*Builders #8074

Merged

Conversation

imranbarbhuiya
Copy link
Contributor

@imranbarbhuiya imranbarbhuiya commented Jun 12, 2022

Please describe the changes this PR makes and why it should be merged:
This pr removes all the Unsafe*Builder in favor of enableValidators/disableValidators.
this will resolve 2nd issue of #8015
Status and versioning classification:

  • Code changes have been tested against the Discord API, or there are no code changes
  • I know how to update typings and have done so, or typings don't need updating
  • This PR changes the library's interface (methods or parameters added)
  • This PR includes breaking changes (methods removed or renamed, parameters moved or removed)

@vercel
Copy link

vercel bot commented Jun 12, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Updated
discord-js ⬜️ Ignored (Inspect) Jul 6, 2022 at 5:52PM (UTC)

@imranbarbhuiya imranbarbhuiya marked this pull request as ready for review June 12, 2022 04:11
@imranbarbhuiya imranbarbhuiya changed the title refactor: remove unsafebuilder refactor(builder): remove unsafe*Builders Jun 12, 2022
@kyranet kyranet added this to the builders v1 milestone Jun 12, 2022
packages/builders/src/util/validation.ts Outdated Show resolved Hide resolved
@vladfrangu
Copy link
Member

Again, not what I said. It should not call that setter every time a validation happens. It should call that setter once when the disable/enable method is called

@imranbarbhuiya
Copy link
Contributor Author

Again, not what I said. It should not call that setter every time a validation happens. It should call that setter once when the disable/enable method is called

Copy pasting from discord

@vladfrangu u said enableValidators should set setValidationEnabled to all the predicate (if I've understood correctly then u mean import all the assertion predicates in the validation file and use setValidationEnabled on them right?) and not just before parsing but how that'll work? https://github.com/sapphiredev/shapeshift/blob/a23d15f533a234a59af54a9ed60bec778f069af8/src/validators/BaseValidator.ts#L80 here everytime we run setValidationEnabled, it makes a clone so if I add setValidationEnabled(false) on a predicate inside of enableValidators, it won't change the already present predicate

@vladfrangu
Copy link
Member

Ooof, rightttt, I made the property protected but the method return a clone... I guess either set the property directly or just keep it as it tbh

@GravIos3

This comment was marked as spam.

@imranbarbhuiya imranbarbhuiya force-pushed the refactor/remove-unsafe-builder branch 3 times, most recently from e431410 to 10246f2 Compare June 20, 2022 06:35
packages/builders/src/components/Assertions.ts Outdated Show resolved Hide resolved
packages/builders/src/components/Assertions.ts Outdated Show resolved Hide resolved
packages/builders/src/components/Assertions.ts Outdated Show resolved Hide resolved
packages/builders/src/components/Assertions.ts Outdated Show resolved Hide resolved
packages/builders/src/messages/embed/Assertions.ts Outdated Show resolved Hide resolved
packages/builders/src/messages/embed/Embed.ts Outdated Show resolved Hide resolved
packages/builders/src/interactions/modals/Modal.ts Outdated Show resolved Hide resolved
packages/builders/src/interactions/modals/Modal.ts Outdated Show resolved Hide resolved
packages/builders/src/components/textInput/TextInput.ts Outdated Show resolved Hide resolved
@imranbarbhuiya imranbarbhuiya force-pushed the refactor/remove-unsafe-builder branch from 708c4c6 to 2921a89 Compare July 4, 2022 05:41
@codecov
Copy link

codecov bot commented Jul 4, 2022

Codecov Report

Merging #8074 (f5dcb03) into main (34531c4) will increase coverage by 0.06%.
The diff coverage is 98.86%.

@@            Coverage Diff             @@
##             main    #8074      +/-   ##
==========================================
+ Coverage   91.01%   91.07%   +0.06%     
==========================================
  Files          85       80       -5     
  Lines        6944     6815     -129     
  Branches     1039      994      -45     
==========================================
- Hits         6320     6207     -113     
+ Misses        580      564      -16     
  Partials       44       44              
Flag Coverage Δ
builders 98.26% <98.86%> (+0.46%) ⬆️
collection 100.00% <ø> (ø)
proxy 79.83% <ø> (ø)
rest 92.31% <ø> (ø)
utilities 50.00% <ø> (ø)
voice 64.16% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ges/builders/src/components/textInput/TextInput.ts 94.87% <94.18%> (-5.13%) ⬇️
packages/builders/src/interactions/modals/Modal.ts 96.29% <95.77%> (-3.71%) ⬇️
packages/builders/src/components/ActionRow.ts 100.00% <100.00%> (ø)
packages/builders/src/components/Assertions.ts 100.00% <100.00%> (ø)
packages/builders/src/components/Components.ts 82.00% <100.00%> (+3.42%) ⬆️
packages/builders/src/components/button/Button.ts 100.00% <100.00%> (ø)
...s/builders/src/components/selectMenu/SelectMenu.ts 100.00% <100.00%> (ø)
...ders/src/components/selectMenu/SelectMenuOption.ts 100.00% <100.00%> (ø)
...es/builders/src/components/textInput/Assertions.ts 100.00% <100.00%> (ø)
packages/builders/src/index.ts 90.69% <100.00%> (-0.97%) ⬇️
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 34531c4...f5dcb03. Read the comment docs.

packages/builders/src/components/button/Button.ts Outdated Show resolved Hide resolved
packages/builders/src/components/button/Button.ts Outdated Show resolved Hide resolved
packages/builders/src/components/button/Button.ts Outdated Show resolved Hide resolved
packages/builders/src/components/selectMenu/SelectMenu.ts Outdated Show resolved Hide resolved
packages/builders/src/components/selectMenu/SelectMenu.ts Outdated Show resolved Hide resolved
packages/builders/src/components/selectMenu/SelectMenu.ts Outdated Show resolved Hide resolved
packages/builders/src/components/textInput/TextInput.ts Outdated Show resolved Hide resolved
packages/builders/src/components/textInput/TextInput.ts Outdated Show resolved Hide resolved
@imranbarbhuiya imranbarbhuiya force-pushed the refactor/remove-unsafe-builder branch 2 times, most recently from c225f98 to 6343ef7 Compare July 6, 2022 10:23
@iCrawl
Copy link
Member

iCrawl commented Jul 6, 2022

This needs a rebase.

@imranbarbhuiya imranbarbhuiya force-pushed the refactor/remove-unsafe-builder branch from 6343ef7 to 14505e3 Compare July 6, 2022 15:59
Copy link
Member

@SpaceEEC SpaceEEC left a comment

Choose a reason for hiding this comment

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

Is it intended that UnsafeEmbed is still around? 👀

@imranbarbhuiya imranbarbhuiya force-pushed the refactor/remove-unsafe-builder branch from 14505e3 to f5dcb03 Compare July 6, 2022 17:52
@imranbarbhuiya
Copy link
Contributor Author

Is it intended that UnsafeEmbed is still around? 👀

fixed. It got added while rebasing lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

7 participants