-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
Handle assertions in conditionals branches in Minitest/MultipleAssertions
cop
#249
Handle assertions in conditionals branches in Minitest/MultipleAssertions
cop
#249
Conversation
# else | ||
# assert bar | ||
# end | ||
# end |
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 worry about losing the symmetry between #bad
and #good
examples. Can you replace the added example code with a description of the cop using natural language?
|
||
assertions = | ||
case node.type | ||
when :if, :case |
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.
Same for case_match
?
assertions_count_in_branches(node.branches) | ||
when :rescue | ||
assertions_count(node.body) + assertions_count_in_branches(node.branches) | ||
when :block |
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.
Same for numblock
?
else | ||
assert foo | ||
end | ||
end |
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.
Can you add a source code comment to the line which line is being counted?
else | ||
assert foo | ||
end | ||
end |
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.
Ditto.
774da8b
to
ab4332c
Compare
Applied suggested changes. CI is failing, because rubocop now requires ruby 2.7, but this gem - ruby 2.6. So it is needed to first drop support for ruby 2.6 and then this PR can be updated. Should I open a separate PR with that change or should you? |
The build error has been fixed by #250. Either way, I understand that the issue is unrelated to this PR change. Thank you :-) |
ab4332c
to
f743944
Compare
Updated, now CI is green 🟢 |
These changes are to allow to have assertions like:
A recent example that inspired this - https://github.com/ixti/sidekiq-throttled/pull/142/files#diff-87c291ea2af263111982285d3dea3083faa62260cc6080cc5396f4bf82a37cf4R22-R27 (it is using rspec, but it does not matter)