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: remove unnecessary not null check #2349

Merged
merged 2 commits into from Dec 11, 2018

Conversation

clarkdo
Copy link
Contributor

@clarkdo clarkdo commented Dec 3, 2018

↪️ Pull Request

Remove option not null check since it won't be null

💻 Examples

🚨 Test instructions

✨ PR Todo

  • Added/updated unit tests for this change
  • Filled out test instructions (In case there aren't any unit tests)
  • Included links to related issues/PRs

Copy link
Member

@DeMoorJasper DeMoorJasper left a comment

Choose a reason for hiding this comment

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

This function does not ensure it's not null.
But you're right that it should not be used if options is null.

In theory options could be null though, but the current implementation of the watcher has a default that parcel uses which makes it currently impossible to have options as null.
If this would change to allowing null, this thing would break down. (Also if these helperfunctions would ever be used outside of the watcher it would require this check)

I'm not sure if I should approve this PR or not, as it just removes a little safety from the functions and doesn't have any benefits afaik.

@clarkdo
Copy link
Contributor Author

clarkdo commented Dec 5, 2018

@DeMoorJasper Thank you for your reply 😄

In my perspective, if option can be null, then we should also check https://github.com/parcel-bundler/parcel/blob/master/packages/core/watcher/src/options.js#L34 since it will lead to exception, otherwise option not null checking can be removed.

But I can understand your suggestion. This is is not a critical issue or new feature, so you can feel free to close this ticket 😸

@DeMoorJasper
Copy link
Member

@clarkdo When I was reviewing this, I actually also realised https://github.com/parcel-bundler/parcel/blob/master/packages/core/watcher/src/options.js#L34 should be inside the check as well. If you'd like to fix that that would be awesome, as that would actually prevent issues if we ever allow the watcher to have null as options.

@clarkdo
Copy link
Contributor Author

clarkdo commented Dec 5, 2018

@DeMoorJasper Updated

@devongovett devongovett merged commit 3d58ac0 into parcel-bundler:master Dec 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants