Add and apply ArgumentAlignment rubocop rule

We're choosing the default `with_first_argument` style because it's the
one we use the most.
This commit is contained in:
Javi Martín
2023-07-01 17:37:58 +02:00
parent 32b1fc53e1
commit 629e208e9d
202 changed files with 907 additions and 830 deletions

View File

@@ -18,6 +18,9 @@ Bundler/OrderedGems:
Enabled: true
ConsiderPunctuation: true
Layout/ArgumentAlignment:
Enabled: true
Layout/ArrayAlignment:
Enabled: true

View File

@@ -29,7 +29,8 @@
<%= enabled_cell(phase) %>
</td>
<td>
<%= render Admin::TableActionsComponent.new(phase,
<%= render Admin::TableActionsComponent.new(
phase,
actions: [:edit],
edit_path: edit_path(phase)
) %>

View File

@@ -17,7 +17,8 @@
</td>
<td>
<% if officer.persisted? %>
<%= render Admin::TableActionsComponent.new(officer,
<%= render Admin::TableActionsComponent.new(
officer,
actions: [:destroy],
destroy_text: t("admin.poll_officers.officer.delete"),
destroy_options: { class: "destroy-officer-link" }

View File

@@ -1,5 +1,6 @@
<% if already_has_role? %>
<%= render Admin::TableActionsComponent.new(record,
<%= render Admin::TableActionsComponent.new(
record,
actions: actions,
destroy_options: { class: "destroy-role-link" }
) %>

View File

@@ -13,7 +13,8 @@
<%= label_tag :status, t("budgets.executions.filters.status.label") %>
<%= select_tag :status,
options_from_collection_for_select(statuses,
:id, lambda { |s| "#{s.name} (#{filters_select_counts(s.id)})" },
:id,
lambda { |s| "#{s.name} (#{filters_select_counts(s.id)})" },
params[:status]),
prompt: t("budgets.executions.filters.status.all",
count: budget.investments.winners.with_milestones.count) %>

View File

@@ -10,8 +10,7 @@
<% elsif assigned_heading.present? %>
<p>
<%= sanitize(t("budgets.investments.index.sidebar.different_heading_assigned",
heading_link: heading_link(assigned_heading, budget)
)) %>
heading_link: heading_link(assigned_heading, budget))) %>
<br>
<small>
<%= sanitize(t("budgets.investments.index.sidebar.change_ballot",

View File

@@ -12,7 +12,8 @@ class GraphqlController < ApplicationController
begin
raise GraphqlController::QueryStringError if query_string.nil?
result = ConsulSchema.execute(query_string,
result = ConsulSchema.execute(
query_string,
variables: prepare_variables,
context: {},
operation_name: params[:operationName]

View File

@@ -62,8 +62,10 @@ class Poll < ApplicationRecord
end
def self.overlaping_with(poll)
where("? < ends_at and ? >= starts_at", poll.starts_at.beginning_of_day,
poll.ends_at.end_of_day).where.not(id: poll.id)
where("? < ends_at and ? >= starts_at",
poll.starts_at.beginning_of_day,
poll.ends_at.end_of_day)
.where.not(id: poll.id)
.where(related: poll.related)
end

View File

@@ -1,5 +1,6 @@
<h2 class="inline-block"><%= t("admin.admin_notifications.index.section_title") %></h2>
<%= link_to t("admin.admin_notifications.index.new_notification"), new_admin_admin_notification_path,
<%= link_to t("admin.admin_notifications.index.new_notification"),
new_admin_admin_notification_path,
class: "button float-right" %>
<% if @admin_notifications.any? %>

View File

@@ -1,5 +1,6 @@
<%= link_to t("admin.banners.index.create"),
new_admin_banner_path, class: "button float-right" %>
new_admin_banner_path,
class: "button float-right" %>
<h2 class="inline-block"><%= t("admin.banners.index.title") %></h2>

View File

@@ -9,7 +9,8 @@
<% if @investments.any? %>
<h3 class="inline-block"><%= page_entries_info @investments %></h3>
<%= render "admin/shared/columns_selector",
cookie: "investments-columns", default: %w[id title supports admin valuator geozone feasibility price valuation_finished visible_to_valuators selected incompatible] %>
cookie: "investments-columns",
default: %w[id title supports admin valuator geozone feasibility price valuation_finished visible_to_valuators selected incompatible] %>
<br>
<%= render "filters_description", i18n_namespace: "admin.budget_investments.index" %>

View File

@@ -5,7 +5,8 @@
<%= f.label :action_type %>
<% ::Dashboard::Action.action_types.keys.each do |action_type_value| %>
<span class="margin-right">
<%= f.radio_button :action_type, action_type_value,
<%= f.radio_button :action_type,
action_type_value,
data: { toggle: "request_to_administrators short_description" } %>
</span>
<% end %>

View File

@@ -1,5 +1,6 @@
<%= link_to t("admin.dashboard.actions.index.create"),
new_admin_dashboard_action_path, class: "button success float-right" %>
new_admin_dashboard_action_path,
class: "button success float-right" %>
<h2 class="inline-block">
<%= t("admin.dashboard.actions.index.title") %>

View File

@@ -25,7 +25,8 @@
</td>
<td>
<% unless task.executed_at? %>
<%= render Admin::TableActionsComponent.new(task,
<%= render Admin::TableActionsComponent.new(
task,
actions: [:edit],
edit_text: t("admin.dashboard.administrator_tasks.index.solve")
) %>

View File

@@ -29,7 +29,9 @@
<div class="js-add-fields-container">
<div class="small-12 medium-9 column">
<%= link_to_add_association t("admin.legislation.questions.form.add_option"),
f, :question_options, class: "button hollow" %>
f,
:question_options,
class: "button hollow" %>
</div>
</div>
</div>

View File

@@ -1,5 +1,6 @@
<h2 class="inline-block"><%= t("admin.newsletters.index.title") %></h2>
<%= link_to t("admin.newsletters.index.new_newsletter"), new_admin_newsletter_path,
<%= link_to t("admin.newsletters.index.new_newsletter"),
new_admin_newsletter_path,
class: "button float-right" %>
<% if @newsletters.any? %>

View File

@@ -12,7 +12,8 @@
</td>
<td>
<% unless @poll.expired? %>
<%= render Admin::TableActionsComponent.new(booth_assignment,
<%= render Admin::TableActionsComponent.new(
booth_assignment,
actions: [:destroy],
destroy_text: t("admin.booth_assignments.manage.actions.unassign"),
destroy_confirmation: (booth_assignment.shifts? ? t("admin.poll_booth_assignments.alert.shifts") : ""),

View File

@@ -7,7 +7,8 @@
<td class="text-center"><%= poll.sdg_target_list %></td>
<% end %>
<td>
<%= render Admin::TableActionsComponent.new(poll,
<%= render Admin::TableActionsComponent.new(
poll,
destroy_confirmation: t("admin.polls.destroy.alert")
) do |actions| %>
<%= actions.action(:configure) %>

View File

@@ -17,7 +17,8 @@
<td><%= shift.officer_email %></td>
<td><%= t("admin.poll_shifts.#{shift.task}") %></td>
<td>
<%= render Admin::TableActionsComponent.new(shift,
<%= render Admin::TableActionsComponent.new(
shift,
actions: [:destroy],
destroy_text: t("admin.poll_shifts.new.remove_shift")
) %>

View File

@@ -93,7 +93,8 @@
<% if investment.should_show_price_explanation? %>
<div class="text-center" data-magellan>
<%= link_to t("budgets.investments.show.see_price_explanation"),
"#price_explanation", class: "small" %>
"#price_explanation",
class: "small" %>
</div>
<% end %>
<% end %>

View File

@@ -3,7 +3,8 @@
<% if can?(:create, Budget::Investment.new(budget: @budget)) %>
<% if current_user && current_user.level_two_or_three_verified? %>
<%= link_to t("budgets.investments.index.sidebar.create"),
new_budget_investment_path(budget_id: @budget.id), class: "button budget expanded" %>
new_budget_investment_path(budget_id: @budget.id),
class: "button budget expanded" %>
<% else %>
<div class="callout warning">
<%= sanitize(t("budgets.investments.index.sidebar.verified_only",

View File

@@ -5,6 +5,7 @@
<p class="topic-info">
<%= t("communities.poll.take_part",
from: l(poll.starts_at.to_date), to: l(poll.ends_at.to_date)) %>
from: l(poll.starts_at.to_date),
to: l(poll.ends_at.to_date)) %>
</p>
</div>

View File

@@ -49,10 +49,10 @@
<tr>
<td style="padding-bottom: 12px; padding-top: 24px; text-align: center;">
<%= link_to progress_proposal_dashboard_url(@proposal),
style: "font-family: 'Open Sans',arial,sans-serif; background: #3700fd;
border-radius: 6px; color: #fff !important; font-weight: bold;
padding: 17px 20px; text-align: center; text-decoration: none;
font-size: 20px; min-width: 200px; display: inline-block;",
style: "font-family: 'Open Sans',arial,sans-serif; background: #3700fd;" \
"border-radius: 6px; color: #fff !important; font-weight: bold;" \
"padding: 17px 20px; text-align: center; text-decoration: none;" \
"font-size: 20px; min-width: 200px; display: inline-block;",
target: "_blank" do %>
<%= t("mailers.new_actions_notification_on_published.dashboard_button") %>
<% end %>

View File

@@ -4,9 +4,15 @@
&nbsp;|&nbsp;
<% if debate.featured? %>
<%= link_to t("admin.actions.unmark_featured").capitalize, unmark_featured_debate_path(debate),
method: :put, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.unmark_featured"), name: debate.title) } %>
method: :put,
data: { confirm: t("admin.actions.confirm_action",
action: t("admin.actions.unmark_featured"),
name: debate.title) } %>
<% else %>
<%= link_to t("admin.actions.mark_featured").capitalize, mark_featured_debate_path(debate),
method: :put, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.mark_featured"), name: debate.title) } %>
method: :put,
data: { confirm: t("admin.actions.confirm_action",
action: t("admin.actions.mark_featured"),
name: debate.title) } %>
<% end %>
<% end %>

View File

@@ -10,7 +10,8 @@
<div class="callout primary">
<p>
<%= sanitize(t("users.login_to_continue",
signin: link_to_signin, signup: link_to_signup)) %>
signin: link_to_signin,
signup: link_to_signup)) %>
</p>
</div>
<% elsif not @receiver.email_on_direct_message? %>

View File

@@ -28,10 +28,14 @@
<h2><%= t("layouts.application.ie_title") %></h2>
<p>
<%= sanitize(t("layouts.application.ie",
chrome: link_to(
t("layouts.application.chrome"), "https://www.google.com/chrome/browser/desktop/", title: t("shared.target_blank"), target: "_blank"),
firefox: link_to(
t("layouts.application.firefox"), "https://www.mozilla.org/firefox", title: t("shared.target_blank"), target: "_blank")
chrome: link_to(t("layouts.application.chrome"),
"https://www.google.com/chrome/browser/desktop/",
title: t("shared.target_blank"),
target: "_blank"),
firefox: link_to(t("layouts.application.firefox"),
"https://www.mozilla.org/firefox",
title: t("shared.target_blank"),
target: "_blank")
)) %>
</p>
</div>

View File

@@ -3,7 +3,8 @@
<div class="small-12 medium-9 column">
<% if banner_color? %>
<%= link_to t("shared.back"), legislation_processes_path,
<%= link_to t("shared.back"),
legislation_processes_path,
class: "icon-angle-left",
style: "color:#{process.font_color};" %>
<% else %>

View File

@@ -12,7 +12,8 @@
<% else %>
<p>
<%= sanitize(t("annotator.help.text",
sign_in: link_to_signin, sign_up: link_to_signup)) %>
sign_in: link_to_signin,
sign_up: link_to_signup)) %>
</p>
<% end %>

View File

@@ -14,7 +14,8 @@
<% elsif !user_signed_in? %>
<div class="participation-not-allowed">
<%= sanitize(t("legislation.questions.participation.unauthenticated",
signin: link_to_signin, signup: link_to_signup)) %>
signin: link_to_signin,
signup: link_to_signup)) %>
</div>
<% elsif !@process.debate_phase.open? %>
<div class="participation-not-allowed">

View File

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

View File

@@ -1,12 +1,10 @@
<td style="<%= css_for_mailer_content %>">
<h1 style="<%= css_for_mailer_heading %>">
<%= t("mailers.user_invite.title",
org: Setting["org_name"]) %>
<%= t("mailers.user_invite.title", org: Setting["org_name"]) %>
</h1>
<p style="<%= css_for_mailer_text %>">
<%= t("mailers.user_invite.text",
org: Setting["org_name"]) %>
<%= t("mailers.user_invite.text", org: Setting["org_name"]) %>
</p>
<p style="text-align: center;">

View File

@@ -17,12 +17,14 @@
<% if notification.unread? %>
<%= link_to t("notifications.notification.mark_as_read"),
mark_as_read_notification_path(notification),
method: :put, remote: true,
method: :put,
remote: true,
class: "mark-notification small" %>
<% else %>
<%= link_to t("notifications.notification.mark_as_unread"),
mark_as_unread_notification_path(notification),
method: :put, remote: true,
method: :put,
remote: true,
class: "mark-notification small" %>
<% end %>
</li>

View File

@@ -5,5 +5,6 @@
<p><%= t("devise_views.organizations.registrations.success.instructions_3") %></p>
<p>
<%= link_to t("devise_views.organizations.registrations.success.back_to_index"),
root_path, class: "button margin-top expanded" %>
root_path,
class: "button margin-top expanded" %>
</p>

View File

@@ -16,7 +16,8 @@
<%= render "shared/errors", resource: @proposal %>
<div class="row column">
<div class="small-12 medium-6 large-4 column">
<%= f.select :retired_reason, retire_proposals_options,
<%= f.select :retired_reason,
retire_proposals_options,
include_blank: t("proposals.retire_form.retired_reason_blank") %>
</div>
</div>
@@ -25,7 +26,8 @@
<%= f.translatable_fields do |translations_form| %>
<div class="small-12 medium-9 column float-left">
<%= translations_form.text_area :retired_explanation,
rows: 4, maxlength: 500,
rows: 4,
maxlength: 500,
placeholder: t("proposals.retire_form.retired_explanation_placeholder") %>
</div>
<% end %>

View File

@@ -7,6 +7,7 @@
<% else %>
<div class="callout primary">
<%= sanitize(t("community.show.create_first_community_topic.sub_first_theme",
sign_in: link_to_signin, sign_up: link_to_signup)) %>
sign_in: link_to_signin,
sign_up: link_to_signup)) %>
</div>
<% end %>

View File

@@ -2,7 +2,8 @@
<div class="row margin-bottom">
<div class="small-12 medium-9 column">
<%= back_link_to community_path(@community), t("community.show.back",
<%= back_link_to community_path(@community),
t("community.show.back",
community: community_text(@community),
proposal: community_title(@community)) %>

View File

@@ -8,7 +8,8 @@
<p>
<%= sanitize(t("devise_views.users.registrations.new.organization_signup",
signup_link: link_to(t("devise_views.users.registrations.new.organization_signup_link"), new_organization_registration_path))) %>
signup_link: link_to(t("devise_views.users.registrations.new.organization_signup_link"),
new_organization_registration_path))) %>
</p>
<div class="row">

View File

@@ -5,5 +5,6 @@
<p><%= t("devise_views.users.registrations.success.instructions_2") %></p>
<p>
<%= link_to t("devise_views.users.registrations.success.back_to_index"),
root_path, class: "button margin-top expanded" %>
root_path,
class: "button margin-top expanded" %>
</p>

View File

@@ -21,7 +21,8 @@ RSpec.describe Legislation::Annotation, type: :model do
" ea. Per ne impedit iracundia neglegentur. Consetetur neglegentur eum ut, vis animal legimus inimicus id."\
"\n\n"\
"His audiam"
annotation = create(:legislation_annotation,
annotation = create(
:legislation_annotation,
draft_version: draft_version,
quote: quote,
ranges: [{ "start" => "/p[1]", "startOffset" => 6, "end" => "/p[3]", "endOffset" => 11 }]
@@ -46,7 +47,8 @@ RSpec.describe Legislation::Annotation, type: :model do
" facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore"\
" te feugait nulla facilisi.\r\n\r\nExpetenda tincidunt in sed, ex partem placerat sea, porro commodo ex eam. His putant"\
" aeterno interesset at. Usu ea mundi tincidunt, omnium virtute aliquando ius ex. Ea aperiri sententiae duo"
annotation = create(:legislation_annotation,
annotation = create(
:legislation_annotation,
draft_version: draft_version,
quote: quote,
ranges: [{ "start" => "/p[1]", "startOffset" => 273, "end" => "/p[2]", "endOffset" => 190 }]
@@ -92,7 +94,8 @@ RSpec.describe Legislation::Annotation, type: :model do
" freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of"\
" free software (and charge for them if you wish)"
annotation = create(:legislation_annotation,
annotation = create(
:legislation_annotation,
draft_version: draft_version,
quote: quote,
ranges: [{ "start" => "/p[2]", "startOffset" => 127, "end" => "/p[3]", "endOffset" => 223 }]

View File

@@ -301,16 +301,20 @@ describe "Admin budget investments", :admin do
end
scenario "Filtering by under valuation" do
create(:budget_investment,
create(
:budget_investment,
:with_administrator,
:with_valuator,
:open,
title: "Investment without valuation",
budget: budget)
create(:budget_investment,
budget: budget
)
create(
:budget_investment,
:with_administrator,
title: "Investment with valuation",
budget: budget)
budget: budget
)
visit admin_budget_budget_investments_path(budget_id: budget)
expect(page).to have_link("Investment without valuation")

View File

@@ -254,11 +254,13 @@ describe "System Emails" do
describe "#evaluation_comment" do
scenario "render correctly evaluaton comment mailer with valuator as a sample user" do
admin = create(:administrator, user: create(:user, username: "Baby Doe"))
investment = create(:budget_investment,
investment = create(
:budget_investment,
title: "Cleaner city",
heading: heading,
author: user,
administrator: admin)
administrator: admin
)
comment = create(:comment, :valuation, commentable: investment)
visit admin_system_email_view_path("evaluation_comment")
@@ -270,7 +272,12 @@ describe "System Emails" do
expect(page).to have_content comment.body
expect(page).to have_link "Cleaner city",
href: admin_budget_budget_investment_url(investment.budget, investment, anchor: "comments", host: app_host)
href: admin_budget_budget_investment_url(
investment.budget,
investment,
anchor: "comments",
host: app_host
)
end
scenario "uses a current_user as a sample user for sample regular comments" do

View File

@@ -163,12 +163,14 @@ describe "Ballots" do
scenario "map and content block shoud be visible before and after" do
stub_const("#{Budgets::InvestmentsController}::PER_PAGE", 1)
create(:budget_investment, :selected, :with_map_location,
create(
:budget_investment, :selected, :with_map_location,
heading: new_york,
price: 10000,
title: "More bridges",
)
create(:budget_investment, :selected, :with_map_location,
create(
:budget_investment, :selected, :with_map_location,
heading: new_york,
price: 5000,
title: "Less bridges"

View File

@@ -157,7 +157,8 @@ describe "Home" do
end
scenario "if there are cards, the 'featured' title will render" do
create(:widget_card,
create(
:widget_card,
title: "Card text",
description: "Card description",
link_text: "Link text",

View File

@@ -197,21 +197,24 @@ describe "Moderate budget investments" do
end
scenario "sorting investments" do
flagged_investment = create(:budget_investment,
flagged_investment = create(
:budget_investment,
heading: heading,
title: "Flagged investment",
created_at: 1.day.ago,
flags_count: 5
)
flagged_new_investment = create(:budget_investment,
flagged_new_investment = create(
:budget_investment,
heading: heading,
title: "Flagged new investment",
created_at: 12.hours.ago,
flags_count: 3
)
latest_investment = create(:budget_investment,
latest_investment = create(
:budget_investment,
heading: heading,
title: "Latest investment",
created_at: Time.current

View File

@@ -80,14 +80,16 @@ describe "Officing Results", :with_frozen_time do
end
scenario "Edit result" do
partial_result = create(:poll_partial_result,
partial_result = create(
:poll_partial_result,
officer_assignment: poll_officer.officer_assignments.first,
booth_assignment: poll_officer.officer_assignments.first.booth_assignment,
date: Date.current,
question: question_1,
answer: question_1.question_answers.first.title,
author: poll_officer.user,
amount: 7777)
amount: 7777
)
visit officing_poll_results_path(poll, date: I18n.l(partial_result.date), booth_assignment_id: partial_result.booth_assignment_id)
@@ -129,20 +131,24 @@ describe "Officing Results", :with_frozen_time do
booth_assignment = officer_assignment.booth_assignment
booth = booth_assignment.booth
create(:poll_partial_result,
create(
:poll_partial_result,
officer_assignment: officer_assignment,
booth_assignment: booth_assignment,
date: poll.ends_at,
question: question_1,
amount: 33)
amount: 33
)
create(:poll_recount,
create(
:poll_recount,
officer_assignment: officer_assignment,
booth_assignment: booth_assignment,
date: poll.ends_at,
white_amount: 21,
null_amount: 44,
total_amount: 66)
total_amount: 66
)
visit officing_poll_results_path(poll,
date: I18n.l(poll.ends_at.to_date),

View File

@@ -4,7 +4,8 @@ describe "Custom Pages" do
context "New custom page" do
context "Published" do
scenario "See page" do
custom_page = create(:site_customization_page, :published,
custom_page = create(
:site_customization_page, :published,
slug: "other-slug",
title_en: "Custom page",
content_en: "Text for new custom page",
@@ -20,7 +21,8 @@ describe "Custom Pages" do
end
scenario "Show all fields and text with links" do
custom_page = create(:site_customization_page, :published,
custom_page = create(
:site_customization_page, :published,
slug: "slug-with-all-fields-filled",
title_en: "Custom page",
subtitle_en: "This is my new custom page",
@@ -39,7 +41,8 @@ describe "Custom Pages" do
end
scenario "Don't show subtitle if its blank" do
custom_page = create(:site_customization_page, :published,
custom_page = create(
:site_customization_page, :published,
slug: "slug-without-subtitle",
title_en: "Custom page",
subtitle_en: "",
@@ -57,7 +60,8 @@ describe "Custom Pages" do
end
scenario "Listed in more information page" do
create(:site_customization_page, :published,
create(
:site_customization_page, :published,
slug: "another-slug",
title_en: "Another custom page",
subtitle_en: "Subtitle for custom page",
@@ -70,7 +74,8 @@ describe "Custom Pages" do
end
scenario "Not listed in more information page" do
custom_page = create(:site_customization_page, :published,
custom_page = create(
:site_customization_page, :published,
slug: "another-slug", title_en: "Another custom page",
subtitle_en: "Subtitle for custom page",
more_info_flag: false