-
-
Notifications
You must be signed in to change notification settings - Fork 276
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
Correct some offenses for RuboCop v1.56.0 #1692
Conversation
``` ❯ bundle exec rubocop -A Inspecting 280 files .....................................................................................................................................C.................................................................................................................................................. Offenses: lib/rubocop/cop/rspec/void_expect.rb:53:11: C: [Corrected] Layout/EmptyLineAfterGuardClause: Add empty line after guard clause. return true if parent.begin_type? ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lib/rubocop/cop/rspec/void_expect.rb:54:11: C: [Corrected] Style/RedundantReturn: Redundant return detected. return true if parent.block_type? && parent.body == expect ^^^^^^ 280 files inspected, 2 offenses detected, 2 offenses corrected ```
@@ -51,7 +51,8 @@ def void?(expect) | |||
parent = expect.parent | |||
return true unless parent | |||
return true if parent.begin_type? | |||
return true if parent.block_type? && parent.body == expect | |||
|
|||
true if parent.block_type? && parent.body == expect |
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.
This could be simplified to
parent.block_type? && parent.body == expect
(removing true if
)
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.
Maybe, would it be good to have a cop to offense this?
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.
We can add support https://docs.rubocop.org/rubocop/cops_style.html#styleredundantconditional
Follow up: #1692 (comment) ``` ❯ bundle exec rubocop -A Inspecting 291 files ...........................................................................................................................................C....................................................................................................................................................... Offenses: lib/rubocop/cop/rspec/void_expect.rb:55:11: C: [Corrected] Workit/RedundantBooleanConditional: This conditional expression can just be replaced by parent.block_type? && parent.body == expect. true if parent.block_type? && parent.body == expect ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 291 files inspected, 1 offense detected, 1 offense corrected ```
#1690 needs this PR's changes.
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).