Skip to content

Commit 75cf9de

Browse files
committed
Merge pull request rubocop#2249 from lumeet/2248_auto_resource_cleanup_block_pass
[Fix rubocop#2248] Allow AutoResourceCleanup block-pass
2 parents e6561af + e929a91 commit 75cf9de

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
* [#2121](https://github.com/bbatsov/rubocop/issues/2121): Allow space before values in hash literals in `Style/ExtraSpacing` to avoid correction conflict. ([@jonas054][])
1212
* [#2241](https://github.com/bbatsov/rubocop/issues/2241): Read cache in binary format. ([@jonas054][])
1313

14+
### Changes
15+
16+
* [#2248](https://github.com/bbatsov/rubocop/issues/2248): Allow block-pass in `Style/AutoResourceCleanup`. ([@lumeet][])
17+
1418
## 0.34.1 (09/09/2015)
1519

1620
### Bug Fixes

lib/rubocop/cop/style/auto_resource_cleanup.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@ class AutoResourceCleanup < Cop
2525
]
2626

2727
def on_send(node)
28-
receiver_node, method_name, *_arg_nodes = *node
28+
receiver_node, method_name, *arg_nodes = *node
2929

3030
TARGET_METHODS.each do |(target_class, target_method)|
3131
target_receiver = s(:const, nil, target_class)
3232

3333
next if receiver_node != target_receiver
3434
next if method_name != target_method
3535
next if node.parent && node.parent.block_type?
36+
next if !arg_nodes.empty? && arg_nodes.last.block_pass_type?
3637

3738
add_offense(node,
3839
:expression,

spec/rubocop/cop/style/auto_resource_cleanup_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,10 @@
1616

1717
expect(cop.offenses).to be_empty
1818
end
19+
20+
it 'does not register an offense for File.open with block-pass' do
21+
inspect_source(cop, 'File.open("file", &:read)')
22+
23+
expect(cop.offenses).to be_empty
24+
end
1925
end

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