diff --git a/.rubocop.yml b/.rubocop.yml index 8bd439eae..3d1c997bf 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -21,6 +21,9 @@ Bundler/OrderedGems: Layout/AssignmentIndentation: Enabled: true +Layout/DotPosition: + Enabled: true + Layout/EmptyLineAfterGuardClause: Enabled: true diff --git a/app/controllers/admin/poll/officer_assignments_controller.rb b/app/controllers/admin/poll/officer_assignments_controller.rb index 8b3d21e0c..008918c3f 100644 --- a/app/controllers/admin/poll/officer_assignments_controller.rb +++ b/app/controllers/admin/poll/officer_assignments_controller.rb @@ -4,10 +4,10 @@ class Admin::Poll::OfficerAssignmentsController < Admin::Poll::BaseController before_action :load_booth_assignment, only: [:create] def index - @officers = ::Poll::Officer. - includes(:user). - order("users.username"). - where( + @officers = ::Poll::Officer + .includes(:user) + .order("users.username") + .where( id: @poll.officer_assignments.select(:officer_id).distinct.map(&:officer_id) ).page(params[:page]).per(50) end @@ -15,11 +15,11 @@ class Admin::Poll::OfficerAssignmentsController < Admin::Poll::BaseController def by_officer @poll = ::Poll.includes(:booths).find(params[:poll_id]) @officer = ::Poll::Officer.includes(:user).find(officer_assignment_params[:officer_id]) - @officer_assignments = ::Poll::OfficerAssignment. - joins(:booth_assignment). - includes(:recounts, booth_assignment: :booth). - by_officer_and_poll(@officer.id, @poll.id). - order(:date) + @officer_assignments = ::Poll::OfficerAssignment + .joins(:booth_assignment) + .includes(:recounts, booth_assignment: :booth) + .by_officer_and_poll(@officer.id, @poll.id) + .order(:date) end def search_officers diff --git a/app/controllers/admin/poll/recounts_controller.rb b/app/controllers/admin/poll/recounts_controller.rb index 7e1756894..04dbc53e5 100644 --- a/app/controllers/admin/poll/recounts_controller.rb +++ b/app/controllers/admin/poll/recounts_controller.rb @@ -4,10 +4,10 @@ class Admin::Poll::RecountsController < Admin::Poll::BaseController def index @stats = Poll::Stats.new(@poll) - @booth_assignments = @poll.booth_assignments. - includes(:booth, :recounts, :voters). - order("poll_booths.name"). - page(params[:page]).per(50) + @booth_assignments = @poll.booth_assignments + .includes(:booth, :recounts, :voters) + .order("poll_booths.name") + .page(params[:page]).per(50) end private diff --git a/app/controllers/officing/ballot_sheets_controller.rb b/app/controllers/officing/ballot_sheets_controller.rb index eb29971e6..fcface1e9 100644 --- a/app/controllers/officing/ballot_sheets_controller.rb +++ b/app/controllers/officing/ballot_sheets_controller.rb @@ -42,13 +42,13 @@ class Officing::BallotSheetsController < Officing::BaseController end def load_officer_assignments - @officer_assignments = ::Poll::OfficerAssignment. - includes(booth_assignment: [:booth]). - joins(:booth_assignment). - final. - where(id: current_user.poll_officer.officer_assignment_ids). - where(poll_booth_assignments: { poll_id: @poll.id }). - where(date: Date.current) + @officer_assignments = ::Poll::OfficerAssignment + .includes(booth_assignment: [:booth]) + .joins(:booth_assignment) + .final + .where(id: current_user.poll_officer.officer_assignment_ids) + .where(poll_booth_assignments: { poll_id: @poll.id }) + .where(date: Date.current) end def load_officer_assignment diff --git a/app/controllers/officing/results_controller.rb b/app/controllers/officing/results_controller.rb index 6dbfe96ab..795122400 100644 --- a/app/controllers/officing/results_controller.rb +++ b/app/controllers/officing/results_controller.rb @@ -21,12 +21,12 @@ class Officing::ResultsController < Officing::BaseController def index @booth_assignment = ::Poll::BoothAssignment.includes(:booth).find(index_params[:booth_assignment_id]) - if current_user.poll_officer.officer_assignments.final. - where(booth_assignment_id: @booth_assignment.id).exists? + if current_user.poll_officer.officer_assignments.final + .where(booth_assignment_id: @booth_assignment.id).exists? - @partial_results = ::Poll::PartialResult.includes(:question). - where(booth_assignment_id: index_params[:booth_assignment_id]). - where(date: index_params[:date]) + @partial_results = ::Poll::PartialResult.includes(:question) + .where(booth_assignment_id: index_params[:booth_assignment_id]) + .where(date: index_params[:date]) @recounts = ::Poll::Recount.where(booth_assignment_id: @booth_assignment.id, date: index_params[:date]) end end @@ -89,18 +89,18 @@ class Officing::ResultsController < Officing::BaseController end def load_officer_assignment - @officer_assignment = current_user.poll_officer. - officer_assignments.final.find_by(id: results_params[:officer_assignment_id]) + @officer_assignment = current_user.poll_officer + .officer_assignments.final.find_by(id: results_params[:officer_assignment_id]) end def load_officer_assignments - @officer_assignments = ::Poll::OfficerAssignment. - includes(booth_assignment: [:booth]). - joins(:booth_assignment). - final. - where(id: current_user.poll_officer.officer_assignment_ids). - where(poll_booth_assignments: { poll_id: @poll.id }). - where(date: Date.current) + @officer_assignments = ::Poll::OfficerAssignment + .includes(booth_assignment: [:booth]) + .joins(:booth_assignment) + .final + .where(id: current_user.poll_officer.officer_assignment_ids) + .where(poll_booth_assignments: { poll_id: @poll.id }) + .where(date: Date.current) end def load_partial_results diff --git a/app/helpers/admin_budget_investments_helper.rb b/app/helpers/admin_budget_investments_helper.rb index f34fbcb65..9efa16e69 100644 --- a/app/helpers/admin_budget_investments_helper.rb +++ b/app/helpers/admin_budget_investments_helper.rb @@ -22,8 +22,8 @@ module AdminBudgetInvestmentsHelper end def valuator_select_options(budget) - budget.valuators.order("description ASC").order("users.email ASC").includes(:user). - map { |v| [v.description_or_email, "valuator_#{v.id}"] } + budget.valuators.order("description ASC").order("users.email ASC").includes(:user) + .map { |v| [v.description_or_email, "valuator_#{v.id}"] } end def valuator_group_select_options diff --git a/app/models/budget/investment.rb b/app/models/budget/investment.rb index 051c569bb..7381ab78e 100644 --- a/app/models/budget/investment.rb +++ b/app/models/budget/investment.rb @@ -109,8 +109,8 @@ class Budget end def self.by_valuator_group(valuator_group_id) - joins(:valuator_group_assignments). - where(budget_valuator_group_assignments: { valuator_group_id: valuator_group_id }) + joins(:valuator_group_assignments) + .where(budget_valuator_group_assignments: { valuator_group_id: valuator_group_id }) end before_validation :set_responsible_name @@ -198,8 +198,8 @@ class Budget def self.search_by_title_or_id(title_or_id) with_joins = with_translations(Globalize.fallbacks(I18n.locale)) - with_joins.where(id: title_or_id). - or(with_joins.where("budget_investment_translations.title ILIKE ?", "%#{title_or_id}%")) + with_joins.where(id: title_or_id) + .or(with_joins.where("budget_investment_translations.title ILIKE ?", "%#{title_or_id}%")) end def searchable_values diff --git a/app/models/poll/officer.rb b/app/models/poll/officer.rb index 0b8d56dc1..f43eb8d04 100644 --- a/app/models/poll/officer.rb +++ b/app/models/poll/officer.rb @@ -16,17 +16,17 @@ class Poll end def voting_days_assigned_polls - officer_assignments.voting_days.includes(booth_assignment: :poll). - map(&:booth_assignment). - map(&:poll).uniq.compact. - sort { |x, y| y.ends_at <=> x.ends_at } + officer_assignments.voting_days.includes(booth_assignment: :poll) + .map(&:booth_assignment) + .map(&:poll).uniq.compact + .sort { |x, y| y.ends_at <=> x.ends_at } end def final_days_assigned_polls - officer_assignments.final.includes(booth_assignment: :poll). - map(&:booth_assignment). - map(&:poll).uniq.compact. - sort { |x, y| y.ends_at <=> x.ends_at } + officer_assignments.final.includes(booth_assignment: :poll) + .map(&:booth_assignment) + .map(&:poll).uniq.compact + .sort { |x, y| y.ends_at <=> x.ends_at } end def todays_booths diff --git a/app/models/tag_cloud.rb b/app/models/tag_cloud.rb index 0ab981653..c891e3f5d 100644 --- a/app/models/tag_cloud.rb +++ b/app/models/tag_cloud.rb @@ -7,11 +7,11 @@ class TagCloud end def tags - resource_model_scoped. - last_week.send(counts). - where("lower(name) NOT IN (?)", category_names + geozone_names + default_blacklist). - order("#{table_name}_count": :desc, name: :asc). - limit(10) + resource_model_scoped + .last_week.send(counts) + .where("lower(name) NOT IN (?)", category_names + geozone_names + default_blacklist) + .order("#{table_name}_count": :desc, name: :asc) + .limit(10) end def counts diff --git a/app/models/verification/management/managed_user.rb b/app/models/verification/management/managed_user.rb index babf18f58..cbf5d29e3 100644 --- a/app/models/verification/management/managed_user.rb +++ b/app/models/verification/management/managed_user.rb @@ -2,8 +2,8 @@ class Verification::Management::ManagedUser include ActiveModel::Model def self.find(document_type, document_number) - User.where.not(document_number: nil). - find_or_initialize_by(document_type: document_type, + User.where.not(document_number: nil) + .find_or_initialize_by(document_type: document_type, document_number: document_number) end end diff --git a/app/views/legislation/annotations/_comments.html.erb b/app/views/legislation/annotations/_comments.html.erb index ea746bac0..33375f40a 100644 --- a/app/views/legislation/annotations/_comments.html.erb +++ b/app/views/legislation/annotations/_comments.html.erb @@ -1,5 +1,5 @@ -<% annotation.comments.roots.sort_by_most_voted. - limit(Legislation::Annotation::COMMENTS_PAGE_SIZE).each do |comment| %> +<% annotation.comments.roots.sort_by_most_voted + .limit(Legislation::Annotation::COMMENTS_PAGE_SIZE).each do |comment| %>

<%= truncate comment.body, length: 250 %>

diff --git a/spec/lib/remote_translations/caller_spec.rb b/spec/lib/remote_translations/caller_spec.rb index b24307cb9..8551096ef 100644 --- a/spec/lib/remote_translations/caller_spec.rb +++ b/spec/lib/remote_translations/caller_spec.rb @@ -220,8 +220,8 @@ describe RemoteTranslations::Caller, :remote_translations do locale = remote_translation.locale fake_response = ["translated title", "translated description", "translated summary", nil] - expect_any_instance_of(client).to receive(:call).with(field_values_sanitized, locale). - and_return(fake_response) + expect_any_instance_of(client).to receive(:call).with(field_values_sanitized, locale) + .and_return(fake_response) caller.call end diff --git a/spec/shared/system/remotely_translatable.rb b/spec/shared/system/remotely_translatable.rb index 1204b8f64..21e0c661e 100644 --- a/spec/shared/system/remotely_translatable.rb +++ b/spec/shared/system/remotely_translatable.rb @@ -10,8 +10,8 @@ shared_examples "remotely_translatable" do |factory_name, path_name, path_argume before do Setting["feature.remote_translations"] = true available_locales_response = %w[de en es fr pt zh-Hans] - expect(RemoteTranslations::Microsoft::AvailableLocales).to receive(:available_locales).at_most(4).times. - and_return(available_locales_response) + expect(RemoteTranslations::Microsoft::AvailableLocales).to receive(:available_locales).at_most(4).times + .and_return(available_locales_response) allow(Rails.application.secrets).to receive(:microsoft_api_key).and_return("123") end diff --git a/spec/support/common_actions.rb b/spec/support/common_actions.rb index 51da757f9..95c3c4e47 100644 --- a/spec/support/common_actions.rb +++ b/spec/support/common_actions.rb @@ -35,8 +35,8 @@ module CommonActions end def validate_officer - allow_any_instance_of(Officing::BaseController). - to receive(:verify_officer_assignment).and_return(true) + allow_any_instance_of(Officing::BaseController) + .to receive(:verify_officer_assignment).and_return(true) end def fill_in_proposal @@ -69,8 +69,8 @@ module CommonActions def set_officing_booth(booth = nil) booth = create(:poll_booth) if booth.blank? - allow_any_instance_of(Officing::BaseController). - to receive(:current_booth).and_return(booth) + allow_any_instance_of(Officing::BaseController) + .to receive(:current_booth).and_return(booth) end def click_sdg_goal(code) diff --git a/spec/system/management/document_verifications_spec.rb b/spec/system/management/document_verifications_spec.rb index 30cb8de69..efb72664b 100644 --- a/spec/system/management/document_verifications_spec.rb +++ b/spec/system/management/document_verifications_spec.rb @@ -32,8 +32,8 @@ describe "DocumentVerifications" do describe "Verifying througth Census" do context "Census API" do scenario "Verifying a user which does not exist and is not in the census shows an error" do - expect_any_instance_of(Verification::Management::Document).to receive(:in_census?). - and_return(false) + expect_any_instance_of(Verification::Management::Document).to receive(:in_census?) + .and_return(false) login_as_manager visit management_document_verifications_path @@ -55,8 +55,8 @@ describe "DocumentVerifications" do context "Remote Census API", :remote_census do scenario "Verifying a user which does not exist and is not in the census shows an error" do - expect_any_instance_of(Verification::Management::Document).to receive(:in_census?). - and_return(false) + expect_any_instance_of(Verification::Management::Document).to receive(:in_census?) + .and_return(false) login_as_manager visit management_document_verifications_path