Skip to content

Commit

Permalink
Fix Rails/SkipsModelValidations cop
Browse files Browse the repository at this point in the history
  • Loading branch information
archanaserver committed May 31, 2024
1 parent 5c1b15f commit 75d5e6f
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 18 deletions.
12 changes: 0 additions & 12 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -273,18 +273,6 @@ Rails/Pick:
- "lib/foreman_inventory_upload/async/progress_output.rb"
- "lib/foreman_inventory_upload/generators/fact_helpers.rb"

# Offense count: 7
# Configuration parameters: ForbiddenMethods, AllowedMethods.
# ForbiddenMethods: decrement!, decrement_counter, increment!, increment_counter, insert, insert!, insert_all, insert_all!, toggle!, touch, touch_all, update_all, update_attribute, update_column, update_columns, update_counters, upsert, upsert_all
Rails/SkipsModelValidations:
Exclude:
- "lib/foreman_inventory_upload/async/progress_output.rb"
- "lib/insights_cloud/async/insights_client_status_aging.rb"
- "lib/insights_cloud/async/insights_full_sync.rb"
- "lib/insights_cloud/async/insights_rules_sync.rb"
- "lib/inventory_sync/async/inventory_hosts_sync.rb"
- "test/unit/foreman_rh_cloud_self_host_test.rb"

# Offense count: 10
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class RemoveOldInsightsStatuses < ActiveRecord::Migration[5.2]
def up
InsightsClientReportStatus.where(status: 2).update_all(status: InsightsClientReportStatus::NO_REPORT)
InsightsClientReportStatus.where(status: 3).update_all(status: InsightsClientReportStatus::REPORTING)
InsightsClientReportStatus.where(status: 2).update(status: InsightsClientReportStatus::NO_REPORT)
InsightsClientReportStatus.where(status: 3).update(status: InsightsClientReportStatus::REPORTING)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

class FixRhCloudSettingsCategoryToDsl < ActiveRecord::Migration[6.0]
def up
Setting.where(category: 'Setting::RhCloud').update_all(category: 'Setting') if column_exists?(:settings, :category)
Setting.where(category: 'Setting::RhCloud').update(category: 'Setting') if column_exists?(:settings, :category)
end
end
2 changes: 1 addition & 1 deletion lib/insights_cloud/async/insights_client_status_aging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def run
host_ids = InsightsClientReportStatus.stale.reporting.pluck(:host_id)

# update all stale records
InsightsClientReportStatus.where(host_id: host_ids).update_all(status: InsightsClientReportStatus::NO_REPORT)
InsightsClientReportStatus.where(host_id: host_ids).update(status: InsightsClientReportStatus::NO_REPORT)

# refresh global status
Host.where(id: host_ids).preload(:host_statuses).find_in_batches do |hosts|
Expand Down
2 changes: 1 addition & 1 deletion lib/insights_cloud/async/insights_full_sync.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def host_id(uuid)
def replace_hits_data(hits, organization)
InsightsHit.transaction do
# Reset hit counters to 0, they will be recreated later
InsightsFacet.for_organizations(organization.id).update_all(hits_count: 0)
InsightsFacet.for_organizations(organization.id).update(hits_count: 0)
InsightsHit.for_organizations(organization.id).delete_all
InsightsHit.create(hits.map { |hits_hash| to_model_hash(hits_hash) }.compact)
end
Expand Down
2 changes: 1 addition & 1 deletion test/unit/foreman_rh_cloud_self_host_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ForemanRhCloudSelfHostTest < ActiveSupport::TestCase

test 'finds host by shortname' do
@host = FactoryBot.create(:host, :managed)
Host.where(name: @host.name).update_all(name: @host.shortname)
Host.where(name: @host.name).update(name: @host.shortname)
ForemanRhCloud.expects(:foreman_host_name).returns(@host.name)

actual = ForemanRhCloud.foreman_host
Expand Down

0 comments on commit 75d5e6f

Please sign in to comment.