Skip to content

Commit

Permalink
[Fix rubocop#5436] Allow empty kwrest args in UncommunicativeName cops
Browse files Browse the repository at this point in the history
Follow up this comment rubocop#5436 (comment)

See also  rubocop#5462
  • Loading branch information
pocke committed Mar 14, 2018
1 parent 841569b commit 770e800
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## master (unreleased)

### New features

* [#5597](https://github.com/bbatsov/rubocop/pull/5597): Add new `Rails/HttpStatus` cop. ([@anthony-robin][])

### Bug fixes
Expand All @@ -15,6 +16,7 @@
* [#5651](https://github.com/bbatsov/rubocop/pull/5651): Fix NoMethodError when specified config file that does not exist. ([@onk][])
* [#5647](https://github.com/bbatsov/rubocop/pull/5647): Fix encoding method of RuboCop::MagicComment::SimpleComment. ([@htwroclau][])
* [#5619](https://github.com/bbatsov/rubocop/issues/5619): Do not register an offense in `Style/InverseMethods` when comparing constants with `<`, `>`, `<=`, or `>=`. If the code is being used to determine class hierarchy, the correction might not be accurate. ([@rrosenblum][])
* [#5436](https://github.com/bbatsov/rubocop/issues/5436): Allow empty kwrest args in UncommunicativeName cops. ([@pocke][])

### Changes

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/mixin/uncommunicative_name.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module UncommunicativeName
def check(node, args)
args.each do |arg|
name = arg.children.first.to_s
next if arg.restarg_type? && name.empty?
next if (arg.restarg_type? || arg.kwrestarg_type?) && name.empty?
next if allowed_names.include?(name)
range = arg_range(arg, name.size)
issue_offenses(node, range, name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ def qux(*)
RUBY
end

it 'does not register offense for empty kwrestarg' do
expect_no_offenses(<<-RUBY.strip_indent)
def qux(**)
stuff!
end
RUBY
end

it 'registers offense when parameter ends in number' do
expect_offense(<<-RUBY.strip_indent)
def something(foo1, bar)
Expand Down

0 comments on commit 770e800

Please sign in to comment.