From 55755bfa04badde8cb5f404c831f8453dc57b320 Mon Sep 17 00:00:00 2001 From: Archana Kumari <32739028+archanaserver@users.noreply.github.com> Date: Wed, 10 Jul 2024 15:40:53 +0530 Subject: [PATCH] Fix some RuboCop rules (#185) * Fix Style/SafeNavigation cop * Fix Rails/FindEach cop --- app/services/foreman_templates/parse_result.rb | 4 ++-- app/services/foreman_templates/template_importer.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/services/foreman_templates/parse_result.rb b/app/services/foreman_templates/parse_result.rb index 3fd9d7ea..3312bfb8 100644 --- a/app/services/foreman_templates/parse_result.rb +++ b/app/services/foreman_templates/parse_result.rb @@ -15,7 +15,7 @@ def to_h(verbose = false) :imported => @imported, :additional_errors => @additional_errors, :additional_info => @additional_info, - :exception => @exception ? @exception.message : nil, + :exception => @exception&.message, :validation_errors => errors.to_h, :file => @template_file, :type => @template.present? ? @template.class.name.underscore : nil @@ -27,7 +27,7 @@ def to_h(verbose = false) end def errors - @template ? @template.errors : nil + @template&.errors end def corrupted_metadata diff --git a/app/services/foreman_templates/template_importer.rb b/app/services/foreman_templates/template_importer.rb index 3f026b38..8a2477d5 100644 --- a/app/services/foreman_templates/template_importer.rb +++ b/app/services/foreman_templates/template_importer.rb @@ -164,7 +164,7 @@ def auto_prefix(name) def purge! clause = "name #{@negate ? 'NOT ' : ''}LIKE ?" - ProvisioningTemplate.where(clause, "#{@prefix}%").each do |template| + ProvisioningTemplate.where(clause, "#{@prefix}%").find_each do |template| puts template if @verbose template.destroy end