Add and apply MultilineMethodCallBraceLayout rule

In order for this rule to work effectively when running `--autocorrect`,
we also need to enable the `ClosingParenthesisIndentation` rule.
This commit is contained in:
Javi Martín
2023-07-01 18:18:22 +02:00
parent 5b6de96241
commit 1a098dfcab
36 changed files with 74 additions and 65 deletions

View File

@@ -30,6 +30,9 @@ Layout/AssignmentIndentation:
Layout/ClosingHeredocIndentation: Layout/ClosingHeredocIndentation:
Enabled: true Enabled: true
Layout/ClosingParenthesisIndentation:
Enabled: true
Layout/DotPosition: Layout/DotPosition:
Enabled: true Enabled: true
@@ -108,6 +111,9 @@ Layout/MultilineHashBraceLayout:
Layout/MultilineHashKeyLineBreaks: Layout/MultilineHashKeyLineBreaks:
Enabled: true Enabled: true
Layout/MultilineMethodCallBraceLayout:
Enabled: true
Layout/MultilineMethodCallIndentation: Layout/MultilineMethodCallIndentation:
Enabled: true Enabled: true

View File

@@ -97,8 +97,7 @@
title: t("form.accept_terms_title"), title: t("form.accept_terms_title"),
label: t("form.accept_terms", label: t("form.accept_terms",
policy: link_to(t("form.policy"), "/privacy", target: "blank"), policy: link_to(t("form.policy"), "/privacy", target: "blank"),
conditions: link_to(t("form.conditions"), "/conditions", target: "blank") conditions: link_to(t("form.conditions"), "/conditions", target: "blank")) %>
) %>
</div> </div>
<% end %> <% end %>

View File

@@ -25,7 +25,8 @@
<p> <p>
<%= sanitize(ballot.change_vote_info( <%= sanitize(ballot.change_vote_info(
link: link_to(t("budgets.investments.index.sidebar.change_vote_link"), link: link_to(t("budgets.investments.index.sidebar.change_vote_link"),
budget_ballot_path(budget)))) %> budget_ballot_path(budget))
)) %>
</p> </p>
<ul class="ballot-list"> <ul class="ballot-list">

View File

@@ -45,8 +45,7 @@
title: t("form.accept_terms_title"), title: t("form.accept_terms_title"),
label: t("form.accept_terms", label: t("form.accept_terms",
policy: link_to(t("form.policy"), "/privacy", target: "blank"), policy: link_to(t("form.policy"), "/privacy", target: "blank"),
conditions: link_to(t("form.conditions"), "/conditions", target: "blank") conditions: link_to(t("form.conditions"), "/conditions", target: "blank")) %>
) %>
</div> </div>
<% end %> <% end %>

View File

@@ -104,8 +104,7 @@
title: t("form.accept_terms_title"), title: t("form.accept_terms_title"),
label: t("form.accept_terms", label: t("form.accept_terms",
policy: link_to(t("form.policy"), "/privacy", target: "blank"), policy: link_to(t("form.policy"), "/privacy", target: "blank"),
conditions: link_to(t("form.conditions"), "/conditions", target: "blank") conditions: link_to(t("form.conditions"), "/conditions", target: "blank")) %>
) %>
</div> </div>
<% end %> <% end %>

View File

@@ -29,7 +29,8 @@ class Admin::BudgetsController < Admin::BaseController
@budget.headings.each { |heading| Budget::Result.new(@budget, heading).delay.calculate_winners } @budget.headings.each { |heading| Budget::Result.new(@budget, heading).delay.calculate_winners }
redirect_to admin_budget_budget_investments_path( redirect_to admin_budget_budget_investments_path(
budget_id: @budget.id, budget_id: @budget.id,
advanced_filters: ["winners"]), advanced_filters: ["winners"]
),
notice: I18n.t("admin.budgets.winners.calculated") notice: I18n.t("admin.budgets.winners.calculated")
end end

View File

@@ -148,7 +148,8 @@ class Comment < ApplicationRecord
def validate_body_length def validate_body_length
validator = ActiveModel::Validations::LengthValidator.new( validator = ActiveModel::Validations::LengthValidator.new(
attributes: :body, attributes: :body,
maximum: Comment.body_max_length) maximum: Comment.body_max_length
)
validator.validate(self) validator.validate(self)
end end

View File

