From 5402b1aff482705d66e0d32d1dc5fcfe9cd2bb8d Mon Sep 17 00:00:00 2001 From: Daniel Vandersluis Date: Wed, 15 Sep 2021 15:00:45 -0400 Subject: [PATCH] Update the documentation for `Lint/BinaryOperatorWithIdenticalOperands` to mention the operators that are ignored. --- .../lint/binary_operator_with_identical_operands.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/rubocop/cop/lint/binary_operator_with_identical_operands.rb b/lib/rubocop/cop/lint/binary_operator_with_identical_operands.rb index f60e574b73d..1af3b74ef0d 100644 --- a/lib/rubocop/cop/lint/binary_operator_with_identical_operands.rb +++ b/lib/rubocop/cop/lint/binary_operator_with_identical_operands.rb @@ -5,12 +5,18 @@ module Cop module Lint # This cop checks for places where binary operator has identical operands. # - # It covers arithmetic operators: `+`, `-`, `*`, `/`, `%`, `**`; + # It covers arithmetic operators: `-`, `/`, `%`; # comparison operators: `==`, `===`, `=~`, `>`, `>=`, `<`, `<=`; - # bitwise operators: `|`, `^`, `&`, `<<`, `>>`; + # bitwise operators: `|`, `^`, `&`; # boolean operators: `&&`, `||` # and "spaceship" operator - `<=>`. # + # Simple arithmetic operations are allowed by this cop: `+`, `*`, `**`, `<<` and `>>`. + # Although these can be rewritten in a different way, it should not be necessary to + # do so. This does not include operations such as `-` or `/` where the result will + # always be the same (`x - x` will always be 0; `x / x` will always be 1), and + # thus are legitimate offenses. + # # This cop is marked as unsafe as it does not consider side effects when calling methods # and thus can generate false positives: # if wr.take_char == '\0' && wr.take_char == '\0'