Skip to content

Commit

Permalink
Merge pull request #8487 from Fatsoma/fix/cond_assign_comparison_ops
Browse files Browse the repository at this point in the history
Recognise < > as comparison operators in cond assign
  • Loading branch information
koic committed Aug 8, 2020
2 parents cc89ca0 + 8966108 commit fad44bf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -11,6 +11,10 @@
* [#8480](https://github.com/rubocop-hq/rubocop/issues/8480): Tweak callback list of `Lint/MissingSuper`. ([@marcandre][])
* [#8481](https://github.com/rubocop-hq/rubocop/pull/8481): Fix autocorrect for elements with newlines in `Style/SymbolArray` and `Style/WordArray`. ([@biinari][])

### Changes

* [#8487](https://github.com/rubocop-hq/rubocop/pull/8487): Detect `<` and `>` as comparison operators in `Style/ConditionalAssignment` cop. ([@biinari][])

## 0.89.0 (2020-08-05)

### New features
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/style/conditional_assignment.rb
Expand Up @@ -233,7 +233,7 @@ class ConditionalAssignment < Cop
def_node_matcher :assignment_type?, <<~PATTERN
{
#{ASSIGNMENT_TYPES.join(' ')}
(send _recv {:[]= :<< :=~ :!~ :<=> #end_with_eq?} ...)
(send _recv {:[]= :<< :=~ :!~ :<=> #end_with_eq? :< :>} ...)
}
PATTERN

Expand Down
Expand Up @@ -282,6 +282,8 @@
it_behaves_like('comparison methods', '===')
it_behaves_like('comparison methods', '<=')
it_behaves_like('comparison methods', '>=')
it_behaves_like('comparison methods', '<')
it_behaves_like('comparison methods', '>')

context 'empty branch' do
it 'allows an empty if statement' do
Expand Down Expand Up @@ -721,8 +723,6 @@
it_behaves_like('all assignment types', '>>=')
it_behaves_like('all assignment types', '||=')
it_behaves_like('all assignment types', '&&=')
it_behaves_like('all assignment types', '+=')
it_behaves_like('all assignment types', '-=')
it_behaves_like('all assignment types', '<<', add_parens: true)

it 'registers an offense for assignment in if elsif else' do
Expand Down

0 comments on commit fad44bf

Please sign in to comment.