@@ -52,14 +52,16 @@ class Organization < ApplicationRecord
def validate_name_length def validate_name_length
validator = ActiveModel::Validations::LengthValidator.new( validator = ActiveModel::Validations::LengthValidator.new(
attributes: :name, attributes: :name,
maximum: Organization.name_max_length) maximum: Organization.name_max_length
)
validator.validate(self) validator.validate(self)
end end
def validate_responsible_name_length def validate_responsible_name_length
validator = ActiveModel::Validations::LengthValidator.new( validator = ActiveModel::Validations::LengthValidator.new(
attributes: :responsible_name, attributes: :responsible_name,
maximum: Organization.responsible_name_max_length) maximum: Organization.responsible_name_max_length
)
validator.validate(self) validator.validate(self)
end end
end end

View File

@@ -427,7 +427,8 @@ class User < ApplicationRecord
def validate_username_length def validate_username_length
validator = ActiveModel::Validations::LengthValidator.new( validator = ActiveModel::Validations::LengthValidator.new(
attributes: :username, attributes: :username,
maximum: User.username_max_length) maximum: User.username_max_length
)
validator.validate(self) validator.validate(self)
end end
end end

View File

@@ -37,7 +37,7 @@
actions: [:edit], actions: [:edit],
edit_path: edit_admin_official_path(user), edit_path: edit_admin_official_path(user),
edit_text: (t("admin.officials.search.make_official") unless user.official?) edit_text: (t("admin.officials.search.make_official") unless user.official?)
) %> ) %>
</td> </td>
</tr> </tr>
<% end %> <% end %>

View File

@@ -35,8 +35,7 @@
firefox: link_to(t("layouts.application.firefox"), firefox: link_to(t("layouts.application.firefox"),
"https://www.mozilla.org/firefox", "https://www.mozilla.org/firefox",
title: t("shared.target_blank"), title: t("shared.target_blank"),
target: "_blank") target: "_blank"))) %>
)) %>
</p> </p>
</div> </div>
<![endif]--> <![endif]-->

View File

@@ -66,8 +66,7 @@
title: t("form.accept_terms_title"), title: t("form.accept_terms_title"),
label: t("form.accept_terms", label: t("form.accept_terms",
policy: link_to(t("form.policy"), "/privacy", target: "blank"), policy: link_to(t("form.policy"), "/privacy", target: "blank"),
conditions: link_to(t("form.conditions"), "/conditions", target: "blank") conditions: link_to(t("form.conditions"), "/conditions", target: "blank")) %>
) %>
<% end %> <% end %>
</div> </div>

View File

@@ -26,7 +26,8 @@
url: legislation_process_proposal_path( url: legislation_process_proposal_path(
proposal.legislation_process_id, proposal.legislation_process_id,
proposal, proposal,
anchor: "comments") anchor: "comments"
)
) %> ) %>
<% if proposal.author.hidden? || proposal.author.erased? %> <% if proposal.author.hidden? || proposal.author.erased? %>

View File

