Skip to content
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

Possible false positive in Lint/DuplicateMatchPattern #11787

Closed
hmcguire-shopify opened this issue Apr 11, 2023 · 0 comments · Fixed by #11788
Closed

Possible false positive in Lint/DuplicateMatchPattern #11787

hmcguire-shopify opened this issue Apr 11, 2023 · 0 comments · Fixed by #11788
Labels

Comments

@hmcguire-shopify
Copy link

Given the following case statement:

case x
in "a" if false
in "a"
end

Expected behavior

Lint/DuplicateMatchPattern should not be reported because of the guard clause

Actual behavior

cop.rb:3:4: W: Lint/DuplicateMatchPattern: Duplicate in pattern detected.
in "a"
   ^^^

Steps to reproduce the problem

echo 'case x\nin "a" if false\nin "a"\nend' > fp.rb && bx rubocop fp.rb

RuboCop version

❯ bx rubocop -V
1.50.0 (using Parser 3.2.2.0, rubocop-ast 1.28.0, running on ruby 3.2.2) [arm64-darwin22]
  - rubocop-rails 2.19.0
@koic koic added the bug label Apr 11, 2023
koic added a commit to koic/rubocop that referenced this issue Apr 12, 2023
…ern`

Fixes rubocop#11787

This PR fixes a false positive for `Lint/DuplicateMatchPattern`
when repeated `in` patterns but different `if` guard is used.
bbatsov pushed a commit that referenced this issue Apr 12, 2023
Fixes #11787

This PR fixes a false positive for `Lint/DuplicateMatchPattern`
when repeated `in` patterns but different `if` guard is used.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants