diff --git a/Rakefile b/Rakefile index 536d51cd911d..30e586c3e063 100755 --- a/Rakefile +++ b/Rakefile @@ -30,9 +30,9 @@ # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. -require File.expand_path('config/application', __dir__) +require File.expand_path("config/application", __dir__) Rails.application.load_rake_tasks Rake::Task[:default].clear -task default: 'test:suite:run' +task default: "test:suite:run" diff --git a/app/components/activities/days_component.rb b/app/components/activities/days_component.rb index 27c7668f5c44..fe76971cb6c8 100644 --- a/app/components/activities/days_component.rb +++ b/app/components/activities/days_component.rb @@ -29,7 +29,7 @@ #++ class Activities::DaysComponent < ViewComponent::Base - def initialize(events:, current_project: nil, display_user: true, header_tag: 'h3', activity_page: nil) + def initialize(events:, current_project: nil, display_user: true, header_tag: "h3", activity_page: nil) super() @events = events @current_project = current_project diff --git a/app/components/add_button_component.rb b/app/components/add_button_component.rb index 46dafe74e648..956d16c5fec5 100644 --- a/app/components/add_button_component.rb +++ b/app/components/add_button_component.rb @@ -33,7 +33,7 @@ class AddButtonComponent < ApplicationComponent options :current_project def render? - raise 'Implement the conditions for which the component should render or not' + raise "Implement the conditions for which the component should render or not" end def dynamic_path @@ -45,7 +45,7 @@ def id end def li_css_class - 'toolbar-item' + "toolbar-item" end def title @@ -55,7 +55,7 @@ def title def label content_tag(:span, label_text, - class: 'button--text') + class: "button--text") end def aria_label @@ -71,10 +71,10 @@ def label_text end def link_css_class - 'button -primary' + "button -primary" end def icon - helpers.op_icon('button--icon icon-add') + helpers.op_icon("button--icon icon-add") end end diff --git a/app/components/admin/quarantined_attachments/row_component.rb b/app/components/admin/quarantined_attachments/row_component.rb index 392929a4db1a..0af393a4b4d1 100644 --- a/app/components/admin/quarantined_attachments/row_component.rb +++ b/app/components/admin/quarantined_attachments/row_component.rb @@ -45,7 +45,7 @@ def row_css_id delegate :filename, to: :attachment def attached_to - description = attachment.description.present? ? "(#{attachment.description})" : '' + description = attachment.description.present? ? "(#{attachment.description})" : "" text = "#{container_name} #{attachment.container_id} #{description}" case container when Message @@ -83,9 +83,9 @@ def button_links def delete_link helpers.link_to( - helpers.op_icon('icon icon-delete'), - { controller: '/admin/attachments/quarantined_attachments', action: :destroy, id: model }, - title: I18n.t('antivirus_scan.quarantined_attachments.delete'), + helpers.op_icon("icon icon-delete"), + { controller: "/admin/attachments/quarantined_attachments", action: :destroy, id: model }, + title: I18n.t("antivirus_scan.quarantined_attachments.delete"), method: :delete, data: { confirm: I18n.t(:text_are_you_sure), disable_with: I18n.t(:label_loading) } ) diff --git a/app/components/admin/quarantined_attachments/table_component.rb b/app/components/admin/quarantined_attachments/table_component.rb index f2f2d429b814..7ea4e52020fd 100644 --- a/app/components/admin/quarantined_attachments/table_component.rb +++ b/app/components/admin/quarantined_attachments/table_component.rb @@ -44,10 +44,10 @@ def sortable? def headers [ - ['filename', { caption: Attachment.human_attribute_name(:filename) }], - ['attached_to', { caption: I18n.t('antivirus_scan.quarantined_attachments.container') }], - ['author', { caption: Attachment.human_attribute_name(:author) }], - ['created_at', { caption: Attachment.human_attribute_name(:created_at) }] + ["filename", { caption: Attachment.human_attribute_name(:filename) }], + ["attached_to", { caption: I18n.t("antivirus_scan.quarantined_attachments.container") }], + ["author", { caption: Attachment.human_attribute_name(:author) }], + ["created_at", { caption: Attachment.human_attribute_name(:created_at) }] ] end end diff --git a/app/components/custom_actions/row_component.rb b/app/components/custom_actions/row_component.rb index 78aae79668f9..a8f2f3586cec 100644 --- a/app/components/custom_actions/row_component.rb +++ b/app/components/custom_actions/row_component.rb @@ -41,7 +41,7 @@ def name delegate :description, to: :action def sort - helpers.reorder_links('custom_action', { action: 'update', id: action }, method: :put) + helpers.reorder_links("custom_action", { action: "update", id: action }, method: :put) end def button_links @@ -53,7 +53,7 @@ def button_links def edit_link link_to( - helpers.op_icon('icon icon-edit'), + helpers.op_icon("icon icon-edit"), helpers.edit_custom_action_path(action), title: t(:button_edit) ) @@ -61,7 +61,7 @@ def edit_link def delete_link link_to( - helpers.op_icon('icon icon-delete'), + helpers.op_icon("icon icon-delete"), helpers.custom_action_path(action), method: :delete, data: { confirm: I18n.t(:text_are_you_sure) }, diff --git a/app/components/custom_actions/table_component.rb b/app/components/custom_actions/table_component.rb index 5b35e3a3c40e..0c7dfe58fd4f 100644 --- a/app/components/custom_actions/table_component.rb +++ b/app/components/custom_actions/table_component.rb @@ -36,18 +36,18 @@ class TableComponent < ::TableComponent def headers [ - ['name', { caption: CustomAction.human_attribute_name(:name) }], - ['description', { caption: CustomAction.human_attribute_name(:description) }], - ['sort', { caption: I18n.t(:label_sort) }] + ["name", { caption: CustomAction.human_attribute_name(:name) }], + ["description", { caption: CustomAction.human_attribute_name(:description) }], + ["sort", { caption: I18n.t(:label_sort) }] ] end def inline_create_link link_to new_custom_action_path, - aria: { label: t('custom_actions.new') }, - class: 'wp-inline-create--add-link', - title: t('custom_actions.new') do - helpers.op_icon('icon icon-add') + aria: { label: t("custom_actions.new") }, + class: "wp-inline-create--add-link", + title: t("custom_actions.new") do + helpers.op_icon("icon icon-add") end end end diff --git a/app/components/enumerations/row_component.rb b/app/components/enumerations/row_component.rb index 78c5597f23cc..9c885f3a3752 100644 --- a/app/components/enumerations/row_component.rb +++ b/app/components/enumerations/row_component.rb @@ -51,7 +51,7 @@ def active end def sort - helpers.reorder_links('enumeration', { action: 'move', id: enumeration }, method: :post) + helpers.reorder_links("enumeration", { action: "move", id: enumeration }, method: :post) end def button_links @@ -62,7 +62,7 @@ def button_links def delete_link helpers.link_to( - helpers.op_icon('icon icon-delete'), + helpers.op_icon("icon icon-delete"), helpers.enumeration_path(enumeration), method: :delete, data: { confirm: I18n.t(:text_are_you_sure) }, diff --git a/app/components/enumerations/table_component.rb b/app/components/enumerations/table_component.rb index 08b5c1a4286c..bba8eff05e1e 100644 --- a/app/components/enumerations/table_component.rb +++ b/app/components/enumerations/table_component.rb @@ -44,13 +44,13 @@ def sortable? def headers [ - ['name', { caption: Enumeration.human_attribute_name(:name) }], - ['is_default', { caption: Enumeration.human_attribute_name(:is_default) }], - ['active', { caption: Enumeration.human_attribute_name(:active) }], - ['sort', { caption: I18n.t(:label_sort) }] + ["name", { caption: Enumeration.human_attribute_name(:name) }], + ["is_default", { caption: Enumeration.human_attribute_name(:is_default) }], + ["active", { caption: Enumeration.human_attribute_name(:active) }], + ["sort", { caption: I18n.t(:label_sort) }] ].tap do |default| if with_colors - default.insert 3, ['color', { caption: Enumeration.human_attribute_name(:color) }] + default.insert 3, ["color", { caption: Enumeration.human_attribute_name(:color) }] end end end @@ -62,10 +62,10 @@ def with_colors def inline_create_link link_to new_enumeration_path(type: rows.name), aria: { label: t(:label_enumeration_new) }, - class: 'wp-inline-create--add-link', - data: { 'test-selector': "create-enumeration-#{rows.name.underscore.dasherize}" }, + class: "wp-inline-create--add-link", + data: { "test-selector": "create-enumeration-#{rows.name.underscore.dasherize}" }, title: t(:label_enumeration_new) do - helpers.op_icon('icon icon-add') + helpers.op_icon("icon icon-add") end end end diff --git a/app/components/individual_principal_base_filter_component.rb b/app/components/individual_principal_base_filter_component.rb index 1bff0229a696..b82f9f6bd263 100644 --- a/app/components/individual_principal_base_filter_component.rb +++ b/app/components/individual_principal_base_filter_component.rb @@ -52,25 +52,25 @@ def filtered?(params) def filter_name(query, name) if name.present? - query.where(:any_name_attribute, '~', name) + query.where(:any_name_attribute, "~", name) end end def filter_group(query, group_id) if group_id.present? - query.where(:group, '=', group_id) + query.where(:group, "=", group_id) end end def filter_role(query, role_id) if role_id.present? - query.where(:role_id, '=', role_id) + query.where(:role_id, "=", role_id) end end def filter_project(query, project_id) if project_id.present? - query.where(:project_id, '=', project_id) + query.where(:project_id, "=", project_id) end end diff --git a/app/components/ldap_auth_sources/row_component.rb b/app/components/ldap_auth_sources/row_component.rb index 2e8a9a8ccdf2..975c87e46252 100644 --- a/app/components/ldap_auth_sources/row_component.rb +++ b/app/components/ldap_auth_sources/row_component.rb @@ -33,7 +33,7 @@ class RowComponent < ::RowComponent def name content = link_to model.name, edit_ldap_auth_source_path(model) if model.seeded_from_env? - content += helpers.op_icon('icon icon-info2', title: I18n.t(:label_seeded_from_env_warning)) + content += helpers.op_icon("icon icon-info2", title: I18n.t(:label_seeded_from_env_warning)) end content @@ -54,17 +54,17 @@ def button_links end def test_link - link_to t(:button_test), { controller: 'ldap_auth_sources', action: 'test_connection', id: model } + link_to t(:button_test), { controller: "ldap_auth_sources", action: "test_connection", id: model } end def delete_link return if users > 0 link_to I18n.t(:button_delete), - { controller: 'ldap_auth_sources', id: model.id, action: :destroy }, + { controller: "ldap_auth_sources", id: model.id, action: :destroy }, method: :delete, data: { confirm: I18n.t(:text_are_you_sure) }, - class: 'icon icon-delete', + class: "icon icon-delete", title: I18n.t(:button_delete) end end diff --git a/app/components/ldap_auth_sources/table_component.rb b/app/components/ldap_auth_sources/table_component.rb index f4735796b600..ffbf507c6b39 100644 --- a/app/components/ldap_auth_sources/table_component.rb +++ b/app/components/ldap_auth_sources/table_component.rb @@ -46,17 +46,17 @@ def sortable_column?(_column) def inline_create_link link_to(new_ldap_auth_source_path, - class: 'budget-add-row wp-inline-create--add-link', + class: "budget-add-row wp-inline-create--add-link", title: I18n.t(:label_ldap_auth_source_new)) do - helpers.op_icon('icon icon-add') + helpers.op_icon("icon icon-add") end end def headers [ - ['name', { caption: LdapAuthSource.human_attribute_name('name') }], - ['host', { caption: LdapAuthSource.human_attribute_name('host') }], - ['users', { caption: I18n.t(:label_user_plural) }] + ["name", { caption: LdapAuthSource.human_attribute_name("name") }], + ["host", { caption: LdapAuthSource.human_attribute_name("host") }], + ["users", { caption: I18n.t(:label_user_plural) }] ] end end diff --git a/app/components/members/index_page_header_component.rb b/app/components/members/index_page_header_component.rb index 689eb40daab8..485aa1e1b6a4 100644 --- a/app/components/members/index_page_header_component.rb +++ b/app/components/members/index_page_header_component.rb @@ -41,20 +41,20 @@ def initialize(project: nil) def add_button_data_attributes attributes = { - 'members-form-target': 'addMemberButton', - action: 'members-form#showAddMemberForm', - 'test-selector': 'member-add-button' + "members-form-target": "addMemberButton", + action: "members-form#showAddMemberForm", + "test-selector": "member-add-button" } - attributes['trigger-initially'] = "true" if params[:show_add_members] + attributes["trigger-initially"] = "true" if params[:show_add_members] attributes end def filter_button_data_attributes { - 'members-form-target': 'filterMemberButton', - action: 'members-form#toggleMemberFilter' + "members-form-target": "filterMemberButton", + action: "members-form#toggleMemberFilter" } end end diff --git a/app/components/members/role_form_component.rb b/app/components/members/role_form_component.rb index 47eca2ba63d5..c207c31c03df 100644 --- a/app/components/members/role_form_component.rb +++ b/app/components/members/role_form_component.rb @@ -41,7 +41,7 @@ def form_html_options id: "#{row.roles_css_id}-form", class: row.toggle_item_class_name, style: "display:none", - data: { 'members-form-target': 'membershipEditForm' } + data: { "members-form-target": "membershipEditForm" } } end diff --git a/app/components/members/user_filter_component.rb b/app/components/members/user_filter_component.rb index 3dc96333fc07..e128e44d99a7 100644 --- a/app/components/members/user_filter_component.rb +++ b/app/components/members/user_filter_component.rb @@ -30,7 +30,7 @@ module Members class UserFilterComponent < ::UserFilterComponent - ALL_SHARED_FILTER_KEY = 'all' + ALL_SHARED_FILTER_KEY = "all" def initially_visible? false @@ -52,12 +52,12 @@ def shares # Adapts the user filter counts to count members as opposed to users. def extra_user_status_options { - all: status_members_query('all').count, - blocked: status_members_query('blocked').count, - active: status_members_query('active').count, - invited: status_members_query('invited').count, - registered: status_members_query('registered').count, - locked: status_members_query('locked').count + all: status_members_query("all").count, + blocked: status_members_query("blocked").count, + active: status_members_query("active").count, + invited: status_members_query("invited").count, + registered: status_members_query("registered").count, + locked: status_members_query("locked").count } end @@ -89,7 +89,7 @@ def share_options .order(builtin: :asc) .map { |role| [mapped_shared_role_name(role), role.id] } - share_options.unshift([I18n.t('members.filters.all_shares'), ALL_SHARED_FILTER_KEY]) + share_options.unshift([I18n.t("members.filters.all_shares"), ALL_SHARED_FILTER_KEY]) end def builtin_share_roles @@ -103,11 +103,11 @@ def builtin_share_roles def mapped_shared_role_name(role) case role.builtin when Role::BUILTIN_WORK_PACKAGE_VIEWER - I18n.t('work_package.sharing.permissions.view') + I18n.t("work_package.sharing.permissions.view") when Role::BUILTIN_WORK_PACKAGE_COMMENTER - I18n.t('work_package.sharing.permissions.comment') + I18n.t("work_package.sharing.permissions.comment") when Role::BUILTIN_WORK_PACKAGE_EDITOR - I18n.t('work_package.sharing.permissions.edit') + I18n.t("work_package.sharing.permissions.edit") else role.name end @@ -121,9 +121,9 @@ def filter_shares(query, role_id) .where(builtin: builtin_share_roles) .pluck(:id) - query.where(:role_id, '=', ids.uniq) + query.where(:role_id, "=", ids.uniq) elsif role_id.to_i > 0 - query.where(:role_id, '=', role_id.to_i) + query.where(:role_id, "=", role_id.to_i) end end diff --git a/app/components/oauth/applications/row_component.rb b/app/components/oauth/applications/row_component.rb index 33bfc1e631db..70b598eac265 100644 --- a/app/components/oauth/applications/row_component.rb +++ b/app/components/oauth/applications/row_component.rb @@ -47,20 +47,20 @@ def owner def confidential if application.confidential? - helpers.op_icon 'icon icon-checkmark' + helpers.op_icon "icon icon-checkmark" end end def redirect_uri urls = application.redirect_uri.split("\n") - safe_join urls, '
'.html_safe + safe_join urls, "
".html_safe end def client_credentials if user_id = application.client_credentials_user_id helpers.link_to_user User.find(user_id) else - '-' + "-" end end diff --git a/app/components/oauth/applications/table_component.rb b/app/components/oauth/applications/table_component.rb index 86b0cd15f099..144742596aa5 100644 --- a/app/components/oauth/applications/table_component.rb +++ b/app/components/oauth/applications/table_component.rb @@ -51,10 +51,10 @@ def columns def inline_create_link link_to new_oauth_application_path, - aria: { label: t('oauth.application.new') }, - class: 'wp-inline-create--add-link', - title: t('oauth.application.new') do - helpers.op_icon('icon icon-add') + aria: { label: t("oauth.application.new") }, + class: "wp-inline-create--add-link", + title: t("oauth.application.new") do + helpers.op_icon("icon icon-add") end end @@ -64,11 +64,11 @@ def empty_row_message def headers [ - ['name', { caption: ::Doorkeeper::Application.human_attribute_name(:name) }], - ['owner', { caption: ::Doorkeeper::Application.human_attribute_name(:owner) }], - ['client_credentials', { caption: I18n.t('oauth.client_credentials') }], - ['redirect_uri', { caption: ::Doorkeeper::Application.human_attribute_name(:redirect_uri) }], - ['confidential', { caption: ::Doorkeeper::Application.human_attribute_name(:confidential) }] + ["name", { caption: ::Doorkeeper::Application.human_attribute_name(:name) }], + ["owner", { caption: ::Doorkeeper::Application.human_attribute_name(:owner) }], + ["client_credentials", { caption: I18n.t("oauth.client_credentials") }], + ["redirect_uri", { caption: ::Doorkeeper::Application.human_attribute_name(:redirect_uri) }], + ["confidential", { caption: ::Doorkeeper::Application.human_attribute_name(:confidential) }] ] end end diff --git a/app/components/open_project/common/duration_component.rb b/app/components/open_project/common/duration_component.rb index f5dd5c34de0e..70639b9dd3a5 100644 --- a/app/components/open_project/common/duration_component.rb +++ b/app/components/open_project/common/duration_component.rb @@ -32,7 +32,7 @@ class DurationComponent < Primer::Component VALID_TYPES = %i[seconds minutes hours days weeks months years].freeze attr_reader :duration, :abbreviated, :separator - def initialize(duration, type = :seconds, separator: ', ', abbreviated: false, **args) + def initialize(duration, type = :seconds, separator: ", ", abbreviated: false, **args) super @duration = parse_duration(duration, type) diff --git a/app/components/placeholder_users/placeholder_user_filter_component.rb b/app/components/placeholder_users/placeholder_user_filter_component.rb index 989b3991a4a0..a9d999197f90 100644 --- a/app/components/placeholder_users/placeholder_user_filter_component.rb +++ b/app/components/placeholder_users/placeholder_user_filter_component.rb @@ -40,7 +40,7 @@ def apply_filters(params, query) # Filter for active placeholders # to skip to-be-deleted users - query.where(:status, '=', :active) + query.where(:status, "=", :active) end end diff --git a/app/components/placeholder_users/row_component.rb b/app/components/placeholder_users/row_component.rb index 3f439b37fb7d..e419ddeb4351 100644 --- a/app/components/placeholder_users/row_component.rb +++ b/app/components/placeholder_users/row_component.rb @@ -47,10 +47,10 @@ def button_links def delete_link if helpers.can_delete_placeholder_user?(placeholder_user, User.current) link_to deletion_info_placeholder_user_path(placeholder_user) do - helpers.tooltip_tag I18n.t('placeholder_users.delete_tooltip'), icon: 'icon-delete' + helpers.tooltip_tag I18n.t("placeholder_users.delete_tooltip"), icon: "icon-delete" end else - helpers.tooltip_tag I18n.t('placeholder_users.right_to_manage_members_missing'), icon: 'icon-help2' + helpers.tooltip_tag I18n.t("placeholder_users.right_to_manage_members_missing"), icon: "icon-help2" end end diff --git a/app/components/placeholder_users/table_component.rb b/app/components/placeholder_users/table_component.rb index 99cd383d0485..cebf3a43a88a 100644 --- a/app/components/placeholder_users/table_component.rb +++ b/app/components/placeholder_users/table_component.rb @@ -43,7 +43,7 @@ def headers def header_options(name) options = { caption: PlaceholderUser.human_attribute_name(name) } - options[:default_order] = 'desc' if desc_by_default.include? name + options[:default_order] = "desc" if desc_by_default.include? name options end diff --git a/app/components/projects/configure_view_modal_component.rb b/app/components/projects/configure_view_modal_component.rb index 173b3bfeaf12..5d1f93d83aae 100644 --- a/app/components/projects/configure_view_modal_component.rb +++ b/app/components/projects/configure_view_modal_component.rb @@ -29,9 +29,9 @@ # ++ class Projects::ConfigureViewModalComponent < ApplicationComponent - MODAL_ID = 'op-project-list-configure-dialog' - COLUMN_FORM_ID = 'op-project-list-configure-columns-form' - COLUMN_HTML_NAME = 'columns' + MODAL_ID = "op-project-list-configure-dialog" + COLUMN_FORM_ID = "op-project-list-configure-columns-form" + COLUMN_HTML_NAME = "columns" options :query diff --git a/app/components/projects/delete_list_modal_component.rb b/app/components/projects/delete_list_modal_component.rb index 70f8c39fdad7..d8ba7523c3a0 100644 --- a/app/components/projects/delete_list_modal_component.rb +++ b/app/components/projects/delete_list_modal_component.rb @@ -29,7 +29,7 @@ # ++ class Projects::DeleteListModalComponent < ApplicationComponent # rubocop:disable OpenProject/AddPreviewForViewComponent - MODAL_ID = 'op-project-list-delete-dialog' + MODAL_ID = "op-project-list-delete-dialog" options :query end diff --git a/app/components/projects/export_list_modal_component.rb b/app/components/projects/export_list_modal_component.rb index 601cc29649a5..e540403fbd98 100644 --- a/app/components/projects/export_list_modal_component.rb +++ b/app/components/projects/export_list_modal_component.rb @@ -29,7 +29,7 @@ # ++ class Projects::ExportListModalComponent < ApplicationComponent # rubocop:disable OpenProject/AddPreviewForViewComponent - MODAL_ID = 'op-project-list-export-dialog' + MODAL_ID = "op-project-list-export-dialog" options :query end diff --git a/app/components/projects/row_component.rb b/app/components/projects/row_component.rb index e6fb6f526ce2..62e6d88d4890 100644 --- a/app/components/projects/row_component.rb +++ b/app/components/projects/row_component.rb @@ -39,7 +39,7 @@ def level # Hierarchy cell is just a placeholder def hierarchy - '' + "" end def column_value(column) @@ -56,10 +56,10 @@ def custom_field_column(column) cf = column.custom_field custom_value = project.formatted_custom_value_for(cf) - if cf.field_format == 'text' && custom_value.present? + if cf.field_format == "text" && custom_value.present? render OpenProject::Common::AttributeComponent.new("dialog-#{project.id}-cf-#{cf.id}", cf.name, custom_value.html_safe) # rubocop:disable Rails/OutputSafety elsif custom_value.is_a?(Array) - safe_join(Array(custom_value).compact_blank, ', ') + safe_join(Array(custom_value).compact_blank, ", ") else custom_value end @@ -74,20 +74,20 @@ def latest_activity_at end def required_disk_space - return '' unless project.required_disk_space.to_i > 0 + return "" unless project.required_disk_space.to_i > 0 number_to_human_size(project.required_disk_space, precision: 2) end def name - content = content_tag(:i, '', class: "projects-table--hierarchy-icon") + content = content_tag(:i, "", class: "projects-table--hierarchy-icon") if project.archived? - content << ' ' - content << content_tag(:span, I18n.t('project.archive.archived'), class: 'archived-label') + content << " " + content << content_tag(:span, I18n.t("project.archive.archived"), class: "archived-label") end - content << ' ' + content << " " content << helpers.link_to_project(project, {}, {}, false) content end @@ -95,13 +95,13 @@ def name def project_status return nil unless user_can_view_project? - content = ''.html_safe + content = "".html_safe status_code = project.status_code if status_code classes = helpers.project_status_css_class(status_code) - content << content_tag(:span, '', class: "project-status--bulb -inline #{classes}") + content << content_tag(:span, "", class: "project-status--bulb -inline #{classes}") content << content_tag(:span, helpers.project_status_name(status_code), class: "project-status--name #{classes}") end @@ -113,7 +113,7 @@ def status_explanation if project.status_explanation.present? && project.status_explanation render OpenProject::Common::AttributeComponent.new("dialog-#{project.id}-status-explanation", - I18n.t('activerecord.attributes.project.status_explanation'), + I18n.t("activerecord.attributes.project.status_explanation"), project.status_explanation) end end @@ -123,7 +123,7 @@ def description if project.description.present? render OpenProject::Common::AttributeComponent.new("dialog-#{project.id}-description", - I18n.t('activerecord.attributes.project.description'), + I18n.t("activerecord.attributes.project.description"), project.description) end end @@ -149,11 +149,11 @@ def row_css_level_classes end def project_css_classes - s = ' project '.html_safe + s = " project ".html_safe - s << ' root' if project.root? - s << ' child' if project.child? - s << (project.leaf? ? ' leaf' : ' parent') + s << " root" if project.root? + s << " child" if project.child? + s << (project.leaf? ? " leaf" : " parent") s end @@ -169,7 +169,7 @@ def additional_css_class(column) "project-long-text-container" elsif custom_field_column?(column) cf = column.custom_field - formattable = cf.field_format == 'text' ? ' project-long-text-container' : '' + formattable = cf.field_format == "text" ? " project-long-text-container" : "" "format-#{cf.field_format}#{formattable}" end end @@ -188,17 +188,17 @@ def more_menu_subproject_item if User.current.allowed_in_project?(:add_subprojects, project) [t(:label_subproject_new), new_project_path(parent_id: project.id), - { class: 'icon-context icon-add', + { class: "icon-context icon-add", title: t(:label_subproject_new) }] end end def more_menu_settings_item - if User.current.allowed_in_project?({ controller: '/projects/settings/general', action: 'show', project_id: project.id }, + if User.current.allowed_in_project?({ controller: "/projects/settings/general", action: "show", project_id: project.id }, project) [t(:label_project_settings), project_settings_general_path(project), - { class: 'icon-context icon-settings', + { class: "icon-context icon-settings", title: t(:label_project_settings) }] end end @@ -207,8 +207,8 @@ def more_menu_activity_item if User.current.allowed_in_project?(:view_project_activity, project) [ t(:label_project_activity), - project_activity_index_path(project, event_types: ['project_attributes']), - { class: 'icon-context icon-checkmark', + project_activity_index_path(project, event_types: ["project_attributes"]), + { class: "icon-context icon-checkmark", title: t(:label_project_activity) } ] end @@ -218,9 +218,9 @@ def more_menu_archive_item if User.current.allowed_in_project?(:archive_project, project) && project.active? [t(:button_archive), project_archive_path(project, status: params[:status]), - { data: { confirm: t('project.archive.are_you_sure', name: project.name) }, + { data: { confirm: t("project.archive.are_you_sure", name: project.name) }, method: :post, - class: 'icon-context icon-locked', + class: "icon-context icon-locked", title: t(:button_archive) }] end end @@ -230,7 +230,7 @@ def more_menu_unarchive_item [t(:button_unarchive), project_archive_path(project, status: params[:status]), { method: :delete, - class: 'icon-context icon-unlocked', + class: "icon-context icon-unlocked", title: t(:button_unarchive) }] end end @@ -239,7 +239,7 @@ def more_menu_copy_item if User.current.allowed_in_project?(:copy_projects, project) && !project.archived? [t(:button_copy), copy_project_path(project), - { class: 'icon-context icon-copy', + { class: "icon-context icon-copy", title: t(:button_copy) }] end end @@ -248,7 +248,7 @@ def more_menu_delete_item if User.current.admin [t(:button_delete), confirm_destroy_project_path(project), - { class: 'icon-context icon-delete', + { class: "icon-context icon-delete", title: t(:button_delete) }] end end diff --git a/app/components/projects/table_component.rb b/app/components/projects/table_component.rb index 2033139373d2..4183827f40f7 100644 --- a/app/components/projects/table_component.rb +++ b/app/components/projects/table_component.rb @@ -48,7 +48,7 @@ def initial_sort end def table_id - 'project-table' + "project-table" end ## @@ -80,13 +80,13 @@ def paginated? def deactivate_class_on_lft_sort if sorted_by_lft? - 'spot-link_inactive' + "spot-link_inactive" end end def href_only_when_not_sort_lft unless sorted_by_lft? - projects_path(sortBy: JSON::dump([['lft', 'asc']])) + projects_path(sortBy: JSON::dump([["lft", "asc"]])) end end @@ -96,9 +96,9 @@ def order_options(select) data: { controller: "params-from-query", - 'application-target': "dynamic", - 'params-from-query-allowed-value': '["query_id"]', - 'params-from-query-all-anchors-value': "true" + "application-target": "dynamic", + "params-from-query-allowed-value": '["query_id"]', + "params-from-query-all-anchors-value": "true" } } end diff --git a/app/components/row_component.rb b/app/components/row_component.rb index 640a26176676..7ed07b4e4af7 100644 --- a/app/components/row_component.rb +++ b/app/components/row_component.rb @@ -70,7 +70,7 @@ def row_css_class def checkmark(condition) if condition - helpers.op_icon 'icon icon-checkmark' + helpers.op_icon "icon icon-checkmark" end end end diff --git a/app/components/settings/time_zone_setting_component.rb b/app/components/settings/time_zone_setting_component.rb index 84b2f964c1b7..7cb43e8120de 100644 --- a/app/components/settings/time_zone_setting_component.rb +++ b/app/components/settings/time_zone_setting_component.rb @@ -79,7 +79,7 @@ def time_zone_entries private def time_zone_option(canonical_zone, zones) - zone_names = zones.map(&:name).join(', ') + zone_names = zones.map(&:name).join(", ") [ "(UTC#{ActiveSupport::TimeZone.seconds_to_utc_offset(canonical_zone.base_utc_offset)}) #{zone_names}", canonical_zone.identifier diff --git a/app/components/statuses/row_component.rb b/app/components/statuses/row_component.rb index 27c24d9b14b2..8c2f1d8d6b6c 100644 --- a/app/components/statuses/row_component.rb +++ b/app/components/statuses/row_component.rb @@ -59,8 +59,8 @@ def done_ratio end def sort - helpers.reorder_links 'status', - { action: 'update', id: status }, + helpers.reorder_links "status", + { action: "update", id: status }, method: :patch end @@ -72,7 +72,7 @@ def button_links def delete_link link_to( - helpers.op_icon('icon icon-delete'), + helpers.op_icon("icon icon-delete"), status_path(status), method: :delete, data: { confirm: I18n.t(:text_are_you_sure) }, diff --git a/app/components/statuses/table_component.rb b/app/components/statuses/table_component.rb index e7792d44ae5b..9bfbaab1d108 100644 --- a/app/components/statuses/table_component.rb +++ b/app/components/statuses/table_component.rb @@ -45,9 +45,9 @@ def columns def inline_create_link link_to new_status_path, aria: { label: t(:label_work_package_status_new) }, - class: 'wp-inline-create--add-link', + class: "wp-inline-create--add-link", title: t(:label_work_package_status_new) do - helpers.op_icon('icon icon-add') + helpers.op_icon("icon icon-add") end end diff --git a/app/components/table_component.rb b/app/components/table_component.rb index 26a88eaa6784..c1c85c05fcc4 100644 --- a/app/components/table_component.rb +++ b/app/components/table_component.rb @@ -174,7 +174,7 @@ def initial_sort end def initial_order - initial_sort_correlation.join(' ') + initial_sort_correlation.join(" ") end def paginated? diff --git a/app/components/user_filter_component.rb b/app/components/user_filter_component.rb index c70909092459..9cd43c565989 100644 --- a/app/components/user_filter_component.rb +++ b/app/components/user_filter_component.rb @@ -35,20 +35,20 @@ class << self # or the default status to be filtered by (all) # if no status is given. def status_param(params) - params[:status].presence || 'all' + params[:status].presence || "all" end def filter_status(query, status) - return unless status && status != 'all' + return unless status && status != "all" case status - when 'blocked' - query.where(:blocked, '=', :blocked) - when 'active' - query.where(:status, '=', status.to_sym) - query.where(:blocked, '!', :blocked) + when "blocked" + query.where(:blocked, "=", :blocked) + when "active" + query.where(:status, "=", status.to_sym) + query.where(:blocked, "!", :blocked) else - query.where(:status, '=', status.to_sym) + query.where(:status, "=", status.to_sym) end end diff --git a/app/components/users/auto_login_tokens/row_component.rb b/app/components/users/auto_login_tokens/row_component.rb index 784205909c99..640415c2af8f 100644 --- a/app/components/users/auto_login_tokens/row_component.rb +++ b/app/components/users/auto_login_tokens/row_component.rb @@ -45,22 +45,22 @@ def current? def is_current # rubocop:disable Naming/PredicateName if current? - helpers.op_icon 'icon-yes' + helpers.op_icon "icon-yes" end end def device - token_data[:platform] || I18n.t('users.sessions.unknown_os') + token_data[:platform] || I18n.t("users.sessions.unknown_os") end def browser - name = token_data[:browser] || 'unknown browser' + name = token_data[:browser] || "unknown browser" version = token_data[:browser_version] "#{name} #{version ? "(Version #{version})" : ''}" end def platform - token_data[:platform] || 'unknown platform' + token_data[:platform] || "unknown platform" end def expires_on @@ -76,9 +76,9 @@ def delete_link return if current? link_to( - helpers.op_icon('icon icon-delete'), - { controller: '/my/auto_login_tokens', action: 'destroy', id: token.id }, - class: 'button--link', + helpers.op_icon("icon icon-delete"), + { controller: "/my/auto_login_tokens", action: "destroy", id: token.id }, + class: "button--link", role: :button, method: :delete, data: { confirm: I18n.t(:text_are_you_sure), disable_with: I18n.t(:label_loading) }, diff --git a/app/components/users/auto_login_tokens/table_component.rb b/app/components/users/auto_login_tokens/table_component.rb index a73c1a959857..eda17cd9ea12 100644 --- a/app/components/users/auto_login_tokens/table_component.rb +++ b/app/components/users/auto_login_tokens/table_component.rb @@ -41,10 +41,10 @@ def sortable? def headers [ - [:is_current, { caption: I18n.t('users.sessions.current') }], - [:browser, { caption: I18n.t('users.sessions.browser') }], - [:device, { caption: I18n.t('users.sessions.device') }], - [:expires_on, { caption: I18n.t('attributes.expires_at') }] + [:is_current, { caption: I18n.t("users.sessions.current") }], + [:browser, { caption: I18n.t("users.sessions.browser") }], + [:device, { caption: I18n.t("users.sessions.device") }], + [:expires_on, { caption: I18n.t("attributes.expires_at") }] ] end end diff --git a/app/components/users/avatar_component.rb b/app/components/users/avatar_component.rb index a95a5f0c3683..df53c25f2394 100644 --- a/app/components/users/avatar_component.rb +++ b/app/components/users/avatar_component.rb @@ -32,7 +32,7 @@ class AvatarComponent < ApplicationComponent include AvatarHelper include OpPrimer::ComponentHelpers - def initialize(user:, show_name: true, link: true, size: 'default', classes: '', title: nil, name_classes: '') + def initialize(user:, show_name: true, link: true, size: "default", classes: "", title: nil, name_classes: "") super @user = user diff --git a/app/components/users/sessions/row_component.rb b/app/components/users/sessions/row_component.rb index 3410ffcda4c2..6888306c7a76 100644 --- a/app/components/users/sessions/row_component.rb +++ b/app/components/users/sessions/row_component.rb @@ -48,27 +48,27 @@ def current? def is_current # rubocop:disable Naming/PredicateName if current? - helpers.op_icon 'icon-yes' + helpers.op_icon "icon-yes" end end def device - session_data[:platform] || I18n.t('users.sessions.unknown_os') + session_data[:platform] || I18n.t("users.sessions.unknown_os") end def browser - name = session_data[:browser] || 'unknown browser' + name = session_data[:browser] || "unknown browser" version = session_data[:browser_version] "#{name} #{version ? "(Version #{version})" : ''}" end def platform - session_data[:platform] || 'unknown platform' + session_data[:platform] || "unknown platform" end def updated_at if current? - I18n.t('users.sessions.current') + I18n.t("users.sessions.current") else helpers.format_time session.updated_at end @@ -82,9 +82,9 @@ def delete_link return if current? link_to( - helpers.op_icon('icon icon-delete'), - { controller: '/my/sessions', action: 'destroy', id: session }, - class: 'button--link', + helpers.op_icon("icon icon-delete"), + { controller: "/my/sessions", action: "destroy", id: session }, + class: "button--link", role: :button, method: :delete, data: { confirm: I18n.t(:text_are_you_sure), disable_with: I18n.t(:label_loading) }, diff --git a/app/components/users/sessions/table_component.rb b/app/components/users/sessions/table_component.rb index 8cff7a6775c2..0abc12875df7 100644 --- a/app/components/users/sessions/table_component.rb +++ b/app/components/users/sessions/table_component.rb @@ -41,10 +41,10 @@ def initial_sort def headers [ - [:is_current, { caption: I18n.t('users.sessions.current') }], - [:browser, { caption: I18n.t('users.sessions.browser') }], - [:device, { caption: I18n.t('users.sessions.device') }], - [:updated_at, { caption: I18n.t('attributes.updated_at') }] + [:is_current, { caption: I18n.t("users.sessions.current") }], + [:browser, { caption: I18n.t("users.sessions.browser") }], + [:device, { caption: I18n.t("users.sessions.device") }], + [:updated_at, { caption: I18n.t("attributes.updated_at") }] ] end end diff --git a/app/components/users/table_component.rb b/app/components/users/table_component.rb index b7f2eea504b3..cd159c89dd0d 100644 --- a/app/components/users/table_component.rb +++ b/app/components/users/table_component.rb @@ -46,7 +46,7 @@ def headers def header_options(name) options = { caption: User.human_attribute_name(name) } - options[:default_order] = 'desc' if desc_by_default.include? name + options[:default_order] = "desc" if desc_by_default.include? name options end diff --git a/app/components/versions/row_component.rb b/app/components/versions/row_component.rb index 0bddbf1bc6cb..d1fb386ecca8 100644 --- a/app/components/versions/row_component.rb +++ b/app/components/versions/row_component.rb @@ -75,11 +75,11 @@ def sharing end def wiki_page - return '' if wiki_page_title.blank? || version.project.wiki.nil? + return "" if wiki_page_title.blank? || version.project.wiki.nil? helpers.link_to_if_authorized(wiki_page_title, - controller: '/wiki', - action: 'show', + controller: "/wiki", + action: "show", project_id: version.project, id: wiki_page_title) || h(wiki_page_title) end @@ -97,20 +97,20 @@ def wiki_page_title def edit_link return unless version.project == table.project - helpers.link_to_if_authorized '', - { controller: '/versions', action: 'edit', id: version }, - class: 'icon icon-edit', + helpers.link_to_if_authorized "", + { controller: "/versions", action: "edit", id: version }, + class: "icon icon-edit", title: t(:button_edit) end def delete_link return unless version.project == table.project - helpers.link_to_if_authorized '', - { controller: '/versions', action: 'destroy', id: version }, + helpers.link_to_if_authorized "", + { controller: "/versions", action: "destroy", id: version }, data: { confirm: t(:text_are_you_sure) }, method: :delete, - class: 'icon icon-delete', + class: "icon icon-delete", title: t(:button_delete) end diff --git a/app/components/versions/table_component.rb b/app/components/versions/table_component.rb index eebc3e41af4f..bede23fbfdcc 100644 --- a/app/components/versions/table_component.rb +++ b/app/components/versions/table_component.rb @@ -49,7 +49,7 @@ def header_options(name) end def wiki_page_header_options - ['wiki_page_title', { caption: WikiPage.model_name.human }] + ["wiki_page_title", { caption: WikiPage.model_name.human }] end end end diff --git a/app/components/work_packages/share/concerns/displayable_roles.rb b/app/components/work_packages/share/concerns/displayable_roles.rb index d02b55255c6d..ff0faa338347 100644 --- a/app/components/work_packages/share/concerns/displayable_roles.rb +++ b/app/components/work_packages/share/concerns/displayable_roles.rb @@ -34,15 +34,15 @@ module Concerns module DisplayableRoles def options [ - { label: I18n.t('work_package.sharing.permissions.edit'), + { label: I18n.t("work_package.sharing.permissions.edit"), value: Role::BUILTIN_WORK_PACKAGE_EDITOR, - description: I18n.t('work_package.sharing.permissions.edit_description') }, - { label: I18n.t('work_package.sharing.permissions.comment'), + description: I18n.t("work_package.sharing.permissions.edit_description") }, + { label: I18n.t("work_package.sharing.permissions.comment"), value: Role::BUILTIN_WORK_PACKAGE_COMMENTER, - description: I18n.t('work_package.sharing.permissions.comment_description') }, - { label: I18n.t('work_package.sharing.permissions.view'), + description: I18n.t("work_package.sharing.permissions.comment_description") }, + { label: I18n.t("work_package.sharing.permissions.view"), value: Role::BUILTIN_WORK_PACKAGE_VIEWER, - description: I18n.t('work_package.sharing.permissions.view_description') } + description: I18n.t("work_package.sharing.permissions.view_description") } ] end end diff --git a/app/components/work_packages/share/modal_body_component.rb b/app/components/work_packages/share/modal_body_component.rb index 2d80e91e9c10..e8a3c661d94a 100644 --- a/app/components/work_packages/share/modal_body_component.rb +++ b/app/components/work_packages/share/modal_body_component.rb @@ -55,39 +55,39 @@ def insert_target_modified? end def insert_target_modifier_id - 'op-share-wp-active-shares' + "op-share-wp-active-shares" end def blankslate_config @blankslate_config ||= {}.tap do |config| if params[:filters].blank? config[:icon] = :people - config[:heading_text] = I18n.t('work_package.sharing.text_empty_state_header') - config[:description_text] = I18n.t('work_package.sharing.text_empty_state_description') + config[:heading_text] = I18n.t("work_package.sharing.text_empty_state_header") + config[:description_text] = I18n.t("work_package.sharing.text_empty_state_description") else config[:icon] = :search - config[:heading_text] = I18n.t('work_package.sharing.text_empty_search_header') - config[:description_text] = I18n.t('work_package.sharing.text_empty_search_description') + config[:heading_text] = I18n.t("work_package.sharing.text_empty_search_header") + config[:description_text] = I18n.t("work_package.sharing.text_empty_search_description") end end end def type_filter_options [ - { label: I18n.t('work_package.sharing.filter.project_member'), - value: { principal_type: 'User', project_member: true } }, - { label: I18n.t('work_package.sharing.filter.not_project_member'), - value: { principal_type: 'User', project_member: false } }, - { label: I18n.t('work_package.sharing.filter.project_group'), - value: { principal_type: 'Group', project_member: true } }, - { label: I18n.t('work_package.sharing.filter.not_project_group'), - value: { principal_type: 'Group', project_member: false } } + { label: I18n.t("work_package.sharing.filter.project_member"), + value: { principal_type: "User", project_member: true } }, + { label: I18n.t("work_package.sharing.filter.not_project_member"), + value: { principal_type: "User", project_member: false } }, + { label: I18n.t("work_package.sharing.filter.project_group"), + value: { principal_type: "Group", project_member: true } }, + { label: I18n.t("work_package.sharing.filter.not_project_group"), + value: { principal_type: "Group", project_member: false } } ] end def type_filter_option_active?(_option) - principal_type_filter_value = current_filter_value(params[:filters], 'principal_type') - project_member_filter_value = current_filter_value(params[:filters], 'also_project_member') + principal_type_filter_value = current_filter_value(params[:filters], "principal_type") + project_member_filter_value = current_filter_value(params[:filters], "also_project_member") return false if principal_type_filter_value.nil? || project_member_filter_value.nil? @@ -100,7 +100,7 @@ def type_filter_option_active?(_option) end def role_filter_option_active?(_option) - role_filter_value = current_filter_value(params[:filters], 'role_id') + role_filter_value = current_filter_value(params[:filters], "role_id") return false if role_filter_value.nil? @@ -122,7 +122,7 @@ def filter_url(type_option: nil, role_option: nil) end def apply_role_filter(_option) - current_role_filter_value = current_filter_value(params[:filters], 'role_id') + current_role_filter_value = current_filter_value(params[:filters], "role_id") filter = [] if _option.nil? && current_role_filter_value.present? @@ -141,8 +141,8 @@ def role_filter_for(_option, builtin_role: true) end def apply_type_filter(_option) - current_type_filter_value = current_filter_value(params[:filters], 'principal_type') - current_member_filter_value = current_filter_value(params[:filters], 'also_project_member') + current_type_filter_value = current_filter_value(params[:filters], "principal_type") + current_member_filter_value = current_filter_value(params[:filters], "also_project_member") filter = [] if _option.nil? && current_type_filter_value.present? && current_member_filter_value.present? @@ -173,7 +173,7 @@ def current_filter_value(filters, filter_key) return nil if filters.nil? given_filters = JSON.parse(filters).find { |key| key.key?(filter_key) } - given_filters ? given_filters[filter_key]['values'].first : nil + given_filters ? given_filters[filter_key]["values"].first : nil end end end diff --git a/app/components/work_packages/share/permission_button_component.rb b/app/components/work_packages/share/permission_button_component.rb index e6e03482a364..9bfee0e573d2 100644 --- a/app/components/work_packages/share/permission_button_component.rb +++ b/app/components/work_packages/share/permission_button_component.rb @@ -54,7 +54,7 @@ def option_active?(option) end def wrapper_uniq_by - share.id || @system_arguments.dig(:data, :'test-selector') + share.id || @system_arguments.dig(:data, :"test-selector") end private @@ -77,8 +77,8 @@ def permission_name(value) def form_inputs(role_id) [].tap do |inputs| - inputs << { name: 'role_ids[]', value: role_id } - inputs << { name: 'filters', value: params[:filters] } if params[:filters] + inputs << { name: "role_ids[]", value: role_id } + inputs << { name: "filters", value: params[:filters] } if params[:filters] end end end diff --git a/app/components/work_packages/share/share_row_component.rb b/app/components/work_packages/share/share_row_component.rb index ef5dbb1fbf7f..16d82a331a09 100644 --- a/app/components/work_packages/share/share_row_component.rb +++ b/app/components/work_packages/share/share_row_component.rb @@ -60,9 +60,9 @@ def share_editable? def grid_css_classes if sharing_manageable? - 'op-share-wp-modal-body--user-row_manageable' + "op-share-wp-modal-body--user-row_manageable" else - 'op-share-wp-modal-body--user-row' + "op-share-wp-modal-body--user-row" end end diff --git a/app/contracts/attachments/validate_replacements.rb b/app/contracts/attachments/validate_replacements.rb index b283805712d0..7bbc91d763bf 100644 --- a/app/contracts/attachments/validate_replacements.rb +++ b/app/contracts/attachments/validate_replacements.rb @@ -26,7 +26,7 @@ # See COPYRIGHT and LICENSE files for more details. #++ -require 'model_contract' +require "model_contract" module Attachments module ValidateReplacements diff --git a/app/contracts/authentication/omniauth_auth_hash_contract.rb b/app/contracts/authentication/omniauth_auth_hash_contract.rb index 3e89231559a0..ba0b257f1761 100644 --- a/app/contracts/authentication/omniauth_auth_hash_contract.rb +++ b/app/contracts/authentication/omniauth_auth_hash_contract.rb @@ -49,9 +49,9 @@ def validate_auth_hash end def validate_auth_hash_not_expired - return unless auth_hash['timestamp'] + return unless auth_hash["timestamp"] - if auth_hash['timestamp'] < Time.now - 30.minutes + if auth_hash["timestamp"] < Time.now - 30.minutes errors.add(:base, I18n.t(:error_omniauth_registration_timed_out)) end end diff --git a/app/contracts/concerns/assignable_custom_field_values.rb b/app/contracts/concerns/assignable_custom_field_values.rb index 91d7339f9bab..133f1ecbf6f2 100644 --- a/app/contracts/concerns/assignable_custom_field_values.rb +++ b/app/contracts/concerns/assignable_custom_field_values.rb @@ -32,9 +32,9 @@ module AssignableCustomFieldValues included do def assignable_custom_field_values(custom_field) case custom_field.field_format - when 'list' + when "list" custom_field.possible_values - when 'version' + when "version" assignable_versions(only_open: !custom_field.allow_non_open_versions?) end end diff --git a/app/contracts/custom_actions/cu_contract.rb b/app/contracts/custom_actions/cu_contract.rb index 54e7025349d1..e2c2d65abcc4 100644 --- a/app/contracts/custom_actions/cu_contract.rb +++ b/app/contracts/custom_actions/cu_contract.rb @@ -26,7 +26,7 @@ # See COPYRIGHT and LICENSE files for more details. #++ -require 'model_contract' +require "model_contract" # Contract for create (c) and update (u) module CustomActions diff --git a/app/contracts/groups/create_contract.rb b/app/contracts/groups/create_contract.rb index 8c7d48ed5005..af3eb12b13ad 100644 --- a/app/contracts/groups/create_contract.rb +++ b/app/contracts/groups/create_contract.rb @@ -36,7 +36,7 @@ class CreateContract < BaseContract def type_is_group unless model.type == Group.name - errors.add(:type, 'Type and class mismatch') + errors.add(:type, "Type and class mismatch") end end end diff --git a/app/contracts/model_contract.rb b/app/contracts/model_contract.rb index 4c482f3cbdf1..07ba44ffd920 100644 --- a/app/contracts/model_contract.rb +++ b/app/contracts/model_contract.rb @@ -26,7 +26,7 @@ # See COPYRIGHT and LICENSE files for more details. #++ -require_relative 'base_contract' +require_relative "base_contract" ## # Model contract for AR records that diff --git a/app/contracts/placeholder_users/create_contract.rb b/app/contracts/placeholder_users/create_contract.rb index 7a02a7b15da7..308b7750fd99 100644 --- a/app/contracts/placeholder_users/create_contract.rb +++ b/app/contracts/placeholder_users/create_contract.rb @@ -39,7 +39,7 @@ class CreateContract < BaseContract def type_is_placeholder_user unless model.type == PlaceholderUser.name - errors.add(:type, 'Type and class mismatch') + errors.add(:type, "Type and class mismatch") end end end diff --git a/app/contracts/queries/copy_contract.rb b/app/contracts/queries/copy_contract.rb index b67a0c02dcd5..c184b13b43f2 100644 --- a/app/contracts/queries/copy_contract.rb +++ b/app/contracts/queries/copy_contract.rb @@ -26,7 +26,7 @@ # See COPYRIGHT and LICENSE files for more details. #++ -require 'queries/base_contract' +require "queries/base_contract" module Queries class CopyContract < BaseContract diff --git a/app/contracts/queries/global_create_contract.rb b/app/contracts/queries/global_create_contract.rb index 586679b96758..ba75246e447a 100644 --- a/app/contracts/queries/global_create_contract.rb +++ b/app/contracts/queries/global_create_contract.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'queries/create_contract' +require "queries/create_contract" module Queries class GlobalCreateContract < CreateContract diff --git a/app/contracts/queries/ical_sharing_contract.rb b/app/contracts/queries/ical_sharing_contract.rb index 64dcc1f8db58..58390a9d0c06 100644 --- a/app/contracts/queries/ical_sharing_contract.rb +++ b/app/contracts/queries/ical_sharing_contract.rb @@ -26,7 +26,7 @@ # See COPYRIGHT and LICENSE files for more details. #++ -require 'queries/base_contract' +require "queries/base_contract" module Queries class ICalSharingContract < BaseContract diff --git a/app/contracts/queries/update_contract.rb b/app/contracts/queries/update_contract.rb index a2479b775187..867c2559b925 100644 --- a/app/contracts/queries/update_contract.rb +++ b/app/contracts/queries/update_contract.rb @@ -26,7 +26,7 @@ # See COPYRIGHT and LICENSE files for more details. #++ -require 'queries/base_contract' +require "queries/base_contract" module Queries class UpdateContract < BaseContract diff --git a/app/contracts/queries/update_form_contract.rb b/app/contracts/queries/update_form_contract.rb index ff83d8dad989..8f2805706d78 100644 --- a/app/contracts/queries/update_form_contract.rb +++ b/app/contracts/queries/update_form_contract.rb @@ -26,7 +26,7 @@ # See COPYRIGHT and LICENSE files for more details. #++ -require 'queries/base_contract' +require "queries/base_contract" module Queries class UpdateFormContract < BaseContract diff --git a/app/contracts/relations/base_contract.rb b/app/contracts/relations/base_contract.rb index 981653ad605c..2a1ddc9d7056 100644 --- a/app/contracts/relations/base_contract.rb +++ b/app/contracts/relations/base_contract.rb @@ -57,7 +57,7 @@ def validate_to_exists def validate_nodes_relatable if (model.from_id_changed? || model.to_id_changed?) && WorkPackage.relatable(model.from, model.relation_type, ignored_relation: model).where(id: model.to_id).empty? - errors.add :base, I18n.t(:'activerecord.errors.messages.circular_dependency') + errors.add :base, I18n.t(:"activerecord.errors.messages.circular_dependency") end end diff --git a/app/contracts/relations/create_contract.rb b/app/contracts/relations/create_contract.rb index 6f6318ceef6d..fe139dfa70bb 100644 --- a/app/contracts/relations/create_contract.rb +++ b/app/contracts/relations/create_contract.rb @@ -26,7 +26,7 @@ # See COPYRIGHT and LICENSE files for more details. #++ -require 'relations/base_contract' +require "relations/base_contract" module Relations class CreateContract < BaseContract diff --git a/app/contracts/types/base_contract.rb b/app/contracts/types/base_contract.rb index 22202424a38b..59d349d82afa 100644 --- a/app/contracts/types/base_contract.rb +++ b/app/contracts/types/base_contract.rb @@ -26,7 +26,7 @@ # See COPYRIGHT and LICENSE files for more details. #++ -require 'model_contract' +require "model_contract" module Types class BaseContract < ::ModelContract @@ -93,7 +93,7 @@ def validate_attribute_group(group) if key.is_a?(String) && valid_attributes.exclude?(key) errors.add( :attribute_groups, - I18n.t('activerecord.errors.models.type.attributes.attribute_groups.attribute_unknown_name', + I18n.t("activerecord.errors.models.type.attributes.attribute_groups.attribute_unknown_name", attribute: key) ) end diff --git a/app/contracts/user_preferences/base_contract.rb b/app/contracts/user_preferences/base_contract.rb index c23970bf1e7f..4aa2a4be0757 100644 --- a/app/contracts/user_preferences/base_contract.rb +++ b/app/contracts/user_preferences/base_contract.rb @@ -81,7 +81,7 @@ def namesake_time_zone(time_zones) if time_zones.length == 1 time_zones.first else - time_zones.detect { |tz| tz.tzinfo.name.include?(tz.name.tr(' ', '_')) } + time_zones.detect { |tz| tz.tzinfo.name.include?(tz.name.tr(" ", "_")) } end end end @@ -109,7 +109,7 @@ def user_allowed_to_access end def full_hour_reminder_time - unless model.daily_reminders[:times].all? { |time| time.end_with?('00:00+00:00') } + unless model.daily_reminders[:times].all? { |time| time.end_with?("00:00+00:00") } errors.add :daily_reminders, :full_hour end end diff --git a/app/contracts/users/base_contract.rb b/app/contracts/users/base_contract.rb index a28ddcd0ec13..2dfb83fd0c6f 100644 --- a/app/contracts/users/base_contract.rb +++ b/app/contracts/users/base_contract.rb @@ -64,7 +64,7 @@ def self.model def reduce_writable_attributes(attributes) super.tap do |writable| - writable << 'password' if password_writable? + writable << "password" if password_writable? end end diff --git a/app/contracts/users/create_contract.rb b/app/contracts/users/create_contract.rb index 3055261bf060..2ef001e6446b 100644 --- a/app/contracts/users/create_contract.rb +++ b/app/contracts/users/create_contract.rb @@ -76,7 +76,7 @@ def user_allowed_to_add def type_is_user unless model.type == User.name - errors.add(:type, 'Type and class mismatch') + errors.add(:type, "Type and class mismatch") end end end diff --git a/app/contracts/work_packages/copy_project_contract.rb b/app/contracts/work_packages/copy_project_contract.rb index 178289a5517c..5aa7993f1fdb 100644 --- a/app/contracts/work_packages/copy_project_contract.rb +++ b/app/contracts/work_packages/copy_project_contract.rb @@ -26,7 +26,7 @@ # See COPYRIGHT and LICENSE files for more details. #++ -require 'work_packages/create_contract' +require "work_packages/create_contract" # Can be used to copy all of a project's work packages. As the # work packages can be old, some of the validations that would diff --git a/app/contracts/work_packages/create_contract.rb b/app/contracts/work_packages/create_contract.rb index 22bf6421b02d..e8086638b262 100644 --- a/app/contracts/work_packages/create_contract.rb +++ b/app/contracts/work_packages/create_contract.rb @@ -26,7 +26,7 @@ # See COPYRIGHT and LICENSE files for more details. #++ -require 'work_packages/base_contract' +require "work_packages/base_contract" module WorkPackages class CreateContract < BaseContract @@ -64,7 +64,7 @@ def user_allowed_to_manage_file_links def attributes_changed_by_user # lock version is initialized by AR itself - super - ['lock_version'] + super - ["lock_version"] end end end diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 9ff7cc1a4114..700a0c132ed2 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -42,7 +42,7 @@ class AccountController < ApplicationController before_action :check_auth_source_sso_failure, only: :auth_source_sso_failed before_action :check_internal_login_enabled, only: :internal_login - layout 'no_menu' + layout "no_menu" # Login request and validation def login @@ -58,7 +58,7 @@ def login end def internal_login - render 'account/login' + render "account/login" end # Log out current user and redirect to welcome page @@ -88,12 +88,12 @@ def lost_password if call.success? @token.destroy - redirect_to action: 'login' + redirect_to action: "login" return end end - render template: 'account/password_recovery' + render template: "account/password_recovery" elsif request.post? mail = params[:mail] user = User.find_by_mail(mail) if mail.present? @@ -120,7 +120,7 @@ def lost_password if token.save UserMailer.password_lost(token).deliver_later flash[:notice] = I18n.t(:notice_account_lost_email_sent) - redirect_to action: 'login', back_url: home_url + redirect_to action: "login", back_url: home_url nil end end @@ -235,7 +235,7 @@ def activate_user(user) if omniauth_direct_login? direct_login user elsif OpenProject::Configuration.disable_password_login? - flash[:notice] = I18n.t('account.omniauth_login') + flash[:notice] = I18n.t("account.omniauth_login") redirect_to signin_path else @@ -249,7 +249,7 @@ def activate_through_ldap(user) ldap_auth_source_id: user.ldap_auth_source_id } - flash[:notice] = I18n.t('account.auth_source_login', login: user.login).html_safe + flash[:notice] = I18n.t("account.auth_source_login", login: user.login).html_safe redirect_to signin_path(username: user.login) end @@ -283,7 +283,7 @@ def auth_source_sso_failed flash.now[:error] = I18n.t(:error_auth_source_sso_failed, value: failure[:login]) + ": " + String(flash.now[:error]) - render action: 'login', back_url: failure[:back_url] + render action: "login", back_url: failure[:back_url] end private @@ -470,11 +470,11 @@ def pending_omniauth_registration? def onthefly_creation_failed(user, auth_source_options = {}) @user = user session[:auth_source_registration] = auth_source_options unless auth_source_options.empty? - render action: 'register' + render action: "register" end def self_registration_disabled - flash[:error] = I18n.t('account.error_self_registration_disabled') + flash[:error] = I18n.t("account.error_self_registration_disabled") redirect_to signin_url end @@ -489,18 +489,18 @@ def account_inactive(user, flash_now: true) # Log an attempt to log in to an account in "registered" state and show a flash message. def account_not_activated(flash_now: true) - flash_error_message(log_reason: 'NOT ACTIVATED', flash_now:) do + flash_error_message(log_reason: "NOT ACTIVATED", flash_now:) do if Setting::SelfRegistration.by_email? - 'account.error_inactive_activation_by_mail' + "account.error_inactive_activation_by_mail" else - 'account.error_inactive_manual_activation' + "account.error_inactive_manual_activation" end end end def invited_account_not_activated(_user) - flash_error_message(log_reason: 'invited, NOT ACTIVATED', flash_now: false) do - 'account.error_inactive_activation_by_mail' + flash_error_message(log_reason: "invited, NOT ACTIVATED", flash_now: false) do + "account.error_inactive_activation_by_mail" end end diff --git a/app/controllers/activities_controller.rb b/app/controllers/activities_controller.rb index 89aec8fd9052..fee13edbd990 100644 --- a/app/controllers/activities_controller.rb +++ b/app/controllers/activities_controller.rb @@ -75,7 +75,7 @@ def set_activity end def verify_activities_module_activated - render_403 if @project && !@project.module_enabled?('activity') + render_403 if @project && !@project.module_enabled?("activity") end def determine_date_range @@ -101,7 +101,7 @@ def determine_subprojects elsif params[:with_subprojects].nil? session[:activity][:with_subprojects] else - params[:with_subprojects] == '1' + params[:with_subprojects] == "1" end end @@ -136,7 +136,7 @@ def activity_scope end def set_current_activity_page - @activity_page = @project ? "projects/#{@project.identifier}" : 'all' + @activity_page = @project ? "projects/#{@project.identifier}" : "all" end def set_session diff --git a/app/controllers/admin/attachments/quarantined_attachments_controller.rb b/app/controllers/admin/attachments/quarantined_attachments_controller.rb index a931d5576ad8..8856adcce0c9 100644 --- a/app/controllers/admin/attachments/quarantined_attachments_controller.rb +++ b/app/controllers/admin/attachments/quarantined_attachments_controller.rb @@ -29,7 +29,7 @@ module Admin module Attachments class QuarantinedAttachmentsController < ApplicationController - layout 'admin' + layout "admin" before_action :require_admin before_action :find_quarantined_attachments @@ -45,14 +45,14 @@ def destroy create_journal(container, User.system, - I18n.t('antivirus_scan.deleted_by_admin', filename: @attachment.filename)) + I18n.t("antivirus_scan.deleted_by_admin", filename: @attachment.filename)) flash[:notice] = t(:notice_successful_delete) redirect_to action: :index end def default_breadcrumb - t('antivirus_scan.quarantined_attachments.title') + t("antivirus_scan.quarantined_attachments.title") end def show_local_breadcrumb diff --git a/app/controllers/admin/settings/aggregation_settings_controller.rb b/app/controllers/admin/settings/aggregation_settings_controller.rb index a01f5b774a33..56ebfd5880c4 100644 --- a/app/controllers/admin/settings/aggregation_settings_controller.rb +++ b/app/controllers/admin/settings/aggregation_settings_controller.rb @@ -37,7 +37,7 @@ def show end def default_breadcrumb - t(:'menus.admin.aggregation') + t(:"menus.admin.aggregation") end def show_local_breadcrumb diff --git a/app/controllers/admin/settings/attachments_settings_controller.rb b/app/controllers/admin/settings/attachments_settings_controller.rb index 929520884250..5b2440de78b3 100644 --- a/app/controllers/admin/settings/attachments_settings_controller.rb +++ b/app/controllers/admin/settings/attachments_settings_controller.rb @@ -31,7 +31,7 @@ class AttachmentsSettingsController < ::Admin::SettingsController menu_item :attachments_settings def default_breadcrumb - t(:'attributes.attachments') + t(:"attributes.attachments") end def settings_params diff --git a/app/controllers/admin/settings/date_format_settings_controller.rb b/app/controllers/admin/settings/date_format_settings_controller.rb index 27f21858d511..9c14335914fe 100644 --- a/app/controllers/admin/settings/date_format_settings_controller.rb +++ b/app/controllers/admin/settings/date_format_settings_controller.rb @@ -48,7 +48,7 @@ def validate_start_of_week_and_first_week_of_year_combination if start_of_week.present? ^ start_of_year.present? flash[:error] = I18n.t( - 'settings.date_format.first_date_of_week_and_year_set', + "settings.date_format.first_date_of_week_and_year_set", first_week_setting_name: I18n.t(:setting_first_week_of_year), day_of_week_setting_name: I18n.t(:setting_start_of_week) ) diff --git a/app/controllers/admin/settings/mail_notifications_settings_controller.rb b/app/controllers/admin/settings/mail_notifications_settings_controller.rb index 2029d00a2a22..8af36f26c00f 100644 --- a/app/controllers/admin/settings/mail_notifications_settings_controller.rb +++ b/app/controllers/admin/settings/mail_notifications_settings_controller.rb @@ -39,7 +39,7 @@ def show end def default_breadcrumb - t(:'menus.admin.mail_notification') + t(:"menus.admin.mail_notification") end def show_local_breadcrumb diff --git a/app/controllers/admin/settings/users_settings_controller.rb b/app/controllers/admin/settings/users_settings_controller.rb index e41ae5479f27..8fb79712df0a 100644 --- a/app/controllers/admin/settings/users_settings_controller.rb +++ b/app/controllers/admin/settings/users_settings_controller.rb @@ -47,7 +47,7 @@ def show_local_breadcrumb def settings_params super.tap do |settings| - if settings["consent_required"] == '1' && params['toggle_consent_time'] == '1' + if settings["consent_required"] == "1" && params["toggle_consent_time"] == "1" settings["consent_time"] = Time.zone.now.iso8601 end end diff --git a/app/controllers/admin/settings/virus_scanning_settings_controller.rb b/app/controllers/admin/settings/virus_scanning_settings_controller.rb index a15aff0fbc87..842990f4a726 100644 --- a/app/controllers/admin/settings/virus_scanning_settings_controller.rb +++ b/app/controllers/admin/settings/virus_scanning_settings_controller.rb @@ -34,7 +34,7 @@ class VirusScanningSettingsController < ::Admin::SettingsController before_action :check_clamav, only: %i[update], if: -> { scan_enabled? } def default_breadcrumb - t('settings.antivirus.title') + t("settings.antivirus.title") end def av_form @@ -52,7 +52,7 @@ def av_form private def require_ee - render('upsale') unless EnterpriseToken.allows_to?(:virus_scanning) + render("upsale") unless EnterpriseToken.allows_to?(:virus_scanning) end def mark_unscanned_attachments @@ -60,7 +60,7 @@ def mark_unscanned_attachments end def check_clamav - return if params.dig(:settings, :antivirus_scan_mode) == 'disabled' + return if params.dig(:settings, :antivirus_scan_mode) == "disabled" service = ::Attachments::ClamAVService.new(params[:settings][:antivirus_scan_mode].to_sym, params[:settings][:antivirus_scan_target]) @@ -68,12 +68,12 @@ def check_clamav service.ping rescue StandardError => e Rails.logger.error { "Failed to check availability of ClamAV: #{e.message}" } - flash[:error] = t(:'settings.antivirus.clamav_ping_failed') + flash[:error] = t(:"settings.antivirus.clamav_ping_failed") redirect_to action: :show end def scan_enabled? - Setting.antivirus_scan_mode != :disabled || params.dig(:settings, :antivirus_scan_mode) != 'disabled' + Setting.antivirus_scan_mode != :disabled || params.dig(:settings, :antivirus_scan_mode) != "disabled" end def success_callback(_call) @@ -87,7 +87,7 @@ def success_callback(_call) end def rescan_files - flash[:notice] = t('settings.antivirus.remaining_rescanned_files', + flash[:notice] = t("settings.antivirus.remaining_rescanned_files", file_count: t(:label_x_files, count: Attachment.status_uploaded.count)) Attachment.status_uploaded.update_all(status: :rescan) @@ -96,8 +96,8 @@ def rescan_files end def remaining_quarantine_warning - flash[:info] = t('settings.antivirus.remaining_quarantined_files_html', - link: helpers.link_to(t('antivirus_scan.quarantined_attachments.title'), + flash[:info] = t("settings.antivirus.remaining_quarantined_files_html", + link: helpers.link_to(t("antivirus_scan.quarantined_attachments.title"), admin_quarantined_attachments_path), file_count: t(:label_x_files, count: Attachment.status_quarantined.count)) redirect_to action: :show diff --git a/app/controllers/admin/settings/working_days_settings_controller.rb b/app/controllers/admin/settings/working_days_settings_controller.rb index f0c7bdfa89fb..fa0d390f7e49 100644 --- a/app/controllers/admin/settings/working_days_settings_controller.rb +++ b/app/controllers/admin/settings/working_days_settings_controller.rb @@ -37,7 +37,7 @@ def default_breadcrumb def failure_callback(call) @modified_non_working_days = modified_non_working_days_for(call.result) flash[:error] = call.message || I18n.t(:notice_internal_server_error) - render action: 'show' + render action: "show" end protected diff --git a/app/controllers/admin/settings_controller.rb b/app/controllers/admin/settings_controller.rb index 72d222b08e68..8d9823ced5a1 100644 --- a/app/controllers/admin/settings_controller.rb +++ b/app/controllers/admin/settings_controller.rb @@ -28,7 +28,7 @@ module Admin class SettingsController < ApplicationController - layout 'admin' + layout "admin" before_action :require_admin before_action :find_plugin, only: %i[show_plugin update_plugin] @@ -99,12 +99,12 @@ def update_service def success_callback(_call) flash[:notice] = t(:notice_successful_update) - redirect_to action: 'show', tab: params[:tab] + redirect_to action: "show", tab: params[:tab] end def failure_callback(call) flash[:error] = call.message || I18n.t(:notice_internal_server_error) - redirect_to action: 'show', tab: params[:tab] + redirect_to action: "show", tab: params[:tab] end end end diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index d670f34df98c..88eb45a947e4 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -25,10 +25,10 @@ # # See COPYRIGHT and LICENSE files for more details. #++ -require 'open3' +require "open3" class AdminController < ApplicationController - layout 'admin' + layout "admin" before_action :require_admin, except: %i[index] before_action :authorize_global, only: %i[index] @@ -53,7 +53,7 @@ def index end def projects - redirect_to controller: 'projects', action: 'index' + redirect_to controller: "projects", action: "index" end def plugins @@ -91,9 +91,9 @@ def info def default_breadcrumb case params[:action] - when 'plugins' + when "plugins" t(:label_plugins) - when 'info' + when "info" t(:label_information) end end @@ -111,12 +111,12 @@ def hidden_admin_menu_items def plaintext_extraction_checks if OpenProject::Database.allows_tsv? [ - [:'extraction.available.pdftotext', Plaintext::PdfHandler.available?], - [:'extraction.available.unrtf', Plaintext::RtfHandler.available?], - [:'extraction.available.catdoc', Plaintext::DocHandler.available?], - [:'extraction.available.xls2csv', Plaintext::XlsHandler.available?], - [:'extraction.available.catppt', Plaintext::PptHandler.available?], - [:'extraction.available.tesseract', Plaintext::ImageHandler.available?] + [:"extraction.available.pdftotext", Plaintext::PdfHandler.available?], + [:"extraction.available.unrtf", Plaintext::RtfHandler.available?], + [:"extraction.available.catdoc", Plaintext::DocHandler.available?], + [:"extraction.available.xls2csv", Plaintext::XlsHandler.available?], + [:"extraction.available.catppt", Plaintext::PptHandler.available?], + [:"extraction.available.tesseract", Plaintext::ImageHandler.available?] ] else [] @@ -124,11 +124,11 @@ def plaintext_extraction_checks end def image_conversion_checks - [[:'image_conversion.imagemagick', image_conversion_libs_available?]] + [[:"image_conversion.imagemagick", image_conversion_libs_available?]] end def image_conversion_libs_available? - Open3.capture2e('convert', '-version').first.include?('ImageMagick') + Open3.capture2e("convert", "-version").first.include?("ImageMagick") rescue StandardError false end diff --git a/app/controllers/angular_controller.rb b/app/controllers/angular_controller.rb index c92abcda3769..d44fd99127a7 100644 --- a/app/controllers/angular_controller.rb +++ b/app/controllers/angular_controller.rb @@ -32,13 +32,13 @@ class AngularController < ApplicationController def empty_layout # Frontend will handle rendering # but we will need to render with layout - render html: '', layout: 'angular/angular' + render html: "", layout: "angular/angular" end def notifications_layout # Frontend will handle rendering # but we will need to render with notification specific layout - render html: '', layout: 'angular/notifications' + render html: "", layout: "angular/notifications" end def login_back_url_params diff --git a/app/controllers/announcements_controller.rb b/app/controllers/announcements_controller.rb index ec637699c1ea..59591fb70d56 100644 --- a/app/controllers/announcements_controller.rb +++ b/app/controllers/announcements_controller.rb @@ -1,5 +1,5 @@ class AnnouncementsController < ApplicationController - layout 'admin' + layout "admin" before_action :require_admin @@ -15,7 +15,7 @@ def update flash[:notice] = t(:notice_successful_update) end - redirect_to action: 'edit' + redirect_to action: "edit" end private @@ -29,6 +29,6 @@ def show_local_breadcrumb end def announcement_params - params.require(:announcement).permit('text', 'show_until', 'active') + params.require(:announcement).permit("text", "show_until", "active") end end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 564973057f70..4375d2aa21dc 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -26,10 +26,10 @@ # See COPYRIGHT and LICENSE files for more details. #++ -require 'uri' -require 'cgi' +require "uri" +require "cgi" -require 'doorkeeper/dashboard_helper' +require "doorkeeper/dashboard_helper" class ApplicationController < ActionController::Base class_attribute :_model_object @@ -51,7 +51,7 @@ class ApplicationController < ActionController::Base include AdditionalUrlHelpers include OpenProjectErrorHelper - layout 'base' + layout "base" protect_from_forgery # CSRF protection prevents two things. It prevents an attacker from using a @@ -74,7 +74,7 @@ class ApplicationController < ActionController::Base # Thus, we show an error message unless the request probably is an API # request. def handle_unverified_request - cookies.delete(OpenProject::Configuration['autologin_cookie_name']) + cookies.delete(OpenProject::Configuration["autologin_cookie_name"]) self.logged_user = nil # Don't render an error message for requests that appear to be API requests. @@ -105,7 +105,7 @@ def handle_unverified_request # Check whether user have cookies enabled, otherwise they'll only be # greeted with the CSRF error upon login. message = I18n.t(:error_token_authenticity) - message << (' ' + I18n.t(:error_cookie_missing)) if openproject_cookie_missing? + message << (" " + I18n.t(:error_cookie_missing)) if openproject_cookie_missing? log_csrf_failure @@ -148,7 +148,7 @@ def handle_unverified_request def default_url_options(_options = {}) { - layout: params['layout'], + layout: params["layout"], protocol: Setting.protocol } end @@ -159,7 +159,7 @@ def default_url_options(_options = {}) # https://websecuritytool.codeplex.com/wikipage?title=Checks#http-cache-control-header-no-store # http://stackoverflow.com/questions/711418/how-to-prevent-browser-page-caching-in-rails def set_cache_buster - if OpenProject::Configuration['disable_browser_cache'] + if OpenProject::Configuration["disable_browser_cache"] response.cache_control.merge!( max_age: 0, public: false, @@ -179,7 +179,7 @@ def reload_mailer_settings! # Checks if the session cookie is missing. # This is useful only on a second request def openproject_cookie_missing? - request.cookies[OpenProject::Configuration['session_cookie_name']].nil? + request.cookies[OpenProject::Configuration["session_cookie_name"]].nil? end helper_method :openproject_cookie_missing? @@ -187,8 +187,8 @@ def openproject_cookie_missing? ## # Create CSRF issue def log_csrf_failure - message = 'CSRF validation error' - message << ' (No session cookie present)' if openproject_cookie_missing? + message = "CSRF validation error" + message << " (No session cookie present)" if openproject_cookie_missing? op_handle_error message, reference: :csrf_validation_failed end @@ -208,7 +208,7 @@ def log_requesting_user # replaces all invalid characters with # def escape_for_logging(string) # only allow numbers, ASCII letters, space and the following characters: @.-"'!?=/ - string.gsub(/[^0-9a-zA-Z@._\-"'!?=\/ ]{1}/, '#') + string.gsub(/[^0-9a-zA-Z@._\-"'!?=\/ ]{1}/, "#") end def reset_i18n_fallbacks @@ -228,7 +228,7 @@ def set_localization user = RequestStore[:current_user] || (session[:authenticated_user_id].present? && User.find_by(id: session[:authenticated_user_id])) || User.anonymous - SetLocalizationService.new(user, request.env['HTTP_ACCEPT_LANGUAGE']).call + SetLocalizationService.new(user, request.env["HTTP_ACCEPT_LANGUAGE"]).call end def deny_access(not_found: false) @@ -413,7 +413,7 @@ def find_object_and_scope associated = find_belongs_to_chained_objects(associations, model_object) associated.each do |a| - instance_variable_set('@' + a.class.to_s.downcase, a) + instance_variable_set("@" + a.class.to_s.downcase, a) end rescue ActiveRecord::RecordNotFound render_404 @@ -452,7 +452,7 @@ def self.model_object(model, options = {}) def find_work_packages @work_packages = WorkPackage.includes(:project) .where(id: params[:work_package_id] || params[:ids]) - .order('id ASC') + .order("id ASC") fail ActiveRecord::RecordNotFound if @work_packages.empty? @projects = @work_packages.filter_map(&:project).uniq @@ -479,7 +479,7 @@ def check_project_privacy end def back_url - params[:back_url] || request.env['HTTP_REFERER'] + params[:back_url] || request.env["HTTP_REFERER"] end def redirect_back_or_default(default, use_escaped = true) @@ -497,7 +497,7 @@ def redirect_back_or_default(default, use_escaped = true) # # @return [boolean, string] name of the layout to use or false for no layout def use_layout - request.xhr? ? false : 'no_menu' + request.xhr? ? false : "no_menu" end def render_feed(items, options = {}) @@ -505,7 +505,7 @@ def render_feed(items, options = {}) @items = @items.sort { |x, y| y.event_datetime <=> x.event_datetime } @items = @items.slice(0, Setting.feeds_limit.to_i) @title = options[:title] || Setting.app_title - render template: 'common/feed', layout: false, content_type: 'application/atom+xml' + render template: "common/feed", layout: false, content_type: "application/atom+xml" end def self.accept_key_auth(*actions) @@ -519,7 +519,7 @@ def accept_key_auth_actions # Returns a string that can be used as filename value in Content-Disposition header def filename_for_content_disposition(name) - %r{(MSIE|Trident)}.match?(request.env['HTTP_USER_AGENT']) ? ERB::Util.url_encode(name) : name + %r{(MSIE|Trident)}.match?(request.env["HTTP_USER_AGENT"]) ? ERB::Util.url_encode(name) : name end def api_request? @@ -534,8 +534,8 @@ def api_request? def api_key_from_request if params[:key].present? params[:key] - elsif request.headers['X-OpenProject-API-Key'].present? - request.headers['X-OpenProject-API-Key'] + elsif request.headers["X-OpenProject-API-Key"].present? + request.headers["X-OpenProject-API-Key"] end end @@ -550,10 +550,10 @@ def object_errors_to_json(object) def render_validation_errors(object) options = { status: :unprocessable_entity, layout: false } errors = case params[:format] - when 'xml' + when "xml" { xml: object.errors } - when 'json' - { json: { 'errors' => object.errors } } # ActiveResource client compliance + when "json" + { json: { "errors" => object.errors } } # ActiveResource client compliance else fail "Unknown format #{params[:format]} in #render_validation_errors" end @@ -566,7 +566,7 @@ def render_validation_errors(object) def default_template(action_name = self.action_name) if api_request? begin - return view_paths.find_template(default_template_name(action_name), 'api') + return view_paths.find_template(default_template_name(action_name), "api") rescue ::ActionView::MissingTemplate # the api template was not found # fallback to the default behaviour @@ -584,7 +584,7 @@ def pick_layout(*args) def default_breadcrumb label = "label_#{controller_name.singularize}" - I18n.t(label + '_plural', + I18n.t(label + "_plural", default: label.to_sym) end @@ -607,8 +607,8 @@ def check_session_lifetime if session_expired? self.logged_user = nil - flash[:warning] = I18n.t('notice_forced_logout', ttl_time: Setting.session_ttl) - redirect_to(controller: '/account', action: 'login', back_url: login_back_url) + flash[:warning] = I18n.t("notice_forced_logout", ttl_time: Setting.session_ttl) + redirect_to(controller: "/account", action: "login", back_url: login_back_url) end session[:updated_at] = Time.now end @@ -623,7 +623,7 @@ def feed_request? def stop_if_feeds_disabled if feed_request? && !Setting.feeds_enabled? - render_404(message: I18n.t('label_disabled')) + render_404(message: I18n.t("label_disabled")) end end @@ -649,7 +649,7 @@ def login_back_url else url_params = params.permit(:action, :id, :project_id, :controller) - unless url_params[:controller].to_s.starts_with?('/') + unless url_params[:controller].to_s.starts_with?("/") url_params[:controller] = "/#{url_params[:controller]}" end diff --git a/app/controllers/attribute_help_texts_controller.rb b/app/controllers/attribute_help_texts_controller.rb index f9a5b2bbdf0b..50e759264db9 100644 --- a/app/controllers/attribute_help_texts_controller.rb +++ b/app/controllers/attribute_help_texts_controller.rb @@ -27,7 +27,7 @@ #++ class AttributeHelpTextsController < ApplicationController - layout 'admin' + layout "admin" menu_item :attribute_help_texts before_action :authorize_global @@ -56,8 +56,8 @@ def create redirect_to attribute_help_texts_path(tab: call.result.attribute_scope) else @attribute_help_text = call.result - flash[:error] = call.message || I18n.t('notice_internal_server_error') - render action: 'new' + flash[:error] = call.message || I18n.t("notice_internal_server_error") + render action: "new" end end @@ -70,8 +70,8 @@ def update flash[:notice] = t(:notice_successful_update) redirect_to attribute_help_texts_path(tab: @attribute_help_text.attribute_scope) else - flash[:error] = call.message || I18n.t('notice_internal_server_error') - render action: 'edit' + flash[:error] = call.message || I18n.t("notice_internal_server_error") + render action: "edit" end end @@ -88,10 +88,10 @@ def destroy protected def default_breadcrumb - if action_name == 'index' - t('attribute_help_texts.label_plural') + if action_name == "index" + t("attribute_help_texts.label_plural") else - ActionController::Base.helpers.link_to(t('attribute_help_texts.label_plural'), attribute_help_texts_path) + ActionController::Base.helpers.link_to(t("attribute_help_texts.label_plural"), attribute_help_texts_path) end end @@ -122,7 +122,7 @@ def find_entry end def find_type_scope - name = params.fetch(:name, 'WorkPackage') + name = params.fetch(:name, "WorkPackage") submodule = AttributeHelpText.available_types.find { |mod| mod == name } if submodule.nil? diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb index 1c9755f07c5a..242abdc4b65a 100644 --- a/app/controllers/categories_controller.rb +++ b/app/controllers/categories_controller.rb @@ -70,7 +70,7 @@ def update flash[:notice] = I18n.t(:notice_successful_update) redirect_to project_settings_categories_path(@project) else - render action: 'edit' + render action: "edit" end end @@ -82,7 +82,7 @@ def destroy redirect_to project_settings_categories_path(@project) return elsif params[:todo] - reassign_to = @project.categories.find_by(id: params[:reassign_to_id]) if params[:todo] == 'reassign' + reassign_to = @project.categories.find_by(id: params[:reassign_to_id]) if params[:todo] == "reassign" @category.destroy(reassign_to) redirect_to project_settings_categories_path(@project) return diff --git a/app/controllers/colors_controller.rb b/app/controllers/colors_controller.rb index 5e671dc1ee5e..018c6cbfaac1 100644 --- a/app/controllers/colors_controller.rb +++ b/app/controllers/colors_controller.rb @@ -29,7 +29,7 @@ class ColorsController < ApplicationController before_action :require_admin_unless_readonly_api_request - layout 'admin' + layout "admin" menu_item :colors @@ -68,7 +68,7 @@ def create redirect_to colors_path else flash.now[:error] = I18n.t(:error_color_could_not_be_saved) - render action: 'new' + render action: "new" end end @@ -80,7 +80,7 @@ def update redirect_to colors_path else flash.now[:error] = I18n.t(:error_color_could_not_be_saved) - render action: 'edit' + render action: "edit" end end @@ -102,7 +102,7 @@ def destroy protected def default_breadcrumb - if action_name == 'index' + if action_name == "index" t(:label_color_plural) else ActionController::Base.helpers.link_to(t(:label_color_plural), colors_path) diff --git a/app/controllers/concerns/accounts/authentication_stages.rb b/app/controllers/concerns/accounts/authentication_stages.rb index c2524f58e16d..1d2dbb19b743 100644 --- a/app/controllers/concerns/accounts/authentication_stages.rb +++ b/app/controllers/concerns/accounts/authentication_stages.rb @@ -65,7 +65,7 @@ def stage_success else flash[:error] = I18n.t( :notice_auth_stage_wrong_stage, - expected: stage || '(none)', + expected: stage || "(none)", actual: params[:stage] ) @@ -119,7 +119,7 @@ def init_authentication_stages(after_activation:) session[:back_url] ||= params[:back_url] # Remember the autologin cookie decision - session[:autologin_requested] = params[:autologin] == '1' + session[:autologin_requested] = params[:autologin] == "1" stages end diff --git a/app/controllers/concerns/accounts/omniauth_login.rb b/app/controllers/concerns/accounts/omniauth_login.rb index 3e882cc5d017..efb866c89664 100644 --- a/app/controllers/concerns/accounts/omniauth_login.rb +++ b/app/controllers/concerns/accounts/omniauth_login.rb @@ -26,7 +26,7 @@ # See COPYRIGHT and LICENSE files for more details. #++ -require 'uri' +require "uri" ## # Intended to be used by the AccountController to handle omniauth logins @@ -47,10 +47,10 @@ module Accounts::OmniauthLogin end def omniauth_login - params[:back_url] = request.env['omniauth.origin'] if remember_back_url? + params[:back_url] = request.env["omniauth.origin"] if remember_back_url? # Extract auth info and perform check / login or activate user - auth_hash = request.env['omniauth.auth'] + auth_hash = request.env["omniauth.auth"] handle_omniauth_authentication(auth_hash) end @@ -75,7 +75,7 @@ def redirect_omniauth_register_modal(user, auth_hash) # Avoid remembering the back_url if we're coming from the login page def remember_back_url? - provided_back_url = request.env['omniauth.origin'] + provided_back_url = request.env["omniauth.origin"] return if provided_back_url.blank? account_routes = /\/(login|account)/ @@ -84,7 +84,7 @@ def remember_back_url? def show_error(error) flash[:error] = error - redirect_to action: 'login' + redirect_to action: "login" end def register_via_omniauth(session, user_attributes) @@ -93,7 +93,7 @@ def register_via_omniauth(session, user_attributes) def handle_omniauth_authentication(auth_hash, user_params: nil) call = ::Authentication::OmniauthService - .new(strategy: request.env['omniauth.strategy'], auth_hash:, controller: self) + .new(strategy: request.env["omniauth.strategy"], auth_hash:, controller: self) .call(user_params) if call.success? diff --git a/app/controllers/concerns/accounts/user_consent.rb b/app/controllers/concerns/accounts/user_consent.rb index a2603dfae3ef..e3beee7a7de0 100644 --- a/app/controllers/concerns/accounts/user_consent.rb +++ b/app/controllers/concerns/accounts/user_consent.rb @@ -34,7 +34,7 @@ module Accounts::UserConsent def consent if user_consent_required? && consenting_user&.consent_expired? - render 'account/consent' + render "account/consent" else consent_finished end @@ -51,12 +51,12 @@ def confirm_consent end def decline_consent - message = I18n.t('consent.decline_warning_message') + "\n" + message = I18n.t("consent.decline_warning_message") + "\n" message << if Setting.consent_decline_mail.present? - I18n.t('consent.contact_this_mail_address', mail_address: Setting.consent_decline_mail) + I18n.t("consent.contact_this_mail_address", mail_address: Setting.consent_decline_mail) else - I18n.t('consent.contact_your_administrator') + I18n.t("consent.contact_your_administrator") end flash[:error] = message @@ -77,7 +77,7 @@ def consent_finished end def reject_consent! - flash[:error] = I18n.t('consent.failure_message') + flash[:error] = I18n.t("consent.failure_message") redirect_to authentication_stage_failure_path :consent end end diff --git a/app/controllers/concerns/accounts/user_password_change.rb b/app/controllers/concerns/accounts/user_password_change.rb index 00ccee1b98bf..1ce7f02cbd4e 100644 --- a/app/controllers/concerns/accounts/user_password_change.rb +++ b/app/controllers/concerns/accounts/user_password_change.rb @@ -70,7 +70,7 @@ def flash_and_log_invalid_credentials(flash_now: true, is_logged_in: false) return end - flash_error_message(log_reason: 'invalid credentials', flash_now:) do + flash_error_message(log_reason: "invalid credentials", flash_now:) do if Setting.brute_force_block_after_failed_logins.to_i > 0 :notice_account_invalid_credentials_or_blocked else @@ -83,7 +83,7 @@ def render_password_change(user, message, show_user_name: false) flash[:error] = message unless message.nil? @user = user @username = user.login - render 'my/password', locals: { show_user_name: } + render "my/password", locals: { show_user_name: } end ## @@ -91,15 +91,15 @@ def render_password_change(user, message, show_user_name: false) def redirect_if_password_change_not_allowed(user) if user and not user.change_password_allowed? logger.warn "Password change for user '#{user}' forced, but user is not allowed " + - 'to change password' + "to change password" flash[:error] = I18n.t(:notice_can_t_change_password) - redirect_to action: 'login' + redirect_to action: "login" return true end false end - def flash_error_message(log_reason: '', flash_now: true) + def flash_error_message(log_reason: "", flash_now: true) flash_hash = flash_now ? flash.now : flash logger.warn "Failed login for '#{params[:username]}' from #{request.remote_ip} " \ diff --git a/app/controllers/concerns/auth_source_sso.rb b/app/controllers/concerns/auth_source_sso.rb index dbfaef94258e..3147ffa84455 100644 --- a/app/controllers/concerns/auth_source_sso.rb +++ b/app/controllers/concerns/auth_source_sso.rb @@ -103,7 +103,7 @@ def get_validated_login!(value) def extract_from_header(value) if header_secret.present? valid_secret = value.end_with?(":#{header_secret}") - login = value.gsub(/:#{Regexp.escape(header_secret)}\z/, '') + login = value.gsub(/:#{Regexp.escape(header_secret)}\z/, "") [login, valid_secret] else diff --git a/app/controllers/concerns/layout.rb b/app/controllers/concerns/layout.rb index c1efaadd2374..47b8057307ca 100644 --- a/app/controllers/concerns/layout.rb +++ b/app/controllers/concerns/layout.rb @@ -36,7 +36,7 @@ def layout_non_or_no_menu elsif @project true else - 'no_menu' + "no_menu" end end diff --git a/app/controllers/concerns/member_helper.rb b/app/controllers/concerns/member_helper.rb index 93f15002b4e7..701b5b237721 100644 --- a/app/controllers/concerns/member_helper.rb +++ b/app/controllers/concerns/member_helper.rb @@ -88,7 +88,7 @@ def transform_array_of_comma_separated_ids(array) return array if array.blank? each_comma_separated(array) do |elem| - elem.to_s.split(',') + elem.to_s.split(",") end end diff --git a/app/controllers/concerns/user_invitation.rb b/app/controllers/concerns/user_invitation.rb index f95192f48ff5..9d33dfaacdf6 100644 --- a/app/controllers/concerns/user_invitation.rb +++ b/app/controllers/concerns/user_invitation.rb @@ -30,11 +30,11 @@ module UserInvitation module Events class << self def user_invited - 'user_invited' + "user_invited" end def user_reinvited - 'user_reinvited' + "user_reinvited" end end end diff --git a/app/controllers/custom_actions_controller.rb b/app/controllers/custom_actions_controller.rb index 50a017ce0247..a676ef0410f9 100644 --- a/app/controllers/custom_actions_controller.rb +++ b/app/controllers/custom_actions_controller.rb @@ -35,7 +35,7 @@ class CustomActionsController < ApplicationController before_action :find_model_object, only: %i(edit update destroy) before_action :pad_params, only: %i(create update) - layout 'admin' + layout "admin" def index @custom_actions = CustomAction.order_by_position @@ -86,12 +86,12 @@ def require_enterprise_token return if EnterpriseToken.allows_to?(:custom_actions) if request.get? - render template: 'common/upsale', + render template: "common/upsale", locals: { - feature_title: I18n.t('custom_actions.upsale.title'), - feature_description: I18n.t('custom_actions.upsale.description'), - feature_reference: 'custom_actions_admin', - feature_video: 'enterprise/custom-actions.mp4' + feature_title: I18n.t("custom_actions.upsale.title"), + feature_description: I18n.t("custom_actions.upsale.description"), + feature_reference: "custom_actions_admin", + feature_video: "enterprise/custom-actions.mp4" } else render_403 @@ -110,10 +110,10 @@ def pad_params end def default_breadcrumb - if action_name == 'index' - t('custom_actions.plural') + if action_name == "index" + t("custom_actions.plural") else - ActionController::Base.helpers.link_to(t('custom_actions.plural'), custom_actions_path) + ActionController::Base.helpers.link_to(t("custom_actions.plural"), custom_actions_path) end end diff --git a/app/controllers/custom_styles_controller.rb b/app/controllers/custom_styles_controller.rb index 236933b16a4d..692a06ec23f1 100644 --- a/app/controllers/custom_styles_controller.rb +++ b/app/controllers/custom_styles_controller.rb @@ -27,7 +27,7 @@ #++ class CustomStylesController < ApplicationController - layout 'admin' + layout "admin" menu_item :custom_style before_action :require_admin, @@ -154,7 +154,7 @@ def show_local_breadcrumb def options_for_theme_select options = OpenProject::CustomStyles::ColorThemes.themes.pluck(:theme) unless @current_theme.present? - options << [t('admin.custom_styles.color_theme_custom'), '', + options << [t("admin.custom_styles.color_theme_custom"), "", { selected: true, disabled: true }] end diff --git a/app/controllers/enterprises_controller.rb b/app/controllers/enterprises_controller.rb index ef36a889c0c6..836b5896ba49 100644 --- a/app/controllers/enterprises_controller.rb +++ b/app/controllers/enterprises_controller.rb @@ -28,7 +28,7 @@ class EnterprisesController < ApplicationController include EnterpriseTrialHelper - layout 'admin' + layout "admin" menu_item :enterprise before_action :chargebee_content_security_policy diff --git a/app/controllers/enumerations_controller.rb b/app/controllers/enumerations_controller.rb index 6dee9f4253fe..8cc2a55280e0 100644 --- a/app/controllers/enumerations_controller.rb +++ b/app/controllers/enumerations_controller.rb @@ -27,7 +27,7 @@ #++ class EnumerationsController < ApplicationController - layout 'admin' + layout "admin" before_action :require_admin before_action :find_enumeration, only: %i[edit update move destroy] @@ -56,9 +56,9 @@ def create if @enumeration.save flash[:notice] = I18n.t(:notice_successful_create) - redirect_to action: 'index', type: @enumeration.type + redirect_to action: "index", type: @enumeration.type else - render action: 'new' + render action: "new" end end @@ -70,7 +70,7 @@ def update flash[:notice] = I18n.t(:notice_successful_update) redirect_to enumerations_path(type: @enumeration.type) else - render action: 'edit' + render action: "edit" end end @@ -78,12 +78,12 @@ def destroy if !@enumeration.in_use? # No associated objects @enumeration.destroy - redirect_to action: 'index' + redirect_to action: "index" return elsif params[:reassign_to_id] if reassign_to = @enumeration.class.find_by(id: params[:reassign_to_id]) @enumeration.destroy(reassign_to) - redirect_to action: 'index' + redirect_to action: "index" return end end @@ -96,14 +96,14 @@ def move redirect_to enumerations_path else flash.now[:error] = I18n.t(:error_type_could_not_be_saved) - render action: 'edit' + render action: "edit" end end protected def default_breadcrumb - if action_name == 'index' + if action_name == "index" t(:label_enumerations) else ActionController::Base.helpers.link_to(t(:label_enumerations), enumerations_path) diff --git a/app/controllers/errors_controller.rb b/app/controllers/errors_controller.rb index d67db8c46e18..aa7d59807d0e 100644 --- a/app/controllers/errors_controller.rb +++ b/app/controllers/errors_controller.rb @@ -26,6 +26,6 @@ def error_options end def use_layout - 'only_logo' + "only_logo" end end diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index b7795a503b42..f28372d7d7fb 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -47,26 +47,26 @@ def index end def show - sort_init 'updated_at', 'desc' - sort_update 'created_at' => "#{Message.table_name}.created_at", - 'replies' => "#{Message.table_name}.replies_count", - 'updated_at' => "#{Message.table_name}.updated_at" + sort_init "updated_at", "desc" + sort_update "created_at" => "#{Message.table_name}.created_at", + "replies" => "#{Message.table_name}.replies_count", + "updated_at" => "#{Message.table_name}.updated_at" respond_to do |format| format.html do set_topics @message = Message.new - render action: 'show', layout: !request.xhr? + render action: "show", layout: !request.xhr? end format.json do set_topics - render template: 'messages/index' + render template: "messages/index" end format.atom do @messages = @forum .messages - .order(["#{Message.table_name}.sticked_on ASC", sort_clause].compact.join(', ')) + .order(["#{Message.table_name}.sticked_on ASC", sort_clause].compact.join(", ")) .includes(:author, :forum) .limit(Setting.feeds_limit.to_i) @@ -78,7 +78,7 @@ def show def set_topics @topics = @forum .topics - .order(["#{Message.table_name}.sticked_on ASC", sort_clause].compact.join(', ')) + .order(["#{Message.table_name}.sticked_on ASC", sort_clause].compact.join(", ")) .includes(:author, last_reply: :author) .page(page_param) .per_page(per_page_param) @@ -91,7 +91,7 @@ def edit; end def create if @forum.save flash[:notice] = I18n.t(:notice_successful_create) - redirect_to action: 'index' + redirect_to action: "index" else render :new end @@ -100,7 +100,7 @@ def create def update if @forum.update(permitted_params.forum) flash[:notice] = I18n.t(:notice_successful_update) - redirect_to action: 'index' + redirect_to action: "index" else render :edit end @@ -110,16 +110,16 @@ def move if @forum.update(permitted_params.forum_move) flash[:notice] = t(:notice_successful_update) else - flash.now[:error] = t('forum_could_not_be_saved') - render action: 'edit' + flash.now[:error] = t("forum_could_not_be_saved") + render action: "edit" end - redirect_to action: 'index' + redirect_to action: "index" end def destroy @forum.destroy flash[:notice] = I18n.t(:notice_successful_delete) - redirect_to action: 'index' + redirect_to action: "index" end private diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index ddd33e3cade7..c305bb1c7f78 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -28,19 +28,19 @@ class GroupsController < ApplicationController include GroupsHelper - layout 'admin' + layout "admin" before_action :require_admin, except: %i[show] before_action :find_group, only: %i[destroy update show create_memberships destroy_membership edit_membership add_users] def index - @groups = Group.order(Arel.sql('lastname ASC')) + @groups = Group.order(Arel.sql("lastname ASC")) end def show @group_users = group_members - render layout: 'no_menu' + render layout: "no_menu" end def new @@ -75,7 +75,7 @@ def update flash[:notice] = I18n.t(:notice_successful_update) redirect_to(groups_path) else - render action: 'edit' + render action: "edit" end end @@ -135,7 +135,7 @@ def destroy_membership .call flash[:notice] = I18n.t :notice_successful_delete - redirect_to controller: '/groups', action: 'edit', id: @group, tab: redirected_to_tab(member) + redirect_to controller: "/groups", action: "edit", id: @group, tab: redirected_to_tab(member) end protected @@ -158,10 +158,10 @@ def visible_group_members? end def default_breadcrumb - if action_name == 'index' || !current_user.admin? - t('label_group_plural') + if action_name == "index" || !current_user.admin? + t("label_group_plural") else - ActionController::Base.helpers.link_to(t('label_group_plural'), groups_path) + ActionController::Base.helpers.link_to(t("label_group_plural"), groups_path) end end @@ -176,14 +176,14 @@ def respond_membership_altered(service_call) flash[:error] = service_call.errors.full_messages.join("\n") end - redirect_to controller: '/groups', action: 'edit', id: @group, tab: redirected_to_tab(service_call.result) + redirect_to controller: "/groups", action: "edit", id: @group, tab: redirected_to_tab(service_call.result) end def redirected_to_tab(membership) if membership.project - 'memberships' + "memberships" else - 'global_roles' + "global_roles" end end @@ -194,6 +194,6 @@ def respond_users_altered(service_call) service_call.apply_flash_message!(flash) end - redirect_to controller: '/groups', action: 'edit', id: @group, tab: 'users' + redirect_to controller: "/groups", action: "edit", id: @group, tab: "users" end end diff --git a/app/controllers/highlighting_controller.rb b/app/controllers/highlighting_controller.rb index 4a19f32904e1..6cd953a7f8f6 100644 --- a/app/controllers/highlighting_controller.rb +++ b/app/controllers/highlighting_controller.rb @@ -36,8 +36,8 @@ def styles expires_in 1.year, public: true, must_revalidate: false if stale?(last_modified: Time.zone.parse(@max_updated_at), etag: @highlight_version_tag, public: true) - OpenProject::Cache.fetch('highlighting/styles', @highlight_version_tag) do - render template: 'highlighting/styles', formats: [:css] + OpenProject::Cache.fetch("highlighting/styles", @highlight_version_tag) do + render template: "highlighting/styles", formats: [:css] end end end diff --git a/app/controllers/homescreen_controller.rb b/app/controllers/homescreen_controller.rb index 686c1434e39f..c4a3b1c53e57 100644 --- a/app/controllers/homescreen_controller.rb +++ b/app/controllers/homescreen_controller.rb @@ -29,7 +29,7 @@ class HomescreenController < ApplicationController skip_before_action :check_if_login_required, only: [:robots] - layout 'global' + layout "global" def index @newest_projects = Project.visible.newest.take(3) @@ -46,7 +46,7 @@ def index def robots if Setting.login_required? - render template: 'homescreen/robots-login-required', format: :text + render template: "homescreen/robots-login-required", format: :text else @projects = Project.active.public_projects end diff --git a/app/controllers/journals_controller.rb b/app/controllers/journals_controller.rb index c1725f4bdbc2..391c70863e12 100644 --- a/app/controllers/journals_controller.rb +++ b/app/controllers/journals_controller.rb @@ -40,7 +40,7 @@ class JournalsController < ApplicationController def index @query = retrieve_query(@project) - sort_init 'id', 'desc' + sort_init "id", "desc" sort_update(@query.sortable_key_by_column_name) if @query.valid? @@ -51,7 +51,7 @@ def index respond_to do |format| format.atom do render layout: false, - content_type: 'application/atom+xml', + content_type: "application/atom+xml", locals: { title: journals_index_title, journals: @journals } end @@ -67,13 +67,13 @@ def diff return render_400 message: I18n.t(:error_journal_attribute_not_present, attribute: field_param) end - @activity_page = params['activity_page'] + @activity_page = params["activity_page"] @diff = Redmine::Helpers::Diff.new(to, from) respond_to do |format| format.html format.js do - render partial: 'diff', locals: { diff: @diff } + render partial: "diff", locals: { diff: @diff } end end end @@ -90,8 +90,8 @@ def find_journal def ensure_permitted permission = case @journal.journable_type - when 'WorkPackage' then :view_work_packages - when 'Project' then :view_project + when "WorkPackage" then :view_work_packages + when "Project" then :view_project end do_authorize(permission) diff --git a/app/controllers/ldap_auth_sources_controller.rb b/app/controllers/ldap_auth_sources_controller.rb index 286329269deb..172a358af681 100644 --- a/app/controllers/ldap_auth_sources_controller.rb +++ b/app/controllers/ldap_auth_sources_controller.rb @@ -29,7 +29,7 @@ class LdapAuthSourcesController < ApplicationController menu_item :ldap_authentication include PaginationHelper - layout 'admin' + layout "admin" before_action :require_admin before_action :block_if_password_login_disabled @@ -55,9 +55,9 @@ def create @ldap_auth_source = LdapAuthSource.new permitted_params.ldap_auth_source if @ldap_auth_source.save flash[:notice] = I18n.t(:notice_successful_create) - redirect_to action: 'index' + redirect_to action: "index" else - render 'new' + render "new" end end @@ -68,9 +68,9 @@ def update if @ldap_auth_source.update updated flash[:notice] = I18n.t(:notice_successful_update) - redirect_to action: 'index' + redirect_to action: "index" else - render 'edit' + render "edit" end end @@ -82,7 +82,7 @@ def test_connection rescue StandardError => e flash[:error] = I18n.t(:error_unable_to_connect, value: e.message) end - redirect_to action: 'index' + redirect_to action: "index" end def destroy @@ -94,7 +94,7 @@ def destroy else flash[:warning] = t(:notice_wont_delete_auth_source) end - redirect_to action: 'index' + redirect_to action: "index" end protected @@ -107,7 +107,7 @@ def prevent_editing_when_seeded end def default_breadcrumb - if action_name == 'index' + if action_name == "index" t(:label_ldap_auth_source_plural) else ActionController::Base.helpers.link_to(t(:label_ldap_auth_source_plural), ldap_auth_sources_path) diff --git a/app/controllers/members/menus_controller.rb b/app/controllers/members/menus_controller.rb index 6d0aeca4cc65..ab205fc3aff0 100644 --- a/app/controllers/members/menus_controller.rb +++ b/app/controllers/members/menus_controller.rb @@ -45,13 +45,13 @@ def first_level_menu_items def user_status_options [ - OpenProject::Menu::MenuItem.new(title: I18n.t('members.menu.all'), + OpenProject::Menu::MenuItem.new(title: I18n.t("members.menu.all"), href: project_members_path, selected: active_filter_count == 0), - OpenProject::Menu::MenuItem.new(title: I18n.t('members.menu.locked'), + OpenProject::Menu::MenuItem.new(title: I18n.t("members.menu.locked"), href: project_members_path(status: :locked), selected: selected?(:status, :locked)), - OpenProject::Menu::MenuItem.new(title: I18n.t('members.menu.invited'), + OpenProject::Menu::MenuItem.new(title: I18n.t("members.menu.invited"), href: project_members_path(status: :invited), selected: selected?(:status, :invited)) ] @@ -59,9 +59,9 @@ def user_status_options def nested_menu_items [ - OpenProject::Menu::MenuGroup.new(header: I18n.t('members.menu.project_roles'), children: project_roles_entries), - OpenProject::Menu::MenuGroup.new(header: I18n.t('members.menu.wp_shares'), children: permission_menu_entries), - OpenProject::Menu::MenuGroup.new(header: I18n.t('members.menu.groups'), children: project_group_entries) + OpenProject::Menu::MenuGroup.new(header: I18n.t("members.menu.project_roles"), children: project_roles_entries), + OpenProject::Menu::MenuGroup.new(header: I18n.t("members.menu.wp_shares"), children: permission_menu_entries), + OpenProject::Menu::MenuGroup.new(header: I18n.t("members.menu.groups"), children: project_group_entries) ] end diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 24937ec88998..efe9fcb66f33 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -57,7 +57,7 @@ def show .per_page(per_page_param) @reply = Message.new(subject: "RE: #{@message.subject}", parent: @topic, forum: @topic.forum) - render action: 'show', layout: !request.xhr? + render action: "show", layout: !request.xhr? end # new topic @@ -87,7 +87,7 @@ def create redirect_to topic_path(@message) else - render action: 'new' + render action: "new" end end @@ -116,7 +116,7 @@ def update @message.reload redirect_to topic_path(@message.root, r: @message.parent_id && @message.id) else - render action: 'edit' + render action: "edit" end end @@ -128,9 +128,9 @@ def destroy @message.destroy flash[:notice] = t(:notice_successful_delete) redirect_target = if @message.parent.nil? - { controller: '/forums', action: 'show', project_id: @project, id: @forum } + { controller: "/forums", action: "show", project_id: @project, id: @forum } else - { action: 'show', id: @message.parent, r: @message } + { action: "show", id: @message.parent, r: @message } end redirect_to redirect_target @@ -140,10 +140,10 @@ def quote user = @message.author text = @message.content subject = @message.subject - subject = "RE: #{subject}" unless subject.starts_with?('RE:') + subject = "RE: #{subject}" unless subject.starts_with?("RE:") user_wrote = I18n.t(:text_user_wrote, value: ERB::Util.html_escape(user), locale: Setting.default_language) content = "#{user_wrote}\n> " - content << (text.to_s.strip.gsub(%r{
(.+?)
}m, '[...]').gsub('"', '\"').gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n") + content << (text.to_s.strip.gsub(%r{
(.+?)
}m, "[...]").gsub('"', '\"').gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n") respond_to do |format| format.json { render json: { subject:, content: } } diff --git a/app/controllers/my/auto_login_tokens_controller.rb b/app/controllers/my/auto_login_tokens_controller.rb index 058012090196..21de9f6f2214 100644 --- a/app/controllers/my/auto_login_tokens_controller.rb +++ b/app/controllers/my/auto_login_tokens_controller.rb @@ -2,7 +2,7 @@ module My class AutoLoginTokensController < ::ApplicationController before_action :find_token, only: %i(destroy) - layout 'my' + layout "my" menu_item :sessions def destroy diff --git a/app/controllers/my/sessions_controller.rb b/app/controllers/my/sessions_controller.rb index 7d244f9549bf..b243be219a6d 100644 --- a/app/controllers/my/sessions_controller.rb +++ b/app/controllers/my/sessions_controller.rb @@ -6,7 +6,7 @@ class SessionsController < ::ApplicationController before_action :find_model_object, only: %i(show destroy) before_action :prevent_current_session_deletion, only: %i(destroy) - layout 'my' + layout "my" menu_item :sessions def index @@ -18,7 +18,7 @@ def index .for_user(current_user) .order(expires_on: :asc) - token = cookies[OpenProject::Configuration['autologin_cookie_name']] + token = cookies[OpenProject::Configuration["autologin_cookie_name"]] if token @current_token = @autologin_tokens.find_by_plaintext_value(token) # rubocop:disable Rails/DynamicFindBy end @@ -37,7 +37,7 @@ def destroy def prevent_current_session_deletion if @session.current?(session) - render_400 message: I18n.t('users.sessions.may_not_delete_current') + render_400 message: I18n.t("users.sessions.may_not_delete_current") end end end diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index 56f9b39854ce..92d31cf6c088 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -77,9 +77,9 @@ def create @news.attributes = permitted_params.news if @news.save flash[:notice] = I18n.t(:notice_successful_create) - redirect_to controller: '/news', action: 'index', project_id: @project + redirect_to controller: "/news", action: "index", project_id: @project else - render action: 'new' + render action: "new" end end @@ -87,16 +87,16 @@ def update @news.attributes = permitted_params.news if @news.save flash[:notice] = I18n.t(:notice_successful_update) - redirect_to action: 'show', id: @news + redirect_to action: "show", id: @news else - render action: 'edit' + render action: "edit" end end def destroy @news.destroy flash[:notice] = I18n.t(:notice_successful_delete) - redirect_to action: 'index', project_id: @project + redirect_to action: "index", project_id: @project end private diff --git a/app/controllers/oauth/applications_controller.rb b/app/controllers/oauth/applications_controller.rb index 11610214d967..d77870eb8019 100644 --- a/app/controllers/oauth/applications_controller.rb +++ b/app/controllers/oauth/applications_controller.rb @@ -32,7 +32,7 @@ class ApplicationsController < ::ApplicationController before_action :new_app, only: %i[new create] before_action :find_app, only: %i[edit update show destroy] - layout 'admin' + layout "admin" menu_item :oauth_applications def index @@ -87,10 +87,10 @@ def destroy protected def default_breadcrumb - if action_name == 'index' - t('oauth.application.plural') + if action_name == "index" + t("oauth.application.plural") else - ActionController::Base.helpers.link_to(t('oauth.application.plural'), oauth_applications_path) + ActionController::Base.helpers.link_to(t("oauth.application.plural"), oauth_applications_path) end end diff --git a/app/controllers/oauth/auth_base_controller.rb b/app/controllers/oauth/auth_base_controller.rb index 7da92dbfe624..1428e5230193 100644 --- a/app/controllers/oauth/auth_base_controller.rb +++ b/app/controllers/oauth/auth_base_controller.rb @@ -37,7 +37,7 @@ class AuthBaseController < ::ApplicationController prepend_before_action :extend_content_security_policy skip_before_action :check_if_login_required - layout 'only_logo' + layout "only_logo" def extend_content_security_policy return unless pre_auth&.authorizable? @@ -51,13 +51,13 @@ def extend_content_security_policy def application_http_redirect_uris registered_redirect_uris - .select { |url| url.start_with?('http') } - .map { |url| URI.join(url, '/').to_s } + .select { |url| url.start_with?("http") } + .map { |url| URI.join(url, "/").to_s } end def application_native_redirect_uris registered_redirect_uris - .reject { |url| url.start_with?('http', 'urn') } + .reject { |url| url.start_with?("http", "urn") } .map(&method(:parse_native_redirect_uri)) .compact end diff --git a/app/controllers/oauth/grants_controller.rb b/app/controllers/oauth/grants_controller.rb index de59afa3ab57..e38afe156b12 100644 --- a/app/controllers/oauth/grants_controller.rb +++ b/app/controllers/oauth/grants_controller.rb @@ -30,7 +30,7 @@ module OAuth class GrantsController < ::ApplicationController before_action :require_login - layout 'my' + layout "my" menu_item :access_token def index @@ -49,8 +49,8 @@ def revoke_application current_user ) - flash[:notice] = I18n.t('oauth.grants.successful_application_revocation', application_name: application.name) - redirect_to controller: '/my', action: :access_token + flash[:notice] = I18n.t("oauth.grants.successful_application_revocation", application_name: application.name) + redirect_to controller: "/my", action: :access_token end private diff --git a/app/controllers/placeholder_users/memberships_controller.rb b/app/controllers/placeholder_users/memberships_controller.rb index 346c8d91edbd..b75532b9a878 100644 --- a/app/controllers/placeholder_users/memberships_controller.rb +++ b/app/controllers/placeholder_users/memberships_controller.rb @@ -28,7 +28,7 @@ class PlaceholderUsers::MembershipsController < ApplicationController include IndividualPrincipals::MembershipControllerMethods - layout 'admin' + layout "admin" before_action :authorize_global before_action :find_individual_principal @@ -40,6 +40,6 @@ def find_individual_principal end def redirected_to_tab(_membership) - 'memberships' + "memberships" end end diff --git a/app/controllers/placeholder_users_controller.rb b/app/controllers/placeholder_users_controller.rb index 06ad095d445a..8ec919515c30 100644 --- a/app/controllers/placeholder_users_controller.rb +++ b/app/controllers/placeholder_users_controller.rb @@ -28,7 +28,7 @@ class PlaceholderUsersController < ApplicationController include EnterpriseTrialHelper - layout 'admin' + layout "admin" before_action :authorize_global, except: %i[show] before_action :find_placeholder_user, only: %i[show @@ -60,7 +60,7 @@ def show .where(id: Member.visible(current_user)) respond_to do |format| - format.html { render layout: 'no_menu' } + format.html { render layout: "no_menu" } end end @@ -153,20 +153,20 @@ def find_placeholder_user def authorize_deletion unless helpers.can_delete_placeholder_user?(@placeholder_user, current_user) - render_403 message: I18n.t('placeholder_users.right_to_manage_members_missing') + render_403 message: I18n.t("placeholder_users.right_to_manage_members_missing") end end def default_breadcrumb - if action_name == 'index' - t('label_placeholder_user_plural') + if action_name == "index" + t("label_placeholder_user_plural") else - ActionController::Base.helpers.link_to(t('label_placeholder_user_plural'), + ActionController::Base.helpers.link_to(t("label_placeholder_user_plural"), placeholder_users_path) end end def show_local_breadcrumb - action_name != 'show' + action_name != "show" end end diff --git a/app/controllers/projects/archive_controller.rb b/app/controllers/projects/archive_controller.rb index 5ac441fa9c8d..b18c6f86c44c 100644 --- a/app/controllers/projects/archive_controller.rb +++ b/app/controllers/projects/archive_controller.rb @@ -48,7 +48,7 @@ def change_status_action(status) redirect_to(projects_path) else flash[:error] = t(:"error_can_not_#{status}_project", - errors: service_call.errors.full_messages.join(', ')) + errors: service_call.errors.full_messages.join(", ")) redirect_back fallback_location: projects_path end end diff --git a/app/controllers/projects/identifier_controller.rb b/app/controllers/projects/identifier_controller.rb index 9d640988e907..5178dc0e94bf 100644 --- a/app/controllers/projects/identifier_controller.rb +++ b/app/controllers/projects/identifier_controller.rb @@ -42,7 +42,7 @@ def update flash[:notice] = I18n.t(:notice_successful_update) redirect_to project_settings_general_path(@project) else - render action: 'show' + render action: "show" end end end diff --git a/app/controllers/projects/menus_controller.rb b/app/controllers/projects/menus_controller.rb index 9a99912c0168..78281abee108 100644 --- a/app/controllers/projects/menus_controller.rb +++ b/app/controllers/projects/menus_controller.rb @@ -41,9 +41,9 @@ def first_level_menu_items [ OpenProject::Menu::MenuGroup.new(header: nil, children: static_filters), - OpenProject::Menu::MenuGroup.new(header: I18n.t(:'projects.lists.my_private'), + OpenProject::Menu::MenuGroup.new(header: I18n.t(:"projects.lists.my_private"), children: my_filters), - OpenProject::Menu::MenuGroup.new(header: I18n.t(:'activerecord.attributes.project.status_code'), + OpenProject::Menu::MenuGroup.new(header: I18n.t(:"activerecord.attributes.project.status_code"), children: static_status_filters) ] end diff --git a/app/controllers/projects/queries_controller.rb b/app/controllers/projects/queries_controller.rb index 35d87f7c9225..b1e2d162eb79 100644 --- a/app/controllers/projects/queries_controller.rb +++ b/app/controllers/projects/queries_controller.rb @@ -39,8 +39,8 @@ class Projects::QueriesController < ApplicationController end def new - render template: '/projects/index', - layout: 'global', + render template: "/projects/index", + layout: "global", locals: { query: @query, state: :edit } end @@ -52,8 +52,8 @@ def create if call.success? redirect_to projects_path(query_id: call.result.id) else - render template: '/projects/index', - layout: 'global', + render template: "/projects/index", + layout: "global", locals: { query: call.result, state: :edit } end end diff --git a/app/controllers/projects/settings/custom_fields_controller.rb b/app/controllers/projects/settings/custom_fields_controller.rb index 03f6a1acacaa..25cbac60b795 100644 --- a/app/controllers/projects/settings/custom_fields_controller.rb +++ b/app/controllers/projects/settings/custom_fields_controller.rb @@ -30,7 +30,7 @@ class Projects::Settings::CustomFieldsController < Projects::SettingsController menu_item :settings_custom_fields def show - @wp_custom_fields = WorkPackageCustomField.order('lower(name)') + @wp_custom_fields = WorkPackageCustomField.order("lower(name)") end def update @@ -39,7 +39,7 @@ def update flash[:notice] = t(:notice_successful_update) else flash[:error] = t(:notice_project_cannot_update_custom_fields, - errors: @project.errors.full_messages.join(', ')) + errors: @project.errors.full_messages.join(", ")) raise ActiveRecord::Rollback end end diff --git a/app/controllers/projects/settings/modules_controller.rb b/app/controllers/projects/settings/modules_controller.rb index 1ef457ae26d1..c7f3dc070e10 100644 --- a/app/controllers/projects/settings/modules_controller.rb +++ b/app/controllers/projects/settings/modules_controller.rb @@ -39,7 +39,7 @@ def update redirect_to project_settings_modules_path(@project) else - render 'show' + render "show" end end end diff --git a/app/controllers/projects/templated_controller.rb b/app/controllers/projects/templated_controller.rb index 6f74a5a77cc5..c59e7c033144 100644 --- a/app/controllers/projects/templated_controller.rb +++ b/app/controllers/projects/templated_controller.rb @@ -50,7 +50,7 @@ def change_templated_action(templated) flash[:notice] = t(:notice_successful_update) else messages = [ - t('activerecord.errors.template.header', model: Project.model_name.human, count: service_call.errors.count), + t("activerecord.errors.template.header", model: Project.model_name.human, count: service_call.errors.count), service_call.message ] diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index de4617468a01..94e4281e5aef 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -53,7 +53,7 @@ def index format.html do flash.now[:error] = @query.errors.full_messages if @query.errors.any? - render layout: 'global', locals: { query: @query, state: :show } + render layout: "global", locals: { query: @query, state: :show } end format.any(*supported_export_formats) do @@ -63,7 +63,7 @@ def index end def new - render layout: 'no_menu' + render layout: "no_menu" end def copy @@ -77,9 +77,9 @@ def destroy .call if service_call.success? - flash[:notice] = I18n.t('projects.delete.scheduled') + flash[:notice] = I18n.t("projects.delete.scheduled") else - flash[:error] = I18n.t('projects.delete.schedule_failed', errors: service_call.errors.full_messages.join("\n")) + flash[:error] = I18n.t("projects.delete.schedule_failed", errors: service_call.errors.full_messages.join("\n")) end redirect_to projects_path @@ -118,7 +118,7 @@ def export_list(query, mime_type) query: query.to_hash ) - if request.headers['Accept']&.include?('application/json') + if request.headers["Accept"]&.include?("application/json") render json: { job_id: job.job_id } else redirect_to job_status_path(job.job_id) diff --git a/app/controllers/queries/params_parser.rb b/app/controllers/queries/params_parser.rb index 301d2dd15deb..d93e5747b025 100644 --- a/app/controllers/queries/params_parser.rb +++ b/app/controllers/queries/params_parser.rb @@ -49,7 +49,7 @@ def parse_orders_from_params(params) .to_h .map { |k, v| { attribute: k, direction: v } } rescue JSON::ParserError - [{ attribute: 'invalid', direction: 'asc' }] + [{ attribute: "invalid", direction: "asc" }] end def parse_columns_from_params(params) @@ -86,7 +86,7 @@ def parse_filter def consume_ampersand case @buffer.peek(1) - when '&', /\s/ + when "&", /\s/ @buffer.getch consume_ampersand end @@ -106,9 +106,9 @@ def parse_values parse_doublequoted_value when "'" parse_singlequoted_value - when '[' + when "[" parse_array_value - when '&' + when "&" [] else parse_unguarded_value @@ -128,7 +128,7 @@ def parse_singlequoted_value def parse_unguarded_value value = @buffer .scan_until(/&|\z/) - .delete_suffix('&') + .delete_suffix("&") [value] end @@ -136,8 +136,8 @@ def parse_unguarded_value def parse_array_value @buffer .scan_until(/]|\z/) - .delete_suffix(']') - .delete_prefix('[') + .delete_suffix("]") + .delete_prefix("[") .scan(/(?:'([^']*)')|(?:"([^"]*)")/) .flatten .compact diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 08cb4596df0c..741493d32a1b 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -26,9 +26,9 @@ # See COPYRIGHT and LICENSE files for more details. #++ -require 'SVG/Graph/Bar' -require 'SVG/Graph/BarHorizontal' -require 'digest/sha1' +require "SVG/Graph/Bar" +require "SVG/Graph/BarHorizontal" +require "digest/sha1" class ChangesetNotFound < StandardError end @@ -63,7 +63,7 @@ def show if request.xhr? if @entries && @repository.valid? - render(partial: 'dir_list_content') + render(partial: "dir_list_content") else render(nothing: true) end @@ -72,7 +72,7 @@ def show else @changesets = @repository.latest_changesets(@path, @rev) @properties = @repository.properties(@path, @rev) - render action: 'show' + render action: "show" end end @@ -80,8 +80,8 @@ def create service = SCM::RepositoryFactoryService.new(@project, params) if service.build_and_save @repository = service.repository - flash[:notice] = I18n.t('repositories.create_successful') - flash[:notice] << (' ' + I18n.t('repositories.create_managed_delay')) if @repository.managed? + flash[:notice] = I18n.t("repositories.create_successful") + flash[:notice] << (" " + I18n.t("repositories.create_managed_delay")) if @repository.managed? else flash[:error] = service.build_error end @@ -111,7 +111,7 @@ def committers h end flash[:notice] = I18n.t(:notice_successful_update) - redirect_to action: 'committers', project_id: @project + redirect_to action: "committers", project_id: @project end end @@ -123,7 +123,7 @@ def destroy_info def destroy repository = @project.repository if repository.destroy - flash[:notice] = I18n.t('repositories.delete_sucessful') + flash[:notice] = I18n.t("repositories.delete_sucessful") else flash[:error] = repository.errors.full_messages end @@ -146,7 +146,7 @@ def changes @properties = @repository.properties(@path, @rev) @changeset = @repository.find_changeset_by_name(@rev) - render 'changes', formats: [:html] + render "changes", formats: [:html] end def revisions @@ -203,7 +203,7 @@ def annotate @annotate = @repository.scm.annotate(@path, @rev) @changeset = @repository.find_changeset_by_name(@rev) - render 'annotate', formats: [:html] + render "annotate", formats: [:html] end def revision @@ -221,7 +221,7 @@ def revision end def diff - if params[:format] == 'diff' + if params[:format] == "diff" @diff = @repository.diff(@path, @rev, @rev_to) unless @diff @@ -233,8 +233,8 @@ def diff filename << "_r#{@rev_to}" if @rev_to send_data @diff.join, filename: "#{filename}.diff", - type: 'text/x-patch', - disposition: 'attachment' + type: "text/x-patch", + disposition: "attachment" else @diff_type = diff_type_persisted @@ -250,7 +250,7 @@ def diff @changeset_to = @rev_to ? @repository.find_changeset_by_name(@rev_to) : nil @diff_format_revisions = @repository.diff_format_revisions(@changeset, @changeset_to) - render 'diff', formats: :html + render "diff", formats: :html end end @@ -264,9 +264,9 @@ def stats def graph data = nil case params[:graph] - when 'commits_per_month' + when "commits_per_month" data = graph_commits_per_month(@repository) - when 'commits_per_author' + when "commits_per_author" unless current_user.allowed_in_project?(:view_commit_author_statistics, @project) return deny_access end @@ -275,8 +275,8 @@ def graph end if data - headers['Content-Type'] = 'image/svg+xml' - send_data(data, type: 'image/svg+xml', disposition: 'inline') + headers["Content-Type"] = "image/svg+xml" + send_data(data, type: "image/svg+xml", disposition: "inline") else render_404 end @@ -290,7 +290,7 @@ def update_repository(repo_params) @repository.attributes = @repository.class.permitted_params(repo_params) if @repository.save - flash[:notice] = I18n.t('repositories.update_settings_successful') + flash[:notice] = I18n.t("repositories.update_settings_successful") else flash[:error] = @repository.errors.full_messages.join('\n') end @@ -306,7 +306,7 @@ def find_repository # Prepare checkout instructions # available on all pages (even empty!) - @path = params[:repo_path] || '' + @path = params[:repo_path] || "" @instructions = ::SCM::CheckoutInstructionsService.new(@repository, path: @path) # Asserts repository availability, or renders an appropriate error @@ -319,7 +319,7 @@ def find_repository raise InvalidRevisionParam end rescue OpenProject::SCM::Exceptions::SCMEmpty - render 'empty' + render "empty" rescue ActiveRecord::RecordNotFound render_404 rescue InvalidRevisionParam @@ -339,7 +339,7 @@ def graph_commits_per_month(repository) @date_from = @date_to << 11 @date_from = Date.civil(@date_from.year, @date_from.month, 1) commits_by_day = Changeset.where( - ['repository_id = ? AND commit_date BETWEEN ? AND ?', repository.id, @date_from, @date_to] + ["repository_id = ? AND commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to] ).group(:commit_date).size commits_by_month = [0] * 12 commits_by_day.each do |c| @@ -389,7 +389,7 @@ def graph_commits_per_month(repository) end def graph_commits_per_author(repository) - commits_by_author = Changeset.where(['repository_id = ?', repository.id]).group(:committer).size + commits_by_author = Changeset.where(["repository_id = ?", repository.id]).group(:committer).size commits_by_author.to_a.sort_by!(&:last) changes_by_author = Change.includes(:changeset) @@ -406,12 +406,12 @@ def graph_commits_per_author(repository) commits_data = commits_by_author.map(&:last) changes_data = commits_by_author.map { |r| h[r.first] || 0 } - fields = fields + ([''] * (10 - fields.length)) if fields.length < 10 + fields = fields + ([""] * (10 - fields.length)) if fields.length < 10 commits_data = commits_data + ([0] * (10 - commits_data.length)) if commits_data.length < 10 changes_data = changes_data + ([0] * (10 - changes_data.length)) if changes_data.length < 10 # Remove email address in usernames - fields = fields.map { |c| c.gsub(%r{<.+@.+>}, '') } + fields = fields.map { |c| c.gsub(%r{<.+@.+>}, "") } graph = SVG::Graph::BarHorizontal.new( height: 400, @@ -440,14 +440,14 @@ def login_back_url_params end def raw_or_to_large_or_non_text(content, path) - params[:format] == 'raw' || + params[:format] == "raw" || (content.size && content.size > Setting.file_max_size_displayed.to_i.kilobyte) || !entry_text_data?(content, path) end def send_raw(content, path) # Force the download - send_opt = { filename: filename_for_content_disposition(path.split('/').last) } + send_opt = { filename: filename_for_content_disposition(path.split("/").last) } send_type = OpenProject::MimeType.of(path) send_opt[:type] = send_type.to_s if send_type send_data content, send_opt @@ -462,14 +462,14 @@ def render_text_entry # Forcing html format here to avoid # rails looking for e.g text when .txt is asked for - render 'entry', formats: [:html] + render "entry", formats: [:html] end def diff_type_persisted preferences = current_user.pref diff_type = params[:type] || preferences.diff_type - diff_type = 'inline' unless %w(inline sbs).include?(diff_type) + diff_type = "inline" unless %w(inline sbs).include?(diff_type) # Save diff type as user preference if current_user.logged? && diff_type != preferences.diff_type @@ -485,7 +485,7 @@ def entry_text_data?(ent, path) # It is very strict that file contains less than 30% of ascii symbols # in non Western Europe. # TODO: need to handle edge cases of non-binary content that isn't UTF-8 - OpenProject::MimeType.is_type?('text', path) || - ent.dup.force_encoding('UTF-8') == ent.dup.force_encoding('BINARY') + OpenProject::MimeType.is_type?("text", path) || + ent.dup.force_encoding("UTF-8") == ent.dup.force_encoding("BINARY") end end diff --git a/app/controllers/roles_controller.rb b/app/controllers/roles_controller.rb index 3fd874957eee..893c26866539 100644 --- a/app/controllers/roles_controller.rb +++ b/app/controllers/roles_controller.rb @@ -29,7 +29,7 @@ class RolesController < ApplicationController include PaginationHelper - layout 'admin' + layout "admin" before_action :require_admin @@ -41,7 +41,7 @@ def index .page(page_param) .per_page(per_page_param) - render action: 'index', layout: false if request.xhr? + render action: "index", layout: false if request.xhr? end def new @@ -52,7 +52,7 @@ def new def edit @role = Role.find(params[:id]) - @call = set_role_attributes(@role, 'update') + @call = set_role_attributes(@role, "update") end def create @@ -61,11 +61,11 @@ def create if @call.success? flash[:notice] = t(:notice_successful_create) - redirect_to action: 'index' + redirect_to action: "index" else @roles = roles_scope - render action: 'new' + render action: "new" end end @@ -75,9 +75,9 @@ def update if @call.success? flash[:notice] = I18n.t(:notice_successful_update) - redirect_to action: 'index' + redirect_to action: "index" else - render action: 'edit' + render action: "edit" end end @@ -92,7 +92,7 @@ def destroy else flash[:error] = I18n.t(:error_can_not_remove_role) end - redirect_to action: 'index' + redirect_to action: "index" end def report @@ -107,11 +107,11 @@ def bulk_update if calls.all?(&:success?) flash[:notice] = I18n.t(:notice_successful_update) - redirect_to action: 'index' + redirect_to action: "index" else @calls = calls @permissions = OpenProject::AccessControl.permissions.reject(&:public?) - render action: 'report' + render action: "report" end end @@ -144,10 +144,10 @@ def roles_scope end def default_breadcrumb - if action_name == 'index' - t('label_role_plural') + if action_name == "index" + t("label_role_plural") else - ActionController::Base.helpers.link_to(t('label_role_plural'), roles_path) + ActionController::Base.helpers.link_to(t("label_role_plural"), roles_path) end end diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index c71ef05ecbd4..dbdf68110eb1 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -53,12 +53,12 @@ def index private def prepare_tokens - @question = search_params[:q] || '' + @question = search_params[:q] || "" @question.strip! @tokens = scan_query_tokens(@question).uniq unless @tokens.any? - @question = '' + @question = "" end end @@ -92,7 +92,7 @@ def limit_results_subsequent_page # extract tokens from the question # eg. hello "bye bye" => ["hello", "bye bye"] def scan_query_tokens(query) - tokens = query.scan(%r{((\s|^)"[\s\w]+"(\s|$)|\S+)}).map { |m| m.first.gsub(%r{(^\s*"\s*|\s*"\s*$)}, '') } + tokens = query.scan(%r{((\s|^)"[\s\w]+"(\s|$)|\S+)}).map { |m| m.first.gsub(%r{(^\s*"\s*|\s*"\s*$)}, "") } # no more than 5 tokens to search for tokens.slice! 5..-1 if tokens.size > 5 @@ -111,9 +111,9 @@ def offset def projects_to_search case search_params[:scope] - when 'all' + when "all" nil - when 'current_project' + when "current_project" @project else @project ? @project.self_and_descendants.active : nil @@ -149,7 +149,7 @@ def search_types if projects_to_search.is_a? Project # don't search projects - types.delete('projects') + types.delete("projects") # only show what the user is allowed to view types = types.select { |o| User.current.allowed_in_project?(:"view_#{o}", projects_to_search) } end @@ -162,7 +162,7 @@ def search_classes scope = if scope.empty? search_types - elsif scope & ['work_packages'] == scope + elsif scope & ["work_packages"] == scope [] else scope @@ -176,7 +176,7 @@ def scope_class(scope) end def provision_gon - available_search_types = search_types.dup.push('all') + available_search_types = search_types.dup.push("all") gon.global_search = { search_term: @question, @@ -187,7 +187,7 @@ def provision_gon name: OpenProject::GlobalSearch.tab_name(search_type) } end, - current_tab: available_search_types.detect { |search_type| search_params[search_type] } || 'all' + current_tab: available_search_types.detect { |search_type| search_params[search_type] } || "all" } end end diff --git a/app/controllers/statuses_controller.rb b/app/controllers/statuses_controller.rb index 38e24b96c080..a9c83c066ed8 100644 --- a/app/controllers/statuses_controller.rb +++ b/app/controllers/statuses_controller.rb @@ -29,7 +29,7 @@ class StatusesController < ApplicationController include PaginationHelper - layout 'admin' + layout "admin" before_action :require_admin @@ -37,7 +37,7 @@ def index @statuses = Status.page(page_param) .per_page(per_page_param) - render action: 'index', layout: false if request.xhr? + render action: "index", layout: false if request.xhr? end def new @@ -52,9 +52,9 @@ def create @status = Status.new(permitted_params.status) if @status.save flash[:notice] = I18n.t(:notice_successful_create) - redirect_to action: 'index' + redirect_to action: "index" else - render action: 'new' + render action: "new" end end @@ -62,9 +62,9 @@ def update @status = Status.find(params[:id]) if @status.update(permitted_params.status) flash[:notice] = I18n.t(:notice_successful_update) - redirect_to action: 'index' + redirect_to action: "index" else - render action: 'edit' + render action: "edit" end end @@ -76,10 +76,10 @@ def destroy status.destroy flash[:notice] = I18n.t(:notice_successful_delete) end - redirect_to action: 'index' + redirect_to action: "index" rescue StandardError flash[:error] = I18n.t(:error_unable_delete_status) - redirect_to action: 'index' + redirect_to action: "index" end def update_work_package_done_ratio @@ -88,13 +88,13 @@ def update_work_package_done_ratio else flash[:error] = I18n.t(:error_work_package_done_ratios_not_updated) end - redirect_to action: 'index' + redirect_to action: "index" end protected def default_breadcrumb - if action_name == 'index' + if action_name == "index" t(:label_work_package_status_plural) else ActionController::Base.helpers.link_to(t(:label_work_package_status_plural), statuses_path) diff --git a/app/controllers/sys_controller.rb b/app/controllers/sys_controller.rb index a94c13e4ea1f..e709ef3b705f 100644 --- a/app/controllers/sys_controller.rb +++ b/app/controllers/sys_controller.rb @@ -26,7 +26,7 @@ # See COPYRIGHT and LICENSE files for more details. #++ -require 'open_project/repository_authentication' +require "open_project/repository_authentication" class SysController < ActionController::Base before_action :check_enabled @@ -38,7 +38,7 @@ def projects p = Project.active.has_module(:repository) .includes(:repository) .references(:repositories) - .order(Arel.sql('identifier')) + .order(Arel.sql("identifier")) respond_to do |format| format.json do render json: p.to_json(include: :repository) @@ -50,7 +50,7 @@ def projects end def update_required_storage - result = update_storage_information(@repository, params[:force] == '1') + result = update_storage_information(@repository, params[:force] == "1") render plain: "Updated: #{result}", status: :ok end @@ -75,9 +75,9 @@ def fetch_changesets def repo_auth project = Project.find_by(identifier: params[:repository]) if project && authorized?(project, @authenticated_user) - render plain: 'Access granted' + render plain: "Access granted" else - render plain: 'Not allowed', status: :forbidden # default to deny + render plain: "Not allowed", status: :forbidden # default to deny end end @@ -96,7 +96,7 @@ def authorized?(project, user) def check_enabled User.current = nil unless Setting.sys_api_enabled? && params[:key].to_s == Setting.sys_api_key - render plain: 'Access denied. Repository management WS is disabled or key is invalid.', + render plain: "Access denied. Repository management WS is disabled or key is invalid.", status: :forbidden false end @@ -125,7 +125,7 @@ def find_repository_with_storage else return true if @repository.scm.storage_available? - render plain: 'repositories.storage.not_available', status: :bad_request + render plain: "repositories.storage.not_available", status: :bad_request end false @@ -137,8 +137,8 @@ def require_basic_auth return true if @authenticated_user end - response.headers['WWW-Authenticate'] = 'Basic realm="Repository Authentication"' - render plain: 'Authorization required', status: :unauthorized + response.headers["WWW-Authenticate"] = 'Basic realm="Repository Authentication"' + render plain: "Authorization required", status: :unauthorized false end @@ -155,10 +155,10 @@ def cached_user_login(username, password) user_id = Rails.cache.fetch(OpenProject::RepositoryAuthentication::CACHE_PREFIX + Digest::SHA1.hexdigest("#{username}#{password}"), expires_in: OpenProject::RepositoryAuthentication::CACHE_EXPIRES_AFTER) do user = user_login(username, password) - user ? user.id.to_s : '-1' + user ? user.id.to_s : "-1" end - return nil if user_id.blank? or user_id == '-1' + return nil if user_id.blank? or user_id == "-1" user || User.find_by(id: user_id.to_i) end diff --git a/app/controllers/types_controller.rb b/app/controllers/types_controller.rb index 43be056024b2..224593c207b2 100644 --- a/app/controllers/types_controller.rb +++ b/app/controllers/types_controller.rb @@ -29,7 +29,7 @@ class TypesController < ApplicationController include PaginationHelper - layout 'admin' + layout "admin" before_action :require_admin before_action :find_type, only: %i[update move destroy] @@ -73,7 +73,7 @@ def create call.on_failure do |result| flash[:error] = result.errors.full_messages.join("\n") load_projects_and_types - render action: 'new' + render action: "new" end end end @@ -99,7 +99,7 @@ def move redirect_to types_path else flash.now[:error] = I18n.t(:error_type_could_not_be_saved) - render action: 'edit' + render action: "edit" end end @@ -113,7 +113,7 @@ def destroy else flash[:error] = destroy_error_message end - redirect_to action: 'index' + redirect_to action: "index" end protected @@ -129,7 +129,7 @@ def permitted_type_params end def load_projects_and_types - @types = ::Type.order(Arel.sql('position')) + @types = ::Type.order(Arel.sql("position")) @projects = Project.all end @@ -140,7 +140,7 @@ def redirect_to_type_tab_path(type, notice) end def default_breadcrumb - if action_name == 'index' + if action_name == "index" t(:label_work_package_types) else ActionController::Base.helpers.link_to(t(:label_work_package_types), types_path) @@ -152,7 +152,7 @@ def render_edit_tab(type) @projects = Project.all @type = type - render action: 'edit' + render action: "edit" end def show_local_breadcrumb @@ -173,7 +173,7 @@ def destroy_error_message else error_message = [ ApplicationController.helpers.sanitize( - t(:'error_can_not_delete_type.explanation', url: belonging_wps_url(@type.id)), + t(:"error_can_not_delete_type.explanation", url: belonging_wps_url(@type.id)), attributes: %w(href target) ) ] diff --git a/app/controllers/users/memberships_controller.rb b/app/controllers/users/memberships_controller.rb index 778675af5c07..2e02321d568c 100644 --- a/app/controllers/users/memberships_controller.rb +++ b/app/controllers/users/memberships_controller.rb @@ -28,7 +28,7 @@ class Users::MembershipsController < ApplicationController include IndividualPrincipals::MembershipControllerMethods - layout 'admin' + layout "admin" before_action :authorize_global before_action :find_individual_principal @@ -41,9 +41,9 @@ def find_individual_principal def redirected_to_tab(membership) if membership.project - 'memberships' + "memberships" else - 'global_roles' + "global_roles" end end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index ffa56f3e5ec9..1a599d96d232 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -27,7 +27,7 @@ #++ class UsersController < ApplicationController - layout 'admin' + layout "admin" before_action :authorize_global, except: %i[show deletion_info destroy] @@ -76,7 +76,7 @@ def show if can_show_user? @events = events - render layout: (can_manage_or_create_users? ? 'admin' : 'no_menu') + render layout: (can_manage_or_create_users? ? "admin" : "no_menu") else render_404 end @@ -102,7 +102,7 @@ def create flash[:notice] = I18n.t(:notice_successful_create) redirect_to(params[:continue] ? new_user_path : helpers.allowed_management_user_profile_path(@user)) else - render action: 'new' + render action: "new" end end @@ -160,14 +160,14 @@ def change_status_info def change_status if @user.id == current_user.id # user is not allowed to change own status - redirect_back_or_default(action: 'edit', id: @user) + redirect_back_or_default(action: "edit", id: @user) return end if (params[:unlock] || params[:activate]) && user_limit_reached? show_user_limit_error! - return redirect_back_or_default(action: 'edit', id: @user) + return redirect_back_or_default(action: "edit", id: @user) end if params[:unlock] @@ -182,7 +182,7 @@ def change_status was_activated = (@user.status_change == %w[registered active]) if params[:activate] && @user.missing_authentication_method? - flash[:error] = I18n.t('user.error_status_change_failed', + flash[:error] = I18n.t("user.error_status_change_failed", errors: I18n.t(:notice_user_missing_authentication_method)) elsif @user.save flash[:notice] = I18n.t(:notice_successful_update) @@ -190,10 +190,10 @@ def change_status UserMailer.account_activated(@user).deliver_later end else - flash[:error] = I18n.t('user.error_status_change_failed', - errors: @user.errors.full_messages.join(', ')) + flash[:error] = I18n.t("user.error_status_change_failed", + errors: @user.errors.full_messages.join(", ")) end - redirect_back_or_default(action: 'edit', id: @user) + redirect_back_or_default(action: "edit", id: @user) end def resend_invitation @@ -218,7 +218,7 @@ def destroy Users::DeleteService.new(model: @user, user: User.current).call - flash[:notice] = I18n.t('account.deletion_pending') + flash[:notice] = I18n.t("account.deletion_pending") respond_to do |format| format.html do @@ -228,7 +228,7 @@ def destroy end def deletion_info - render action: 'deletion_info', layout: my_or_admin_layout + render action: "deletion_info", layout: my_or_admin_layout end private @@ -267,9 +267,9 @@ def authorize_for_user respond_to do |format| format.html { render_403 } - format.xml { head :unauthorized, 'WWW-Authenticate' => 'Basic realm="OpenProject API"' } - format.js { head :unauthorized, 'WWW-Authenticate' => 'Basic realm="OpenProject API"' } - format.json { head :unauthorized, 'WWW-Authenticate' => 'Basic realm="OpenProject API"' } + format.xml { head :unauthorized, "WWW-Authenticate" => 'Basic realm="OpenProject API"' } + format.js { head :unauthorized, "WWW-Authenticate" => 'Basic realm="OpenProject API"' } + format.json { head :unauthorized, "WWW-Authenticate" => 'Basic realm="OpenProject API"' } end false @@ -288,9 +288,9 @@ def my_or_admin_layout # TODO: how can this be done better: # check if the route used to call the action is in the 'my' namespace if url_for(:delete_my_account_info) == request.url - 'my' + "my" else - 'admin' + "admin" end end @@ -301,10 +301,10 @@ def set_password?(params) protected def default_breadcrumb - if action_name == 'index' - t('label_user_plural') + if action_name == "index" + t("label_user_plural") else - ActionController::Base.helpers.link_to(t('label_user_plural'), users_path) + ActionController::Base.helpers.link_to(t("label_user_plural"), users_path) end end diff --git a/app/controllers/versions_controller.rb b/app/controllers/versions_controller.rb index 8576812a74a0..9d4d4fd40ae1 100644 --- a/app/controllers/versions_controller.rb +++ b/app/controllers/versions_controller.rb @@ -37,7 +37,7 @@ class VersionsController < ApplicationController before_action :authorize def index - @types = @project.types.order(Arel.sql('position')) + @types = @project.types.order(Arel.sql("position")) retrieve_selected_type_ids(@types, @types.select(&:is_in_roadmap?)) @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_work_packages? : (params[:with_subprojects].to_i == 1) project_ids = @with_subprojects ? @project.self_and_descendants.includes(:wiki).map(&:id) : [@project.id] @@ -76,7 +76,7 @@ def create .new(user: current_user) .call(attributes) - render_cu(call, :notice_successful_create, 'new') + render_cu(call, :notice_successful_create, "new") end def update @@ -88,7 +88,7 @@ def update model: @version) .call(attributes) - render_cu(call, :notice_successful_update, 'edit') + render_cu(call, :notice_successful_update, "edit") end def close_completed @@ -146,7 +146,7 @@ def retrieve_selected_type_ids(selectable_types, default_types = nil) def selected_type_ids(selectable_types, default_types = nil) if (ids = params[:type_ids]) - ids.is_a?(Array) ? ids.map(&:to_s) : ids.split('/') + ids.is_a?(Array) ? ids.map(&:to_s) : ids.split("/") else (default_types || selectable_types).map { |t| t.id.to_s } end diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index 0babd91d5d37..d0b646e7df9b 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -26,7 +26,7 @@ # See COPYRIGHT and LICENSE files for more details. #++ -require 'htmldiff' +require "htmldiff" # The WikiController follows the Rails REST controller pattern but with # a few differences @@ -76,10 +76,10 @@ class WikiController < ApplicationController # List of pages, sorted alphabetically and by parent (hierarchy) def index - slug = wiki_page_title.nil? ? 'wiki' : WikiPage.slug(wiki_page_title) + slug = wiki_page_title.nil? ? "wiki" : WikiPage.slug(wiki_page_title) @related_page = WikiPage.find_by(wiki_id: @wiki.id, slug:) - @pages = @wiki.pages.order(Arel.sql('title')).includes(wiki: :project) + @pages = @wiki.pages.order(Arel.sql("title")).includes(wiki: :project) @pages_by_parent_id = @pages.group_by(&:parent_id) end @@ -92,8 +92,8 @@ def show @page = ::WikiPages::AtVersion.new(@page, version) - if params[:format] == 'markdown' && User.current.allowed_in_project?(:export_wiki_pages, @project) - send_data(@page.text, type: 'text/plain', filename: "#{@page.title}.md") + if params[:format] == "markdown" && User.current.allowed_in_project?(:export_wiki_pages, @project) + send_data(@page.text, type: "text/plain", filename: "#{@page.title}.md") return end @@ -111,7 +111,7 @@ def new_child build_wiki_page @page.parent = old_page - render action: 'new' + render action: "new" end def menu @@ -144,7 +144,7 @@ def create flash[:notice] = I18n.t(:notice_successful_create) redirect_to_show else - render action: 'new' + render action: "new" end end @@ -170,12 +170,12 @@ def update flash[:notice] = I18n.t(:notice_successful_update) redirect_to_show else - render action: 'edit' + render action: "edit" end rescue ActiveRecord::StaleObjectError # Optimistic locking exception flash.now[:error] = I18n.t(:notice_locking_conflict) - render action: 'edit' + render action: "edit" end # rename a page @@ -237,7 +237,7 @@ def update_parent_page redirect_to_show else @parent_pages = @wiki.pages.includes(:parent) - @page.self_and_descendants - render 'edit_parent_page' + render "edit_parent_page" end end @@ -252,7 +252,7 @@ def history @versions = @page .journals .select(:id, :user_id, :notes, :created_at, :version) - .order(Arel.sql('version DESC')) + .order(Arel.sql("version DESC")) .page(page_param) .per_page(per_page_param) @@ -286,12 +286,12 @@ def destroy @descendants_count = @page.descendants.size if @descendants_count > 0 case params[:todo] - when 'nullify' + when "nullify" # Nothing to do - when 'destroy' + when "destroy" # Removes all its descendants @page.descendants.each(&:destroy) - when 'reassign' + when "reassign" # Reassign children to another parent page reassign_to = @wiki.pages.find_by(id: params[:reassign_to_id].presence) return unless reassign_to @@ -308,7 +308,7 @@ def destroy if page = @wiki.find_page(@wiki.start_page) || @wiki.pages.first flash[:notice] = I18n.t(:notice_successful_delete) - redirect_to action: 'index', project_id: @project, id: page + redirect_to action: "index", project_id: @project, id: page else flash[:notice] = I18n.t(:notice_successful_delete) redirect_to project_path(@project) @@ -318,11 +318,11 @@ def destroy # Export wiki to a single html file def export if User.current.allowed_in_project?(:export_wiki_pages, @project) - @pages = @wiki.pages.order(Arel.sql('title')) - export = render_to_string action: 'export_multiple', layout: false - send_data(export, type: 'text/html', filename: 'wiki.html') + @pages = @wiki.pages.order(Arel.sql("title")) + export = render_to_string action: "export_multiple", layout: false + send_data(export, type: "text/html", filename: "wiki.html") else - redirect_to action: 'show', project_id: @project, id: nil + redirect_to action: "show", project_id: @project, id: nil end end @@ -360,7 +360,7 @@ def page_for_menu_item(page) end def wiki_page_title - params[:title] || (action_name == 'new_child' ? '' : params[:id].to_s.capitalize.tr('-', ' ')) + params[:title] || (action_name == "new_child" ? "" : params[:id].to_s.capitalize.tr("-", " ")) end def find_wiki @@ -384,8 +384,8 @@ def handle_new_wiki_page if User.current.allowed_in_project?(:edit_wiki_pages, @project) && editable? edit render action: :new - elsif params[:id] == 'wiki' - flash[:info] = I18n.t('wiki.page_not_editable_index') + elsif params[:id] == "wiki" + flash[:info] = I18n.t("wiki.page_not_editable_index") redirect_to action: :index else render_404 diff --git a/app/controllers/wiki_menu_items_controller.rb b/app/controllers/wiki_menu_items_controller.rb index b3dcb8d87351..6ac9c2358cc6 100644 --- a/app/controllers/wiki_menu_items_controller.rb +++ b/app/controllers/wiki_menu_items_controller.rb @@ -68,7 +68,7 @@ def update get_data_from_params(params) - if wiki_menu_setting == 'no_item' + if wiki_menu_setting == "no_item" unless @wiki_menu_item.nil? if @wiki_menu_item.is_only_main_item? if @page.only_wiki_page? @@ -86,9 +86,9 @@ def update @wiki_menu_item.name = @page.slug @wiki_menu_item.title = wiki_menu_item_params[:title] || @page_title - if wiki_menu_setting == 'sub_item' + if wiki_menu_setting == "sub_item" @wiki_menu_item.parent_id = parent_wiki_menu_item - elsif wiki_menu_setting == 'main_item' + elsif wiki_menu_setting == "main_item" @wiki_menu_item.parent_id = nil assign_wiki_menu_item_params @wiki_menu_item end @@ -101,11 +101,11 @@ def update flash[:notice] = t(:notice_successful_update) end - redirect_back_or_default(action: 'edit', id: @page) + redirect_back_or_default(action: "edit", id: @page) else respond_to do |format| format.html do - render action: 'edit', id: @page + render action: "edit", id: @page end end end @@ -163,15 +163,15 @@ def get_data_from_params(params) end def assign_wiki_menu_item_params(menu_item) - if wiki_menu_item_params[:new_wiki_page] == '1' + if wiki_menu_item_params[:new_wiki_page] == "1" menu_item.new_wiki_page = true - elsif wiki_menu_item_params[:new_wiki_page] == '0' + elsif wiki_menu_item_params[:new_wiki_page] == "0" menu_item.new_wiki_page = false end - if wiki_menu_item_params[:index_page] == '1' + if wiki_menu_item_params[:index_page] == "1" menu_item.index_page = true - elsif wiki_menu_item_params[:index_page] == '0' + elsif wiki_menu_item_params[:index_page] == "0" menu_item.index_page = false end end diff --git a/app/controllers/work_packages/auto_completes_controller.rb b/app/controllers/work_packages/auto_completes_controller.rb index 955140e59050..58152a1e5ff0 100644 --- a/app/controllers/work_packages/auto_completes_controller.rb +++ b/app/controllers/work_packages/auto_completes_controller.rb @@ -26,7 +26,7 @@ # See COPYRIGHT and LICENSE files for more details. #++ -require 'rack/utils' +require "rack/utils" class WorkPackages::AutoCompletesController < ApplicationController def index @@ -41,7 +41,7 @@ def index def work_packages_matching_query_prop Query.new.tap do |query| - query.add_filter(:typeahead, '**', params[:q]) + query.add_filter(:typeahead, "**", params[:q]) query.sort_criteria = [%i[updated_at desc]] query.include_subprojects = true end @@ -52,7 +52,7 @@ def work_packages_matching_query_prop def wp_hashes_with_string(work_packages) work_packages.map do |work_package| - work_package.attributes.merge('to_s' => work_package.to_s) + work_package.attributes.merge("to_s" => work_package.to_s) end end end diff --git a/app/controllers/work_packages/bulk_error_message.rb b/app/controllers/work_packages/bulk_error_message.rb index 05df1e659b17..a0e5a9acf2ad 100644 --- a/app/controllers/work_packages/bulk_error_message.rb +++ b/app/controllers/work_packages/bulk_error_message.rb @@ -33,7 +33,7 @@ module WorkPackages::BulkErrorMessage private def bulk_error_message(selected_work_packages, service_result) - ApplicationController.renderer.render partial: 'work_packages/bulk/errors', + ApplicationController.renderer.render partial: "work_packages/bulk/errors", locals: { service_result:, selected_work_packages: } end diff --git a/app/controllers/work_packages/moves_controller.rb b/app/controllers/work_packages/moves_controller.rb index 3d0cc952d960..42c65161fafa 100644 --- a/app/controllers/work_packages/moves_controller.rb +++ b/app/controllers/work_packages/moves_controller.rb @@ -104,7 +104,7 @@ def default_breadcrumb def check_project_uniqueness unless @project # TODO: let users bulk move/copy work packages from different projects - render_error message: :'work_packages.move.unsupported_for_multiple_projects', status: 400 + render_error message: :"work_packages.move.unsupported_for_multiple_projects", status: 400 false end end @@ -118,7 +118,7 @@ def prepare_for_work_package_move @target_type = @types.find { |t| t.id.to_s == params[:new_type_id].to_s } @available_versions = @target_project.assignable_versions @available_statuses = Workflow.available_statuses(@project) - @notes = params[:notes] || '' + @notes = params[:notes] || "" end def attributes_for_create @@ -126,7 +126,7 @@ def attributes_for_create .move_work_package .compact_blank # 'none' is used in the frontend as a value to unset the property, e.g. the assignee. - .transform_values { |v| v == 'none' ? nil : v } + .transform_values { |v| v == "none" ? nil : v } .to_h end end diff --git a/app/controllers/work_packages/reports_controller.rb b/app/controllers/work_packages/reports_controller.rb index 76be8b1393ac..e1cb28000300 100644 --- a/app/controllers/work_packages/reports_controller.rb +++ b/app/controllers/work_packages/reports_controller.rb @@ -34,16 +34,16 @@ def report reports_service = Reports::ReportsService.new(@project) @reports = [ - reports_service.report_for('type'), - reports_service.report_for('priority'), - reports_service.report_for('assigned_to'), - reports_service.report_for('responsible'), - reports_service.report_for('author'), - reports_service.report_for('version'), - reports_service.report_for('category') + reports_service.report_for("type"), + reports_service.report_for("priority"), + reports_service.report_for("assigned_to"), + reports_service.report_for("responsible"), + reports_service.report_for("author"), + reports_service.report_for("version"), + reports_service.report_for("category") ] - @reports << reports_service.report_for('subproject') if @project.children.any? + @reports << reports_service.report_for("subproject") if @project.children.any? end def report_details diff --git a/app/controllers/work_packages/shares/bulk_controller.rb b/app/controllers/work_packages/shares/bulk_controller.rb index ea553b7657f9..79db00e72854 100644 --- a/app/controllers/work_packages/shares/bulk_controller.rb +++ b/app/controllers/work_packages/shares/bulk_controller.rb @@ -70,7 +70,7 @@ def respond_with_update_permission_buttons @selected_shares.each do |share| replace_via_turbo_stream( component: WorkPackages::Share::PermissionButtonComponent.new(share:, - data: { 'test-selector': 'op-share-wp-update-role' }) + data: { "test-selector": "op-share-wp-update-role" }) ) end diff --git a/app/controllers/work_packages/shares_controller.rb b/app/controllers/work_packages/shares_controller.rb index 8facf685413f..c539a7185685 100644 --- a/app/controllers/work_packages/shares_controller.rb +++ b/app/controllers/work_packages/shares_controller.rb @@ -168,7 +168,7 @@ def respond_with_new_invite_form def respond_with_update_permission_button replace_via_turbo_stream( component: WorkPackages::Share::PermissionButtonComponent.new(share: @share, - data: { 'test-selector': 'op-share-wp-update-role' }) + data: { "test-selector": "op-share-wp-update-role" }) ) respond_with_turbo_streams @@ -223,9 +223,9 @@ def load_query .call(params) # Set default filter on the entity - @query.where('entity_id', '=', @work_package.id) - @query.where('entity_type', '=', WorkPackage.name) - @query.where('project_id', '=', @project.id) + @query.where("entity_id", "=", @work_package.id) + @query.where("entity_type", "=", WorkPackage.name) + @query.where("project_id", "=", @project.id) @query.order(name: :asc) unless params[:sortBy] diff --git a/app/controllers/work_packages_controller.rb b/app/controllers/work_packages_controller.rb index 2b0f2fbfce19..8bbc4624afb4 100644 --- a/app/controllers/work_packages_controller.rb +++ b/app/controllers/work_packages_controller.rb @@ -47,7 +47,7 @@ def index format.html do render :index, locals: { query: @query, project: @project, menu_name: project_or_global_menu }, - layout: 'angular/angular' + layout: "angular/angular" end format.any(*supported_list_formats) do @@ -65,7 +65,7 @@ def show format.html do render :show, locals: { work_package:, menu_name: project_or_global_menu }, - layout: 'angular/angular' + layout: "angular/angular" end format.any(*supported_single_formats) do @@ -90,7 +90,7 @@ def export_list(mime_type) .call(query: @query, mime_type:, params:) .result - if request.headers['Accept']&.include?('application/json') + if request.headers["Accept"]&.include?("application/json") render json: { job_id: } else redirect_to job_status_path(job_id) @@ -110,9 +110,9 @@ def export_single(mime_type) end def atom_journals - render template: 'journals/index', + render template: "journals/index", layout: false, - content_type: 'application/atom+xml', + content_type: "application/atom+xml", locals: { title: "#{Setting.app_title} - #{work_package}", journals: } end @@ -125,7 +125,7 @@ def authorize_on_work_package def per_page_param case params[:format] - when 'atom' + when "atom" Setting.feeds_limit.to_i else super @@ -144,9 +144,9 @@ def journals @journals ||= begin order = if current_user.wants_comments_in_reverse_order? - Journal.arel_table['created_at'].desc + Journal.arel_table["created_at"].desc else - Journal.arel_table['created_at'].asc + Journal.arel_table["created_at"].asc end work_package diff --git a/app/controllers/workflows_controller.rb b/app/controllers/workflows_controller.rb index 00a7ac3b7b0f..26f94fb71b36 100644 --- a/app/controllers/workflows_controller.rb +++ b/app/controllers/workflows_controller.rb @@ -27,7 +27,7 @@ #++ class WorkflowsController < ApplicationController - layout 'admin' + layout "admin" before_action :require_admin @@ -45,7 +45,7 @@ def show end def edit - @used_statuses_only = params[:used_statuses_only] != '0' + @used_statuses_only = params[:used_statuses_only] != "0" statuses_for_form @@ -57,21 +57,21 @@ def edit def update call = Workflows::BulkUpdateService .new(role: @role, type: @type) - .call(params['status']) + .call(params["status"]) if call.success? flash[:notice] = I18n.t(:notice_successful_update) - redirect_to action: 'edit', role_id: @role, type_id: @type + redirect_to action: "edit", role_id: @role, type_id: @type end end def copy - @source_type = if params[:source_type_id].blank? || params[:source_type_id] == 'any' + @source_type = if params[:source_type_id].blank? || params[:source_type_id] == "any" nil else ::Type.find(params[:source_type_id]) end - @source_role = if params[:source_role_id].blank? || params[:source_role_id] == 'any' + @source_role = if params[:source_role_id].blank? || params[:source_role_id] == "any" nil else eligible_roles.find(params[:source_role_id]) @@ -88,16 +88,16 @@ def copy else Workflow.copy(@source_type, @source_role, @target_types, @target_roles) flash[:notice] = I18n.t(:notice_successful_update) - redirect_to action: 'copy', source_type_id: @source_type, source_role_id: @source_role + redirect_to action: "copy", source_type_id: @source_type, source_role_id: @source_role end end end def default_breadcrumb - if action_name == 'edit' - t('label_workflow') + if action_name == "edit" + t("label_workflow") else - ActionController::Base.helpers.link_to(t('label_workflow'), url_for(controller: '/workflows', action: 'edit')) + ActionController::Base.helpers.link_to(t("label_workflow"), url_for(controller: "/workflows", action: "edit")) end end @@ -118,9 +118,9 @@ def statuses_for_form def workflows_for_form workflows = Workflow.where(role_id: @role.id, type_id: @type.id) @workflows = {} - @workflows['always'] = workflows.select { |w| !w.author && !w.assignee } - @workflows['author'] = workflows.select(&:author) - @workflows['assignee'] = workflows.select(&:assignee) + @workflows["always"] = workflows.select { |w| !w.author && !w.assignee } + @workflows["author"] = workflows.select(&:author) + @workflows["assignee"] = workflows.select(&:assignee) end def find_roles diff --git a/app/forms/queries/projects/create.rb b/app/forms/queries/projects/create.rb index c53f999538f1..f6cc39ce1a29 100644 --- a/app/forms/queries/projects/create.rb +++ b/app/forms/queries/projects/create.rb @@ -35,9 +35,9 @@ class Queries::Projects::Create < ApplicationForm visually_hide_label: true, required: true, autofocus: true, - name: 'name', + name: "name", label: Queries::Projects::ProjectQuery.human_attribute_name(:name), - placeholder: I18n.t(:'projects.lists.new.placeholder') + placeholder: I18n.t(:"projects.lists.new.placeholder") ) group.submit( @@ -51,7 +51,7 @@ class Queries::Projects::Create < ApplicationForm scheme: :secondary, label: I18n.t(:button_cancel), tag: :a, - data: { 'params-from-query-target': 'anchor' }, + data: { "params-from-query-target": "anchor" }, href: OpenProject::StaticRouting::StaticUrlHelpers.new.projects_path ) end diff --git a/app/helpers/accessibility_helper.rb b/app/helpers/accessibility_helper.rb index 3568ac8ddc83..155fd8269faa 100644 --- a/app/helpers/accessibility_helper.rb +++ b/app/helpers/accessibility_helper.rb @@ -33,12 +33,12 @@ def you_are_here_info(condition = true, disabled = nil) elsif condition && disabled "".html_safe else - '' + "" end end def empty_element_tag - @empty_element_tag ||= ApplicationController.new.render_to_string(partial: 'accessibility/empty_element_tag').html_safe + @empty_element_tag ||= ApplicationController.new.render_to_string(partial: "accessibility/empty_element_tag").html_safe end # Returns the locale :en for the given menu item if the user locale is diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb index 4c62e7e928b3..d7578d9c5bb5 100644 --- a/app/helpers/admin_helper.rb +++ b/app/helpers/admin_helper.rb @@ -28,13 +28,13 @@ module AdminHelper def project_status_options_for_select(selected) - options_for_select([[I18n.t(:label_all), ''], + options_for_select([[I18n.t(:label_all), ""], [I18n.t(:status_active), 1]], selected) end def linked_sha_reference(sha, url) if sha && url - link_to sha, url, target: '_blank', rel: 'noopener' + link_to sha, url, target: "_blank", rel: "noopener" else sha end diff --git a/app/helpers/angular_helper.rb b/app/helpers/angular_helper.rb index be0fb75e6146..a287f2b40aa1 100644 --- a/app/helpers/angular_helper.rb +++ b/app/helpers/angular_helper.rb @@ -38,10 +38,10 @@ def angular_component_tag(component, options = {}) .transform_values(&:to_json) options[:data] = options.fetch(:data, {}).merge(inputs) - options[:class] ||= [options[:class], 'op-angular-component'] + options[:class] ||= [options[:class], "op-angular-component"] .compact - .join(' ') + .join(" ") - content_tag(component, '', options) + content_tag(component, "", options) end end diff --git a/app/helpers/announcements_helper.rb b/app/helpers/announcements_helper.rb index ef727a2ddba7..891b354e69b5 100644 --- a/app/helpers/announcements_helper.rb +++ b/app/helpers/announcements_helper.rb @@ -1,9 +1,9 @@ module AnnouncementsHelper def notice_annoucement_active if @announcement.active_and_current? - I18n.t(:'announcements.is_active') + I18n.t(:"announcements.is_active") else - I18n.t(:'announcements.is_inactive') + I18n.t(:"announcements.is_inactive") end end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 86113995dcac..5a1610f8a357 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -26,8 +26,8 @@ # See COPYRIGHT and LICENSE files for more details. #++ -require 'forwardable' -require 'cgi' +require "forwardable" +require "cgi" module ApplicationHelper include OpenProject::TextFormatting @@ -72,8 +72,8 @@ def link_to_if_authorized(*args, &) end end - def required_field_name(name = '') - safe_join [name, ' ', content_tag('span', '*', class: 'required')] + def required_field_name(name = "") + safe_join [name, " ", content_tag("span", "*", class: "required")] end def li_unless_nil(link, options = {}) @@ -82,12 +82,12 @@ def li_unless_nil(link, options = {}) # Show a sorted linkified (if active) comma-joined list of users def list_users(users, options = {}) - users.sort.map { |u| link_to_user(u, options) }.join(', ') + users.sort.map { |u| link_to_user(u, options) }.join(", ") end # returns a class name based on the user's status def user_status_class(user) - 'status_' + user.status + "status_" + user.status end def user_status_i18n(user) @@ -98,7 +98,7 @@ def delete_link(url, options = {}) options = { method: :delete, data: { confirm: I18n.t(:text_are_you_sure) }, - class: 'icon icon-delete' + class: "icon icon-delete" }.merge(options) link_to I18n.t(:button_delete), url, options @@ -123,7 +123,7 @@ def project_tree(projects, &) end def project_nested_ul(projects, &) - s = '' + s = "" if projects.any? ancestors = [] Project.project_tree(projects) do |project, _level| @@ -131,13 +131,13 @@ def project_nested_ul(projects, &) s << "\n" end end - s << '
  • ' + s << "
  • " s << yield(project).to_s ancestors << project end @@ -154,7 +154,7 @@ def principals_check_box_tags(name, principals) def labeled_check_box_tags(name, collection, options = {}) collection.sort.map do |object| - id = name.gsub(/[\[\]]+/, '_') + object.id.to_s + id = name.gsub(/[\[\]]+/, "_") + object.id.to_s object_options = options.inject({}) do |h, (k, v)| h[k] = v.is_a?(Symbol) ? send(v, object) : v @@ -163,7 +163,7 @@ def labeled_check_box_tags(name, collection, options = {}) object_options[:class] = Array(object_options[:class]) + %w(form--label-with-check-box) - content_tag :div, class: 'form--field' do + content_tag :div, class: "form--field" do label_tag(id, object, object_options) do styled_check_box_tag(name, object.id, false, id:) + object.to_s end @@ -185,7 +185,7 @@ def authoring(created, author, options = {}) def authoring_at(created, author) return if author.nil? - I18n.t(:'js.label_added_time_by', + I18n.t(:"js.label_added_time_by", author: html_escape(author.name), age: created, authorLink: user_path(author)).html_safe @@ -193,16 +193,16 @@ def authoring_at(created, author) def time_tag(time) text = distance_of_time_in_words(Time.now, time) - if @project and @project.module_enabled?('activity') - link_to(text, { controller: '/activities', - action: 'index', + if @project and @project.module_enabled?("activity") + link_to(text, { controller: "/activities", + action: "index", project_id: @project, from: time.to_date }, title: format_time(time)) else datetime = time.acts_like?(:time) ? time.xmlschema : time.iso8601 content_tag(:time, text, datetime:, - title: format_time(time), class: 'timestamp') + title: format_time(time), class: "timestamp") end end @@ -220,7 +220,7 @@ def to_path_param(path) def other_formats_links(&) formats = capture(Redmine::Views::OtherFormatsBuilder.new(self), &) unless formats.nil? || formats.strip.empty? - content_tag 'p', class: 'other-formats' do + content_tag "p", class: "other-formats" do (I18n.t(:label_export_to) + formats).html_safe end end @@ -229,11 +229,11 @@ def other_formats_links(&) # Returns the theme, controller name, and action as css classes for the # HTML body. def body_css_classes - css = ['theme-' + OpenProject::CustomStyles::Design.identifier.to_s] + css = ["theme-" + OpenProject::CustomStyles::Design.identifier.to_s] if params[:controller] && params[:action] - css << ('controller-' + params[:controller]) - css << ('action-' + params[:action]) + css << ("controller-" + params[:controller]) + css << ("action-" + params[:action]) end css << "ee-banners-#{EnterpriseToken.show_banners? ? 'visible' : 'hidden'}" @@ -243,7 +243,7 @@ def body_css_classes # Add browser specific classes to aid css fixes css += browser_specific_classes - css.join(' ') + css.join(" ") end def accesskey(s) @@ -254,14 +254,14 @@ def accesskey(s) def simple_format_without_paragraph(text) text.to_s .gsub(/\r\n?/, "\n") # \r\n and \r -> \n - .gsub(/\n\n+/, '

    ') # 2+ newline -> 2 br + .gsub(/\n\n+/, "

    ") # 2+ newline -> 2 br .gsub(/([^\n]\n)(?=[^\n])/, '\1
    ') # 1 newline -> br .html_safe end def lang_options_for_select(blank = true) auto = if blank && (valid_languages - all_languages) == (all_languages - valid_languages) - [['(auto)', '']] + [["(auto)", ""]] else [] end @@ -279,8 +279,8 @@ def all_lang_options_for_select def theme_options_for_select [ - [t('themes.light'), 'light'], - [t('themes.light_high_contrast'), 'light_high_contrast'] + [t("themes.light"), "light"], + [t("themes.light_high_contrast"), "light_high_contrast"] ] end @@ -292,7 +292,7 @@ def user_theme_data_attributes def highlight_default_language(lang_options) lang_options.map do |(language_name, code)| if code == Setting.default_language - [I18n.t('settings.language_name_being_default', language_name:), code, { disabled: true, checked: true }] + [I18n.t("settings.language_name_being_default", language_name:), code, { disabled: true, checked: true }] else [language_name, code] end @@ -301,14 +301,14 @@ def highlight_default_language(lang_options) def labelled_tabular_form_for(record, options = {}, &) options.reverse_merge!(builder: TabularFormBuilder, html: {}) - options[:html][:class] = 'form' unless options[:html].has_key?(:class) + options[:html][:class] = "form" unless options[:html].has_key?(:class) form_for(record, options, &) end def back_url_hidden_field_tag(use_referer: true) - back_url = params[:back_url] || (use_referer ? request.env['HTTP_REFERER'] : nil) + back_url = params[:back_url] || (use_referer ? request.env["HTTP_REFERER"] : nil) back_url = CGI.unescape(back_url.to_s) - hidden_field_tag('back_url', CGI.escape(back_url), id: nil) if back_url.present? + hidden_field_tag("back_url", CGI.escape(back_url), id: nil) if back_url.present? end def back_url_to_current_page_hidden_field_tag @@ -319,12 +319,12 @@ def back_url_to_current_page_hidden_field_tag back_url = request.url end - hidden_field_tag('back_url', back_url) if back_url.present? + hidden_field_tag("back_url", back_url) if back_url.present? end def check_all_links(form_name) link_to_function(t(:button_check_all), "OpenProject.helpers.checkAll('#{form_name}', true)") + - ' | ' + + " | " + link_to_function(t(:button_uncheck_all), "OpenProject.helpers.checkAll('#{form_name}', false)") end @@ -347,23 +347,23 @@ def progress_bar(pcts, options = {}) pcts = Array(pcts).map(&:round) closed = pcts[0] done = pcts[1] || 0 - width = options[:width] || '100px;' - legend = options[:legend] || '' - total_progress = options[:hide_total_progress] ? '' : t(:total_progress) - percent_sign = options[:hide_percent_sign] ? '' : '%' + width = options[:width] || "100px;" + legend = options[:legend] || "" + total_progress = options[:hide_total_progress] ? "" : t(:total_progress) + percent_sign = options[:hide_percent_sign] ? "" : "%" content_tag :span do - progress = content_tag :span, class: 'progress-bar', style: "width: #{width}" do - concat content_tag(:span, '', class: 'inner-progress closed', style: "width: #{closed}%") - concat content_tag(:span, '', class: 'inner-progress done', style: "width: #{done}%") + progress = content_tag :span, class: "progress-bar", style: "width: #{width}" do + concat content_tag(:span, "", class: "inner-progress closed", style: "width: #{closed}%") + concat content_tag(:span, "", class: "inner-progress done", style: "width: #{done}%") end - progress + content_tag(:span, "#{legend}#{percent_sign} #{total_progress}", class: 'progress-bar-legend') + progress + content_tag(:span, "#{legend}#{percent_sign} #{total_progress}", class: "progress-bar-legend") end end def checked_image(checked = true) if checked - icon_wrapper('icon-context icon-checkmark', t(:label_checked)) + icon_wrapper("icon-context icon-checkmark", t(:label_checked)) end end @@ -375,41 +375,41 @@ def calendar_for(*_args) def locale_first_day_of_week case Setting.start_of_week.to_i when 1 - '1' # Monday + "1" # Monday when 7 - '0' # Sunday + "0" # Sunday when 6 - '6' # Saturday + "6" # Saturday else # use language default (pass a blank string) and moment.js will reuse existing info # /frontend/src/main.ts - '' + "" end end def locale_first_week_of_year case Setting.first_week_of_year.to_i when 1 - '1' # Monday + "1" # Monday when 4 - '4' # Thursday + "4" # Thursday else # use language default (pass a blank string) and moment.js will reuse existing info # /frontend/src/main.ts - '' + "" end end # To avoid the menu flickering, disable it # by default unless we're in test mode def initial_menu_styles(side_displayed) - Rails.env.test? || !side_displayed ? '' : 'display:none' + Rails.env.test? || !side_displayed ? "" : "display:none" end def initial_menu_classes(side_displayed, show_decoration) - classes = 'can-hide-navigation' - classes << ' nosidebar' unless side_displayed - classes << ' nomenus' unless show_decoration + classes = "can-hide-navigation" + classes << " nosidebar" unless side_displayed + classes << " nomenus" unless show_decoration classes end @@ -418,7 +418,7 @@ def initial_menu_classes(side_displayed, show_decoration) # # @param [optional, String] content the content of the ROBOTS tag. # defaults to no index, follow, and no archive - def robot_exclusion_tag(content = 'NOINDEX,FOLLOW,NOARCHIVE') + def robot_exclusion_tag(content = "NOINDEX,FOLLOW,NOARCHIVE") "".html_safe end @@ -437,7 +437,7 @@ def translate_language(lang_code) ::I18n.locale != Redmine::I18n::IN_CONTEXT_TRANSLATION_CODE [Redmine::I18n::IN_CONTEXT_TRANSLATION_NAME, lang_code.to_s] else - [I18n.t('cldr.language_name', locale: lang_code), lang_code.to_s] + [I18n.t("cldr.language_name", locale: lang_code), lang_code.to_s] end end @@ -450,8 +450,8 @@ def password_complexity_requirements # use 0..0, so this doesn't fail if rules is an empty string rules[0] = rules[0..0].upcase - s = raw '' + OpenProject::Passwords::Evaluator.min_length_description + '' - s += raw '
    ' + rules + '' unless rules.empty? + s = raw "" + OpenProject::Passwords::Evaluator.min_length_description + "" + s += raw "
    " + rules + "" unless rules.empty? s end end diff --git a/app/helpers/appsignal_helper.rb b/app/helpers/appsignal_helper.rb index 9203f4878fc9..592f1d7c0e17 100644 --- a/app/helpers/appsignal_helper.rb +++ b/app/helpers/appsignal_helper.rb @@ -1,9 +1,9 @@ module AppsignalHelper def appsignal_frontend_tag - return '' unless OpenProject::Configuration.appsignal_frontend_key + return "" unless OpenProject::Configuration.appsignal_frontend_key tag :meta, - name: 'openproject_appsignal', + name: "openproject_appsignal", data: { push_key: OpenProject::Configuration.appsignal_frontend_key, version: OpenProject::VERSION.to_s diff --git a/app/helpers/archived_projects_helper.rb b/app/helpers/archived_projects_helper.rb index 7246f0f8a2bb..20535782cba4 100644 --- a/app/helpers/archived_projects_helper.rb +++ b/app/helpers/archived_projects_helper.rb @@ -31,19 +31,19 @@ def archived_projects_urls_for(projects) urls = projects.map do |project| link_to project.name, projects_path(filters: archived_project_filters_for(project)), - target: '_blank', - rel: 'noopener' + target: "_blank", + rel: "noopener" end - safe_join(urls, ', ') + safe_join(urls, ", ") end private def archived_project_filters_for(project) [ - { active: { operator: '=', values: ['f'] } }, - { name_and_identifier: { operator: '=', values: [html_escape(project.name)] } } + { active: { operator: "=", values: ["f"] } }, + { name_and_identifier: { operator: "=", values: [html_escape(project.name)] } } ].to_json end end diff --git a/app/helpers/attachments_helper.rb b/app/helpers/attachments_helper.rb index 9d71015f3b6b..368ad7e253a3 100644 --- a/app/helpers/attachments_helper.rb +++ b/app/helpers/attachments_helper.rb @@ -29,10 +29,10 @@ module AttachmentsHelper def to_utf8_for_attachments(str) forced_str = str.dup - forced_str.force_encoding('UTF-8') + forced_str.force_encoding("UTF-8") return forced_str if forced_str.valid_encoding? - str.encode('UTF-8', invalid: :replace, undef: :replace, replace: '') # better replace: '?' + str.encode("UTF-8", invalid: :replace, undef: :replace, replace: "") # better replace: '?' end ## @@ -42,11 +42,11 @@ def to_utf8_for_attachments(str) # Within ckeditor-augmented-textarea-form, this attachment list is added automatically # when a resource is added. def list_attachments(resource, options = {}) - content_tag 'op-attachments', - '', - 'data-resource': resource.to_json, - 'data-allow-uploading': false, - 'data-destroy-immediately': true, + content_tag "op-attachments", + "", + "data-resource": resource.to_json, + "data-allow-uploading": false, + "data-destroy-immediately": true, **options end end diff --git a/app/helpers/augmenting_helper.rb b/app/helpers/augmenting_helper.rb index a86884220676..dd3f5ccf4b03 100644 --- a/app/helpers/augmenting_helper.rb +++ b/app/helpers/augmenting_helper.rb @@ -37,7 +37,7 @@ module AugmentingHelper # @param block [Block] A block that renders the section's body. def augmented_collapsible_section(title:, initiallyExpanded: true, &block) render( - partial: '/augmented/collapsible_section', + partial: "/augmented/collapsible_section", locals: { title:, initiallyExpanded: !!initiallyExpanded, block: } ) end diff --git a/app/helpers/browser_helper.rb b/app/helpers/browser_helper.rb index c3b3190eb06e..73e076d21111 100644 --- a/app/helpers/browser_helper.rb +++ b/app/helpers/browser_helper.rb @@ -32,14 +32,14 @@ def unsupported_browser? # or mobile detection def browser_specific_classes [].tap do |classes| - classes << '-browser-chrome' if browser.chrome? - classes << '-browser-firefox' if browser.firefox? - classes << '-browser-safari' if browser.safari? - classes << '-browser-edge' if browser.edge? - - classes << '-browser-mobile' if browser.device.mobile? - classes << '-browser-windows' if browser.platform.windows? - classes << '-unsupported-browser' if unsupported_browser? + classes << "-browser-chrome" if browser.chrome? + classes << "-browser-firefox" if browser.firefox? + classes << "-browser-safari" if browser.safari? + classes << "-browser-edge" if browser.edge? + + classes << "-browser-mobile" if browser.device.mobile? + classes << "-browser-windows" if browser.platform.windows? + classes << "-unsupported-browser" if unsupported_browser? end end end diff --git a/app/helpers/calendars_helper.rb b/app/helpers/calendars_helper.rb index 4cdf772bb153..8273fc5b3bff 100644 --- a/app/helpers/calendars_helper.rb +++ b/app/helpers/calendars_helper.rb @@ -35,7 +35,7 @@ module CalendarsHelper # @return [String] link to the calendar def link_to_previous_month(year, month, options = {}) target_date = Date.new(year, month, 1) - 1.month - link_to_month(target_date, options.merge(class: 'navigate-left', + link_to_month(target_date, options.merge(class: "navigate-left", display_year: target_date.year != year)) end @@ -46,7 +46,7 @@ def link_to_previous_month(year, month, options = {}) # @return [String] link to the calendar def link_to_next_month(year, month, options = {}) target_date = Date.new(year, month, 1) + 1.month - link_to_month(target_date, options.merge(class: 'navigate-right', + link_to_month(target_date, options.merge(class: "navigate-right", display_year: target_date.year != year)) end @@ -57,7 +57,7 @@ def link_to_next_month(year, month, options = {}) # @return [String] link to the calendar def link_to_month(date_to_show, options = {}) date = date_to_show.to_date - name = ::I18n.l date, format: options.delete(:display_year) ? '%B %Y' : '%B' + name = ::I18n.l date, format: options.delete(:display_year) ? "%B %Y" : "%B" merged_params = permitted_params .calendar_filter diff --git a/app/helpers/colors_helper.rb b/app/helpers/colors_helper.rb index 618eaa53b534..c2dfcd88511b 100644 --- a/app/helpers/colors_helper.rb +++ b/app/helpers/colors_helper.rb @@ -37,7 +37,7 @@ def options_for_colors(colored_thing) color: c.hexcode, bright: c.bright?, dark: c.dark?, - background: c.contrasting_color(light_color: 'transparent') + background: c.contrasting_color(light_color: "transparent") } options[:selected] = true if c.id == colored_thing.color_id @@ -51,9 +51,9 @@ def selected_color(colored_thing) end def colored_text(color) - background = color.contrasting_color(dark_color: '#333', light_color: 'transparent') + background = color.contrasting_color(dark_color: "#333", light_color: "transparent") style = "background-color: #{background}; color: #{color.hexcode}" - content_tag(:span, color.hexcode, class: 'color--text-preview', style:) + content_tag(:span, color.hexcode, class: "color--text-preview", style:) end # @@ -81,16 +81,16 @@ def resource_color_css(name, scope) end styles = color.color_styles - background_style = styles.map { |k, v| "#{k}:#{v} !important" }.join(';') + background_style = styles.map { |k, v| "#{k}:#{v} !important" }.join(";") - if name === 'type' + if name === "type" concat ".__hl_inline_#{name}_#{entry.id} { color: #{color.hexcode} !important;}" concat ".__hl_inline_#{name}_#{entry.id} { -webkit-text-stroke: 0.5px grey;}" if color.super_bright? - border_color = color.super_bright? ? '#555555' : color.hexcode + border_color = color.super_bright? ? "#555555" : color.hexcode concat ".__hl_background_#{name}_#{entry.id} { border-color: #{border_color} !important; }" else - border_color = color.bright? ? '#555555' : color.hexcode + border_color = color.bright? ? "#555555" : color.hexcode concat ".__hl_inline_#{name}_#{entry.id}::before { #{background_style}; border-color: #{border_color}; }\n" end @@ -107,11 +107,11 @@ def resource_color_css(name, scope) def icon_for_color(color, options = {}) return unless color - options.merge! class: 'color--preview ' + options[:class].to_s, + options.merge! class: "color--preview " + options[:class].to_s, title: color.name, style: "background-color: #{color.hexcode};" + options[:style].to_s - content_tag(:span, ' ', options) + content_tag(:span, " ", options) end def color_by_variable(variable) diff --git a/app/helpers/confirmation_dialog_helper.rb b/app/helpers/confirmation_dialog_helper.rb index a7e41f366328..a0f7eed4a362 100644 --- a/app/helpers/confirmation_dialog_helper.rb +++ b/app/helpers/confirmation_dialog_helper.rb @@ -45,7 +45,7 @@ def augmented_confirmation_dialog( passed_data: nil ) { - 'augmented-confirm-dialog': { + "augmented-confirm-dialog": { text: { title:, text:, diff --git a/app/helpers/error_message_helper.rb b/app/helpers/error_message_helper.rb index 6b3205e4f3ac..1c435aafe894 100644 --- a/app/helpers/error_message_helper.rb +++ b/app/helpers/error_message_helper.rb @@ -38,12 +38,12 @@ def error_messages_for(object) end def render_error_messages_partial(errors, object) - return '' if errors.empty? + return "" if errors.empty? base_error_messages = errors.full_messages_for(:base) fields_error_messages = errors.full_messages - base_error_messages - render partial: 'common/validation_error', + render partial: "common/validation_error", locals: { base_error_messages:, fields_error_messages:, object_name: object.class.model_name.human } @@ -52,7 +52,7 @@ def render_error_messages_partial(errors, object) def text_header_invalid_fields(base_error_messages, fields_error_messages) return if fields_error_messages.blank? - i18n_key = base_error_messages.present? ? 'errors.header_additional_invalid_fields' : 'errors.header_invalid_fields' + i18n_key = base_error_messages.present? ? "errors.header_additional_invalid_fields" : "errors.header_invalid_fields" t(i18n_key, count: fields_error_messages.count) end diff --git a/app/helpers/errors_helper.rb b/app/helpers/errors_helper.rb index f1af78315794..a7c389dfe810 100644 --- a/app/helpers/errors_helper.rb +++ b/app/helpers/errors_helper.rb @@ -94,7 +94,7 @@ def render_error(arg) @message_details = arg[:message_details] respond_to do |format| format.html do - render template: 'common/error', layout: use_layout, status: @status + render template: "common/error", layout: use_layout, status: @status end format.any do head @status diff --git a/app/helpers/flash_messages_helper.rb b/app/helpers/flash_messages_helper.rb index edd9139efb7d..0fc868657ed8 100644 --- a/app/helpers/flash_messages_helper.rb +++ b/app/helpers/flash_messages_helper.rb @@ -50,7 +50,7 @@ def render_flash_messages return if render_primer_banner_message? messages = flash - .reject { |k, _| k.start_with? '_' } + .reject { |k, _| k.start_with? "_" } .map do |k, v| if k.to_sym == :modal component = v[:type].constantize @@ -65,31 +65,31 @@ def render_flash_messages def join_flash_messages(messages) if messages.respond_to?(:join) - safe_join(messages, '
    '.html_safe) + safe_join(messages, "
    ".html_safe) else messages end end def render_flash_message(type, message, html_options = {}) # rubocop:disable Metrics/AbcSize - if type.to_s == 'notice' - type = 'success' + if type.to_s == "notice" + type = "success" end toast_css_classes = ["op-toast -#{type}", html_options.delete(:class)] # Add autohide class to notice flashes if configured - if type.to_s == 'success' && User.current.pref.auto_hide_popups? - toast_css_classes << 'autohide-toaster' + if type.to_s == "success" && User.current.pref.auto_hide_popups? + toast_css_classes << "autohide-toaster" end - html_options = { class: toast_css_classes.join(' '), role: 'alert' }.merge(html_options) - close_button = content_tag :a, '', class: 'op-toast--close icon-context icon-close', - title: I18n.t('js.close_popup_title'), - tabindex: '0' - toast = content_tag(:div, join_flash_messages(message), class: 'op-toast--content') - content_tag :div, '', class: 'op-toast--wrapper' do - content_tag :div, '', class: 'op-toast--casing' do + html_options = { class: toast_css_classes.join(" "), role: "alert" }.merge(html_options) + close_button = content_tag :a, "", class: "op-toast--close icon-context icon-close", + title: I18n.t("js.close_popup_title"), + tabindex: "0" + toast = content_tag(:div, join_flash_messages(message), class: "op-toast--content") + content_tag :div, "", class: "op-toast--wrapper" do + content_tag :div, "", class: "op-toast--casing" do content_tag :div, html_options do concat(close_button) concat(toast) diff --git a/app/helpers/groups_helper.rb b/app/helpers/groups_helper.rb index 24a0baddcb97..f64b3ef16da7 100644 --- a/app/helpers/groups_helper.rb +++ b/app/helpers/groups_helper.rb @@ -30,26 +30,26 @@ module GroupsHelper def group_settings_tabs(group) [ { - name: 'general', - partial: 'groups/general', + name: "general", + partial: "groups/general", path: edit_group_path(group), label: :label_general }, { - name: 'users', - partial: 'groups/users', + name: "users", + partial: "groups/users", path: edit_group_path(group, tab: :users), label: :label_user_plural }, { - name: 'memberships', - partial: 'groups/memberships', + name: "memberships", + partial: "groups/memberships", path: edit_group_path(group, tab: :memberships), label: :label_project_plural }, { - name: 'global_roles', - partial: 'principals/global_roles', + name: "global_roles", + partial: "principals/global_roles", path: edit_group_path(group, tab: :global_roles), label: :label_global_roles } @@ -58,8 +58,8 @@ def group_settings_tabs(group) def autocompleter_filters(group) [ - { name: 'status', operator: '=', values: ['active', 'invited'] }, - { name: 'group', operator: '!', values: [group.id] } + { name: "status", operator: "=", values: ["active", "invited"] }, + { name: "group", operator: "!", values: [group.id] } ] end end diff --git a/app/helpers/homescreen_helper.rb b/app/helpers/homescreen_helper.rb index 06bdf8d6452a..e0c624877b78 100644 --- a/app/helpers/homescreen_helper.rb +++ b/app/helpers/homescreen_helper.rb @@ -36,7 +36,7 @@ def organization_name ## # Homescreen organization icon def organization_icon - op_icon('icon-context icon-enterprise') + op_icon("icon-context icon-enterprise") end ## @@ -48,7 +48,7 @@ def static_link_to(key) link_to label, link[:href], title: label, - target: '_blank', rel: 'noopener' + target: "_blank", rel: "noopener" end ## diff --git a/app/helpers/hook_helper.rb b/app/helpers/hook_helper.rb index c4e4a81b86cd..40e10e1e5dab 100644 --- a/app/helpers/hook_helper.rb +++ b/app/helpers/hook_helper.rb @@ -27,7 +27,7 @@ def call_hook(hook, context = {}) default_context = { project: @project, hook_caller: self } default_context[:controller] = controller if respond_to?(:controller) default_context[:request] = request if respond_to?(:request) - OpenProject::Hook.call_hook(hook, default_context.merge(context)).join(' ').html_safe + OpenProject::Hook.call_hook(hook, default_context.merge(context)).join(" ").html_safe end end end diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb index 33a794a2285d..b9b6db8386ab 100644 --- a/app/helpers/icons_helper.rb +++ b/app/helpers/icons_helper.rb @@ -43,7 +43,7 @@ def spot_icon(icon_name, title: nil, size: nil, inline: false, classnames: nil) inline ? "spot-icon_inline" : nil, "spot-icon_#{icon_name}", classnames - ].compact.join(' ') + ].compact.join(" ") content_tag(:span, title, class: classes) end @@ -52,7 +52,7 @@ def spot_icon(icon_name, title: nil, size: nil, inline: false, classnames: nil) # Icon wrapper with an invisible label def icon_wrapper(icon_class, label) content = op_icon(icon_class) - content << content_tag(:span, label, class: 'hidden-for-sighted') + content << content_tag(:span, label, class: "hidden-for-sighted") content end end diff --git a/app/helpers/journals_helper.rb b/app/helpers/journals_helper.rb index 1682c1e96edc..1fcd32af5b64 100644 --- a/app/helpers/journals_helper.rb +++ b/app/helpers/journals_helper.rb @@ -30,14 +30,14 @@ module JournalsHelper def back_to_activity_page_url(activity_page) - case activity_page&.split('/') - in ['all'] + case activity_page&.split("/") + in ["all"] activities_url - in ['projects', project_id] + in ["projects", project_id] project_activities_url(project_id) - in ['users', user_id] + in ["users", user_id] user_url(user_id) - in ['work_packages', work_package_id] + in ["work_packages", work_package_id] work_package_url(work_package_id) else nil diff --git a/app/helpers/mail_digest_helper.rb b/app/helpers/mail_digest_helper.rb index a299e59289cc..a449114a15a1 100644 --- a/app/helpers/mail_digest_helper.rb +++ b/app/helpers/mail_digest_helper.rb @@ -28,8 +28,8 @@ module MailDigestHelper def digest_summary_text(notification_count, mentioned_count) - mentioned = mentioned_count > 1 ? 'plural' : 'singular' - notifications = notification_count > 1 ? 'plural' : 'singular' + mentioned = mentioned_count > 1 ? "plural" : "singular" + notifications = notification_count > 1 ? "plural" : "singular" summary = I18n.t(:"mail.digests.unread_notification_#{notifications}", number_unread: notification_count).to_s @@ -63,7 +63,7 @@ def digest_additional_author_text(notifications) number_of_additional_authors = number_of_authors(notifications) - 1 if notifications.length > 1 && number_of_additional_authors > 0 - amount = number_of_additional_authors === 1 ? 'one' : 'other' + amount = number_of_additional_authors === 1 ? "one" : "other" I18n.t(:"js.notifications.center.and_more_users.#{amount}", count: number_of_additional_authors) end end @@ -76,7 +76,7 @@ def timestamp_text(user, journal) I18n.t(:"mail.work_packages.#{value}_at", user:, timestamp: journal.created_at.strftime( - "#{I18n.t(:'date.formats.default')}, #{I18n.t(:'time.formats.time')}" + "#{I18n.t(:"date.formats.default")}, #{I18n.t(:"time.formats.time")}" )) ) end @@ -100,27 +100,27 @@ def text_modifiers_for(notification, value) end def build_property_text(notification, is_overdue, days_diff) - return I18n.t('js.notifications.date_alerts.overdue') if is_overdue && days_diff > 0 - return I18n.t('js.notifications.date_alerts.milestone_date') if notification.resource.milestone? - return I18n.t('js.work_packages.properties.startDate') if notification.reason == "date_alert_start_date" + return I18n.t("js.notifications.date_alerts.overdue") if is_overdue && days_diff > 0 + return I18n.t("js.notifications.date_alerts.milestone_date") if notification.resource.milestone? + return I18n.t("js.work_packages.properties.startDate") if notification.reason == "date_alert_start_date" - I18n.t('js.work_packages.properties.dueDate') + I18n.t("js.work_packages.properties.dueDate") end def build_alert_text(date_value, is_past, is_overdue, days_diff) - return I18n.t('js.notifications.date_alerts.property_is_deleted') unless date_value - return I18n.t('js.notifications.date_alerts.property_today') if days_diff == 0 + return I18n.t("js.notifications.date_alerts.property_is_deleted") unless date_value + return I18n.t("js.notifications.date_alerts.property_today") if days_diff == 0 - days_text = I18n.t('js.units.day', count: days_diff) - return I18n.t('js.notifications.date_alerts.overdue_since', difference_in_days: days_text) if is_overdue - return I18n.t('js.notifications.date_alerts.property_was', difference_in_days: days_text) if is_past + days_text = I18n.t("js.units.day", count: days_diff) + return I18n.t("js.notifications.date_alerts.overdue_since", difference_in_days: days_text) if is_overdue + return I18n.t("js.notifications.date_alerts.property_was", difference_in_days: days_text) if is_past - I18n.t('js.notifications.date_alerts.property_is', difference_in_days: days_text) + I18n.t("js.notifications.date_alerts.property_is", difference_in_days: days_text) end def highlight_overdue(text, is_overdue, html) return text unless html && is_overdue - content_tag :span, text, style: 'color: #C92A2A' + content_tag :span, text, style: "color: #C92A2A" end end diff --git a/app/helpers/mail_layout_helper.rb b/app/helpers/mail_layout_helper.rb index 3ca91ed4817b..911fe514f0d1 100644 --- a/app/helpers/mail_layout_helper.rb +++ b/app/helpers/mail_layout_helper.rb @@ -29,32 +29,32 @@ module MailLayoutHelper def placeholder_table_styles(options = {}) default_options = { - style: 'table-layout:fixed;border-collapse:separate;border-spacing:0;font-family:Helvetica;' << - (options[:style].present? ? options.delete(:style) : ''), + style: "table-layout:fixed;border-collapse:separate;border-spacing:0;font-family:Helvetica;" << + (options[:style].present? ? options.delete(:style) : ""), cellspacing: "0", cellpadding: "0" } - default_options.merge(options).map { |k, v| "#{k}=#{v}" }.join(' ') + default_options.merge(options).map { |k, v| "#{k}=#{v}" }.join(" ") end def placeholder_text_styles(**overwrites) { - color: '#878787', - 'line-height': '24px', - 'font-size': '14px', - 'white-space': 'normal', - overflow: 'hidden', - 'max-width': '100%', - width: '100%' + color: "#878787", + "line-height": "24px", + "font-size": "14px", + "white-space": "normal", + overflow: "hidden", + "max-width": "100%", + width: "100%" }.merge(overwrites) .map { |k, v| "#{k}: #{v}" } - .join('; ') + .join("; ") end def action_button(&block) render( - partial: 'mailer/mailer_button', + partial: "mailer/mailer_button", locals: { block: } ) end @@ -66,15 +66,15 @@ def placeholder_cell(number, vertical:) "line-height:#{number}; max-width:0; min-width:0; height:#{number}; width:0; font-size:#{number}" end - content_tag('td', ' '.html_safe, style:) + content_tag("td", " ".html_safe, style:) end def user_salutation(user) case Setting.emails_salutation when :name - I18n.t(:'mail.salutation', user: user.name) + I18n.t(:"mail.salutation", user: user.name) else - I18n.t(:'mail.salutation', user: user.firstname) + I18n.t(:"mail.salutation", user: user.firstname) end end end diff --git a/app/helpers/mail_notification_helper.rb b/app/helpers/mail_notification_helper.rb index ef987c475f8d..6adcbea006ef 100644 --- a/app/helpers/mail_notification_helper.rb +++ b/app/helpers/mail_notification_helper.rb @@ -36,7 +36,7 @@ def unique_reasons_of_notifications(notifications) end def notifications_path(id) - notifications_center_url(['details', id, 'activity']) + notifications_center_url(["details", id, "activity"]) end def type_color(type, default_fallback) @@ -51,6 +51,6 @@ def type_color(type, default_fallback) def status_colors(status) color_id = selected_color(status) - Color.find(color_id).color_styles.map { |k, v| "#{k}:#{v};" }.join(' ') if color_id + Color.find(color_id).color_styles.map { |k, v| "#{k}:#{v};" }.join(" ") if color_id end end diff --git a/app/helpers/members_helper.rb b/app/helpers/members_helper.rb index 16d9998b0ded..464e87e9f315 100644 --- a/app/helpers/members_helper.rb +++ b/app/helpers/members_helper.rb @@ -34,13 +34,13 @@ module MembersHelper # If it is the later, the ids of the non delete roles are appended to the url so that they are kept. def global_member_role_deletion_link(member, role) if member.roles.length == 1 - link_to('', + link_to("", principal_membership_path(member.principal, member), - { method: :delete, class: 'icon icon-delete', title: t(:button_delete) }) + { method: :delete, class: "icon icon-delete", title: t(:button_delete) }) else - link_to('', - principal_membership_path(member.principal, member, 'membership[role_ids]' => member.roles - [role]), - { method: :patch, class: 'icon icon-delete', title: t(:button_delete) }) + link_to("", + principal_membership_path(member.principal, member, "membership[role_ids]" => member.roles - [role]), + { method: :patch, class: "icon icon-delete", title: t(:button_delete) }) end end diff --git a/app/helpers/meta_tags_helper.rb b/app/helpers/meta_tags_helper.rb index 2f8b27616bd6..480d244e13bd 100644 --- a/app/helpers/meta_tags_helper.rb +++ b/app/helpers/meta_tags_helper.rb @@ -32,7 +32,7 @@ module MetaTagsHelper def output_title_and_meta_tags display_meta_tags site: Setting.app_title, title: html_title_parts, - separator: ' | ', # Update the TitleService when changing this! + separator: " | ", # Update the TitleService when changing this! reverse: true end @@ -47,7 +47,7 @@ def initializer_meta_tag firstDayOfWeek: locale_first_day_of_week, environment: Rails.env, edition: OpenProject::Configuration.edition, - 'asset-host': OpenProject::Configuration.rails_asset_host.presence + "asset-host": OpenProject::Configuration.rails_asset_host.presence }.compact end diff --git a/app/helpers/no_results_helper.rb b/app/helpers/no_results_helper.rb index 872690b0b8cd..1e4e7f25a4b1 100644 --- a/app/helpers/no_results_helper.rb +++ b/app/helpers/no_results_helper.rb @@ -53,15 +53,15 @@ def no_results_box(action_url: nil, display_action: false, custom_title: nil, custom_action_text: nil) - title_text = custom_title || t('.no_results_title_text', cascade: true) || '' + title_text = custom_title || t(".no_results_title_text", cascade: true) || "" action_text = if display_action - custom_action_text || t('.no_results_content_text') + custom_action_text || t(".no_results_content_text") else - '' + "" end - action_url = action_url || '' + action_url = action_url || "" - render partial: '/common/no_results', + render partial: "/common/no_results", locals: { title_text:, action_text:, diff --git a/app/helpers/oauth_helper.rb b/app/helpers/oauth_helper.rb index 824be596f1a8..52b85a0a25fe 100644 --- a/app/helpers/oauth_helper.rb +++ b/app/helpers/oauth_helper.rb @@ -35,7 +35,7 @@ def oauth_scope_translations(application) if strings.empty? I18n.t("oauth.scopes.api_v3") else - safe_join(strings.map { |scope| I18n.t("oauth.scopes.#{scope}", default: scope) }, '
    '.html_safe) + safe_join(strings.map { |scope| I18n.t("oauth.scopes.#{scope}", default: scope) }, "
    ".html_safe) end end diff --git a/app/helpers/omniauth_helper.rb b/app/helpers/omniauth_helper.rb index 78904124ec5c..b8507f9b8589 100644 --- a/app/helpers/omniauth_helper.rb +++ b/app/helpers/omniauth_helper.rb @@ -42,6 +42,6 @@ def omniauth_direct_login? # If this option is active /login will lead directly to the configured omniauth provider # and so will a click on 'Sign in' (as opposed to opening the drop down menu). def direct_login_provider - OpenProject::Configuration['omniauth_direct_login_provider'] + OpenProject::Configuration["omniauth_direct_login_provider"] end end diff --git a/app/helpers/pagination_helper.rb b/app/helpers/pagination_helper.rb index 72389977c074..95793c3f7be0 100644 --- a/app/helpers/pagination_helper.rb +++ b/app/helpers/pagination_helper.rb @@ -26,7 +26,7 @@ # See COPYRIGHT and LICENSE files for more details. #++ -require 'will_paginate' +require "will_paginate" module PaginationHelper def pagination_links_full(paginator, options = {}) @@ -34,10 +34,10 @@ def pagination_links_full(paginator, options = {}) pagination_options = default_options.merge(options) - content_tag(:div, class: 'op-pagination') do + content_tag(:div, class: "op-pagination") do content = content_tag(:nav, pagination_entries(paginator, pagination_options), - class: 'op-pagination--pages') + class: "op-pagination--pages") if pagination_options[:per_page_links] content << pagination_option_links(paginator, pagination_options) @@ -52,7 +52,7 @@ def pagination_option_links(paginator, pagination_options) pagination_options[:params] .merge(safe_query_params(%w{filters sortBy expand}))) - content_tag(:div, option_links, class: 'op-pagination--options') + content_tag(:div, option_links, class: "op-pagination--options") end ## @@ -62,12 +62,12 @@ def pagination_entries(paginator, options) page_last = paginator.offset + paginator.length total = paginator.total_entries - content_tag(:ul, class: 'op-pagination--items op-pagination--items_start') do + content_tag(:ul, class: "op-pagination--items op-pagination--items_start") do # will_paginate will return nil early when no pages available - content = will_paginate(paginator, options) || '' + content = will_paginate(paginator, options) || "" range = "(#{page_first} - #{page_last}/#{total})" - content << content_tag(:li, range, class: 'op-pagination--range', title: range) + content << content_tag(:li, range, class: "op-pagination--range", title: range) content.html_safe end @@ -80,8 +80,8 @@ def pagination_settings(paginator, options) if links.size > 1 label = I18n.t(:label_per_page) - content_tag(:ul, class: 'op-pagination--items op-pagination--items_end') do - content_tag(:li, label + ':', class: 'op-pagination--label', title: label) + links + content_tag(:ul, class: "op-pagination--items op-pagination--items_end") do + content_tag(:li, label + ":", class: "op-pagination--label", title: label) + links end end end @@ -90,12 +90,12 @@ def pagination_settings(paginator, options) # Constructs the 'n items per page' entries # determined from available options in the settings. def per_page_links(paginator, options) - Setting.per_page_options_array.inject('') do |html, n| + Setting.per_page_options_array.inject("") do |html, n| if n == paginator.per_page - html + content_tag(:li, n, class: 'op-pagination--item op-pagination--item_current') + html + content_tag(:li, n, class: "op-pagination--item op-pagination--item_current") else - link = link_to_content_update(n, options.merge(page: 1, per_page: n), { class: 'op-pagination--item-link' }) - html + content_tag(:li, link.html_safe, class: 'op-pagination--item') + link = link_to_content_update(n, options.merge(page: 1, per_page: n), { class: "op-pagination--item-link" }) + html + content_tag(:li, link.html_safe, class: "op-pagination--item") end end.html_safe end @@ -159,7 +159,7 @@ def per_page_param(options = params) class LinkRenderer < ::WillPaginate::ActionView::LinkRenderer def to_html - pagination.inject('') do |html, item| + pagination.inject("") do |html, item| html + (item.is_a?(Integer) ? page_number(item) : send(item)) end.html_safe end @@ -173,33 +173,33 @@ def merge_get_params(url_params) def page_number(page) if page == current_page - tag(:li, page, class: 'op-pagination--item op-pagination--item_current') + tag(:li, page, class: "op-pagination--item op-pagination--item_current") else - tag(:li, link(page, page, { class: 'op-pagination--item-link' }), class: 'op-pagination--item') + tag(:li, link(page, page, { class: "op-pagination--item-link" }), class: "op-pagination--item") end end def gap - tag(:li, '…', class: 'op-pagination--space') + tag(:li, "…", class: "op-pagination--space") end def previous_page num = @collection.current_page > 1 && (@collection.current_page - 1) - previous_or_next_page(num, I18n.t(:label_previous), 'prev') + previous_or_next_page(num, I18n.t(:label_previous), "prev") end def next_page num = @collection.current_page < total_pages && (@collection.current_page + 1) - previous_or_next_page(num, I18n.t(:label_next), 'next') + previous_or_next_page(num, I18n.t(:label_next), "next") end def previous_or_next_page(page, text, class_suffix) if page tag(:li, - link(text, page, { class: 'op-pagination--item-link op-pagination--item-link_' + class_suffix }), - class: 'op-pagination--item op-pagination--item_' + class_suffix) + link(text, page, { class: "op-pagination--item-link op-pagination--item-link_" + class_suffix }), + class: "op-pagination--item op-pagination--item_" + class_suffix) else - '' + "" end end diff --git a/app/helpers/password_helper.rb b/app/helpers/password_helper.rb index c210329a4f31..fb2f3cf47366 100644 --- a/app/helpers/password_helper.rb +++ b/app/helpers/password_helper.rb @@ -56,7 +56,7 @@ def password_confirmation_form_tag(url_for_options = {}, options = {}, &) def password_confirmation_data_attribute(with_data = {}) if password_confirmation_required? - with_data.merge('request-for-confirmation': true) + with_data.merge("request-for-confirmation": true) else with_data end @@ -84,7 +84,7 @@ def password_active_rules # Returns a text describing the active password complexity rules, # the minimum number of rules to adhere to and the total number of rules. def password_rules_description - return '' if OpenProject::Passwords::Evaluator.min_adhered_rules == 0 + return "" if OpenProject::Passwords::Evaluator.min_adhered_rules == 0 OpenProject::Passwords::Evaluator.rules_description_locale(password_active_rules) end diff --git a/app/helpers/project_status_helper.rb b/app/helpers/project_status_helper.rb index 8510e2d43dbb..c919bb61c825 100644 --- a/app/helpers/project_status_helper.rb +++ b/app/helpers/project_status_helper.rb @@ -29,7 +29,7 @@ module ProjectStatusHelper def project_status_css_class(status_code) code = project_status_ensure_default_code(status_code) - '-' + code.tr('_', '-') + "-" + code.tr("_", "-") end def project_status_name(status_code) @@ -38,11 +38,11 @@ def project_status_name(status_code) end def project_status_name_for_code(code) - code ||= 'not_set' - I18n.t('js.grid.widgets.project_status.' + code) + code ||= "not_set" + I18n.t("js.grid.widgets.project_status." + code) end def project_status_ensure_default_code(status_code) - status_code || 'not_set' + status_code || "not_set" end end diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index e69ab162878d..25557a74abec 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -35,7 +35,7 @@ module ProjectsHelper def projects_sort_header_tag(*) former_criteria = @sort_criteria.criteria.dup - @sort_criteria.criteria.reject! { |a, _| a == 'lft' } + @sort_criteria.criteria.reject! { |a, _| a == "lft" } sort_header_tag(*) ensure @@ -44,7 +44,7 @@ def projects_sort_header_tag(*) def short_project_description(project, length = 255) if project.description.blank? - return '' + return "" end project.description.gsub(/\A(.{#{length}}[^\n\r]*).*\z/m, '\1...').strip diff --git a/app/helpers/removed_js_helpers_helper.rb b/app/helpers/removed_js_helpers_helper.rb index 0c29d1809af1..1d0b68095e3a 100644 --- a/app/helpers/removed_js_helpers_helper.rb +++ b/app/helpers/removed_js_helpers_helper.rb @@ -36,7 +36,7 @@ def link_to_function(content, function, html_options = {}) id = html_options.delete(:id) { "link-to-function-#{SecureRandom.uuid}" } csp_onclick(function, "##{id}") - content_tag(:a, content, html_options.merge(id:, href: '')) + content_tag(:a, content, html_options.merge(id:, href: "")) end ## diff --git a/app/helpers/reorder_links_helper.rb b/app/helpers/reorder_links_helper.rb index efa2463f4787..85e48232cbda 100644 --- a/app/helpers/reorder_links_helper.rb +++ b/app/helpers/reorder_links_helper.rb @@ -31,19 +31,19 @@ def reorder_links(name, url, options = {}) method = options[:method] || :post content_tag(:span, - reorder_link(name, url, 'highest', 'icon-sort-up', t(:label_sort_highest), method) + - reorder_link(name, url, 'higher', 'icon-arrow-up2', t(:label_sort_higher), method) + - reorder_link(name, url, 'lower', 'icon-arrow-down2', t(:label_sort_lower), method) + - reorder_link(name, url, 'lowest', 'icon-sort-down', t(:label_sort_lowest), method), - class: 'reorder-icons') + reorder_link(name, url, "highest", "icon-sort-up", t(:label_sort_highest), method) + + reorder_link(name, url, "higher", "icon-arrow-up2", t(:label_sort_higher), method) + + reorder_link(name, url, "lower", "icon-arrow-down2", t(:label_sort_lower), method) + + reorder_link(name, url, "lowest", "icon-sort-down", t(:label_sort_lowest), method), + class: "reorder-icons") end def reorder_link(name, url, direction, icon_class, label, method) text = content_tag(:span, label, - class: 'hidden-for-sighted') + class: "hidden-for-sighted") icon = content_tag(:span, - '', + "", class: "icon-context #{icon_class} icon-small") link_to(text + icon, url.merge("#{name}[move_to]" => direction), diff --git a/app/helpers/reports_helper.rb b/app/helpers/reports_helper.rb index a2896d9f195f..13f30ad0b890 100644 --- a/app/helpers/reports_helper.rb +++ b/app/helpers/reports_helper.rb @@ -32,10 +32,10 @@ module ReportsHelper def aggregate(data, criteria) data&.inject(0) do |sum, row| match = criteria&.all? do |k, v| - row[k].to_s == v.to_s || (k == 'closed' && row[k] == ActiveRecord::Type::Boolean.new.cast(v)) + row[k].to_s == v.to_s || (k == "closed" && row[k] == ActiveRecord::Type::Boolean.new.cast(v)) end - sum += row['total'].to_i if match + sum += row["total"].to_i if match sum end || 0 @@ -43,6 +43,6 @@ def aggregate(data, criteria) def aggregate_link(data, criteria, *) a = aggregate data, criteria - a.positive? ? link_to(h(a), *) : '-' + a.positive? ? link_to(h(a), *) : "-" end end diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb index 151811a6fad9..0fd7366f5804 100644 --- a/app/helpers/repositories_helper.rb +++ b/app/helpers/repositories_helper.rb @@ -38,7 +38,7 @@ def format_revision(revision) ## # Format revision commits with plain formatter def format_revision_text(commit_message) - format_text(commit_message, format: 'plain') + format_text(commit_message, format: "plain") end def truncate_at_line_break(text, length = 255) @@ -47,25 +47,25 @@ def truncate_at_line_break(text, length = 255) def render_properties(properties) unless properties.nil? || properties.empty? - content = '' + content = "" properties.keys.sort.each do |property| - content << content_tag('li', raw("#{h property}: #{h properties[property]}")) + content << content_tag("li", raw("#{h property}: #{h properties[property]}")) end - content_tag('ul', content.html_safe, class: 'properties') + content_tag("ul", content.html_safe, class: "properties") end end def render_changeset_changes - changes = @changeset.file_changes.limit(1000).order(Arel.sql('path')).filter_map do |change| + changes = @changeset.file_changes.limit(1000).order(Arel.sql("path")).filter_map do |change| case change.action - when 'A' + when "A" # Detects moved/copied files if change.from_path.present? - action = @changeset.file_changes.detect { |c| c.action == 'D' && c.path == change.from_path } - change.action = action ? 'R' : 'C' + action = @changeset.file_changes.detect { |c| c.action == "D" && c.path == change.from_path } + change.action = action ? "R" : "C" end change - when 'D' + when "D" @changeset.file_changes.detect { |c| c.from_path == change.path } ? nil : change else change @@ -75,8 +75,8 @@ def render_changeset_changes tree = {} changes.each do |change| p = tree - dirs = change.path.to_s.split('/').select { |d| d.present? } - path = '' + dirs = change.path.to_s.split("/").select { |d| d.present? } + path = "" dirs.each do |dir| path += with_leading_slash(dir) p[:s] ||= {} @@ -93,8 +93,8 @@ def render_changeset_changes # Mapping from internal action to (folder|file)-icon type def change_action_mapping { - 'A' => :add, - 'B' => :remove + "A" => :add, + "B" => :remove } end @@ -112,14 +112,14 @@ def calculate_folder_action(tree) end def render_changes_tree(tree) - return '' if tree.nil? + return "" if tree.nil? - output = '" output.html_safe end @@ -166,7 +166,7 @@ def to_utf8_for_repositories(str) str = to_utf8_internal(str) if str.respond_to?(:force_encoding) - str.force_encoding('UTF-8') + str.force_encoding("UTF-8") end str end @@ -175,17 +175,17 @@ def to_utf8_internal(str) return str if str.nil? if str.respond_to?(:force_encoding) - str.force_encoding('ASCII-8BIT') + str.force_encoding("ASCII-8BIT") end return str if str.empty? return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match?(str) # for us-ascii if str.respond_to?(:force_encoding) - str.force_encoding('UTF-8') + str.force_encoding("UTF-8") end - @encodings ||= Setting.repositories_encodings.split(',').map(&:strip) + @encodings ||= Setting.repositories_encodings.split(",").map(&:strip) @encodings.each do |encoding| - return str.to_s.encode('UTF-8', encoding) + return str.to_s.encode("UTF-8", encoding) rescue Encoding::InvalidByteSequenceError, Encoding::UndefinedConversionError # do nothing here and try the next encoding end @@ -198,15 +198,15 @@ def replace_invalid_utf8(str) return str if str.nil? if str.respond_to?(:force_encoding) - str.force_encoding('UTF-8') + str.force_encoding("UTF-8") if !str.valid_encoding? str = str.encode("US-ASCII", invalid: :replace, - undef: :replace, replace: '?').encode("UTF-8") + undef: :replace, replace: "?").encode("UTF-8") end else # removes invalid UTF8 sequences begin - (str + ' ').encode('UTF-8', invalid: :replace, undef: :replace, replace: '?')[0..-3] + (str + " ").encode("UTF-8", invalid: :replace, undef: :replace, replace: "?")[0..-3] rescue Encoding::InvalidByteSequenceError, Encoding::UndefinedConversionError end end @@ -234,29 +234,29 @@ def scm_options(repository = nil) def default_selected_option [ "--- #{I18n.t(:actionview_instancetag_blank_option)} ---", - '', + "", { disabled: true, selected: true } ] end def scm_vendor_tag(repository) # rubocop:disable Rails/HelperInstanceVariable - url = url_for(controller: '/projects/settings/repository', action: 'show', id: @project.id) + url = url_for(controller: "/projects/settings/repository", action: "show", id: @project.id) # rubocop:enable Rails/HelperInstanceVariable # - select_tag('scm_vendor', + select_tag("scm_vendor", scm_options(repository), - class: 'form--select', + class: "form--select", data: { url:, - action: 'repository-settings#updateSelectedType', - 'repository-settings-target': 'scmVendor' + action: "repository-settings#updateSelectedType", + "repository-settings-target": "scmVendor" }, disabled: repository && !repository.new_record?) end def git_path_encoding_options(repository) - default = repository.new_record? ? 'UTF-8' : repository.path_encoding + default = repository.new_record? ? "UTF-8" : repository.path_encoding options_for_select(Setting::ENCODINGS, default) end @@ -270,22 +270,22 @@ def show_settings_save_button?(_repository) end def with_leading_slash(path) - path.to_s.starts_with?('/') ? path : "/#{path}" + path.to_s.starts_with?("/") ? path : "/#{path}" end def without_leading_slash(path) - path.gsub(%r{\A/+}, '') + path.gsub(%r{\A/+}, "") end def changes_tree_change_title(action) case action - when 'A' + when "A" I18n.t(:label_added) - when 'D' + when "D" I18n.t(:label_deleted) - when 'C' + when "C" I18n.t(:label_copied) - when 'R' + when "R" I18n.t(:label_renamed) else I18n.t(:label_modified) @@ -294,16 +294,16 @@ def changes_tree_change_title(action) def changes_tree_li_element(action, text, style) icon_name = case action - when 'A' - 'icon-add' - when 'D' - 'icon-delete' - when 'C' - 'icon-copy' - when 'R' - 'icon-rename' + when "A" + "icon-add" + when "D" + "icon-delete" + when "C" + "icon-copy" + when "R" + "icon-rename" else - 'icon-arrow-left-right' + "icon-arrow-left-right" end "