From d160c22a0b995a14e1e6cebbeb8344d295f6ad0b Mon Sep 17 00:00:00 2001 From: Dimitris Date: Thu, 15 Jun 2017 23:04:28 +0300 Subject: [PATCH] Enable rails/findEach Rubocop cop This cop enforce the use of `find_each` instead of `each`. Closes #1535 --- .rubocop.yml | 4 ++++ .rubocop_todo.yml | 8 -------- app/models/conference.rb | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 5cc5d541..f722ba55 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -196,6 +196,10 @@ Lint/DuplicatedKey: Rails: Enabled: true +# Use `find_each` instead of `each`. +Rails/FindEach: + Enabled: true + # Avoid use of old-style attribute validation Rails/Validation: Enabled: true diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 928205b0..ef9bcd98 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -154,14 +154,6 @@ Rails/FindBy: - 'app/models/ticket_purchase.rb' - 'app/models/user.rb' -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: Include. -# Include: app/models/**/*.rb -Rails/FindEach: - Exclude: - - 'app/models/conference.rb' - # Offense count: 7 # Configuration parameters: Include. # Include: app/models/**/*.rb diff --git a/app/models/conference.rb b/app/models/conference.rb index f58c50ed..04fe1b52 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -643,7 +643,7 @@ class Conference < ActiveRecord::Base def self.write_event_distribution_to_db week = DateTime.now.end_of_week - Conference.where('end_date > ?', Date.today).each do |conference| + Conference.where('end_date > ?', Date.today).find_each do |conference| result = {} Event.state_machine.states.each do |state| count = conference.program.events.where('state = ?', state.name).count