From 3998c22c8cd005cfd57e77b1727255f1ff2e0363 Mon Sep 17 00:00:00 2001 From: archanaserver Date: Wed, 10 Jan 2024 11:05:30 +0530 Subject: [PATCH] Fix Rails/FindEach cop --- app/controllers/foreman_salt/state_importer.rb | 4 ++-- db/migrate/20150220122707_fix_incorrect_report_metrics.rb | 2 +- db/migrate/20150411003302_add_environments_to_modules.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/foreman_salt/state_importer.rb b/app/controllers/foreman_salt/state_importer.rb index 635ca038..1054b0ad 100644 --- a/app/controllers/foreman_salt/state_importer.rb +++ b/app/controllers/foreman_salt/state_importer.rb @@ -63,11 +63,11 @@ def remove_from_environment(states, environment) end def clean_orphans - SaltModule.all.each do |state| + SaltModule.all.find_each do |state| state.destroy if state.salt_environments.empty? end - SaltEnvironment.all.each do |environment| + SaltEnvironment.all.find_each do |environment| environment.destroy if environment.salt_modules.empty? end end diff --git a/db/migrate/20150220122707_fix_incorrect_report_metrics.rb b/db/migrate/20150220122707_fix_incorrect_report_metrics.rb index 20bd71d3..d4e50c2b 100644 --- a/db/migrate/20150220122707_fix_incorrect_report_metrics.rb +++ b/db/migrate/20150220122707_fix_incorrect_report_metrics.rb @@ -1,6 +1,6 @@ class FixIncorrectReportMetrics < ActiveRecord::Migration[4.2] def up - Report.all.each do |report| + Report.all.find_each do |report| next unless report.metrics && report.metrics['time'] metrics = report.metrics.dup diff --git a/db/migrate/20150411003302_add_environments_to_modules.rb b/db/migrate/20150411003302_add_environments_to_modules.rb index c1122e38..75febe1f 100644 --- a/db/migrate/20150411003302_add_environments_to_modules.rb +++ b/db/migrate/20150411003302_add_environments_to_modules.rb @@ -6,7 +6,7 @@ def up end environments = ForemanSalt::SaltEnvironment.all - ForemanSalt::SaltModule.all.each do |state| + ForemanSalt::SaltModule.all.find_each do |state| state.salt_environments << environments end end