-
-
Notifications
You must be signed in to change notification settings - Fork 277
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
Cover and then remove ancestor.send_type?
branch in UnspecifiedException
#1991
Conversation
83d264f
to
4faeb39
Compare
While looking at these PRs to improve our test/code coverage, I have been going a bit back and forth on whether 100% coverage should be a goal in itself. We should at least take care not to add nonsensical test cases, just to achieve better coverage. I think such tests may become a source of confusion for developers fixing another edge case, perhaps 6 months or 2 years from now. I think it’s better to look back through the commit history, find out why a particular piece of code was added, and use that information to inspire a more realistic test case. On the other hand, having (and enforcing) a high coverage percentage will ensure that no new code is added without having a meaningful test case to complement it. It will be harder to introduce code that is not well explained by its tests. So yeah, let’s continue increasing the coverage toward the 100% 👍🏼 That said, even with your added test case, you could delete |
Thanks @bquorning, I'm happy to close this PR if you want to delete that line instead! |
Although, it might still be worth documenting this. I.e. that one cannot escape the Cop here by adding layers of nodes inside the |
Yeah, let's do both. In one PR? |
4faeb39
to
4136dac
Compare
@aarestad Thoughts on this discovery? Are we missing anything here? I see you added both guard clauses here: We now think only the 1st is needed, but let me know if I'm missing anything! |
@@ -64,7 +64,6 @@ def empty_exception_matcher?(node) | |||
def find_expect_to(node) | |||
node.each_ancestor.find do |ancestor| | |||
break if ancestor.block_type? | |||
next unless ancestor.send_type? |
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.
The other thing is, does this give us any reasonable performance benefit?
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.
I don’t think so. It’s not an optimization we’ve deliberately done elsewhere.
ancestor.send_type?
branch in UnspecifiedException
ancestor.send_type?
branch in UnspecifiedException
…eption` Wraps a non-send type conditional branch around `raise_error` spec
4136dac
to
5d0fbfb
Compare
Wraps some non-send type branches around
raise_error
specsFrom:
To:
Then we remove this line, because all specs pass without it due to the node pattern covering both branches.
Before submitting the PR make sure the following are checked:
master
(if not - rebase it).CHANGELOG.md
if the new code introduces user-observable changes.bundle exec rake
) passes (be sure to run this locally, since it may produce updated documentation that you will need to commit).If you have created a new cop:
config/default.yml
.Enabled: pending
inconfig/default.yml
.Enabled: true
in.rubocop.yml
.VersionAdded: "<<next>>"
indefault/config.yml
.If you have modified an existing cop's configuration options:
VersionChanged: "<<next>>"
inconfig/default.yml
.