Skip to content

Commit

Permalink
Merge pull request rubocop#1206 from yujinakayama/fix-error-at-anonym…
Browse files Browse the repository at this point in the history
…ous-keyword-splat-arg

Fix error at anonymous keyword splat arguments
  • Loading branch information
bbatsov committed Jul 14, 2014
2 parents 8aef42b + 81b8f9c commit 834328c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
### Bugs fixed

* [#1197](https://github.com/bbatsov/rubocop/issues/1197): Fix false positive for new lambda syntax in `SpaceInsideBlockBraces`. ([@jonas054][])
* [#1201](https://github.com/bbatsov/rubocop/issues/1201): Fix error at anonymous keyword splat arguments in some variable cops. ([@yujinakayama][])

## 0.24.1 (03/07/2014)

Expand Down
7 changes: 4 additions & 3 deletions lib/rubocop/cop/variable_force.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,14 @@ def dispatch_node(node)
# rubocop:enable Style/MethodLength, Style/CyclomaticComplexity

def process_variable_declaration(node)
# restarg would have no name:
variable_name = node.children.first

# restarg and kwrestarg would have no name:
#
# def initialize(*)
# end
return if node.type == :restarg && node.children.empty?
return unless variable_name

variable_name = node.children.first
variable_table.declare_variable(variable_name, node)
end

Expand Down
12 changes: 12 additions & 0 deletions spec/rubocop/cop/lint/useless_assignment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1516,6 +1516,18 @@
include_examples 'mimics MRI 2.1'
end

context 'when an anonymous keyword splat method argument is defined' do
let(:source) do
[
'def some_method(name: value, **)',
'end'
]
end

include_examples 'accepts' unless RUBY_VERSION < '2.0'
include_examples 'mimics MRI 2.1'
end

context 'when a block argument is not used' do
let(:source) do
[
Expand Down

0 comments on commit 834328c

Please sign in to comment.