-
-
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
Fix raise error when usgin assert with block #175
Conversation
e609604
to
c04885e
Compare
Can you refactor to the following? diff --git a/lib/rubocop/cop/mixin/predicate_assertion_handleable.rb b/lib/rubocop/cop/mixin/predicate_assertion_handleable.rb
index 4a0f204..5269553 100644
--- a/lib/rubocop/cop/mixin/predicate_assertion_handleable.rb
+++ b/lib/rubocop/cop/mixin/predicate_assertion_handleable.rb
@@ -13,7 +13,10 @@ module RuboCop
first_argument = arguments.first
- return if no_offense_first_argument?(first_argument)
+ return unless first_argument
+ return if first_argument.block_type? || first_argument.numblock_type?
+ return unless predicate_method?(first_argument)
+ return unless first_argument.arguments.count.zero?
add_offense(node, message: offense_message(arguments)) do |corrector|
autocorrect(corrector, node, arguments)
@@ -36,6 +39,10 @@ module RuboCop
peel_redundant_parentheses_from(arguments.first.children)
end
+ def predicate_method?(first_argument)
+ first_argument.respond_to?(:predicate_method?) && first_argument.predicate_method?
+ end
+
def offense_message(arguments)
message_argument = arguments.last if arguments.first != arguments.last
@@ -57,15 +64,6 @@ module RuboCop
def correct_receiver(receiver)
receiver ? receiver.source : 'self'
end
-
- def no_offense_first_argument?(first_argument)
- return true unless first_argument
- return true if first_argument.block_type? || first_argument.numblock_type?
- return true unless first_argument.respond_to?(:predicate_method?) && first_argument.predicate_method?
- return true unless first_argument.arguments.count.zero?
-
- false
- end
end
end
end So, |
@@ -0,0 +1 @@ | |||
* Fix raise error when using assert with block. ([@ippachi][]) |
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 the pull request address?
* Fix raise error when using assert with block. ([@ippachi][]) | |
* [#175](https://github.com/rubocop/rubocop-minitest/pull/175): Fix raise error when using assert with block. ([@ippachi][]) |
c04885e
to
c9bd43a
Compare
Thanks for the fast response! |
Good catch and great work! RuboCop Minitest 0.20.1 has been released. Thank you! |
rubocop-minitest was raising error if the style was to pass a block to an assert, such as power-assert.
So, I made it so that such cases are ignored.
This is stacktrace.
Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).bundle exec rake default
. It executes all tests and runs RuboCop on its own code.{change_type}_{change_description}.md
if the new code introduces user-observable changes. See changelog entry format for details.