Class: RuboCop::Cop::MemoryManagement::UnpairedResource
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::MemoryManagement::UnpairedResource
- Defined in:
- lib/rubocop/cop/memory_management/unpaired_resource.rb
Overview
Checks for instances of unpaired resource initialization and closing.
Configuration example:
MemoryManagement/UnpairedResource:
Raylib:
init_audio_device: close_audio_device
begin_drawing: end_drawing
...
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/rubocop/cop/memory_management/unpaired_resource.rb', line 17 def on_send(node) pairs.each do |init_method, close_method| if node.method?(init_method) && !paired?(node, close_method) msg = "Found `#{node.method_name}` without a corresponding `#{close_method}`." add_offense(node, message: msg) end end end |