-
Notifications
You must be signed in to change notification settings - Fork 186
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
Adds expect_that()
to undesirable functions linter
#1377
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking the time to create a PR - it looks quite good already.
From a meta point of view: Is there any circumstance where expect_that()
is preferrable to other expectations?
It might also be worthwhile to call this linter expect_that_linter()
and have it lint all flavors of expect_that(x, some_condition)
where there is an appropriate equivalent expect_some_condition(x)
. WDYT?
Came here to say just that -- the documentation explicitly says:
So linting this to encourage folks to move off of it (maybe with |
But then, isn't this just a use case for |
Thanks for the feedback, both. Yeah, I initially thought of writing But, given that we are just issuing a warning, I think it might be worth it.
Wasn't aware of this linter. Yeah, I would agree then that this should just be part of this linter. I will update the PR accordingly. |
expect_error_linter()
expect_that()
to undesirable functions linter
@MichaelChirico, @AshesITR WDYT? Is this better? |
Again per the docs: So actually this function is deprecated in 3e... that eliminates any hesitation I had about adding it as a default undesirable. But let's also make note of that in the lint message/documentation. |
You mean we should mention that this function is deprecated in 3e in the message/documentation? |
yep, exactly |
@MichaelChirico I've updated the message. Lemme know if you want me to change the wording. |
be sure to add a NEWS bullet & cite yourself! |
Done! |
LGTM, but now I'm wondering -- why stop here? shouldn't we add all deprecated tidyverse functions here? 🤔 WDYT @AshesITR should we just merge this now and consider that in follow-up? |
Hmm, I would say that that would be expanding the scope of this PR beyond its initial purview. It'd be better to create a new issue solely for tidyverse's deprecated functions, and then I can make a separate PR targeting that particular issue. Sounds reasonable? |
I agree. Let's create a follow-up issue (maybe one per package?) to keep the PR focused. Are there other deprecated functions in testthat? |
expect_known_output(), I am not sure about linting these, though. If you are using 3rd edition of testthat, testthat itself will warn you about these functions being deprecated in the 3rd edition. |
there are a bunch: expect_more_than(), expect_less_than() everything in these files: an added complication is some are plain deprecated, others are 3e-deprecated only. maybe what we want to do is export an object to encapsulate all this. because that would entail a user-facing change vs this PR as of now, I lean towards tabling this until after 3.0.0 release so we can handle the design more carefully, WDYT? |
Sounds good. I am marking this as a draft for now. We can come back to it later. Similar to |
Closing in favour of #1386. |
Thanks again for the PR! Sorry it didn't land, & thank you for your understanding. Looking forward to the bigger & better version! |
If code is expected to produce an error, usingexpect_that(x, throws_error())
works but is unadvised. It is better to use the function dedicated specifically for checking errors:expect_error(x)
. The additional benefit is that you can also check for the expected error message using regular expressions.First time making a PR to lintr, so any help in getting the PR aligned with coding standards (if I'm violating any) adopted in this repo is greatly appreciated.