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

Fix false positive in Style/EvenOdd #7522

Merged
merged 1 commit into from Nov 25, 2019
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
6 changes: 2 additions & 4 deletions CHANGELOG.md
Expand Up @@ -8,17 +8,15 @@
* [#7509](https://github.com/rubocop-hq/rubocop/issues/7509): Fix `Layout/SpaceInsideArrayLiteralBrackets` to correct empty lines. ([@ayacai115][])
* [#7517](https://github.com/rubocop-hq/rubocop/issues/7517): `Style/SpaceAroundKeyword` allows `::` after `super`. ([@ozydingo][])
* [#7515](https://github.com/rubocop-hq/rubocop/issues/7515): Fix a false negative for `Style/RedundantParentheses` when calling a method with safe navigation operator. ([@koic][])
* [#7477](https://github.com/rubocop-hq/rubocop/issues/7477): Fix line length autocorrect for semicolons in string literals. ([@maxh][])
* [#7522](https://github.com/rubocop-hq/rubocop/pull/7522): Fix a false-positive edge case (`n % 2 == 2`) for `Style/EvenOdd`. ([@buehmann][])

### Changes

* [#7077](https://github.com/rubocop-hq/rubocop/issues/7077): **(Breaking)** Further standardisation of cop names. ([@scottmatthewman][])
* [#7469](https://github.com/rubocop-hq/rubocop/pull/7469): **(Breaking)** Replace usages of the terms `Whitelist` and `Blacklist` with better alternatives. ([@koic][])
* [#7502](https://github.com/rubocop-hq/rubocop/pull/7502): Remove `SafeMode` module. ([@koic][])

### Bug fixes

* [#7477](https://github.com/rubocop-hq/rubocop/issues/7477): Fix line length autocorrect for semicolons in string literals. ([@maxh][])

## 0.76.0 (2019-10-28)

### Bug fixes
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/style/even_odd.rb
Expand Up @@ -23,7 +23,7 @@ class EvenOdd < Cop
{(send $_ :% (int 2))
(begin (send $_ :% (int 2)))}
${:== :!=}
(int ${0 1 2}))
(int ${0 1}))
PATTERN

def on_send(node)
Expand Down
4 changes: 4 additions & 0 deletions spec/rubocop/cop/style/even_odd_spec.rb
Expand Up @@ -73,6 +73,10 @@
RUBY
end

it 'accepts x % 2 == 2' do
expect_no_offenses('x % 2 == 2')
end

it 'accepts x % 3 == 0' do
expect_no_offenses('x % 3 == 0')
end
Expand Down