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

@fatkodima fatkodima commented Aug 1, 2020

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.'

This comment has been minimized.

@bbatsov

bbatsov Aug 4, 2020
Collaborator

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

This comment has been minimized.

@fatkodima

fatkodima Aug 4, 2020
Author Contributor

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 fatkodima:binary_operator_identical_operands branch from 6b79b36 to 1d7a7e9 Aug 4, 2020
@bbatsov bbatsov merged commit d94c4a4 into rubocop-hq:master Aug 5, 2020
26 checks passed
26 checks passed
windows 2.4
Details
windows 2.5
Details
windows 2.6
Details
windows 2.7
Details
windows mingw
Details
ci/circleci: cc-setup Your tests passed on CircleCI!
Details
ci/circleci: cc-upload-coverage Your tests passed on CircleCI!
Details
ci/circleci: documentation-checks Your tests passed on CircleCI!
Details
ci/circleci: jruby-9.2-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: jruby-9.2-rubocop Your tests passed on CircleCI!
Details
ci/circleci: jruby-9.2-spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.4-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.4-rubocop Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.4-spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.5-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.5-rubocop Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.5-spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.6-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.6-rubocop Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.6-spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.7-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.7-rubocop Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.7-spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-head-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-head-rubocop Your tests passed on CircleCI!
Details
ci/circleci: ruby-head-spec Your tests passed on CircleCI!
Details
@bbatsov
Copy link
Collaborator

@bbatsov bbatsov commented Aug 5, 2020

Thanks!

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

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.