@@ -20,7 +20,8 @@
<p style="<%= css_for_mailer_text %>"> <p style="<%= css_for_mailer_text %>">
<%= sanitize( <%= sanitize(
t("mailers.budget_investment_created.follow", t(
"mailers.budget_investment_created.follow",
link: link_to(t("mailers.budget_investment_created.follow_link"), link: link_to(t("mailers.budget_investment_created.follow_link"),
budgets_url, budgets_url,
style: css_for_mailer_link) style: css_for_mailer_link)

View File

@@ -14,7 +14,8 @@
<p style="<%= css_for_mailer_text %>"> <p style="<%= css_for_mailer_text %>">
<%= sanitize( <%= sanitize(
t("mailers.budget_investment_unfeasible.new", t(
"mailers.budget_investment_unfeasible.new",
url: link_to(t("mailers.budget_investment_unfeasible.new_href"), url: link_to(t("mailers.budget_investment_unfeasible.new_href"),
new_budget_investment_url(@investment.budget), new_budget_investment_url(@investment.budget),
style: css_for_mailer_link) style: css_for_mailer_link)

View File

@@ -19,7 +19,8 @@
<p style="<%= css_for_mailer_text %>"> <p style="<%= css_for_mailer_text %>">
<%= sanitize( <%= sanitize(
t("mailers.config.unsubscribe_text", t(
"mailers.config.unsubscribe_text",
notifications: link_to( notifications: link_to(
t("mailers.config.notifications_link"), t("mailers.config.notifications_link"),
edit_subscriptions_url(token: @token), edit_subscriptions_url(token: @token),

View File

@@ -22,11 +22,13 @@
<p style="<%= css_for_mailer_text %>"> <p style="<%= css_for_mailer_text %>">
<%= sanitize( <%= sanitize(
t("mailers.direct_message_for_receiver.unsubscribe_text", t(
"mailers.direct_message_for_receiver.unsubscribe_text",
notifications: link_to( notifications: link_to(
t("mailers.config.notifications_link"), t("mailers.config.notifications_link"),
edit_subscriptions_url(token: @token), edit_subscriptions_url(token: @token),
style: css_for_mailer_link) style: css_for_mailer_link
)
), ),
attributes: %w[href style] attributes: %w[href style]
) %> ) %>

View File

@@ -10,11 +10,13 @@
<p style="<%= css_for_mailer_text %>"> <p style="<%= css_for_mailer_text %>">
<%= sanitize( <%= sanitize(
t("mailers.email_verification.instructions", t(
"mailers.email_verification.instructions",
verification_link: link_to( verification_link: link_to(
t("mailers.email_verification.click_here_to_verify"), t("mailers.email_verification.click_here_to_verify"),
email_url(email_verification_token: @token), email_url(email_verification_token: @token),
style: css_for_mailer_link) style: css_for_mailer_link
)
), ),
attributes: %w[href style] attributes: %w[href style]
) %> ) %>

View File

@@ -12,8 +12,7 @@
<%= sanitize( <%= sanitize(
t("mailers.evaluation_comment.new_comment_by", t("mailers.evaluation_comment.new_comment_by",
commenter: @email.comment.author.name, commenter: @email.comment.author.name,
investment: valuation_comments_link(@email.commentable) investment: valuation_comments_link(@email.commentable))
)
) %> ) %>
</p> </p>

View File

@@ -6,7 +6,8 @@
<p style="<%= css_for_mailer_text %>"> <p style="<%= css_for_mailer_text %>">
<%= sanitize( <%= sanitize(
t("mailers.config.unsubscribe_text", t(
"mailers.config.unsubscribe_text",
notifications: link_to( notifications: link_to(
t("mailers.config.notifications_link"), t("mailers.config.notifications_link"),
edit_subscriptions_url(token: @token), edit_subscriptions_url(token: @token),

View File

@@ -64,12 +64,14 @@
<p style="<%= css_for_mailer_text %>"> <p style="<%= css_for_mailer_text %>">
<%= sanitize( <%= sanitize(
t("mailers.proposal_notification_digest.unsubscribe_text", t(
"mailers.proposal_notification_digest.unsubscribe_text",
notifications: link_to( notifications: link_to(
t("mailers.config.notifications_link"), t("mailers.config.notifications_link"),
edit_subscriptions_url(token: @token), edit_subscriptions_url(token: @token),
style: css_for_mailer_link) style: css_for_mailer_link
), )
),
attributes: %w[href style] attributes: %w[href style]
) %> ) %>
</p> </p>

View File

@@ -19,7 +19,8 @@
<p style="<%= css_for_mailer_text %>"> <p style="<%= css_for_mailer_text %>">
<%= sanitize( <%= sanitize(
t("mailers.config.unsubscribe_text", t(
"mailers.config.unsubscribe_text",
notifications: link_to( notifications: link_to(
t("mailers.config.notifications_link"), t("mailers.config.notifications_link"),
edit_subscriptions_url(token: @token), edit_subscriptions_url(token: @token),

View File

@@ -30,8 +30,7 @@
terms: link_to(t("devise_views.users.registrations.new.terms_link"), terms: link_to(t("devise_views.users.registrations.new.terms_link"),
"/conditions", "/conditions",
title: t("shared.target_blank"), title: t("shared.target_blank"),
target: "_blank") target: "_blank")) %>
) %>
<div class="small-12 medium-6 small-centered"> <div class="small-12 medium-6 small-centered">
<%= f.submit t("devise_views.organizations.registrations.new.submit"), class: "button expanded" %> <%= f.submit t("devise_views.organizations.registrations.new.submit"), class: "button expanded" %>

View File

@@ -7,7 +7,8 @@
<% stats.channels.each do |channel| %> <% stats.channels.each do |channel| %>
<%= number_with_info_tags( <%= number_with_info_tags(
stats.send("total_participants_#{channel}"), stats.send("total_participants_#{channel}"),
t("stats.polls.#{channel}_percentage", t(
"stats.polls.#{channel}_percentage",
percentage: number_to_stats_percentage(stats.send(:"total_participants_#{channel}_percentage")) percentage: number_to_stats_percentage(stats.send(:"total_participants_#{channel}_percentage"))
), ),
html_class: channel html_class: channel

View File

@@ -37,10 +37,10 @@
<%= f.check_box :terms_of_service, <%= f.check_box :terms_of_service,
title: t("devise_views.users.registrations.new.terms_title"), title: t("devise_views.users.registrations.new.terms_title"),
label: t("devise_views.users.registrations.new.terms", label: t("devise_views.users.registrations.new.terms",
terms: link_to(t("devise_views.users.registrations.new.terms_link"), "/conditions", terms: link_to(t("devise_views.users.registrations.new.terms_link"),
"/conditions",
title: t("shared.target_blank"), title: t("shared.target_blank"),
target: "_blank") target: "_blank")) %>
) %>
<div class="small-12 medium-6 small-centered"> <div class="small-12 medium-6 small-centered">
<%= f.submit t("devise_views.users.registrations.new.submit"), class: "button expanded" %> <%= f.submit t("devise_views.users.registrations.new.submit"), class: "button expanded" %>

View File

@@ -71,10 +71,10 @@
<%= f.check_box :terms_of_service, <%= f.check_box :terms_of_service,
title: t("verification.residence.new.accept_terms_text_title"), title: t("verification.residence.new.accept_terms_text_title"),
label: t("verification.residence.new.accept_terms_text", label: t("verification.residence.new.accept_terms_text",
terms_url: link_to(t("verification.residence.new.terms"), page_path("census_terms"), terms_url: link_to(t("verification.residence.new.terms"),
page_path("census_terms"),
title: t("shared.target_blank"), title: t("shared.target_blank"),
target: "_blank") target: "_blank")) %>
) %>
</div> </div>
<div class="small-12 medium-3 clear"> <div class="small-12 medium-3 clear">

View File

@@ -4,8 +4,7 @@ describe SDG::TagListComponent do
let(:debate) do let(:debate) do
create(:debate, create(:debate,
sdg_goals: [SDG::Goal[3]], sdg_goals: [SDG::Goal[3]],
sdg_targets: [SDG::Target[3.2], create(:sdg_local_target, code: "3.2.1")] sdg_targets: [SDG::Target[3.2], create(:sdg_local_target, code: "3.2.1")])
)
end end
let(:component) { SDG::TagListComponent.new(debate) } let(:component) { SDG::TagListComponent.new(debate) }

View File

@@ -3,8 +3,7 @@ require "rails_helper"
describe SDG::Targets::PlainTagListComponent do describe SDG::Targets::PlainTagListComponent do
let(:debate) do let(:debate) do
create(:debate, create(:debate,
sdg_targets: [SDG::Target[1.1], SDG::Target[3.2], create(:sdg_local_target, code: "3.2.1")] sdg_targets: [SDG::Target[1.1], SDG::Target[3.2], create(:sdg_local_target, code: "3.2.1")])
)
end end
let(:component) { SDG::Targets::PlainTagListComponent.new(debate) } let(:component) { SDG::Targets::PlainTagListComponent.new(debate) }

View File

@@ -3,8 +3,7 @@ require "rails_helper"
describe SDG::Targets::TagListComponent do describe SDG::Targets::TagListComponent do
let(:debate) do let(:debate) do
create(:debate, create(:debate,
sdg_targets: [SDG::Target[1.1], SDG::Target[3.2], create(:sdg_local_target, code: "3.2.1")] sdg_targets: [SDG::Target[1.1], SDG::Target[3.2], create(:sdg_local_target, code: "3.2.1")])
)
end end
let(:component) { SDG::Targets::TagListComponent.new(debate) } let(:component) { SDG::Targets::TagListComponent.new(debate) }

View File

@@ -9,8 +9,7 @@ describe Shared::BannerComponent do
post_started_at: (Date.current - 4.days), post_started_at: (Date.current - 4.days),
post_ended_at: (Date.current + 10.days), post_ended_at: (Date.current + 10.days),
background_color: "#FF0000", background_color: "#FF0000",
font_color: "#FFFFFF" font_color: "#FFFFFF")
)
render_inline Shared::BannerComponent.new(banner) render_inline Shared::BannerComponent.new(banner)
@@ -38,15 +37,13 @@ describe Shared::BannerComponent do
web_sections: [WebSection.find_by!(name: "debates")], web_sections: [WebSection.find_by!(name: "debates")],
title: "First banner", title: "First banner",
description: "First description", description: "First description",
target_url: "/first_target" target_url: "/first_target")
)
create(:banner, create(:banner,
web_sections: [WebSection.find_by!(name: "debates")], web_sections: [WebSection.find_by!(name: "debates")],
title: "Second banner", title: "Second banner",
description: "Second description", description: "Second description",
target_url: "/second_target" target_url: "/second_target")
)
end end
it "only renders one banner" do it "only renders one banner" do

View File

@@ -77,8 +77,7 @@ describe Budget::Stats do
it "doesn't count nil user ids" do it "doesn't count nil user ids" do
create(:budget_ballot_line, investment: investment, create(:budget_ballot_line, investment: investment,
ballot: create(:budget_ballot, budget: budget.reload, user: nil, physical: true) ballot: create(:budget_ballot, budget: budget.reload, user: nil, physical: true))
)
expect(stats.total_participants_vote_phase).to be 0 expect(stats.total_participants_vote_phase).to be 0
end end

View File

@@ -73,7 +73,8 @@ describe Geozone do
expect(geozone.outline_points).to eq( expect(geozone.outline_points).to eq(
[[-3.9259027239257, 40.8792937308316], [[-3.9259027239257, 40.8792937308316],
[-3.9249047078766, 40.8788966596619], [-3.9249047078766, 40.8788966596619],
[-3.9247799675785, 40.8789131852224]]) [-3.9247799675785, 40.8789131852224]]
)
end end
end end
end end

View File

@@ -937,8 +937,7 @@ describe "Admin budget investments", :admin do
price: 1234, price: 1234,
price_first_year: 1000, price_first_year: 1000,
administrator: administrator, administrator: administrator,
valuators: [valuator] valuators: [valuator])
)
visit admin_budget_budget_investments_path(budget_investment.budget) visit admin_budget_budget_investments_path(budget_investment.budget)
@@ -1757,8 +1756,7 @@ describe "Admin budget investments", :admin do
:winner, :winner,
:visible_to_valuators, :visible_to_valuators,
budget: budget, budget: budget,
author: create(:user, username: "Jon Doe") author: create(:user, username: "Jon Doe"))
)
end end
let(:default_columns) do let(:default_columns) do
%w[id title supports admin valuator geozone feasibility price %w[id title supports admin valuator geozone feasibility price

View File

@@ -496,7 +496,8 @@ describe "Emails" do
expect(email.body.encoded).to include("This is a different body") expect(email.body.encoded).to include("This is a different body")
expect(email).to have_body_text("To unsubscribe from these emails, visit") expect(email).to have_body_text("To unsubscribe from these emails, visit")
expect(email).to have_body_text( expect(email).to have_body_text(
edit_subscriptions_path(token: user_with_newsletter_in_segment_2.subscriptions_token)) edit_subscriptions_path(token: user_with_newsletter_in_segment_2.subscriptions_token)
)
expect(email).to have_body_text('and uncheck "Receive relevant information by email"') expect(email).to have_body_text('and uncheck "Receive relevant information by email"')
end end
end end

View File

@@ -401,8 +401,7 @@ describe "Legislation" do
create(:milestone, create(:milestone,
milestoneable: process, milestoneable: process,
description: "Something important happened", description: "Something important happened",
publication_date: Date.new(2018, 3, 22) publication_date: Date.new(2018, 3, 22))
)
visit legislation_process_path(process) visit legislation_process_path(process)

View File

@@ -22,8 +22,7 @@ describe "Legislation" do
scenario "empty process" do scenario "empty process" do
process = create(:legislation_process, :empty, process = create(:legislation_process, :empty,
result_publication_enabled: true, result_publication_enabled: true,
end_date: Date.current - 1.day end_date: Date.current - 1.day)
)
visit summary_legislation_process_path(process) visit summary_legislation_process_path(process)