Skip to content

Remove defaults for private code #611

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

Closed
novemberborn opened this issue Mar 7, 2016 · 5 comments
Closed

Remove defaults for private code #611

novemberborn opened this issue Mar 7, 2016 · 5 comments

Comments

@novemberborn
Copy link
Member

AVA exposes two public interfaces: the CLI and the programmatic API. All other code is private. Currently a lot of the private code has defaults, e.g. Runner can be instantiated without options.

This tends to happen in tests and causes confusion where code has to be extra defensive against scenarios that wouldn't occur if defaults were set at the public interface level.

Allowing defaults throughout the code makes it hard to reason about expected values. I'm proposing we remove defaults from internal code and make our tests more explicit.

Thoughts?

@vadimdemedes
Copy link
Contributor

I think we shouldn't do it, because those libraries/components should be stable on their own. They should not depend on other code passing these arguments correctly.

Allowing defaults throughout the code makes it hard to reason about expected values.

We can improve our checking of value types, using functions like Array.isArray(), so that it's more clear what we're expecting.

@novemberborn
Copy link
Member Author

I think we shouldn't do it, because those libraries/components should be stable on their own

Sure, they'd just require valid options to be passed.

@novemberborn
Copy link
Member Author

@avajs/core any thoughts on this?

@sindresorhus
Copy link
Member

👍 Sounds good.

@novemberborn
Copy link
Member Author

We'll just do this when we're touching code. No need to keep the issue open.

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

No branches or pull requests

3 participants