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 #9599] Fix an error for Style/CaseLikeIf
#9600
Conversation
aa22e6e
to
36b15ec
Compare
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.
Looks good!
I was about to post a similiar issue to #9599 after I found a similar situation in an old project. Thanks for providing a fix @koic 👍 My spec which also seems to catch the situation was looking like this: diff --git a/spec/rubocop/cop/style/case_like_if_spec.rb b/spec/rubocop/cop/style/case_like_if_spec.rb
index 0d52df5dc..68429a336 100644
--- a/spec/rubocop/cop/style/case_like_if_spec.rb
+++ b/spec/rubocop/cop/style/case_like_if_spec.rb
@@ -66,6 +66,15 @@ RSpec.describe RuboCop::Cop::Style::CaseLikeIf, :config do
RUBY
end
+ it 'does not register an offense when using cover? without a receiver' do
+ expect_no_offenses(<<~RUBY)
+ if x == 1
+ elsif cover?(Bar)
+ else
+ end
+ RUBY
+ end
+
it 'does not register an offense when using `==` with class reference' do
expect_no_offenses(<<~RUBY)
if x == Foo This spec seems to be still failing with these changes with a similar error:
|
36b15ec
to
add9f51
Compare
@pderichs Thank you for quick feedback! I confirmed this and updated this PR! |
Works perfectly. Thank you @koic 🙇♂️ |
Fixes rubocop#9599. This PR fixes an error for `Style/CaseLikeIf` when using `include?` without a receiver.
add9f51
to
62d0620
Compare
Fixes #9599.
This PR fixes an error for
Style/CaseLikeIf
when usinginclude?
without a receiver.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.