Add and appy MultilineOperationIndentation rule

This way it's easier to see when lines are part of multiline
statements and when they belong to `if` statements.
This commit is contained in:
Javi Martín
2023-07-01 17:02:52 +02:00
parent 8b13daad95
commit 32b1fc53e1
14 changed files with 25 additions and 22 deletions

View File

@@ -105,6 +105,9 @@ Layout/MultilineHashBraceLayout:
Layout/MultilineHashKeyLineBreaks: Layout/MultilineHashKeyLineBreaks:
Enabled: true Enabled: true
Layout/MultilineOperationIndentation:
Enabled: true
Layout/SpaceAfterColon: Layout/SpaceAfterColon:
Enabled: true Enabled: true

View File

@@ -41,7 +41,7 @@ class Admin::MenuComponent < ApplicationComponent
def polls? def polls?
controller.class.module_parent == Admin::Poll::Questions::Answers || controller.class.module_parent == Admin::Poll::Questions::Answers ||
%w[polls active_polls recounts results questions answers].include?(controller_name) && %w[polls active_polls recounts results questions answers].include?(controller_name) &&
action_name != "booth_assignments" action_name != "booth_assignments"
end end
def booths? def booths?

View File

@@ -1,8 +1,8 @@
module AdminBudgetInvestmentsHelper module AdminBudgetInvestmentsHelper
def advanced_menu_visibility def advanced_menu_visibility
if params[:advanced_filters].empty? && if params[:advanced_filters].empty? &&
params["min_total_supports"].blank? && params["min_total_supports"].blank? &&
params["max_total_supports"].blank? params["max_total_supports"].blank?
"hide" "hide"
else else
"" ""

View File

@@ -35,7 +35,7 @@ module GlobalizeHelper
def first_i18n_content_translation_locale def first_i18n_content_translation_locale
if I18nContentTranslation.existing_languages.count == 0 || if I18nContentTranslation.existing_languages.count == 0 ||
I18nContentTranslation.existing_languages.include?(I18n.locale) I18nContentTranslation.existing_languages.include?(I18n.locale)
I18n.locale I18n.locale
else else
I18nContentTranslation.existing_languages.first I18nContentTranslation.existing_languages.first

View File

@@ -25,17 +25,17 @@ module ManagementHelper
def menu_create_investments? def menu_create_investments?
(controller_name == "budget_investments" && action_name == "new") || (controller_name == "budget_investments" && action_name == "new") ||
(controller_name == "budgets" && action_name == "create_investments") (controller_name == "budgets" && action_name == "create_investments")
end end
def menu_support_investments? def menu_support_investments?
(controller_name == "budget_investments" && action_name == "index") || (controller_name == "budget_investments" && action_name == "index") ||
(controller_name == "budgets" && action_name == "support_investments") (controller_name == "budgets" && action_name == "support_investments")
end end
def menu_print_investments? def menu_print_investments?
(controller_name == "budget_investments" && action_name == "print") || (controller_name == "budget_investments" && action_name == "print") ||
(controller_name == "budgets" && action_name == "print_investments") (controller_name == "budgets" && action_name == "print_investments")
end end
def menu_user_invites? def menu_user_invites?

View File

@@ -10,7 +10,7 @@ module MilestonesHelper
"aria-valuemin": "0", "aria-valuemin": "0",
tabindex: "0" do tabindex: "0" do
tag.span(class: "progress-meter", style: "width: #{progress_bar.percentage}%;") + tag.span(class: "progress-meter", style: "width: #{progress_bar.percentage}%;") +
tag.p(text, class: "progress-meter-text") tag.p(text, class: "progress-meter-text")
end end
end end
end end

View File

@@ -2,8 +2,8 @@ module PollRecountsHelper
def total_recounts_by_booth(booth_assignment) def total_recounts_by_booth(booth_assignment)
if booth_assignment.recounts.any? if booth_assignment.recounts.any?
booth_assignment.recounts.sum(:total_amount) + booth_assignment.recounts.sum(:total_amount) +
booth_assignment.recounts.sum(:white_amount) + booth_assignment.recounts.sum(:white_amount) +
booth_assignment.recounts.sum(:null_amount) booth_assignment.recounts.sum(:null_amount)
end end
end end
end end

View File

@@ -49,7 +49,7 @@ module ProposalsDashboardHelper
def is_proposed_action_request? def is_proposed_action_request?
controller_name == "dashboard" && action_name == "new_request" && controller_name == "dashboard" && action_name == "new_request" &&
dashboard_action&.proposed_action? dashboard_action&.proposed_action?
end end
def is_request_active(id) def is_request_active(id)

View File

@@ -16,7 +16,7 @@ module UsersHelper
deleted_commentable_text(comment) deleted_commentable_text(comment)
elsif commentable.hidden? elsif commentable.hidden?
tag.del(commentable.title) + " " + tag.del(commentable.title) + " " +
tag.span("(#{deleted_commentable_text(comment)})", class: "small") tag.span("(#{deleted_commentable_text(comment)})", class: "small")
else else
link_to(commentable.title, comment) link_to(commentable.title, comment)
end end

View File

@@ -25,7 +25,7 @@ module WelcomeHelper
def calculate_image_path(recommended, image_default) def calculate_image_path(recommended, image_default)
if recommended.respond_to?(:image) && recommended.image.present? && if recommended.respond_to?(:image) && recommended.image.present? &&
recommended.image.attachment.attached? recommended.image.attachment.attached?
recommended.image.variant(:medium) recommended.image.variant(:medium)
elsif image_default.present? elsif image_default.present?
image_default image_default

View File

@@ -73,7 +73,7 @@ class LocalCensusRecords::Import
def file_headers_definition def file_headers_definition
headers = fetch_file_headers headers = fetch_file_headers
return if headers.all? { |header| ATTRIBUTES.include? header } && return if headers.all? { |header| ATTRIBUTES.include? header } &&
ATTRIBUTES.all? { |attr| headers.include? attr } ATTRIBUTES.all? { |attr| headers.include? attr }
errors.add :file, :headers, required_headers: ATTRIBUTES.join(", ") errors.add :file, :headers, required_headers: ATTRIBUTES.join(", ")
end end

View File

@@ -396,7 +396,7 @@ class User < ApplicationRecord
conditions = warden_conditions.dup conditions = warden_conditions.dup
login = conditions.delete(:login) login = conditions.delete(:login)
where(conditions.to_hash).find_by(["lower(email) = ?", login.downcase]) || where(conditions.to_hash).find_by(["lower(email) = ?", login.downcase]) ||
where(conditions.to_hash).find_by(["username = ?", login]) where(conditions.to_hash).find_by(["username = ?", login])
end end
def self.find_by_manager_login(manager_login) def self.find_by_manager_login(manager_login)

View File

@@ -38,7 +38,7 @@
<%= link_to proposal_dashboard_polls_path(proposal), <%= link_to proposal_dashboard_polls_path(proposal),
class: ("submenu-active" if polls_menu_active?) do %> class: ("submenu-active" if polls_menu_active?) do %>
<span data-tooltip title="<%= Setting["proposals.poll_short_title"] || <span data-tooltip title="<%= Setting["proposals.poll_short_title"] ||
t("dashboard.menu.polls") %>"> t("dashboard.menu.polls") %>">
<%= t("dashboard.menu.polls") %> <%= t("dashboard.menu.polls") %>
</span> </span>
<% end %> <% end %>
@@ -50,7 +50,7 @@
<%= link_to new_proposal_dashboard_mailing_path(proposal), <%= link_to new_proposal_dashboard_mailing_path(proposal),
class: ("submenu-active" if mailing_menu_active?) do %> class: ("submenu-active" if mailing_menu_active?) do %>
<span data-tooltip title="<%= Setting["proposals.email_short_title"] || <span data-tooltip title="<%= Setting["proposals.email_short_title"] ||
t("dashboard.menu.mailing") %>"> t("dashboard.menu.mailing") %>">
<%= t("dashboard.menu.mailing") %> <%= t("dashboard.menu.mailing") %>
</span> </span>
<% end %> <% end %>
@@ -62,7 +62,7 @@
<%= link_to new_proposal_dashboard_poster_path(proposal), <%= link_to new_proposal_dashboard_poster_path(proposal),
class: ("submenu-active" if poster_menu_active?) do %> class: ("submenu-active" if poster_menu_active?) do %>
<span data-tooltip title="<%= Setting["proposals.poster_short_title"] || <span data-tooltip title="<%= Setting["proposals.poster_short_title"] ||
t("dashboard.menu.poster") %>"> t("dashboard.menu.poster") %>">
<%= t("dashboard.menu.poster") %> <%= t("dashboard.menu.poster") %>
</span> </span>
<% end %> <% end %>

View File

@@ -19,8 +19,8 @@ describe Shared::LinkListComponent do
) )
expect(page).to be_rendered with: '<ul class="menu">' + "\n" + expect(page).to be_rendered with: '<ul class="menu">' + "\n" +
'<li><a href="/">Home</a></li>' + "\n" + '<li><a href="/">Home</a></li>' + "\n" +
'<li><a href="/info">Info</a></li>' + "\n</ul>\n" '<li><a href="/info">Info</a></li>' + "\n</ul>\n"
end end
it "accepts anchor tags" do it "accepts anchor tags" do
@@ -29,8 +29,8 @@ describe Shared::LinkListComponent do
) )
expect(page).to be_rendered with: '<ul class="menu">' + "\n" + expect(page).to be_rendered with: '<ul class="menu">' + "\n" +
'<li><a href="/">Home</a></li>' + "\n" + '<li><a href="/">Home</a></li>' + "\n" +
'<li><a href="/info">Info</a></li>' + "\n</ul>\n" '<li><a href="/info">Info</a></li>' + "\n</ul>\n"
end end
it "accepts options for links" do it "accepts options for links" do