Add and apply Rails/RedundantActiveRecordAllMethod

This rule was introduced in rubocop-rails 2.21.0.
This commit is contained in:
Javi Martín
2023-10-03 19:45:00 +02:00
parent 522eb6cfa3
commit 0aee568977
17 changed files with 20 additions and 17 deletions

View File

@@ -437,6 +437,9 @@ Rails/PluralizationGrammar:
Rails/Presence:
Enabled: true
Rails/RedundantActiveRecordAllMethod:
Enabled: true
Rails/RedundantTravelBack:
Enabled: true

View File

@@ -115,7 +115,7 @@ class Admin::BudgetInvestmentsController < Admin::BaseController
end
def load_valuator_groups
@valuator_groups = ValuatorGroup.all.order(name: :asc)
@valuator_groups = ValuatorGroup.order(name: :asc)
end
def load_tags

View File

@@ -4,7 +4,7 @@ class Admin::GeozonesController < Admin::BaseController
load_and_authorize_resource
def index
@geozones = Geozone.all.order(Arel.sql("LOWER(name)"))
@geozones = Geozone.order(Arel.sql("LOWER(name)"))
end
def new

View File

@@ -46,7 +46,7 @@ class Admin::Poll::BoothAssignmentsController < Admin::Poll::BaseController
end
def manage
@booths = ::Poll::Booth.all.order(name: :asc).page(params[:page]).per(300)
@booths = ::Poll::Booth.order(name: :asc).page(params[:page]).per(300)
@poll = Poll.find(params[:poll_id])
end

View File

@@ -59,7 +59,7 @@ class Admin::Poll::PollsController < Admin::Poll::BaseController
private
def load_geozones
@geozones = Geozone.all.order(:name)
@geozones = Geozone.order(:name)
end
def poll_params

View File

@@ -1,6 +1,6 @@
class Admin::SignatureSheetsController < Admin::BaseController
def index
@signature_sheets = SignatureSheet.all.order(created_at: :desc)
@signature_sheets = SignatureSheet.order(created_at: :desc)
end
def new

View File

@@ -1,6 +1,6 @@
class Admin::ValuatorGroupsController < Admin::BaseController
def index
@groups = ValuatorGroup.all.page(params[:page])
@groups = ValuatorGroup.page(params[:page])
end
def show

View File

@@ -83,7 +83,7 @@ module CommentableActions
end
def load_geozones
@geozones = Geozone.all.order(name: :asc)
@geozones = Geozone.order(name: :asc)
end
def set_geozone

View File

@@ -4,6 +4,6 @@ module GeozonesHelper
end
def geozone_select_options
Geozone.all.order(name: :asc).map { |g| [g.name, g.id] }
Geozone.order(name: :asc).map { |g| [g.name, g.id] }
end
end

View File

@@ -171,7 +171,7 @@ module Statisticable
end
def geozones
Geozone.all.order("name")
Geozone.order("name")
end
def geozone_stats

View File

@@ -48,7 +48,7 @@ section "Creating Budgets" do
end
end
Budget.all.find_each do |budget|
Budget.find_each do |budget|
city_group = budget.groups.create!(
random_locales_attributes(name: -> { I18n.t("seeds.budgets.groups.all_city") })
)

View File

@@ -32,7 +32,7 @@ section "Creating Sustainable Development Goals" do
end
section "Creating SDG homepage cards" do
SDG::Phase.all.find_each do |phase|
SDG::Phase.find_each do |phase|
Widget::Card.create!(cardable: phase, title: "#{phase.title} card",
link_text: "Link Text", link_url: "/any_path")
end

View File

@@ -75,7 +75,7 @@ describe Shared::BannerComponent do
end
it "does not render anything with no active banners" do
Banner.all.find_each { |banner| banner.update!(post_ended_at: Date.current - 1.day) }
Banner.find_each { |banner| banner.update!(post_ended_at: Date.current - 1.day) }
render_inline Shared::BannerComponent.new("debates")

View File

@@ -24,6 +24,6 @@ describe Poll::BoothAssignment do
assignment.destroy!
expect(Poll::Shift.all.count).to eq(0)
expect(Poll::Shift.count).to eq 0
end
end

View File

@@ -71,7 +71,7 @@ describe Poll::Shift do
expect do
create(:poll_shift, booth: booth, officer: officer, date: Date.current)
end.to change { Poll::OfficerAssignment.all.count }.by(2)
end.to change { Poll::OfficerAssignment.count }.by(2)
officer_assignments = Poll::OfficerAssignment.all
oa1 = officer_assignments.first
@@ -91,7 +91,7 @@ describe Poll::Shift do
booth_assignment: booth_assignment1,
date: Date.tomorrow)
expect { Poll::Shift.last.destroy }.to change { Poll::OfficerAssignment.all.count }.by(-2)
expect { Poll::Shift.last.destroy }.to change { Poll::OfficerAssignment.count }.by(-2)
end
it "creates final officer_assignments" do

View File

@@ -167,7 +167,7 @@ describe ProposalNotification do
it "removes all notifications related to the proposal notification" do
proposal_notification.moderate_system_email(admin.user)
expect(Notification.all.count).to be(0)
expect(Notification.count).to be 0
end
it "records the moderation action in the Activity table" do

View File

@@ -241,7 +241,7 @@ describe "Notifications" do
end
def users_without_notifications
User.all.select do |user|
User.select do |user|
user.notifications.not_emailed.where(notifiable_type: "ProposalNotification").blank?
end
end