Skip to content

Commit

Permalink
[Fix rubocop#8664] Fix a false positive for `Naming/BinaryOperatorPar…
Browse files Browse the repository at this point in the history
…ameterName`

Fixes rubocop#8664.

This PR fixes a false positive for `Naming/BinaryOperatorParameterName`
when naming multibyte character method name.
  • Loading branch information
koic committed Sep 8, 2020
1 parent 0d5d52b commit 92d66cb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* [#8655](https://github.com/rubocop-hq/rubocop/pull/8655): Fix a false positive for `Style/ClassAndModuleChildren` when using cbase class name. ([@koic][])
* [#8654](https://github.com/rubocop-hq/rubocop/pull/8654): Fix a false positive for `Style/SafeNavigation` when checking `foo&.empty?` in a conditional. ([@koic][])
* [#8660](https://github.com/rubocop-hq/rubocop/pull/8660): Fix a false positive for `Style/ClassAndModuleChildren` when using cbase module name. ([@koic][])
* [#8664](https://github.com/rubocop-hq/rubocop/issues/8664): Fix a false positive for `Naming/BinaryOperatorParameterName` when naming multibyte character method name. ([@koic][])

### Changes

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/naming/binary_operator_parameter_name.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def on_def(node)
def op_method?(name)
return false if EXCLUDED.include?(name)

!/\A\w/.match?(name) || OP_LIKE_METHODS.include?(name)
!/\A[[:word:]]/.match?(name) || OP_LIKE_METHODS.include?(name)
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ def ===(string)
RUBY
end

it 'does not register an offense for multibyte character method name' do
expect_no_offenses(<<~RUBY)
def do_something(string)
string
end
RUBY
end

it 'does not register an offense for non binary operators' do
expect_no_offenses(<<~RUBY)
def -@; end
Expand Down

0 comments on commit 92d66cb

Please sign in to comment.