From 083e28002526885f57e74f4e940503e078294fdf Mon Sep 17 00:00:00 2001 From: markuszilch Date: Tue, 20 Feb 2024 15:28:54 +0100 Subject: [PATCH] fix safenavigation cop --- .rubocop_todo.yml | 8 -------- lib/puppet/provider/cs_primitive/pcs.rb | 2 +- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 4815cc22..94105234 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -59,14 +59,6 @@ Style/ClassEqualityComparison: - 'lib/puppet/provider/cs_primitive/crm.rb' - 'lib/puppet/provider/cs_primitive/pcs.rb' -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength. -# AllowedMethods: present?, blank?, presence, try, try! -Style/SafeNavigation: - Exclude: - - 'lib/puppet/provider/cs_primitive/pcs.rb' - # Offense count: 5 # This cop supports unsafe autocorrection (--autocorrect-all). Style/SlicingWithRange: diff --git a/lib/puppet/provider/cs_primitive/pcs.rb b/lib/puppet/provider/cs_primitive/pcs.rb index 62b96df3..7e27a1d5 100644 --- a/lib/puppet/provider/cs_primitive/pcs.rb +++ b/lib/puppet/provider/cs_primitive/pcs.rb @@ -269,7 +269,7 @@ def flush if @resource && @resource.class.name == :cs_primitive && @resource[:unmanaged_metadata] @resource[:unmanaged_metadata].each do |parameter_name| @property_hash[:metadata].delete(parameter_name) - @property_hash[:existing_metadata].delete(parameter_name) if @property_hash[:existing_metadata] + @property_hash[:existing_metadata]&.delete(parameter_name) end end