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

Add new Lint/BinaryOperatorIdenticalOperands cop #8433

Merged

Conversation

fatkodima
Copy link
Contributor

Inspired by https://www.viva64.com/en/w/v501/

This cop supersedes (with other binary operators) and deprecates Lint/UselessComparison. That existent cop should already be marked as unsafe due to reasons - https://github.com/rubocop-hq/rubocop/compare/master...fatkodima:binary_operator_identical_operands?expand=1#diff-e9973b98907964eb1cc98fd20b55fe1cR8-R10

So I marked this cop as unsafe.

# end
#
class BinaryOperatorIdenticalOperands < Base
MSG = 'Binary operator has identical operands.'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd mention in the message the name of the binary operator (and maybe even the operand in question).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added mention about operator. I think, mentioning the operand is not necessary, as it will be obvious from code. Example: foo == foo.

@fatkodima fatkodima force-pushed the binary_operator_identical_operands branch from 6b79b36 to 1d7a7e9 Compare August 4, 2020 16:54
@bbatsov bbatsov merged commit d94c4a4 into rubocop:master Aug 5, 2020
@bbatsov
Copy link
Collaborator

bbatsov commented Aug 5, 2020

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants