Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

erb_lint auto fix rails stuff

Ivan Kuchin4eb956e5c603
diff --git a/app/components/open_project/common/submenu_component.html.erb b/app/components/open_project/common/submenu_component.html.erb
index 5ff89b510cd..58410624ad3 100644
--- a/app/components/open_project/common/submenu_component.html.erb
+++ b/app/components/open_project/common/submenu_component.html.erb
@@ -111,11 +111,7 @@
classes: "op-submenu--footer-action"
) do |button|
button.with_leading_visual_icon(icon: "plus")
- if @create_btn_options[:btn_text].present?
- @create_btn_options[:btn_text]
- else
- I18n.t("label_#{@create_btn_options[:module_key]}")
- end
+ @create_btn_options[:btn_text].presence || I18n.t("label_#{@create_btn_options[:module_key]}")
end %>
</div>
<% end %>
diff --git a/app/components/work_packages/activities_tab/error_frame_component.html.erb b/app/components/work_packages/activities_tab/error_frame_component.html.erb
index 8d9bd239539..673bdaf7155 100644
--- a/app/components/work_packages/activities_tab/error_frame_component.html.erb
+++ b/app/components/work_packages/activities_tab/error_frame_component.html.erb
@@ -1,6 +1,6 @@
<%=
content_tag("turbo-frame", id: "work-package-activities-tab-content") do
- unless error_message.blank?
+ if error_message.present?
render(Primer::Alpha::Banner.new(scheme: :danger)) { error_message }
end
end
diff --git a/app/components/work_packages/activities_tab/error_stream_component.html.erb b/app/components/work_packages/activities_tab/error_stream_component.html.erb
index 675995b9c9f..0e86b752ef0 100644
--- a/app/components/work_packages/activities_tab/error_stream_component.html.erb
+++ b/app/components/work_packages/activities_tab/error_stream_component.html.erb
@@ -1,6 +1,6 @@
<%=
component_wrapper do
- unless error_message.blank?
+ if error_message.present?
render(Primer::Alpha::Banner.new(scheme: :danger, dismiss_scheme: :hide)) { error_message }
end
end
diff --git a/app/components/work_packages/activities_tab/journals/item_component/details.html.erb b/app/components/work_packages/activities_tab/journals/item_component/details.html.erb
index c1dcbc7499f..25cc575ff2b 100644
--- a/app/components/work_packages/activities_tab/journals/item_component/details.html.erb
+++ b/app/components/work_packages/activities_tab/journals/item_component/details.html.erb
@@ -19,7 +19,7 @@
render_details(details_container)
end
else
- if has_details? && !journal.notes.present?
+ if has_details? && journal.notes.blank?
render_details_header(details_container)
end
render_details(details_container)
diff --git a/app/views/account/_password_login_form.html.erb b/app/views/account/_password_login_form.html.erb
index 98903b8bc75..86766524f92 100644
--- a/app/views/account/_password_login_form.html.erb
+++ b/app/views/account/_password_login_form.html.erb
@@ -45,7 +45,7 @@ See COPYRIGHT and LICENSE files for more details.
<div class="form--field -required">
<%= styled_label_tag "password", User.human_attribute_name(:password) %>
<div class="form--field-container">
- <%= styled_password_field_tag "password", nil, autofocus: !params[:username].blank? %>
+ <%= styled_password_field_tag "password", nil, autofocus: params[:username].present? %>
</div>
</div>
diff --git a/app/views/admin/backups/show.html.erb b/app/views/admin/backups/show.html.erb
index 59c3a0acb8a..cd098e289e1 100644
--- a/app/views/admin/backups/show.html.erb
+++ b/app/views/admin/backups/show.html.erb
@@ -41,7 +41,7 @@ See COPYRIGHT and LICENSE files for more details.
<div class="wiki">
<ul>
- <% Token::Backup.all.includes(:user).each do |token| %>
+ <% Token::Backup.includes(:user).each do |token| %>
<li>
<% if current_user.allowed_globally?(:manage_user) %>
<%= link_to token.user.name, edit_user_path(token.user) %>
diff --git a/app/views/admin/settings/authentication_settings/show.html.erb b/app/views/admin/settings/authentication_settings/show.html.erb
index edc60d3071e..19feeecd90e 100644
--- a/app/views/admin/settings/authentication_settings/show.html.erb
+++ b/app/views/admin/settings/authentication_settings/show.html.erb
@@ -42,7 +42,7 @@ See COPYRIGHT and LICENSE files for more details.
<%= styled_form_tag(admin_settings_authentication_path, method: :patch) do %>
<section class="form--section">
<fieldset class="form--fieldset">
- <legend class="form--fieldset-legend"><%= I18n.t(:general, scope: [:settings]) %></legend>
+ <legend class="form--fieldset-legend"><%= I18n.t("settings.general") %></legend>
<div class="form--field"><%= setting_check_box :login_required %></div>
<div class="form--field"><%= setting_select :self_registration, [[t(:label_disabled), Setting::SelfRegistration.disabled.to_s],
@@ -88,7 +88,7 @@ See COPYRIGHT and LICENSE files for more details.
</fieldset>
<fieldset class="form--fieldset">
- <legend class="form--fieldset-legend"><%= I18n.t(:passwords, scope: [:settings]) %></legend>
+ <legend class="form--fieldset-legend"><%= I18n.t("settings.passwords") %></legend>
<% if !OpenProject::Configuration.disable_password_login? %>
<div class="form--field -wide-label"><%= setting_text_field :password_min_length, size: 6, container_class: "-xslim" %></div>
<div class="form--field -wide-label">
@@ -123,7 +123,7 @@ See COPYRIGHT and LICENSE files for more details.
<% unless OpenProject::Configuration.disable_password_login? %>
<fieldset class="form--fieldset">
- <legend class="form--fieldset-legend"><%= I18n.t(:brute_force_prevention, scope: [:settings]) %></legend>
+ <legend class="form--fieldset-legend"><%= I18n.t("settings.brute_force_prevention") %></legend>
<div class="form--field -wide-label"><%= setting_text_field :brute_force_block_after_failed_logins, container_class: "-xslim" %>
<span class="form--field-instructions">
<%= t(:text_hint_disable_with_0) %>
@@ -134,7 +134,7 @@ See COPYRIGHT and LICENSE files for more details.
<% end %>
<fieldset class="form--fieldset">
- <legend class="form--fieldset-legend"><%= I18n.t(:session, scope: [:settings]) %></legend>
+ <legend class="form--fieldset-legend"><%= I18n.t("settings.session") %></legend>
<div class="form--field -wide-label"><%= setting_select :autologin,
([[t(:label_disabled), 0]] +
Settings::Definition[:autologin].allowed.collect do |days|
@@ -153,7 +153,7 @@ See COPYRIGHT and LICENSE files for more details.
</fieldset>
<fieldset class="form--fieldset">
- <legend class="form--fieldset-legend"><%= I18n.t(:other, scope: [:settings]) %></legend>
+ <legend class="form--fieldset-legend"><%= I18n.t("settings.other") %></legend>
<div class="form--field -wide-label"><%= setting_check_box :log_requesting_user %></div>
</fieldset>
</section>
diff --git a/app/views/admin/settings/show_plugin.html.erb b/app/views/admin/settings/show_plugin.html.erb
index 14448a63138..21546178724 100644
--- a/app/views/admin/settings/show_plugin.html.erb
+++ b/app/views/admin/settings/show_plugin.html.erb
@@ -34,7 +34,7 @@ See COPYRIGHT and LICENSE files for more details.
header.with_title { @page_title }
header.with_breadcrumbs(
[{ href: admin_index_path, text: t("label_administration") },
- *(@breadcrumb_elements if @breadcrumb_elements.present?),
+ *@breadcrumb_elements.presence,
@page_title]
)
end
diff --git a/app/views/admin/settings/users_settings/show.html.erb b/app/views/admin/settings/users_settings/show.html.erb
index 00afcfbcf1c..7ca9d92401d 100644
--- a/app/views/admin/settings/users_settings/show.html.erb
+++ b/app/views/admin/settings/users_settings/show.html.erb
@@ -92,7 +92,7 @@ See COPYRIGHT and LICENSE files for more details.
<span class="form--check-box-field-container -slim">
<%= check_box_tag "toggle_consent_time",
"1",
- !Setting.consent_time.present?,
+ Setting.consent_time.blank?,
id: "toggle_consent_time" %>
</span>
<% end %>
diff --git a/app/views/colors/_color_autocomplete_field.html.erb b/app/views/colors/_color_autocomplete_field.html.erb
index 4609d2ee1aa..559f0b9ded2 100644
--- a/app/views/colors/_color_autocomplete_field.html.erb
+++ b/app/views/colors/_color_autocomplete_field.html.erb
@@ -10,7 +10,7 @@
<%= content_tag(
"opce-colors-autocompleter",
"",
- class: "colors-autocomplete form--select-container " + (container_class.present? ? container_class : "-middle").to_s,
+ class: "colors-autocomplete form--select-container " + (container_class.presence || "-middle").to_s,
data: { colors: options_for_colors(object),
selected_color: selected_color(object),
highlight_text_inline: highlight_text_inline,
diff --git a/app/views/custom_styles/_pdf_export_styles.html.erb b/app/views/custom_styles/_pdf_export_styles.html.erb
index 8c1f67200ce..a36589219e7 100644
--- a/app/views/custom_styles/_pdf_export_styles.html.erb
+++ b/app/views/custom_styles/_pdf_export_styles.html.erb
@@ -97,7 +97,7 @@ See COPYRIGHT and LICENSE files for more details.
<span class="form--field-container">
<div class="form--field-affix">
<% design_color_name = "export_cover_text_color" %>
- <% design_color_hex = @custom_style.export_cover_text_color.present? ? @custom_style.export_cover_text_color : "" %>
+ <% design_color_hex = @custom_style.export_cover_text_color.presence || "" %>
<%= icon_for_color(
OpenStruct.new(
variable: design_color_name,
diff --git a/app/views/custom_styles/show.html.erb b/app/views/custom_styles/show.html.erb
index 412bc87bc41..cd3640a7575 100644
--- a/app/views/custom_styles/show.html.erb
+++ b/app/views/custom_styles/show.html.erb
@@ -43,7 +43,7 @@ See COPYRIGHT and LICENSE files for more details.
</div>
<%= styled_button_tag t(:button_save),
- data: { test_selector: "color-theme-button", confirm: (t("admin.custom_styles.theme_warning") unless @current_theme.present?) } %>
+ data: { test_selector: "color-theme-button", confirm: (t("admin.custom_styles.theme_warning") if @current_theme.blank?) } %>
</fieldset>
</section>
<% end %>
diff --git a/app/views/my/_password_form_fields.html.erb b/app/views/my/_password_form_fields.html.erb
index 58ca3971439..3431f01f7e8 100644
--- a/app/views/my/_password_form_fields.html.erb
+++ b/app/views/my/_password_form_fields.html.erb
@@ -78,13 +78,11 @@ See COPYRIGHT and LICENSE files for more details.
</div>
<div class="form--field-instructions">
<%= I18n.t(
- :confirm,
- scope: %i[activerecord errors models user attributes password match]
+ "activerecord.errors.models.user.attributes.password.match.confirm"
) %>
<br>
<%= I18n.t(
- :description,
- scope: %i[activerecord errors models user attributes password match]
+ "activerecord.errors.models.user.attributes.password.match.description"
) %>
</div>
</div>
diff --git a/app/views/news/index.html.erb b/app/views/news/index.html.erb
index 8e237a5206e..8f83adecc4f 100644
--- a/app/views/news/index.html.erb
+++ b/app/views/news/index.html.erb
@@ -70,7 +70,7 @@ See COPYRIGHT and LICENSE files for more details.
<%= "(#{t(:label_x_comments, count: news.comments_count)})" if news.comments_count > 0 %></h3>
<p class="author additional-information"><%= authoring news.created_at, news.author %></p>
<div class="wiki op-uc-container">
- <%= format_text(news.summary.present? ? news.summary : truncate(news.description, length: 150, escape: false), object: news) %>
+ <%= format_text((news.summary.presence || truncate(news.description, length: 150, escape: false)), object: news) %>
</div>
</div>
<% end %>
diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb
index 7c1ea059508..4ec0e6575f9 100644
--- a/app/views/repositories/show.html.erb
+++ b/app/views/repositories/show.html.erb
@@ -118,7 +118,7 @@ See COPYRIGHT and LICENSE files for more details.
<% end %>
<p>
<%
+ has_branches = @repository.branches.present?
sep = ""
%>
diff --git a/app/views/search/index.html.erb b/app/views/search/index.html.erb
index d51723d1467..404dd236a4b 100644
--- a/app/views/search/index.html.erb
+++ b/app/views/search/index.html.erb
@@ -72,5 +72,5 @@ See COPYRIGHT and LICENSE files for more details.
<% end %>
<% end %>
-<%= render partial: "pagination", locals: { pagination_previous_date: @pagination_previous_date, pagination_next_date: @pagination_next_date } unless params[:work_packages].present? %>
+<%= render partial: "pagination", locals: { pagination_previous_date: @pagination_previous_date, pagination_next_date: @pagination_next_date } if params[:work_packages].blank? %>
<% html_title(t(:label_search)) -%>
diff --git a/app/views/users/_general.html.erb b/app/views/users/_general.html.erb
index b4c082efa9c..db0ed243fa8 100644
--- a/app/views/users/_general.html.erb
+++ b/app/views/users/_general.html.erb
@@ -29,7 +29,7 @@ See COPYRIGHT and LICENSE files for more details.
<section class="form--section">
<div class="form--field">
- <%= styled_label_tag "FIXME", I18n.t(:status, scope: [:attributes]) %>
+ <%= styled_label_tag "FIXME", I18n.t("attributes.status") %>
<div class="form--field-container">
<span>
<span class=""><%= full_user_status(@user, true) %></span>
diff --git a/app/views/users/form/authentication/_internal_password.html.erb b/app/views/users/form/authentication/_internal_password.html.erb
index 462717be175..407f9bc708e 100644
--- a/app/views/users/form/authentication/_internal_password.html.erb
+++ b/app/views/users/form/authentication/_internal_password.html.erb
@@ -9,7 +9,7 @@
params[:user][:assign_random_password] %>
<div class="form--field">
<%= styled_label_tag "user_assign_random_password",
- I18n.t(:assign_random_password, scope: :user) %>
+ I18n.t("user.assign_random_password") %>
<div class="form--field-container">
<%= styled_check_box_tag "user[assign_random_password]",
"1",
diff --git a/lookbook/docs/styles/deprecated/03-colors.md.erb b/lookbook/docs/styles/deprecated/03-colors.md.erb
index 0b7c011933e..864eba5b8c4 100644
--- a/lookbook/docs/styles/deprecated/03-colors.md.erb
+++ b/lookbook/docs/styles/deprecated/03-colors.md.erb
@@ -186,7 +186,7 @@ This colour indicates that the requested user action was successful. It should b
<div class="colors">
<%
-tokens = JSON.parse File.read(Rails.root.join("frontend/src/app/spot/styles/tokens/dist/tokens.json"))
+tokens = JSON.parse Rails.root.join("frontend/src/app/spot/styles/tokens/dist/tokens.json").read
tokens.select { |k, _v| k.start_with?("spot-color-") }.each do |name, value|
%>
diff --git a/lookbook/docs/styles/deprecated/04-spacings.md.erb b/lookbook/docs/styles/deprecated/04-spacings.md.erb
index e2f1bcdde3a..63c39bccb47 100644
--- a/lookbook/docs/styles/deprecated/04-spacings.md.erb
+++ b/lookbook/docs/styles/deprecated/04-spacings.md.erb
@@ -6,7 +6,7 @@ title: Spacings
<div class="spacings">
<%
-tokens = JSON.parse File.read(Rails.root.join("frontend/src/app/spot/styles/tokens/dist/tokens.json"))
+tokens = JSON.parse Rails.root.join("frontend/src/app/spot/styles/tokens/dist/tokens.json").read
tokens
.select { |k, _v| k.start_with?("spot-spacing-") }
.sort_by { |k,| k.split("-")[2].tr("_", ".").to_f }
diff --git a/lookbook/docs/styles/deprecated/05-shadows.md.erb b/lookbook/docs/styles/deprecated/05-shadows.md.erb
index 8bb595e0a43..e1a5c0fd93b 100644
--- a/lookbook/docs/styles/deprecated/05-shadows.md.erb
+++ b/lookbook/docs/styles/deprecated/05-shadows.md.erb
@@ -15,7 +15,7 @@ Our shadows definitions divided between Light and Hard and three levels of eleva
<%
cols = ["Low", "Mid", "High"]
rows = ["Light", "Hard"]
-tokens = JSON.parse File.read(Rails.root.join("frontend/src/app/spot/styles/tokens/dist/tokens.json"))
+tokens = JSON.parse Rails.root.join("frontend/src/app/spot/styles/tokens/dist/tokens.json").read
tokens = tokens
.select { |k, _v| k.start_with?("spot-shadow-") }
.sort_by { |k,| k.split("-")[2].tr("_", ".").to_f }
diff --git a/lookbook/previews/open_project/common/autocomplete_preview/project.html.erb b/lookbook/previews/open_project/common/autocomplete_preview/project.html.erb
index 67d91c467bf..56a10ce64e5 100644
--- a/lookbook/previews/open_project/common/autocomplete_preview/project.html.erb
+++ b/lookbook/previews/open_project/common/autocomplete_preview/project.html.erb
@@ -9,7 +9,7 @@
openDirectly: false,
focusDirectly: false,
dropdownPosition: "bottom",
- disabledProjects: Project.visible.take(10).pluck(:id).to_h { |id| [id, "Disabled reason!"] }
+ disabledProjects: Project.visible.take(10).pluck(:id).index_with { |_id| "Disabled reason!" }
}
)
end
diff --git a/lookbook/previews/open_project/common/autocomplete_preview/project_with_search_icon.html.erb b/lookbook/previews/open_project/common/autocomplete_preview/project_with_search_icon.html.erb
index 85e840900a6..4650004a474 100644
--- a/lookbook/previews/open_project/common/autocomplete_preview/project_with_search_icon.html.erb
+++ b/lookbook/previews/open_project/common/autocomplete_preview/project_with_search_icon.html.erb
@@ -10,7 +10,7 @@
openDirectly: false,
focusDirectly: false,
dropdownPosition: "bottom",
- disabledProjects: Project.visible.take(10).pluck(:id).to_h { |id| [id, "Disabled reason!"] }
+ disabledProjects: Project.visible.take(10).pluck(:id).index_with { |_id| "Disabled reason!" }
}
)
end