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

Recognise < > as comparison operators in cond assign #8487

Merged
merged 2 commits into from Aug 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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