Skip to content

Commit 6a263d5

Browse files
committed
Merge pull request rubocop#2220 from lumeet/2217_symbol_proc_block_args
[Fix rubocop#2217] Allow block arguments in SymbolProc
2 parents 91d75a0 + e39056a commit 6a263d5

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Bug Fixes
66

77
* [#2214](https://github.com/bbatsov/rubocop/pull/2214): Fix `File name too long error` when `STDIN` option is provided. ([@mrfoto][])
8+
* [#2217](https://github.com/bbatsov/rubocop/issues/2217): Allow block arguments in `Style/SymbolProc`. ([@lumeet][])
89

910
## 0.34.0 (05/09/2015)
1011

lib/rubocop/cop/style/symbol_proc.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ def ignored_method?(name)
103103
def can_shorten?(block_args, block_body)
104104
# something { |x, y| ... }
105105
return false unless block_args.children.size == 1
106+
return false if block_args.children.first.blockarg_type?
106107
return false unless block_body && block_body.type == :send
107108

108109
receiver, _method_name, args = *block_body

spec/rubocop/cop/style/symbol_proc_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@
7676
expect(cop.offenses).to be_empty
7777
end
7878

79+
it 'accepts block with a block argument ' do
80+
inspect_source(cop, 'something { |&x| x.call }')
81+
82+
expect(cop.offenses).to be_empty
83+
end
84+
7985
context 'when the method has arguments' do
8086
let(:source) { 'method(one, 2) { |x| x.test }' }
8187

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy