Add and apply Layout/DotPosition rule

Since IRB has improved its support for multiline, the main argument
towars using a trailing dot no longer affects most people.

It still affects me, though, since I use Pry :), but I agree
leading dots are more readable, so I'm enabling the rule anyway.
This commit is contained in:
Javi Martín
2023-07-01 14:53:02 +02:00
parent fd71ae5333
commit 09c63e354c
15 changed files with 72 additions and 69 deletions

View File

@@ -21,6 +21,9 @@ Bundler/OrderedGems:
Layout/AssignmentIndentation: Layout/AssignmentIndentation:
Enabled: true Enabled: true
Layout/DotPosition:
Enabled: true
Layout/EmptyLineAfterGuardClause: Layout/EmptyLineAfterGuardClause:
Enabled: true Enabled: true

View File

@@ -4,10 +4,10 @@ class Admin::Poll::OfficerAssignmentsController < Admin::Poll::BaseController
before_action :load_booth_assignment, only: [:create] before_action :load_booth_assignment, only: [:create]
def index def index
@officers = ::Poll::Officer. @officers = ::Poll::Officer
includes(:user). .includes(:user)
order("users.username"). .order("users.username")
where( .where(
id: @poll.officer_assignments.select(:officer_id).distinct.map(&:officer_id) id: @poll.officer_assignments.select(:officer_id).distinct.map(&:officer_id)
).page(params[:page]).per(50) ).page(params[:page]).per(50)
end end
@@ -15,11 +15,11 @@ class Admin::Poll::OfficerAssignmentsController < Admin::Poll::BaseController
def by_officer def by_officer
@poll = ::Poll.includes(:booths).find(params[:poll_id]) @poll = ::Poll.includes(:booths).find(params[:poll_id])
@officer = ::Poll::Officer.includes(:user).find(officer_assignment_params[:officer_id]) @officer = ::Poll::Officer.includes(:user).find(officer_assignment_params[:officer_id])
@officer_assignments = ::Poll::OfficerAssignment. @officer_assignments = ::Poll::OfficerAssignment
joins(:booth_assignment). .joins(:booth_assignment)
includes(:recounts, booth_assignment: :booth). .includes(:recounts, booth_assignment: :booth)
by_officer_and_poll(@officer.id, @poll.id). .by_officer_and_poll(@officer.id, @poll.id)
order(:date) .order(:date)
end end
def search_officers def search_officers

View File

@@ -4,10 +4,10 @@ class Admin::Poll::RecountsController < Admin::Poll::BaseController
def index def index
@stats = Poll::Stats.new(@poll) @stats = Poll::Stats.new(@poll)
@booth_assignments = @poll.booth_assignments. @booth_assignments = @poll.booth_assignments
includes(:booth, :recounts, :voters). .includes(:booth, :recounts, :voters)
order("poll_booths.name"). .order("poll_booths.name")
page(params[:page]).per(50) .page(params[:page]).per(50)
end end
private private

View File

@@ -42,13 +42,13 @@ class Officing::BallotSheetsController < Officing::BaseController
end end
def load_officer_assignments def load_officer_assignments
@officer_assignments = ::Poll::OfficerAssignment. @officer_assignments = ::Poll::OfficerAssignment
includes(booth_assignment: [:booth]). .includes(booth_assignment: [:booth])
joins(:booth_assignment). .joins(:booth_assignment)
final. .final
where(id: current_user.poll_officer.officer_assignment_ids). .where(id: current_user.poll_officer.officer_assignment_ids)
where(poll_booth_assignments: { poll_id: @poll.id }). .where(poll_booth_assignments: { poll_id: @poll.id })
where(date: Date.current) .where(date: Date.current)
end end
def load_officer_assignment def load_officer_assignment

View File

@@ -21,12 +21,12 @@ class Officing::ResultsController < Officing::BaseController
def index def index
@booth_assignment = ::Poll::BoothAssignment.includes(:booth).find(index_params[:booth_assignment_id]) @booth_assignment = ::Poll::BoothAssignment.includes(:booth).find(index_params[:booth_assignment_id])
if current_user.poll_officer.officer_assignments.final. if current_user.poll_officer.officer_assignments.final
where(booth_assignment_id: @booth_assignment.id).exists? .where(booth_assignment_id: @booth_assignment.id).exists?
@partial_results = ::Poll::PartialResult.includes(:question). @partial_results = ::Poll::PartialResult.includes(:question)
where(booth_assignment_id: index_params[:booth_assignment_id]). .where(booth_assignment_id: index_params[:booth_assignment_id])
where(date: index_params[:date]) .where(date: index_params[:date])
@recounts = ::Poll::Recount.where(booth_assignment_id: @booth_assignment.id, date: index_params[:date]) @recounts = ::Poll::Recount.where(booth_assignment_id: @booth_assignment.id, date: index_params[:date])
end end
end end
@@ -89,18 +89,18 @@ class Officing::ResultsController < Officing::BaseController
end end
def load_officer_assignment def load_officer_assignment
@officer_assignment = current_user.poll_officer. @officer_assignment = current_user.poll_officer
officer_assignments.final.find_by(id: results_params[:officer_assignment_id]) .officer_assignments.final.find_by(id: results_params[:officer_assignment_id])
end end
def load_officer_assignments def load_officer_assignments
@officer_assignments = ::Poll::OfficerAssignment. @officer_assignments = ::Poll::OfficerAssignment
includes(booth_assignment: [:booth]). .includes(booth_assignment: [:booth])
joins(:booth_assignment). .joins(:booth_assignment)
final. .final
where(id: current_user.poll_officer.officer_assignment_ids). .where(id: current_user.poll_officer.officer_assignment_ids)
where(poll_booth_assignments: { poll_id: @poll.id }). .where(poll_booth_assignments: { poll_id: @poll.id })
where(date: Date.current) .where(date: Date.current)
end end
def load_partial_results def load_partial_results

View File

@@ -22,8 +22,8 @@ module AdminBudgetInvestmentsHelper
end end
def valuator_select_options(budget) def valuator_select_options(budget)
budget.valuators.order("description ASC").order("users.email ASC").includes(:user). budget.valuators.order("description ASC").order("users.email ASC").includes(:user)
map { |v| [v.description_or_email, "valuator_#{v.id}"] } .map { |v| [v.description_or_email, "valuator_#{v.id}"] }
end end
def valuator_group_select_options def valuator_group_select_options

View File

@@ -109,8 +109,8 @@ class Budget
end end
def self.by_valuator_group(valuator_group_id) def self.by_valuator_group(valuator_group_id)
joins(:valuator_group_assignments). joins(:valuator_group_assignments)
where(budget_valuator_group_assignments: { valuator_group_id: valuator_group_id }) .where(budget_valuator_group_assignments: { valuator_group_id: valuator_group_id })
end end
before_validation :set_responsible_name before_validation :set_responsible_name
@@ -198,8 +198,8 @@ class Budget
def self.search_by_title_or_id(title_or_id) def self.search_by_title_or_id(title_or_id)
with_joins = with_translations(Globalize.fallbacks(I18n.locale)) with_joins = with_translations(Globalize.fallbacks(I18n.locale))
with_joins.where(id: title_or_id). with_joins.where(id: title_or_id)
or(with_joins.where("budget_investment_translations.title ILIKE ?", "%#{title_or_id}%")) .or(with_joins.where("budget_investment_translations.title ILIKE ?", "%#{title_or_id}%"))
end end
def searchable_values def searchable_values

View File

@@ -16,17 +16,17 @@ class Poll
end end
def voting_days_assigned_polls def voting_days_assigned_polls
officer_assignments.voting_days.includes(booth_assignment: :poll). officer_assignments.voting_days.includes(booth_assignment: :poll)
map(&:booth_assignment). .map(&:booth_assignment)
map(&:poll).uniq.compact. .map(&:poll).uniq.compact
sort { |x, y| y.ends_at <=> x.ends_at } .sort { |x, y| y.ends_at <=> x.ends_at }
end end
def final_days_assigned_polls def final_days_assigned_polls
officer_assignments.final.includes(booth_assignment: :poll). officer_assignments.final.includes(booth_assignment: :poll)
map(&:booth_assignment). .map(&:booth_assignment)
map(&:poll).uniq.compact. .map(&:poll).uniq.compact
sort { |x, y| y.ends_at <=> x.ends_at } .sort { |x, y| y.ends_at <=> x.ends_at }
end end
def todays_booths def todays_booths

View File

@@ -7,11 +7,11 @@ class TagCloud
end end
def tags def tags
resource_model_scoped. resource_model_scoped
last_week.send(counts). .last_week.send(counts)
where("lower(name) NOT IN (?)", category_names + geozone_names + default_blacklist). .where("lower(name) NOT IN (?)", category_names + geozone_names + default_blacklist)
order("#{table_name}_count": :desc, name: :asc). .order("#{table_name}_count": :desc, name: :asc)
limit(10) .limit(10)
end end
def counts def counts

View File

@@ -2,8 +2,8 @@ class Verification::Management::ManagedUser
include ActiveModel::Model include ActiveModel::Model
def self.find(document_type, document_number) def self.find(document_type, document_number)
User.where.not(document_number: nil). User.where.not(document_number: nil)
find_or_initialize_by(document_type: document_type, .find_or_initialize_by(document_type: document_type,
document_number: document_number) document_number: document_number)
end end
end end

View File

@@ -1,5 +1,5 @@
<% annotation.comments.roots.sort_by_most_voted. <% annotation.comments.roots.sort_by_most_voted
limit(Legislation::Annotation::COMMENTS_PAGE_SIZE).each do |comment| %> .limit(Legislation::Annotation::COMMENTS_PAGE_SIZE).each do |comment| %>
<div class="comment"> <div class="comment">
<div class="comment-text"> <div class="comment-text">
<p><%= truncate comment.body, length: 250 %></p> <p><%= truncate comment.body, length: 250 %></p>

View File

@@ -220,8 +220,8 @@ describe RemoteTranslations::Caller, :remote_translations do
locale = remote_translation.locale locale = remote_translation.locale
fake_response = ["translated title", "translated description", "translated summary", nil] fake_response = ["translated title", "translated description", "translated summary", nil]
expect_any_instance_of(client).to receive(:call).with(field_values_sanitized, locale). expect_any_instance_of(client).to receive(:call).with(field_values_sanitized, locale)
and_return(fake_response) .and_return(fake_response)
caller.call caller.call
end end

View File

@@ -10,8 +10,8 @@ shared_examples "remotely_translatable" do |factory_name, path_name, path_argume
before do before do
Setting["feature.remote_translations"] = true Setting["feature.remote_translations"] = true
available_locales_response = %w[de en es fr pt zh-Hans] available_locales_response = %w[de en es fr pt zh-Hans]
expect(RemoteTranslations::Microsoft::AvailableLocales).to receive(:available_locales).at_most(4).times. expect(RemoteTranslations::Microsoft::AvailableLocales).to receive(:available_locales).at_most(4).times
and_return(available_locales_response) .and_return(available_locales_response)
allow(Rails.application.secrets).to receive(:microsoft_api_key).and_return("123") allow(Rails.application.secrets).to receive(:microsoft_api_key).and_return("123")
end end

View File

@@ -35,8 +35,8 @@ module CommonActions
end end
def validate_officer def validate_officer
allow_any_instance_of(Officing::BaseController). allow_any_instance_of(Officing::BaseController)
to receive(:verify_officer_assignment).and_return(true) .to receive(:verify_officer_assignment).and_return(true)
end end
def fill_in_proposal def fill_in_proposal
@@ -69,8 +69,8 @@ module CommonActions
def set_officing_booth(booth = nil) def set_officing_booth(booth = nil)
booth = create(:poll_booth) if booth.blank? booth = create(:poll_booth) if booth.blank?
allow_any_instance_of(Officing::BaseController). allow_any_instance_of(Officing::BaseController)
to receive(:current_booth).and_return(booth) .to receive(:current_booth).and_return(booth)
end end
def click_sdg_goal(code) def click_sdg_goal(code)

View File

@@ -32,8 +32,8 @@ describe "DocumentVerifications" do
describe "Verifying througth Census" do describe "Verifying througth Census" do
context "Census API" do context "Census API" do
scenario "Verifying a user which does not exist and is not in the census shows an error" 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?). expect_any_instance_of(Verification::Management::Document).to receive(:in_census?)
and_return(false) .and_return(false)
login_as_manager login_as_manager
visit management_document_verifications_path visit management_document_verifications_path
@@ -55,8 +55,8 @@ describe "DocumentVerifications" do
context "Remote Census API", :remote_census 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 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?). expect_any_instance_of(Verification::Management::Document).to receive(:in_census?)
and_return(false) .and_return(false)
login_as_manager login_as_manager
visit management_document_verifications_path visit management_document_verifications_path