diff options
author | Toon Claes <toon@gitlab.com> | 2019-02-28 19:57:34 +0100 |
---|---|---|
committer | Toon Claes <toon@gitlab.com> | 2019-02-28 19:57:34 +0100 |
commit | 62d7990b9bb30cf33ed87017c5c633d1cccc75c2 (patch) | |
tree | c3e1b69c58a412ba1c6f50a0337a23d9f9d6e1a4 /app/helpers | |
parent | f6453eca992a9c142268e78ac782cef98110d183 (diff) | |
download | gitlab-ce-tc-standard-gem.tar.gz |
Ran standardrb --fix on the whole codebasetc-standard-gem
Inspired by https://twitter.com/searls/status/1101137953743613952 I
decided to try https://github.com/testdouble/standard on our codebase.
It's opinionated, but at least it's a _standard_.
Diffstat (limited to 'app/helpers')
83 files changed, 1277 insertions, 1265 deletions
diff --git a/app/helpers/active_sessions_helper.rb b/app/helpers/active_sessions_helper.rb index 84aa1160f12..35e139b7f60 100644 --- a/app/helpers/active_sessions_helper.rb +++ b/app/helpers/active_sessions_helper.rb @@ -8,18 +8,18 @@ module ActiveSessionsHelper def active_session_device_type_icon(active_session) icon_name = case active_session.device_type - when 'smartphone', 'feature phone', 'phablet' - 'mobile' - when 'tablet' - 'tablet' - when 'tv', 'smart display', 'camera', 'portable media player', 'console' - 'media' - when 'car browser' - 'car' + when "smartphone", "feature phone", "phablet" + "mobile" + when "tablet" + "tablet" + when "tv", "smart display", "camera", "portable media player", "console" + "media" + when "car browser" + "car" else - 'monitor-o' + "monitor-o" end - sprite_icon(icon_name, size: 16, css_class: 'prepend-top-2') + sprite_icon(icon_name, size: 16, css_class: "prepend-top-2") end end diff --git a/app/helpers/appearances_helper.rb b/app/helpers/appearances_helper.rb index c0db9910143..a51551ac46d 100644 --- a/app/helpers/appearances_helper.rb +++ b/app/helpers/appearances_helper.rb @@ -9,7 +9,7 @@ module AppearancesHelper def default_brand_title # This resides in a separate method so that EE can easily redefine it. - 'GitLab Community Edition' + "GitLab Community Edition" end def brand_image @@ -30,16 +30,16 @@ module AppearancesHelper def brand_header_logo if current_appearance&.header_logo? - image_tag current_appearance.header_logo_path, class: 'brand-header-logo' + image_tag current_appearance.header_logo_path, class: "brand-header-logo" else - render 'shared/logo.svg' + render "shared/logo.svg" end end # Skip the 'GitLab' type logo when custom brand logo is set def brand_header_logo_type unless current_appearance&.header_logo? - render 'shared/logo_type.svg' + render "shared/logo_type.svg" end end @@ -47,7 +47,7 @@ module AppearancesHelper return unless current_appearance&.show_header? class_names = [] - class_names << 'with-performance-bar' if performance_bar_enabled? + class_names << "with-performance-bar" if performance_bar_enabled? render_message(:header_message, class_names: class_names) end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ffa5719fefb..a51f9f79fae 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require 'digest/md5' -require 'uri' +require "digest/md5" +require "uri" module ApplicationHelper # See https://docs.gitlab.com/ee/development/ee_features.html#code-in-app-views @@ -58,10 +58,10 @@ module ApplicationHelper if project.repo_exists? time_ago_with_tooltip(project.repository.commit.committed_date) else - 'Never' + "Never" end rescue - 'Never' + "Never" end # Define whenever show last push event @@ -69,7 +69,7 @@ module ApplicationHelper # rubocop: disable CodeReuse/ActiveRecord def show_last_push_widget?(event) # Skip if event is not about added or modified non-master branch - return false unless event && event.last_push_to_non_root? && !event.rm_ref? + return false unless event&.last_push_to_non_root? && !event.rm_ref? project = event.project @@ -91,11 +91,11 @@ module ApplicationHelper end def simple_sanitize(str) - sanitize(str, tags: %w(a span)) + sanitize(str, tags: %w[a span]) end def body_data_page - [*controller.controller_path.split('/'), controller.action_name].compact.join(':') + [*controller.controller_path.split("/"), controller.action_name].compact.join(":") end # shortcut for gitlab config @@ -124,32 +124,32 @@ module ApplicationHelper # `html_class` argument is provided. # # Returns an HTML-safe String - def time_ago_with_tooltip(time, placement: 'top', html_class: '', short_format: false) - css_classes = [short_format ? 'js-short-timeago' : 'js-timeago'] + def time_ago_with_tooltip(time, placement: "top", html_class: "", short_format: false) + css_classes = [short_format ? "js-short-timeago" : "js-timeago"] css_classes << html_class unless html_class.blank? element = content_tag :time, l(time, format: "%b %d, %Y"), - class: css_classes.join(' '), + class: css_classes.join(" "), title: l(time.to_time.in_time_zone, format: :timeago_tooltip), datetime: time.to_time.getutc.iso8601, data: { - toggle: 'tooltip', + toggle: "tooltip", placement: placement, - container: 'body' + container: "body", } element end - def edited_time_ago_with_tooltip(object, placement: 'top', html_class: 'time_ago', exclude_author: false) + def edited_time_ago_with_tooltip(object, placement: "top", html_class: "time_ago", exclude_author: false) return unless object.edited? - content_tag :small, class: 'edited-text' do - output = content_tag(:span, 'Edited ') + content_tag :small, class: "edited-text" do + output = content_tag(:span, "Edited ") output << time_ago_with_tooltip(object.last_edited_at, placement: placement, html_class: html_class) if !exclude_author && object.last_edited_by - output << content_tag(:span, ' by ') + output << content_tag(:span, " by ") output << link_to_member(object.project, object.last_edited_by, avatar: false, author_class: nil) end @@ -158,15 +158,15 @@ module ApplicationHelper end def promo_host - 'about.gitlab.com' + "about.gitlab.com" end def promo_url - 'https://' + promo_host + "https://" + promo_host end def support_url - Gitlab::CurrentSettings.current_application_settings.help_page_support_url.presence || promo_url + '/getting-help/' + Gitlab::CurrentSettings.current_application_settings.help_page_support_url.presence || promo_url + "/getting-help/" end def page_filter_path(options = {}) @@ -212,8 +212,8 @@ module ApplicationHelper def page_class class_names = [] - class_names << 'issue-boards-page' if current_controller?(:boards) - class_names << 'with-performance-bar' if performance_bar_enabled? + class_names << "issue-boards-page" if current_controller?(:boards) + class_names << "with-performance-bar" if performance_bar_enabled? class_names << system_message_class class_names end @@ -223,8 +223,8 @@ module ApplicationHelper return class_names unless appearance - class_names << 'with-system-header' if appearance.show_header? - class_names << 'with-system-footer' if appearance.show_footer? + class_names << "with-system-header" if appearance.show_header? + class_names << "with-system-footer" if appearance.show_footer? class_names end @@ -235,16 +235,16 @@ module ApplicationHelper # Example: # %li{ class: active_when(params[:filter] == '1') } def active_when(condition) - 'active' if condition + "active" if condition end def show_callout?(name) - cookies[name] != 'true' + cookies[name] != "true" end def linkedin_url(user) name = user.linkedin - if name =~ %r{\Ahttps?://(www\.)?linkedin\.com/in/} + if %r{\Ahttps?://(www\.)?linkedin\.com/in/}.match?(name) name else "https://www.linkedin.com/in/#{name}" @@ -253,7 +253,7 @@ module ApplicationHelper def twitter_url(user) name = user.twitter - if name =~ %r{\Ahttps?://(www\.)?twitter\.com/} + if %r{\Ahttps?://(www\.)?twitter\.com/}.match?(name) name else "https://twitter.com/#{name}" @@ -272,7 +272,7 @@ module ApplicationHelper def read_only_message return unless Gitlab::Database.read_only? - _('You are on a read-only GitLab instance.') + _("You are on a read-only GitLab instance.") end def client_class_list @@ -281,8 +281,8 @@ module ApplicationHelper def client_js_flags { - "is#{browser.id.to_s.titlecase}": true, - "is#{browser.platform.id.to_s.titlecase}": true + :"is#{browser.id.to_s.titlecase}" => true, + :"is#{browser.platform.id.to_s.titlecase}" => true, } end @@ -296,7 +296,7 @@ module ApplicationHelper labels: labels_project_autocomplete_sources_path(object, type: noteable_type, type_id: params[:id]), milestones: milestones_project_autocomplete_sources_path(object), commands: commands_project_autocomplete_sources_path(object, type: noteable_type, type_id: params[:id]), - snippets: snippets_project_autocomplete_sources_path(object) + snippets: snippets_project_autocomplete_sources_path(object), } end diff --git a/app/helpers/application_settings_helper.rb b/app/helpers/application_settings_helper.rb index e635f608237..4b2fdb69f18 100644 --- a/app/helpers/application_settings_helper.rb +++ b/app/helpers/application_settings_helper.rb @@ -3,11 +3,11 @@ module ApplicationSettingsHelper extend self - delegate :allow_signup?, - :gravatar_enabled?, - :password_authentication_enabled_for_web?, - :akismet_enabled?, - to: :'Gitlab::CurrentSettings.current_application_settings' + delegate :allow_signup?, + :gravatar_enabled?, + :password_authentication_enabled_for_web?, + :akismet_enabled?, + to: :'Gitlab::CurrentSettings.current_application_settings' def user_oauth_applications? Gitlab::CurrentSettings.user_oauth_applications @@ -19,10 +19,10 @@ module ApplicationSettingsHelper def enabled_protocol case Gitlab::CurrentSettings.enabled_git_access_protocol - when 'http' + when "http" Gitlab.config.gitlab.protocol - when 'ssh' - 'ssh' + when "ssh" + "ssh" end end @@ -31,16 +31,16 @@ module ApplicationSettingsHelper end def ssh_enabled? - all_protocols_enabled? || enabled_protocol == 'ssh' + all_protocols_enabled? || enabled_protocol == "ssh" end def http_enabled? - all_protocols_enabled? || Gitlab::CurrentSettings.enabled_git_access_protocol == 'http' + all_protocols_enabled? || Gitlab::CurrentSettings.enabled_git_access_protocol == "http" end def enabled_project_button(project, protocol) case protocol - when 'ssh' + when "ssh" ssh_clone_button(project, append_link: false) else http_clone_button(project, append_link: false) @@ -52,15 +52,15 @@ module ApplicationSettingsHelper def restricted_level_checkboxes(help_block_id, checkbox_name, options = {}) Gitlab::VisibilityLevel.values.map do |level| checked = restricted_visibility_levels(true).include?(level) - css_class = checked ? 'active' : '' + css_class = checked ? "active" : "" tag_name = "application_setting_visibility_level_#{level}" label_tag(tag_name, class: css_class) do check_box_tag(checkbox_name, level, checked, - autocomplete: 'off', - 'aria-describedby' => help_block_id, - 'class' => options[:class], - id: tag_name) + visibility_level_icon(level) + visibility_level_label(level) + :autocomplete => "off", + "aria-describedby" => help_block_id, + "class" => options[:class], + :id => tag_name) + visibility_level_icon(level) + visibility_level_label(level) end end end @@ -70,15 +70,15 @@ module ApplicationSettingsHelper def import_sources_checkboxes(help_block_id, options = {}) Gitlab::ImportSources.options.map do |name, source| checked = Gitlab::CurrentSettings.import_sources.include?(source) - css_class = checked ? 'active' : '' - checkbox_name = 'application_setting[import_sources][]' + css_class = checked ? "active" : "" + checkbox_name = "application_setting[import_sources][]" label_tag(name, class: css_class) do check_box_tag(checkbox_name, source, checked, - autocomplete: 'off', - 'aria-describedby' => help_block_id, - 'class' => options[:class], - id: name.tr(' ', '_')) + name + :autocomplete => "off", + "aria-describedby" => help_block_id, + "class" => options[:class], + :id => name.tr(" ", "_")) + name end end end @@ -86,35 +86,35 @@ module ApplicationSettingsHelper def oauth_providers_checkboxes button_based_providers.map do |source| disabled = Gitlab::CurrentSettings.disabled_oauth_sign_in_sources.include?(source.to_s) - css_class = ['btn'] - css_class << 'active' unless disabled - checkbox_name = 'application_setting[enabled_oauth_sign_in_sources][]' + css_class = ["btn"] + css_class << "active" unless disabled + checkbox_name = "application_setting[enabled_oauth_sign_in_sources][]" name = Gitlab::Auth::OAuth::Provider.label_for(source) - label_tag(checkbox_name, class: css_class.join(' ')) do + label_tag(checkbox_name, class: css_class.join(" ")) do check_box_tag(checkbox_name, source, !disabled, - autocomplete: 'off', - id: name.tr(' ', '_')) + name + autocomplete: "off", + id: name.tr(" ", "_")) + name end end end def key_restriction_options_for_select(type) - bit_size_options = Gitlab::SSHPublicKey.supported_sizes(type).map do |bits| + bit_size_options = Gitlab::SSHPublicKey.supported_sizes(type).map { |bits| ["Must be at least #{bits} bits", bits] - end + } [ - ['Are allowed', 0], + ["Are allowed", 0], *bit_size_options, - ['Are forbidden', ApplicationSetting::FORBIDDEN_KEY_VALUE] + ["Are forbidden", ApplicationSetting::FORBIDDEN_KEY_VALUE], ] end def repository_storages_options_for_select(selected) - options = Gitlab.config.repositories.storages.map do |name, storage| - ["#{name} - #{storage['gitaly_address']}", name] - end + options = Gitlab.config.repositories.storages.map { |name, storage| + ["#{name} - #{storage["gitaly_address"]}", name] + } options_for_select(options, selected) end @@ -233,7 +233,7 @@ module ApplicationSettingsHelper :diff_max_patch_bytes, :commit_email_hostname, :protected_ci_variables, - :local_markdown_version + :local_markdown_version, ] end diff --git a/app/helpers/auth_helper.rb b/app/helpers/auth_helper.rb index 2b1d6f49878..410c6041c7a 100644 --- a/app/helpers/auth_helper.rb +++ b/app/helpers/auth_helper.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module AuthHelper - PROVIDERS_WITH_ICONS = %w(twitter github gitlab bitbucket google_oauth2 facebook azure_oauth2 authentiq).freeze + PROVIDERS_WITH_ICONS = %w[twitter github gitlab bitbucket google_oauth2 facebook azure_oauth2 authentiq].freeze LDAP_PROVIDER = /\Aldap/ def ldap_enabled? @@ -18,8 +18,8 @@ module AuthHelper def qa_class_for_provider(provider) { - saml: 'qa-saml-login-button', - github: 'qa-github-login-button' + saml: "qa-saml-login-button", + github: "qa-github-login-button", }[provider.to_sym] end @@ -32,7 +32,7 @@ module AuthHelper end def form_based_provider_priority - ['crowd', /^ldap/, 'kerberos'] + ["crowd", /^ldap/, "kerberos"] end def form_based_provider_with_highest_priority @@ -49,7 +49,7 @@ module AuthHelper end def form_based_provider?(name) - [LDAP_PROVIDER, 'crowd'].any? { |pattern| pattern === name.to_s } + [LDAP_PROVIDER, "crowd"].any? { |pattern| pattern === name.to_s } end def form_based_providers @@ -86,7 +86,7 @@ module AuthHelper label = label_for_provider(provider) if provider_has_icon?(provider) - file_name = "#{provider.to_s.split('_').first}_#{size}.png" + file_name = "#{provider.to_s.split("_").first}_#{size}.png" image_tag("auth_buttons/#{file_name}", alt: label, title: "Sign in with #{label}") else @@ -101,7 +101,7 @@ module AuthHelper # rubocop: enable CodeReuse/ActiveRecord def unlink_allowed?(provider) - %w(saml cas3).exclude?(provider.to_s) + %w[saml cas3].exclude?(provider.to_s) end extend self diff --git a/app/helpers/auto_devops_helper.rb b/app/helpers/auto_devops_helper.rb index 67e7e475920..e792bf4bbb4 100644 --- a/app/helpers/auto_devops_helper.rb +++ b/app/helpers/auto_devops_helper.rb @@ -3,7 +3,7 @@ module AutoDevopsHelper def show_auto_devops_callout?(project) Feature.get(:auto_devops_banner_disabled).off? && - show_callout?('auto_devops_settings_dismissed') && + show_callout?("auto_devops_settings_dismissed") && can?(current_user, :admin_pipeline, project) && project.has_auto_devops_implicitly_disabled? && !project.repository.gitlab_ci_yml && diff --git a/app/helpers/avatars_helper.rb b/app/helpers/avatars_helper.rb index 5906ddabee4..bf099890f6e 100644 --- a/app/helpers/avatars_helper.rb +++ b/app/helpers/avatars_helper.rb @@ -38,13 +38,13 @@ module AvatarsHelper end end - def gravatar_icon(user_email = '', size = nil, scale = 2) + def gravatar_icon(user_email = "", size = nil, scale = 2) GravatarService.new.execute(user_email, size, scale) || default_avatar end def default_avatar - ActionController::Base.helpers.image_path('no_avatar.png') + ActionController::Base.helpers.image_path("no_avatar.png") end def author_avatar(commit_or_event, options = {}) @@ -52,7 +52,7 @@ module AvatarsHelper user: commit_or_event.author, user_name: commit_or_event.author_name, user_email: commit_or_event.author_email, - css_class: 'd-none d-sm-inline' + css_class: "d-none d-sm-inline", })) end @@ -77,22 +77,22 @@ module AvatarsHelper css_class = %W[avatar s#{avatar_size}].push(*options[:css_class]) if has_tooltip - css_class.push('has-tooltip') - data_attributes[:container] = 'body' + css_class.push("has-tooltip") + data_attributes[:container] = "body" end if options[:lazy] - css_class << 'lazy' + css_class << "lazy" data_attributes[:src] = avatar_url avatar_url = LazyImageTagHelper.placeholder_image end image_options = { - alt: "#{user_name}'s avatar", - src: avatar_url, - data: data_attributes, + alt: "#{user_name}'s avatar", + src: avatar_url, + data: data_attributes, class: css_class, - title: user_name + title: user_name, } tag(:img, image_options) @@ -124,7 +124,7 @@ module AvatarsHelper bg_key = (source.id % 7) + 1 options[:class] = - [*options[:class], "identicon bg#{bg_key}"].join(' ') + [*options[:class], "identicon bg#{bg_key}"].join(" ") content_tag(:div, class: options[:class].strip) do source.name[0, 1].upcase diff --git a/app/helpers/blame_helper.rb b/app/helpers/blame_helper.rb index 82c74e2416d..ace4bf539b1 100644 --- a/app/helpers/blame_helper.rb +++ b/app/helpers/blame_helper.rb @@ -8,7 +8,7 @@ module BlameHelper { now: now, - started_days_ago: (now - start_date).to_i / 1.day + started_days_ago: (now - start_date).to_i / 1.day, } end diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index 3e1bb9af5cc..62da4a47afd 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -8,18 +8,18 @@ module BlobHelper end def no_highlight_files - %w(credits changelog news copying copyright license authors) + %w[credits changelog news copying copyright license authors] end def edit_blob_path(project = @project, ref = @ref, path = @path, options = {}) project_edit_blob_path(project, - tree_join(ref, path), - options[:link_opts]) + tree_join(ref, path), + options[:link_opts]) end def ide_edit_path(project = @project, ref = @ref, path = @path, options = {}) - segments = [ide_path, 'project', project.full_path, 'edit', ref] - segments.concat(['-', path]) if path.present? + segments = [ide_path, "project", project.full_path, "edit", ref] + segments.concat(["-", path]) if path.present? File.join(segments) end @@ -29,11 +29,11 @@ module BlobHelper common_classes = "btn js-edit-blob #{options[:extra_class]}" edit_button_tag(blob, - common_classes, - _('Edit'), - Feature.enabled?(:web_ide_default) ? ide_edit_path(project, ref, path, options) : edit_blob_path(project, ref, path, options), - project, - ref) + common_classes, + _("Edit"), + Feature.enabled?(:web_ide_default) ? ide_edit_path(project, ref, path, options) : edit_blob_path(project, ref, path, options), + project, + ref) end def ide_edit_button(project = @project, ref = @ref, path = @path, options = {}) @@ -41,28 +41,32 @@ module BlobHelper return unless blob = readable_blob(options, path, project, ref) edit_button_tag(blob, - 'btn btn-default', - _('Web IDE'), - ide_edit_path(project, ref, path, options), - project, - ref) + "btn btn-default", + _("Web IDE"), + ide_edit_path(project, ref, path, options), + project, + ref) end def modify_file_button(project = @project, ref = @ref, path = @path, label:, action:, btn_class:, modal_type:) return unless current_user - blob = project.repository.blob_at(ref, path) rescue nil + blob = begin + project.repository.blob_at(ref, path) + rescue + nil + end return unless blob common_classes = "btn btn-#{btn_class}" if !on_top_of_branch?(project, ref) - button_tag label, class: "#{common_classes} disabled has-tooltip", title: "You can only #{action} files when you are on a branch", data: { container: 'body' } + button_tag label, class: "#{common_classes} disabled has-tooltip", title: "You can only #{action} files when you are on a branch", data: {container: "body"} elsif blob.stored_externally? - button_tag label, class: "#{common_classes} disabled has-tooltip", title: "It is not possible to #{action} files that are stored in LFS using the web interface", data: { container: 'body' } + button_tag label, class: "#{common_classes} disabled has-tooltip", title: "It is not possible to #{action} files that are stored in LFS using the web interface", data: {container: "body"} elsif can_modify_blob?(blob, project, ref) - button_tag label, class: "#{common_classes}", 'data-target' => "#modal-#{modal_type}-blob", 'data-toggle' => 'modal' + button_tag label, :class => common_classes.to_s, "data-target" => "#modal-#{modal_type}-blob", "data-toggle" => "modal" elsif can?(current_user, :fork_project, project) && can?(current_user, :create_merge_request_in, project) edit_fork_button_tag(common_classes, project, label, edit_modify_file_fork_params(action), action) end @@ -73,9 +77,9 @@ module BlobHelper project, ref, path, - label: "Replace", - action: "replace", - btn_class: "default", + label: "Replace", + action: "replace", + btn_class: "default", modal_type: "upload" ) end @@ -85,9 +89,9 @@ module BlobHelper project, ref, path, - label: "Delete", - action: "delete", - btn_class: "remove", + label: "Delete", + action: "delete", + btn_class: "remove", modal_type: "remove" ) end @@ -102,9 +106,9 @@ module BlobHelper def editing_preview_title(filename) if Gitlab::MarkupHelper.previewable?(filename) - 'Preview' + "Preview" else - 'Preview changes' + "Preview changes" end end @@ -113,7 +117,7 @@ module BlobHelper # mode - File unix mode # mode - File name def blob_icon(mode, name) - icon("#{file_type_icon_class('file', mode, name)} fw") + icon("#{file_type_icon_class("file", mode, name)} fw") end def blob_raw_url(**kwargs) @@ -150,9 +154,9 @@ module BlobHelper categories = grouped.keys categories.each_with_object({}) do |category, hash| - hash[category] = grouped[category].map do |item| - { name: item.name, id: item.key } - end + hash[category] = grouped[category].map { |item| + {name: item.name, id: item.key} + } end end private :template_dropdown_names @@ -175,16 +179,16 @@ module BlobHelper def blob_editor_paths(project) { - 'relative-url-root' => Rails.application.config.relative_url_root, - 'assets-prefix' => Gitlab::Application.config.assets.prefix, - 'blob-filename' => @blob && @blob.path, - 'project-id' => project.id, - 'is-markdown' => @blob && @blob.path && Gitlab::MarkupHelper.gitlab_markdown?(@blob.path) + "relative-url-root" => Rails.application.config.relative_url_root, + "assets-prefix" => Gitlab::Application.config.assets.prefix, + "blob-filename" => @blob&.path, + "project-id" => project.id, + "is-markdown" => @blob&.path && Gitlab::MarkupHelper.gitlab_markdown?(@blob.path), } end def copy_file_path_button(file_path) - clipboard_button(text: file_path, gfm: "`#{file_path}`", class: 'btn-clipboard btn-transparent prepend-left-5', title: 'Copy file path to clipboard') + clipboard_button(text: file_path, gfm: "`#{file_path}`", class: "btn-clipboard btn-transparent prepend-left-5", title: "Copy file path to clipboard") end def copy_blob_source_button(blob) @@ -197,15 +201,15 @@ module BlobHelper return if blob.empty? return if blob.binary? || blob.stored_externally? - title = 'Open raw' - link_to icon('file-code-o'), blob_raw_path, class: 'btn btn-sm has-tooltip', target: '_blank', rel: 'noopener noreferrer', title: title, data: { container: 'body' } + title = "Open raw" + link_to icon("file-code-o"), blob_raw_path, class: "btn btn-sm has-tooltip", target: "_blank", rel: "noopener noreferrer", title: title, data: {container: "body"} end def download_blob_button(blob) return if blob.empty? - title = 'Download' - link_to sprite_icon('download'), blob_raw_path(inline: false), download: @path, class: 'btn btn-sm has-tooltip', target: '_blank', rel: 'noopener noreferrer', title: title, data: { container: 'body' } + title = "Download" + link_to sprite_icon("download"), blob_raw_path(inline: false), download: @path, class: "btn btn-sm has-tooltip", target: "_blank", rel: "noopener noreferrer", title: title, data: {container: "body"} end def blob_render_error_reason(viewer) @@ -217,11 +221,11 @@ module BlobHelper when :server_side_but_stored_externally case viewer.blob.external_storage when :lfs - 'it is stored in LFS' + "it is stored in LFS" when :build_artifact - 'it is stored as a job artifact' + "it is stored as a job artifact" else - 'it is stored externally' + "it is stored externally" end end end @@ -231,16 +235,16 @@ module BlobHelper options = [] if error == :collapsed - options << link_to('load it anyway', url_for(safe_params.merge(viewer: viewer.type, expanded: true, format: nil))) + options << link_to("load it anyway", url_for(safe_params.merge(viewer: viewer.type, expanded: true, format: nil))) end # If the error is `:server_side_but_stored_externally`, the simple viewer will show the same error, # so don't bother switching. if viewer.rich? && viewer.blob.rendered_as_text? && error != :server_side_but_stored_externally - options << link_to('view the source', '#', class: 'js-blob-viewer-switch-btn', data: { viewer: 'simple' }) + options << link_to("view the source", "#", class: "js-blob-viewer-switch-btn", data: {viewer: "simple"}) end - options << link_to('download it', blob_raw_path, target: '_blank', rel: 'noopener noreferrer') + options << link_to("download it", blob_raw_path, target: "_blank", rel: "noopener noreferrer") options end @@ -262,7 +266,11 @@ module BlobHelper def readable_blob(options, path, project, ref) blob = options.delete(:blob) - blob ||= project.repository.blob_at(ref, path) rescue nil + blob ||= begin + project.repository.blob_at(ref, path) + rescue + nil + end blob if blob&.readable_text? end @@ -271,7 +279,7 @@ module BlobHelper { to: path, notice: edit_in_new_fork_notice, - notice_now: edit_in_new_fork_notice_now + notice_now: edit_in_new_fork_notice_now, } end @@ -279,20 +287,20 @@ module BlobHelper { to: request.fullpath, notice: edit_in_new_fork_notice_action(action), - notice_now: edit_in_new_fork_notice_now + notice_now: edit_in_new_fork_notice_now, } end - def edit_fork_button_tag(common_classes, project, label, params, action = 'edit') + def edit_fork_button_tag(common_classes, project, label, params, action = "edit") fork_path = project_forks_path(project, namespace_key: current_user.namespace.id, continue: params) button_tag label, - class: "#{common_classes} js-edit-blob-link-fork-toggler", - data: { action: action, fork_path: fork_path } + class: "#{common_classes} js-edit-blob-link-fork-toggler", + data: {action: action, fork_path: fork_path} end def edit_disabled_button_tag(button_text, common_classes) - button_tag(button_text, class: "#{common_classes} disabled has-tooltip", title: _('You can only edit files when you are on a branch'), data: { container: 'body' }) + button_tag(button_text, class: "#{common_classes} disabled has-tooltip", title: _("You can only edit files when you are on a branch"), data: {container: "body"}) end def edit_link_tag(link_text, edit_path, common_classes) diff --git a/app/helpers/boards_helper.rb b/app/helpers/boards_helper.rb index be1e7016a1e..d869897db07 100644 --- a/app/helpers/boards_helper.rb +++ b/app/helpers/boards_helper.rb @@ -10,11 +10,11 @@ module BoardsHelper boards_endpoint: @boards_endpoint, lists_endpoint: board_lists_path(board), board_id: board.id, - disabled: "#{!can?(current_user, :admin_list, current_board_parent)}", + disabled: (!can?(current_user, :admin_list, current_board_parent)).to_s, issue_link_base: build_issue_link_base, root_path: root_path, bulk_update_path: @bulk_issues_path, - default_avatar: image_path(default_avatar) + default_avatar: image_path(default_avatar), } end @@ -40,10 +40,10 @@ module BoardsHelper def current_board_path(board) @current_board_path ||= if board.group_board? - group_board_path(current_board_parent, board) - else - project_board_path(current_board_parent, board) - end + group_board_path(current_board_parent, board) + else + project_board_path(current_board_parent, board) + end end def current_board_parent @@ -64,7 +64,7 @@ module BoardsHelper labels_endpoint: @labels_endpoint, namespace_path: @namespace_path, project_path: @project&.path, - group_path: @group&.path + group_path: @group&.path, } end @@ -72,16 +72,16 @@ module BoardsHelper dropdown_options = issue_assignees_dropdown_options { - toggle: 'dropdown', - field_name: 'issue[assignee_ids][]', + toggle: "dropdown", + field_name: "issue[assignee_ids][]", first_user: current_user&.username, - current_user: 'true', + current_user: "true", project_id: @project&.id, group_id: @group&.id, - null_user: 'true', - multi_select: 'true', + null_user: "true", + multi_select: "true", 'dropdown-header': dropdown_options[:data][:'dropdown-header'], - 'max-select': dropdown_options[:data][:'max-select'] + 'max-select': dropdown_options[:data][:'max-select'], } end diff --git a/app/helpers/breadcrumbs_helper.rb b/app/helpers/breadcrumbs_helper.rb index b067376cea0..377d5099ec0 100644 --- a/app/helpers/breadcrumbs_helper.rb +++ b/app/helpers/breadcrumbs_helper.rb @@ -5,7 +5,7 @@ module BreadcrumbsHelper @breadcrumbs_extra_links ||= [] @breadcrumbs_extra_links.push({ text: text, - link: link + link: link, }) end diff --git a/app/helpers/broadcast_messages_helper.rb b/app/helpers/broadcast_messages_helper.rb index 289cb44f1e8..394d5d54cba 100644 --- a/app/helpers/broadcast_messages_helper.rb +++ b/app/helpers/broadcast_messages_helper.rb @@ -4,8 +4,8 @@ module BroadcastMessagesHelper def broadcast_message(message) return unless message.present? - content_tag :div, class: 'broadcast-message', style: broadcast_message_style(message) do - icon('bullhorn') << ' ' << render_broadcast_message(message) + content_tag :div, class: "broadcast-message", style: broadcast_message_style(message) do + icon("bullhorn") << " " << render_broadcast_message(message) end end @@ -20,16 +20,16 @@ module BroadcastMessagesHelper style << "color: #{broadcast_message.font}" end - style.join('; ') + style.join("; ") end def broadcast_message_status(broadcast_message) if broadcast_message.active? - 'Active' + "Active" elsif broadcast_message.ended? - 'Expired' + "Expired" else - 'Pending' + "Pending" end end diff --git a/app/helpers/builds_helper.rb b/app/helpers/builds_helper.rb index 3c8caec3fe5..c1df49473b2 100644 --- a/app/helpers/builds_helper.rb +++ b/app/helpers/builds_helper.rb @@ -15,9 +15,9 @@ module BuildsHelper def sidebar_build_class(build, current_build) build_class = [] - build_class << 'active' if build.id === current_build.id - build_class << 'retried' if build.retried? - build_class.join(' ') + build_class << "active" if build.id === current_build.id + build_class << "retried" if build.retried? + build_class.join(" ") end def javascript_build_options @@ -25,14 +25,14 @@ module BuildsHelper page_path: project_job_path(@project, @build), build_status: @build.status, build_stage: @build.stage, - log_state: '' + log_state: "", } end def build_failed_issue_options { title: "Job Failed ##{@build.id}", - description: project_job_url(@project, @build) + description: project_job_url(@project, @build), } end end diff --git a/app/helpers/button_helper.rb b/app/helpers/button_helper.rb index 494c754e7d5..b13bbbf518b 100644 --- a/app/helpers/button_helper.rb +++ b/app/helpers/button_helper.rb @@ -20,9 +20,9 @@ module ButtonHelper # # See http://clipboardjs.com/#usage def clipboard_button(data = {}) - css_class = data[:class] || 'btn-clipboard btn-transparent' - title = data[:title] || 'Copy to clipboard' - button_text = data[:button_text] || '' + css_class = data[:class] || "btn-clipboard btn-transparent" + title = data[:title] || "Copy to clipboard" + button_text = data[:button_text] || "" hide_tooltip = data[:hide_tooltip] || false hide_button_icon = data[:hide_button_icon] || false @@ -31,7 +31,7 @@ module ButtonHelper if text = data.delete(:text) data[:clipboard_text] = if gfm = data.delete(:gfm) - { text: text, gfm: gfm } + {text: text, gfm: gfm} else text end @@ -41,7 +41,7 @@ module ButtonHelper data[:clipboard_target] = target if target unless hide_tooltip - data = { toggle: 'tooltip', placement: 'bottom', container: 'body' }.merge(data) + data = {toggle: "tooltip", placement: "bottom", container: "body"}.merge(data) end button_attributes = { @@ -49,11 +49,11 @@ module ButtonHelper data: data, type: :button, title: title, - aria: { label: title } + aria: {label: title}, } content_tag :button, button_attributes do - concat(sprite_icon('duplicate')) unless hide_button_icon + concat(sprite_icon("duplicate")) unless hide_button_icon concat(button_text) end end @@ -63,14 +63,14 @@ module ButtonHelper dropdown_description = http_dropdown_description(protocol) append_url = project.http_url_to_repo if append_link - dropdown_item_with_description(protocol, dropdown_description, href: append_url, data: { clone_type: 'http' }) + dropdown_item_with_description(protocol, dropdown_description, href: append_url, data: {clone_type: "http"}) end def http_dropdown_description(protocol) if current_user.try(:require_password_creation_for_git?) - _("Set a password on your account to pull or push via %{protocol}.") % { protocol: protocol } + _("Set a password on your account to pull or push via %{protocol}.") % {protocol: protocol} elsif current_user.try(:require_personal_access_token_creation_for_git_auth?) - _("Create a personal access token on your account to pull or push via %{protocol}.") % { protocol: protocol } + _("Create a personal access token on your account to pull or push via %{protocol}.") % {protocol: protocol} end end @@ -82,18 +82,18 @@ module ButtonHelper append_url = project.ssh_url_to_repo if append_link - dropdown_item_with_description('SSH', dropdown_description, href: append_url, data: { clone_type: 'ssh' }) + dropdown_item_with_description("SSH", dropdown_description, href: append_url, data: {clone_type: "ssh"}) end def dropdown_item_with_description(title, description, href: nil, data: nil, default: false) active_class = "is-active" if default - button_content = content_tag(:strong, title, class: 'dropdown-menu-inner-title') - button_content << content_tag(:span, description, class: 'dropdown-menu-inner-content') if description + button_content = content_tag(:strong, title, class: "dropdown-menu-inner-title") + button_content << content_tag(:span, description, class: "dropdown-menu-inner-content") if description content_tag (href ? :a : :span), (href ? button_content : title), class: "#{title.downcase}-selector #{active_class}", - href: (href if href), - data: (data if data) + href: href, + data: data end end diff --git a/app/helpers/calendar_helper.rb b/app/helpers/calendar_helper.rb index ad4116fc3da..c36d74ff80a 100644 --- a/app/helpers/calendar_helper.rb +++ b/app/helpers/calendar_helper.rb @@ -2,9 +2,9 @@ module CalendarHelper def calendar_url_options - { format: :ics, - feed_token: current_user.try(:feed_token), - due_date: Issue::DueNextMonthAndPreviousTwoWeeks.name, - sort: 'closest_future_date' } + {format: :ics, + feed_token: current_user.try(:feed_token), + due_date: Issue::DueNextMonthAndPreviousTwoWeeks.name, + sort: "closest_future_date",} end end diff --git a/app/helpers/ci_status_helper.rb b/app/helpers/ci_status_helper.rb index 923a06a0512..9accced1237 100644 --- a/app/helpers/ci_status_helper.rb +++ b/app/helpers/ci_status_helper.rb @@ -14,17 +14,17 @@ module CiStatusHelper end label = case status - when 'success' - 'passed' - when 'success_with_warnings' - 'passed with warnings' - when 'manual' - 'waiting for manual action' - when 'scheduled' - 'waiting for delayed job' + when "success" + "passed" + when "success_with_warnings" + "passed with warnings" + when "manual" + "waiting for manual action" + when "scheduled" + "waiting for delayed job" else status - end + end translation = "CiStatusLabel|#{label}" s_(translation) end @@ -35,14 +35,14 @@ module CiStatusHelper end case status - when 'success' - s_('CiStatusText|passed') - when 'success_with_warnings' - s_('CiStatusText|passed') - when 'manual' - s_('CiStatusText|blocked') - when 'scheduled' - s_('CiStatusText|delayed') + when "success" + s_("CiStatusText|passed") + when "success_with_warnings" + s_("CiStatusText|passed") + when "manual" + s_("CiStatusText|blocked") + when "scheduled" + s_("CiStatusText|delayed") else # All states are already being translated inside the detailed statuses: # :running => Gitlab::Ci::Status::Running @@ -58,7 +58,7 @@ module CiStatusHelper end def ci_status_for_statuseable(subject) - status = subject.try(:status) || 'not found' + status = subject.try(:status) || "not found" status.humanize end @@ -69,28 +69,28 @@ module CiStatusHelper icon_name = case status - when 'success' - 'status_success' - when 'success_with_warnings' - 'status_warning' - when 'failed' - 'status_failed' - when 'pending' - 'status_pending' - when 'running' - 'status_running' - when 'play' - 'play' - when 'created' - 'status_created' - when 'skipped' - 'status_skipped' - when 'manual' - 'status_manual' - when 'scheduled' - 'status_scheduled' + when "success" + "status_success" + when "success_with_warnings" + "status_warning" + when "failed" + "status_failed" + when "pending" + "status_pending" + when "running" + "status_running" + when "play" + "play" + when "created" + "status_created" + when "skipped" + "status_skipped" + when "manual" + "status_manual" + when "scheduled" + "status_scheduled" else - 'status_canceled' + "status_canceled" end sprite_icon(icon_name, size: size) @@ -100,46 +100,48 @@ module CiStatusHelper "pipeline-status/#{pipeline_status.sha}-#{pipeline_status.status}" end - def render_project_pipeline_status(pipeline_status, tooltip_placement: 'left') + def render_project_pipeline_status(pipeline_status, tooltip_placement: "left") project = pipeline_status.project path = pipelines_project_commit_path(project, pipeline_status.sha, ref: pipeline_status.ref) render_status_with_link( - 'commit', + "commit", pipeline_status.status, path, - tooltip_placement: tooltip_placement) + tooltip_placement: tooltip_placement + ) end - def render_commit_status(commit, ref: nil, tooltip_placement: 'left') + def render_commit_status(commit, ref: nil, tooltip_placement: "left") project = commit.project path = pipelines_project_commit_path(project, commit, ref: ref) render_status_with_link( - 'commit', + "commit", commit.status(ref), path, tooltip_placement: tooltip_placement, - icon_size: 24) + icon_size: 24 + ) end - def render_pipeline_status(pipeline, tooltip_placement: 'left') + def render_pipeline_status(pipeline, tooltip_placement: "left") project = pipeline.project path = project_pipeline_path(project, pipeline) - render_status_with_link('pipeline', pipeline.status, path, tooltip_placement: tooltip_placement) + render_status_with_link("pipeline", pipeline.status, path, tooltip_placement: tooltip_placement) end - def render_status_with_link(type, status, path = nil, tooltip_placement: 'left', cssclass: '', container: 'body', icon_size: 16) + def render_status_with_link(type, status, path = nil, tooltip_placement: "left", cssclass: "", container: "body", icon_size: 16) klass = "ci-status-link ci-status-icon-#{status.dasherize} #{cssclass}" title = "#{type.titleize}: #{ci_label_for_status(status)}" - data = { toggle: 'tooltip', placement: tooltip_placement, container: container } + data = {toggle: "tooltip", placement: tooltip_placement, container: container} if path link_to ci_icon_for_status(status, size: icon_size), path, - class: klass, title: title, data: data + class: klass, title: title, data: data else content_tag :span, ci_icon_for_status(status, size: icon_size), - class: klass, title: title, data: data + class: klass, title: title, data: data end end diff --git a/app/helpers/clusters_helper.rb b/app/helpers/clusters_helper.rb index 916dcb1a308..e7e3093cee3 100644 --- a/app/helpers/clusters_helper.rb +++ b/app/helpers/clusters_helper.rb @@ -10,8 +10,8 @@ module ClustersHelper return if Gitlab::CurrentSettings.current_application_settings.hide_third_party_offers? return unless show_gcp_signup_offer? - content_tag :section, class: 'no-animate expanded' do - render 'clusters/clusters/gcp_signup_offer_banner' + content_tag :section, class: "no-animate expanded" do + render "clusters/clusters/gcp_signup_offer_banner" end end end diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb index d58f634425b..f1e4531c21d 100644 --- a/app/helpers/commits_helper.rb +++ b/app/helpers/commits_helper.rb @@ -18,7 +18,7 @@ module CommitsHelper end def commit_to_html(commit, ref, project) - render 'projects/commits/commit', + render "projects/commits/commit", commit: commit, ref: ref, project: project @@ -29,27 +29,27 @@ module CommitsHelper return unless @project && @ref # Add the root project link and the arrow icon - crumbs = content_tag(:li, class: 'breadcrumb-item') do + crumbs = content_tag(:li, class: "breadcrumb-item") { link_to( @project.path, project_commits_path(@project, @ref) ) - end + } if @path - parts = @path.split('/') + parts = @path.split("/") parts.each_with_index do |part, i| - crumbs << content_tag(:li, class: 'breadcrumb-item') do + crumbs << content_tag(:li, class: "breadcrumb-item") { # The text is just the individual part, but the link needs all the parts before it link_to( part, project_commits_path( @project, - tree_join(@ref, parts[0..i].join('/')) + tree_join(@ref, parts[0..i].join("/")) ) ) - end + } end end @@ -64,31 +64,31 @@ module CommitsHelper # Returns a link formatted as a commit branch link def commit_branch_link(url, text) - link_to(url, class: 'badge badge-gray ref-name branch-link') do - sprite_icon('branch', size: 12, css_class: 'fork-svg') + "#{text}" + link_to(url, class: "badge badge-gray ref-name branch-link") do + sprite_icon("branch", size: 12, css_class: "fork-svg") + text.to_s end end # Returns the sorted alphabetically links to branches, separated by a comma def commit_branches_links(project, branches) - branches.sort.map do |branch| + branches.sort.map { |branch| commit_branch_link(project_ref_path(project, branch), branch) - end.join(' ').html_safe + }.join(" ").html_safe end # Returns a link formatted as a commit tag link def commit_tag_link(url, text) - link_to(url, class: 'badge badge-gray ref-name') do - sprite_icon('tag', size: 12, css_class: 'append-right-5 vertical-align-middle') + "#{text}" + link_to(url, class: "badge badge-gray ref-name") do + sprite_icon("tag", size: 12, css_class: "append-right-5 vertical-align-middle") + text.to_s end end # Returns the sorted links to tags, separated by a comma def commit_tags_links(project, tags) sorted = VersionSorter.rsort(tags) - sorted.map do |tag| + sorted.map { |tag| commit_tag_link(project_ref_path(project, tag), tag) - end.join(' ').html_safe + }.join(" ").html_safe end def link_to_browse_code(project, commit) @@ -105,21 +105,21 @@ module CommitsHelper tooltip = _("Browse Directory") end - link_to url, class: "btn btn-default has-tooltip", title: tooltip, data: { container: "body" } do - sprite_icon('folder-open') + link_to url, class: "btn btn-default has-tooltip", title: tooltip, data: {container: "body"} do + sprite_icon("folder-open") end end def revert_commit_link(commit, continue_to_path, btn_class: nil, has_tooltip: true) - commit_action_link('revert', commit, continue_to_path, btn_class: btn_class, has_tooltip: has_tooltip) + commit_action_link("revert", commit, continue_to_path, btn_class: btn_class, has_tooltip: has_tooltip) end def cherry_pick_commit_link(commit, continue_to_path, btn_class: nil, has_tooltip: true) - commit_action_link('cherry-pick', commit, continue_to_path, btn_class: btn_class, has_tooltip: has_tooltip) + commit_action_link("cherry-pick", commit, continue_to_path, btn_class: btn_class, has_tooltip: has_tooltip) end def commit_signature_badge_classes(additional_classes) - %w(btn gpg-status-box) + Array(additional_classes) + %w[btn gpg-status-box] + Array(additional_classes) end protected @@ -148,13 +148,13 @@ module CommitsHelper end link_options = { - class: "commit-#{options[:source]}-link" + class: "commit-#{options[:source]}-link", } if user.nil? mail_to(source_email, text, link_options) else - link_to(text, user_path(user), { class: "commit-#{options[:source]}-link js-user-link", data: { user_id: user.id } }) + link_to(text, user_path(user), {class: "commit-#{options[:source]}-link js-user-link", data: {user_id: user.id}}) end end @@ -165,31 +165,31 @@ module CommitsHelper btn_class = "btn btn-#{btn_class}" unless btn_class.nil? if can_collaborate_with_project?(@project) - link_to action.capitalize, "#modal-#{action}-commit", 'data-toggle' => 'modal', 'data-container' => 'body', title: (tooltip if has_tooltip), class: "#{btn_class} #{'has-tooltip' if has_tooltip}" + link_to action.capitalize, "#modal-#{action}-commit", "data-toggle" => "modal", "data-container" => "body", :title => (tooltip if has_tooltip), :class => "#{btn_class} #{"has-tooltip" if has_tooltip}" elsif can?(current_user, :fork_project, @project) continue_params = { to: continue_to_path, notice: "#{edit_in_new_fork_notice} Try to #{action} this commit again.", - notice_now: edit_in_new_fork_notice_now + notice_now: edit_in_new_fork_notice_now, } fork_path = project_forks_path(@project, namespace_key: current_user.namespace.id, continue: continue_params) - link_to action.capitalize, fork_path, class: btn_class, method: :post, 'data-toggle' => 'tooltip', 'data-container' => 'body', title: (tooltip if has_tooltip) + link_to action.capitalize, fork_path, :class => btn_class, :method => :post, "data-toggle" => "tooltip", "data-container" => "body", :title => (tooltip if has_tooltip) end end def view_file_button(commit_sha, diff_new_path, project, replaced: false) - title = replaced ? _('View replaced file @ ') : _('View file @ ') + title = replaced ? _("View replaced file @ ") : _("View file @ ") link_to( project_blob_path(project, - tree_join(commit_sha, diff_new_path)), - class: 'btn view-file js-view-file' + tree_join(commit_sha, diff_new_path)), + class: "btn view-file js-view-file" ) do raw(title) + content_tag(:span, Commit.truncate_sha(commit_sha), - class: 'commit-sha') + class: "commit-sha") end end @@ -199,8 +199,8 @@ module CommitsHelper external_url = environment.external_url_for(diff_new_path, commit_sha) return unless external_url - link_to(external_url, class: 'btn btn-file-option has-tooltip', target: '_blank', rel: 'noopener noreferrer', title: "View on #{environment.formatted_external_url}", data: { container: 'body' }) do - icon('external-link') + link_to(external_url, class: "btn btn-file-option has-tooltip", target: "_blank", rel: "noopener noreferrer", title: "View on #{environment.formatted_external_url}", data: {container: "body"}) do + icon("external-link") end end diff --git a/app/helpers/compare_helper.rb b/app/helpers/compare_helper.rb index 9ece8b0bc5b..f2d2e42eb96 100644 --- a/app/helpers/compare_helper.rb +++ b/app/helpers/compare_helper.rb @@ -15,7 +15,7 @@ module CompareHelper project, merge_request: { source_branch: to, - target_branch: from + target_branch: from, } ) end diff --git a/app/helpers/components_helper.rb b/app/helpers/components_helper.rb index d0ef86851ad..ea1474fbb9d 100644 --- a/app/helpers/components_helper.rb +++ b/app/helpers/components_helper.rb @@ -2,8 +2,8 @@ module ComponentsHelper def gitlab_workhorse_version - if request.headers['Gitlab-Workhorse'].present? - request.headers['Gitlab-Workhorse'].split('-').first + if request.headers["Gitlab-Workhorse"].present? + request.headers["Gitlab-Workhorse"].split("-").first else Gitlab::Workhorse.version end diff --git a/app/helpers/conversational_development_index_helper.rb b/app/helpers/conversational_development_index_helper.rb index 37e5bb325fb..60c8a0457c8 100644 --- a/app/helpers/conversational_development_index_helper.rb +++ b/app/helpers/conversational_development_index_helper.rb @@ -3,11 +3,11 @@ module ConversationalDevelopmentIndexHelper def score_level(score) if score < 33.33 - 'low' + "low" elsif score < 66.66 - 'average' + "average" else - 'high' + "high" end end diff --git a/app/helpers/cookies_helper.rb b/app/helpers/cookies_helper.rb index 3a7e9987190..1670f2b59cc 100644 --- a/app/helpers/cookies_helper.rb +++ b/app/helpers/cookies_helper.rb @@ -4,6 +4,6 @@ module CookiesHelper def set_secure_cookie(key, value, httponly: false, permanent: false) cookie_jar = permanent ? cookies.permanent : cookies - cookie_jar[key] = { value: value, secure: Gitlab.config.gitlab.https, httponly: httponly } + cookie_jar[key] = {value: value, secure: Gitlab.config.gitlab.https, httponly: httponly} end end diff --git a/app/helpers/diff_helper.rb b/app/helpers/diff_helper.rb index 32431959851..7b733c496eb 100644 --- a/app/helpers/diff_helper.rb +++ b/app/helpers/diff_helper.rb @@ -16,7 +16,7 @@ module DiffHelper def diff_view @diff_view ||= begin - diff_views = %w(inline parallel) + diff_views = %w[inline parallel] diff_view = params[:view] || cookies[:diff_view] diff_view = diff_views.first unless diff_views.include?(diff_view) diff_view.to_sym @@ -24,9 +24,9 @@ module DiffHelper end def diff_options - options = { ignore_whitespace_change: hide_whitespace?, expanded: diffs_expanded? } + options = {ignore_whitespace_change: hide_whitespace?, expanded: diffs_expanded?} - if action_name == 'diff_for_path' + if action_name == "diff_for_path" options[:expanded] = true options[:paths] = params.values_at(:old_path, :new_path) end @@ -34,23 +34,23 @@ module DiffHelper options end - def diff_match_line(old_pos, new_pos, text: '', view: :inline, bottom: false) + def diff_match_line(old_pos, new_pos, text: "", view: :inline, bottom: false) content_line_class = %w[line_content match] - content_line_class << 'parallel' if view == :parallel + content_line_class << "parallel" if view == :parallel line_num_class = %w[diff-line-num unfold js-unfold] - line_num_class << 'js-unfold-bottom' if bottom + line_num_class << "js-unfold-bottom" if bottom html = [] if old_pos - html << content_tag(:td, '...', class: [*line_num_class, 'old_line'], data: { linenumber: old_pos }) - html << content_tag(:td, text, class: [*content_line_class, 'left-side']) if view == :parallel + html << content_tag(:td, "...", class: [*line_num_class, "old_line"], data: {linenumber: old_pos}) + html << content_tag(:td, text, class: [*content_line_class, "left-side"]) if view == :parallel end if new_pos - html << content_tag(:td, '...', class: [*line_num_class, 'new_line'], data: { linenumber: new_pos }) - html << content_tag(:td, text, class: [*content_line_class, ('right-side' if view == :parallel)]) + html << content_tag(:td, "...", class: [*line_num_class, "new_line"], data: {linenumber: new_pos}) + html << content_tag(:td, text, class: [*content_line_class, ("right-side" if view == :parallel)]) end html.join.html_safe @@ -61,7 +61,7 @@ module DiffHelper " ".html_safe else # We can't use `sub` because the HTML-safeness of `line` will not survive. - line[0] = '' if line.start_with?('+', '-', ' ') + line[0] = "" if line.start_with?("+", "-", " ") line end end @@ -71,12 +71,12 @@ module DiffHelper discussions_left = discussions_right = nil - if left && left.discussable? && (left.unchanged? || left.removed?) + if left&.discussable? && (left&.unchanged? || left&.removed?) line_code = diff_file.line_code(left) discussions_left = @grouped_diff_discussions[line_code] end - if right && right.discussable? && right.added? + if right&.discussable? && right&.added? line_code = diff_file.line_code(right) discussions_right = @grouped_diff_discussions[line_code] end @@ -85,26 +85,26 @@ module DiffHelper end def inline_diff_btn - diff_btn('Inline', 'inline', diff_view == :inline) + diff_btn("Inline", "inline", diff_view == :inline) end def parallel_diff_btn - diff_btn('Side-by-side', 'parallel', diff_view == :parallel) + diff_btn("Side-by-side", "parallel", diff_view == :parallel) end def submodule_link(blob, ref, repository = @repository) project_url, tree_url = submodule_links(blob, ref, repository) commit_id = if tree_url.nil? - Commit.truncate_sha(blob.id) - else - link_to Commit.truncate_sha(blob.id), tree_url - end + Commit.truncate_sha(blob.id) + else + link_to Commit.truncate_sha(blob.id), tree_url + end [ content_tag(:span, link_to(truncate(blob.name, length: 40), project_url)), - '@', - content_tag(:span, commit_id, class: 'commit-sha') - ].join(' ').html_safe + "@", + content_tag(:span, commit_id, class: "commit-sha"), + ].join(" ").html_safe end def diff_file_blob_raw_url(diff_file, only_path: false) @@ -129,8 +129,8 @@ module DiffHelper def diff_file_html_data(project, diff_file_path, diff_commit_id) { blob_diff_path: project_blob_diff_path(project, - tree_join(diff_commit_id, diff_file_path)), - view: diff_view + tree_join(diff_commit_id, diff_file_path)), + view: diff_view, } end @@ -165,7 +165,7 @@ module DiffHelper # Always use HTML to handle case where JSON diff rendered this button params_copy.delete(:format) - link_to url_for(params_copy), id: "#{name}-diff-btn", class: (selected ? 'btn active' : 'btn'), data: { view_type: name } do + link_to url_for(params_copy), id: "#{name}-diff-btn", class: (selected ? "btn active" : "btn"), data: {view_type: name} do title end end @@ -186,7 +186,7 @@ module DiffHelper end def hide_whitespace? - params[:w] == '1' + params[:w] == "1" end # rubocop: disable CodeReuse/ActiveRecord @@ -196,8 +196,8 @@ module DiffHelper # rubocop: enable CodeReuse/ActiveRecord def toggle_whitespace_link(url, options) - options[:class] = [*options[:class], 'btn btn-default'].join(' ') - link_to "#{hide_whitespace? ? 'Show' : 'Hide'} whitespace changes", url, class: options[:class] + options[:class] = [*options[:class], "btn btn-default"].join(" ") + link_to "#{hide_whitespace? ? "Show" : "Hide"} whitespace changes", url, class: options[:class] end def render_overflow_warning?(diff_files) diff --git a/app/helpers/dropdowns_helper.rb b/app/helpers/dropdowns_helper.rb index 8d8c62f1291..890d506d6c5 100644 --- a/app/helpers/dropdowns_helper.rb +++ b/app/helpers/dropdowns_helper.rb @@ -3,7 +3,7 @@ module DropdownsHelper def dropdown_tag(toggle_text, options: {}, &block) content_tag :div, class: "dropdown #{options[:wrapper_class] if options.key?(:wrapper_class)}" do - data_attr = { toggle: "dropdown" } + data_attr = {toggle: "dropdown"} if options.key?(:data) data_attr = options[:data].merge(data_attr) @@ -15,7 +15,7 @@ module DropdownsHelper dropdown_output = dropdown_toggle_link(toggle_text, data_attr, options) end - dropdown_output << content_tag(:div, class: "dropdown-menu dropdown-select #{options[:dropdown_class] if options.key?(:dropdown_class)}") do + dropdown_output << content_tag(:div, class: "dropdown-menu dropdown-select #{options[:dropdown_class] if options.key?(:dropdown_class)}") { output = [] if options.key?(:title) @@ -26,19 +26,19 @@ module DropdownsHelper output << dropdown_filter(options[:placeholder]) end - output << content_tag(:div, class: "dropdown-content #{options[:content_class] if options.key?(:content_class)}") do + output << content_tag(:div, class: "dropdown-content #{options[:content_class] if options.key?(:content_class)}") { capture(&block) if block && !options.key?(:footer_content) - end + } if block && options[:footer_content] - output << content_tag(:div, class: "dropdown-footer") do + output << content_tag(:div, class: "dropdown-footer") { capture(&block) - end + } end output << dropdown_loading output.join.html_safe - end + } dropdown_output.html_safe end @@ -47,8 +47,8 @@ module DropdownsHelper def dropdown_toggle(toggle_text, data_attr, options = {}) default_label = data_attr[:default_label] content_tag(:button, disabled: options[:disabled], class: "dropdown-menu-toggle #{options[:toggle_class] if options.key?(:toggle_class)}", id: (options[:id] if options.key?(:id)), type: "button", data: data_attr) do - output = content_tag(:span, toggle_text, class: "dropdown-toggle-text #{'is-default' if toggle_text == default_label}") - output << icon('chevron-down') + output = content_tag(:span, toggle_text, class: "dropdown-toggle-text #{"is-default" if toggle_text == default_label}") + output << icon("chevron-down") output.html_safe end end @@ -63,17 +63,17 @@ module DropdownsHelper title_output = [] if options.fetch(:back, false) - title_output << content_tag(:button, class: "dropdown-title-button dropdown-menu-back", aria: { label: "Go back" }, type: "button") do - icon('arrow-left') - end + title_output << content_tag(:button, class: "dropdown-title-button dropdown-menu-back", aria: {label: "Go back"}, type: "button") { + icon("arrow-left") + } end title_output << content_tag(:span, title) if options.fetch(:close, true) - title_output << content_tag(:button, class: "dropdown-title-button dropdown-menu-close", aria: { label: "Close" }, type: "button") do - icon('times', class: 'dropdown-menu-close-icon') - end + title_output << content_tag(:button, class: "dropdown-title-button dropdown-menu-close", aria: {label: "Close"}, type: "button") { + icon("times", class: "dropdown-menu-close-icon") + } end title_output.join.html_safe @@ -82,8 +82,8 @@ module DropdownsHelper def dropdown_input(placeholder, input_id: nil) content_tag :div, class: "dropdown-input" do - filter_output = text_field_tag input_id, nil, class: "dropdown-input-field dropdown-no-filter", placeholder: placeholder, autocomplete: 'off' - filter_output << icon('times', class: "dropdown-input-clear js-dropdown-input-clear", role: "button") + filter_output = text_field_tag input_id, nil, class: "dropdown-input-field dropdown-no-filter", placeholder: placeholder, autocomplete: "off" + filter_output << icon("times", class: "dropdown-input-clear js-dropdown-input-clear", role: "button") filter_output.html_safe end @@ -91,9 +91,9 @@ module DropdownsHelper def dropdown_filter(placeholder, search_id: nil) content_tag :div, class: "dropdown-input" do - filter_output = search_field_tag search_id, nil, class: "dropdown-input-field", placeholder: placeholder, autocomplete: 'off' - filter_output << icon('search', class: "dropdown-input-search") - filter_output << icon('times', class: "dropdown-input-clear js-dropdown-input-clear", role: "button") + filter_output = search_field_tag search_id, nil, class: "dropdown-input-field", placeholder: placeholder, autocomplete: "off" + filter_output << icon("search", class: "dropdown-input-search") + filter_output << icon("times", class: "dropdown-input-clear js-dropdown-input-clear", role: "button") filter_output.html_safe end @@ -119,7 +119,7 @@ module DropdownsHelper def dropdown_loading content_tag :div, class: "dropdown-loading" do - icon('spinner spin') + icon("spinner spin") end end end diff --git a/app/helpers/emails_helper.rb b/app/helpers/emails_helper.rb index 96471d15aac..ed5f011644e 100644 --- a/app/helpers/emails_helper.rb +++ b/app/helpers/emails_helper.rb @@ -14,11 +14,11 @@ module EmailsHelper "action" => { "@type" => "ViewAction", "name" => name, - "url" => url - } - } + "url" => url, + }, + } - content_tag :script, type: 'application/ld+json' do + content_tag :script, type: "application/ld+json" do data.to_json.html_safe end end @@ -27,7 +27,7 @@ module EmailsHelper def action_title(url) return unless url - %w(merge_requests issues commit).each do |action| + %w[merge_requests issues commit].each do |action| if url.split("/").include?(action) return "View #{action.humanize.singularize}" end @@ -37,8 +37,8 @@ module EmailsHelper end def sanitize_name(name) - if name =~ URI::DEFAULT_PARSER.regexp[:URI_REF] - name.tr('.', '_') + if name&.match?(URI::DEFAULT_PARSER.regexp[:URI_REF]) + name.tr(".", "_") else name end @@ -47,10 +47,10 @@ module EmailsHelper def password_reset_token_valid_time valid_hours = Devise.reset_password_within / 60 / 60 if valid_hours >= 24 - unit = 'day' + unit = "day" valid_length = (valid_hours / 24).floor else - unit = 'hour' + unit = "hour" valid_length = valid_hours.floor end @@ -58,7 +58,7 @@ module EmailsHelper end def reset_token_expire_message - link_tag = link_to('request a new one', new_user_password_url(user_email: @user.email)) + link_tag = link_to("request a new one", new_user_password_url(user_email: @user.email)) "This link is valid for #{password_reset_token_valid_time}. " \ "After it expires, you can #{link_tag}." end @@ -67,13 +67,13 @@ module EmailsHelper if current_appearance&.header_logo? image_tag( current_appearance.header_logo_path, - style: 'height: 50px' + style: "height: 50px" ) else image_tag( - image_url('mailers/gitlab_header_logo.gif'), - size: '55x50', - alt: 'GitLab' + image_url("mailers/gitlab_header_logo.gif"), + size: "55x50", + alt: "GitLab" ) end end @@ -81,38 +81,38 @@ module EmailsHelper def email_default_heading(text) content_tag :h1, text, style: [ "font-family:'Helvetica Neue',Helvetica,Arial,sans-serif", - 'color:#333333', - 'font-size:18px', - 'font-weight:400', - 'line-height:1.4', - 'padding:0', - 'margin:0', - 'text-align:center' - ].join(';') + "color:#333333", + "font-size:18px", + "font-weight:400", + "line-height:1.4", + "padding:0", + "margin:0", + "text-align:center", + ].join(";") end # "You are receiving this email because #{reason}" def notification_reason_text(reason) string = case reason when NotificationReason::OWN_ACTIVITY - 'of your activity' + "of your activity" when NotificationReason::ASSIGNED - 'you have been assigned an item' + "you have been assigned an item" when NotificationReason::MENTIONED - 'you have been mentioned' + "you have been mentioned" else - 'of your account' - end + "of your account" + end "#{string} on #{Gitlab.config.gitlab.host}" end def create_list_id_string(project, list_id_max_length = 255) project_path_as_domain = project.full_path.downcase - .split('/').reverse.join('/') - .gsub(%r{[^a-z0-9\/]}, '-') - .gsub(%r{\/+}, '.') - .gsub(/(\A\.+|\.+\z)/, '') + .split("/").reverse.join("/") + .gsub(%r{[^a-z0-9\/]}, "-") + .gsub(%r{\/+}, ".") + .gsub(/(\A\.+|\.+\z)/, "") max_domain_length = list_id_max_length - Gitlab.config.gitlab.host.length - project.id.to_s.length - 2 @@ -135,25 +135,25 @@ module EmailsHelper def html_header_message return unless show_header? - render_message(:header_message, style: '') + render_message(:header_message, style: "") end def html_footer_message return unless show_footer? - render_message(:footer_message, style: '') + render_message(:footer_message, style: "") end def text_header_message return unless show_header? - strip_tags(render_message(:header_message, style: '')) + strip_tags(render_message(:header_message, style: "")) end def text_footer_message return unless show_footer? - strip_tags(render_message(:footer_message, style: '')) + strip_tags(render_message(:footer_message, style: "")) end private diff --git a/app/helpers/environment_helper.rb b/app/helpers/environment_helper.rb index 2b7320817ed..1b45ec53a2c 100644 --- a/app/helpers/environment_helper.rb +++ b/app/helpers/environment_helper.rb @@ -21,7 +21,7 @@ module EnvironmentHelper def deployment_link(deployment, text: nil) return unless deployment - link_label = text ? text : "##{deployment.iid}" + link_label = text || "##{deployment.iid}" link_to link_label, [deployment.project.namespace.becomes(Namespace), deployment.project, deployment.deployable] end diff --git a/app/helpers/environments_helper.rb b/app/helpers/environments_helper.rb index 365b94f5a3e..39a7c473f58 100644 --- a/app/helpers/environments_helper.rb +++ b/app/helpers/environments_helper.rb @@ -3,7 +3,7 @@ module EnvironmentsHelper def environments_list_data { - endpoint: project_environments_path(@project, format: :json) + endpoint: project_environments_path(@project, format: :json), } end @@ -11,26 +11,26 @@ module EnvironmentsHelper { "endpoint" => folder_project_environments_path(@project, @folder, format: :json), "folder-name" => @folder, - "can-read-environment" => can?(current_user, :read_environment, @project).to_s + "can-read-environment" => can?(current_user, :read_environment, @project).to_s, } end def metrics_data(project, environment) { - "settings-path" => edit_project_service_path(project, 'prometheus'), + "settings-path" => edit_project_service_path(project, "prometheus"), "clusters-path" => project_clusters_path(project), - "current-environment-name": environment.name, - "documentation-path" => help_page_path('administration/monitoring/prometheus/index.md'), - "empty-getting-started-svg-path" => image_path('illustrations/monitoring/getting_started.svg'), - "empty-loading-svg-path" => image_path('illustrations/monitoring/loading.svg'), - "empty-no-data-svg-path" => image_path('illustrations/monitoring/no_data.svg'), - "empty-unable-to-connect-svg-path" => image_path('illustrations/monitoring/unable_to_connect.svg'), + :"current-environment-name" => environment.name, + "documentation-path" => help_page_path("administration/monitoring/prometheus/index.md"), + "empty-getting-started-svg-path" => image_path("illustrations/monitoring/getting_started.svg"), + "empty-loading-svg-path" => image_path("illustrations/monitoring/loading.svg"), + "empty-no-data-svg-path" => image_path("illustrations/monitoring/no_data.svg"), + "empty-unable-to-connect-svg-path" => image_path("illustrations/monitoring/unable_to_connect.svg"), "metrics-endpoint" => additional_metrics_project_environment_path(project, environment, format: :json), "deployment-endpoint" => project_environment_deployments_path(project, environment, format: :json), - "environments-endpoint": project_environments_path(project, format: :json), + :"environments-endpoint" => project_environments_path(project, format: :json), "project-path" => project_path(project), "tags-path" => project_tags_path(project), - "has-metrics" => "#{environment.has_metrics?}" + "has-metrics" => environment.has_metrics?.to_s, } end end diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb index 1371e9993b4..42739862aa1 100644 --- a/app/helpers/events_helper.rb +++ b/app/helpers/events_helper.rb @@ -2,23 +2,23 @@ module EventsHelper ICON_NAMES_BY_EVENT_TYPE = { - 'pushed to' => 'commit', - 'pushed new' => 'commit', - 'created' => 'status_open', - 'opened' => 'status_open', - 'closed' => 'status_closed', - 'accepted' => 'fork', - 'commented on' => 'comment', - 'deleted' => 'remove', - 'imported' => 'import', - 'joined' => 'users' + "pushed to" => "commit", + "pushed new" => "commit", + "created" => "status_open", + "opened" => "status_open", + "closed" => "status_closed", + "accepted" => "fork", + "commented on" => "comment", + "deleted" => "remove", + "imported" => "import", + "joined" => "users", }.freeze def link_to_author(event, self_added: false) author = event.author if author - name = self_added ? 'You' : author.name + name = self_added ? "You" : author.name link_to name, user_path(author.username), title: name else escape_once(event.author_name) @@ -26,31 +26,31 @@ module EventsHelper end def event_action_name(event) - target = if event.target_type - if event.note? - event.note_target_type - else - event.target_type.titleize.downcase - end - else - 'project' - end + target = if event.target_type + if event.note? + event.note_target_type + else + event.target_type.titleize.downcase + end + else + "project" + end [event.action_name, target].join(" ") end def event_filter_link(key, text, tooltip) key = key.to_s - active = 'active' if @event_filter.active?(key) + active = "active" if @event_filter.active?(key) link_opts = { class: "event-filter-link", - id: "#{key}_event_filter", - title: tooltip + id: "#{key}_event_filter", + title: tooltip, } content_tag :li, class: active do link_to request.path, link_opts do - content_tag(:span, ' ' + text) + content_tag(:span, " " + text) end end end @@ -111,12 +111,12 @@ module EventsHelper def event_feed_url(event) if event.issue? project_issue_url(event.project, - event.issue) + event.issue) elsif event.merge_request? project_merge_request_url(event.project, event.merge_request) elsif event.commit_note? project_commit_url(event.project, - event.note_target) + event.note_target) elsif event.note? if event.note_target event_note_target_url(event) @@ -132,15 +132,15 @@ module EventsHelper if event.push_with_commits? && event.md_ref? if event.commits_count > 1 project_compare_url(event.project, - from: event.commit_from, to: - event.commit_to) + from: event.commit_from, to: + event.commit_to) else project_commit_url(event.project, - id: event.commit_to) + id: event.commit_to) end else project_commits_url(event.project, - event.ref_name) + event.ref_name) end end @@ -167,8 +167,8 @@ module EventsHelper project_merge_request_url(event.project, id: event.note_target, anchor: dom_id(event.target)) else polymorphic_url([event.project.namespace.becomes(Namespace), - event.project, event.note_target], - anchor: dom_id(event.target)) + event.project, event.note_target,], + anchor: dom_id(event.target)) end end @@ -176,15 +176,15 @@ module EventsHelper if event.note_target capture do concat content_tag(:span, event.note_target_type, class: "event-target-type append-right-4") - concat link_to(event.note_target_reference, event_note_target_url(event), title: event.target_title, class: 'has-tooltip event-target-link append-right-4') + concat link_to(event.note_target_reference, event_note_target_url(event), title: event.target_title, class: "has-tooltip event-target-link append-right-4") end else - content_tag(:strong, '(deleted)') + content_tag(:strong, "(deleted)") end end def event_commit_title(message) - message ||= '' + message ||= "" (message.split("\n").first || "").truncate(70) rescue "--broken encoding" @@ -196,19 +196,19 @@ module EventsHelper end def icon_for_profile_event(event) - if current_path?('users#show') + if current_path?("users#show") content_tag :div, class: "system-note-image #{event.action_name.parameterize}-icon" do icon_for_event(event.action_name) end else - content_tag :div, class: 'system-note-image user-avatar' do + content_tag :div, class: "system-note-image user-avatar" do author_avatar(event, size: 40) end end end def inline_event_icon(event) - unless current_path?('users#show') + unless current_path?("users#show") content_tag :span, class: "system-note-image-inline d-none d-sm-flex append-right-4 #{event.action_name.parameterize}-icon align-self-center" do icon_for_event(event.action_name, size: 14) end diff --git a/app/helpers/explore_helper.rb b/app/helpers/explore_helper.rb index 62be591ec47..1282aa32eee 100644 --- a/app/helpers/explore_helper.rb +++ b/app/helpers/explore_helper.rb @@ -12,7 +12,7 @@ module ExploreHelper personal: params[:personal], archived: params[:archived], shared: params[:shared], - namespace_id: params[:namespace_id] + namespace_id: params[:namespace_id], } options = exist_opts.merge(options).delete_if { |key, value| value.blank? } diff --git a/app/helpers/form_helper.rb b/app/helpers/form_helper.rb index 5705ee54cee..ff4f8a91f85 100644 --- a/app/helpers/form_helper.rb +++ b/app/helpers/form_helper.rb @@ -1,44 +1,44 @@ # frozen_string_literal: true module FormHelper - def form_errors(model, type: 'form') + def form_errors(model, type: "form") return unless model.errors.any? - pluralized = 'error'.pluralize(model.errors.count) + pluralized = "error".pluralize(model.errors.count) headline = "The #{type} contains the following #{pluralized}:" - content_tag(:div, class: 'alert alert-danger', id: 'error_explanation') do + content_tag(:div, class: "alert alert-danger", id: "error_explanation") do content_tag(:h4, headline) << - content_tag(:ul) do + content_tag(:ul) { model.errors.full_messages .map { |msg| content_tag(:li, msg) } .join .html_safe - end + } end end def issue_assignees_dropdown_options { - toggle_class: 'js-user-search js-assignee-search js-multiselect js-save-user-data', - title: 'Select assignee', + toggle_class: "js-user-search js-assignee-search js-multiselect js-save-user-data", + title: "Select assignee", filter: true, - dropdown_class: 'dropdown-menu-user dropdown-menu-selectable dropdown-menu-assignee', - placeholder: 'Search users', + dropdown_class: "dropdown-menu-user dropdown-menu-selectable dropdown-menu-assignee", + placeholder: "Search users", data: { first_user: current_user&.username, null_user: true, current_user: true, project_id: @project&.id, - field_name: 'issue[assignee_ids][]', - default_label: 'Unassigned', + field_name: "issue[assignee_ids][]", + default_label: "Unassigned", 'max-select': 1, - 'dropdown-header': 'Assignee', + 'dropdown-header': "Assignee", multi_select: true, - 'input-meta': 'name', + 'input-meta': "name", 'always-show-selectbox': true, - current_user_info: UserSerializer.new.represent(current_user) - } + current_user_info: UserSerializer.new.represent(current_user), + }, } end end diff --git a/app/helpers/gitlab_routing_helper.rb b/app/helpers/gitlab_routing_helper.rb index 04cf43be452..0ac4d0b08a0 100644 --- a/app/helpers/gitlab_routing_helper.rb +++ b/app/helpers/gitlab_routing_helper.rb @@ -154,17 +154,17 @@ module GitlabRoutingHelper # Artifacts def artifacts_action_path(path, project, build) - action, path_params = path.split('/', 2) + action, path_params = path.split("/", 2) args = [project, build, path_params] case action - when 'download' + when "download" download_project_job_artifacts_path(*args) - when 'browse' + when "browse" browse_project_job_artifacts_path(*args) - when 'file' + when "file" file_project_job_artifacts_path(*args) - when 'raw' + when "raw" raw_project_job_artifacts_path(*args) end end diff --git a/app/helpers/graph_helper.rb b/app/helpers/graph_helper.rb index 49b15cde009..30093bf23f2 100644 --- a/app/helpers/graph_helper.rb +++ b/app/helpers/graph_helper.rb @@ -2,11 +2,11 @@ module GraphHelper def refs(repo, commit) - refs = [commit.ref_names(repo).join(' ')] + refs = [commit.ref_names(repo).join(" ")] # append note count notes_count = @graph.notes[commit.id] - refs << "[#{pluralize(notes_count, 'note')}]" if notes_count > 0 + refs << "[#{pluralize(notes_count, "note")}]" if notes_count > 0 refs.join end diff --git a/app/helpers/groups_helper.rb b/app/helpers/groups_helper.rb index 4a9ed123161..bc16822987a 100644 --- a/app/helpers/groups_helper.rb +++ b/app/helpers/groups_helper.rb @@ -49,7 +49,7 @@ module GroupsHelper group = Group.find_by_full_path(group) end - group.try(:avatar_url) || ActionController::Base.helpers.image_path('no_group_avatar.png') + group.try(:avatar_url) || ActionController::Base.helpers.image_path("no_group_avatar.png") end def group_title(group, name = nil, url = nil) @@ -67,7 +67,7 @@ module GroupsHelper full_title << render("layouts/nav/breadcrumbs/collapsed_dropdown", location: :before, title: _("Show parent subgroups")) full_title << breadcrumb_list_item(group_title_link(group)) - full_title << ' · '.html_safe + link_to(simple_sanitize(name), url, class: 'group-path breadcrumb-item-text js-breadcrumb-item-text') if name + full_title << " · ".html_safe + link_to(simple_sanitize(name), url, class: "group-path breadcrumb-item-text js-breadcrumb-item-text") if name full_title.join.html_safe end @@ -83,14 +83,14 @@ module GroupsHelper size = group.projects.size if lfs_status == size - 'for all projects' + "for all projects" else - "for #{lfs_status} out of #{pluralize(size, 'project')}" + "for #{lfs_status} out of #{pluralize(size, "project")}" end end def group_lfs_status(group) - status = group.lfs_enabled? ? 'enabled' : 'disabled' + status = group.lfs_enabled? ? "enabled" : "disabled" content_tag(:span, class: "lfs-#{status}") do "#{status.humanize} #{projects_lfs_status(group)}" @@ -99,7 +99,7 @@ module GroupsHelper def remove_group_message(group) _("You are going to remove %{group_name}. Removed groups CANNOT be restored! Are you ABSOLUTELY sure?") % - { group_name: group.name } + {group_name: group.name} end def share_with_group_lock_help_text(group) @@ -117,9 +117,9 @@ module GroupsHelper end def parent_group_options(current_group) - groups = current_user.owned_groups.sort_by(&:human_name).map do |group| - { id: group.id, text: group.human_name } - end + groups = current_user.owned_groups.sort_by(&:human_name).map { |group| + {id: group.id, text: group.human_name} + } groups.delete_if { |group| group[:id] == current_group.id } groups.to_json @@ -135,10 +135,10 @@ module GroupsHelper links = [:overview, :group_members] resources = [:activity, :issues, :boards, :labels, :milestones, - :merge_requests] - links += resources.select do |resource| + :merge_requests,] + links += resources.select { |resource| can?(current_user, "read_group_#{resource}".to_sym, @group) - end + } if can?(current_user, :read_cluster, @group) && @group.group_clusters_enabled? links << :kubernetes @@ -152,7 +152,7 @@ module GroupsHelper end def group_title_link(group, hidable: false, show_avatar: false, for_dropdown: false) - link_to(group_path(group), class: "group-path #{'breadcrumb-item-text' unless for_dropdown} js-breadcrumb-item-text #{'hidable' if hidable}") do + link_to(group_path(group), class: "group-path #{"breadcrumb-item-text" unless for_dropdown} js-breadcrumb-item-text #{"hidable" if hidable}") do icon = group_icon(group, class: "avatar-tile", width: 15, height: 15) if (group.try(:avatar_url) || show_avatar) && !Rails.env.test? [icon, simple_sanitize(group.name)].join.html_safe end @@ -169,7 +169,7 @@ module GroupsHelper def remove_the_share_with_group_lock_from_ancestor(group) ancestor = oldest_consecutively_locked_ancestor(group) - text = s_("GroupSettings|remove the share with group lock from %{ancestor_group_name}") % { ancestor_group_name: ancestor.name } + text = s_("GroupSettings|remove the share with group lock from %{ancestor_group_name}") % {ancestor_group_name: ancestor.name} if can?(current_user, :admin_group, ancestor) link_to text, edit_group_path(ancestor) else @@ -188,14 +188,14 @@ module GroupsHelper end def ancestor_locked_but_you_can_override(group) - s_("GroupSettings|This setting is applied on %{ancestor_group}. You can override the setting or %{remove_ancestor_share_with_group_lock}.").html_safe % { ancestor_group: ancestor_group(group), remove_ancestor_share_with_group_lock: remove_the_share_with_group_lock_from_ancestor(group) } + s_("GroupSettings|This setting is applied on %{ancestor_group}. You can override the setting or %{remove_ancestor_share_with_group_lock}.").html_safe % {ancestor_group: ancestor_group(group), remove_ancestor_share_with_group_lock: remove_the_share_with_group_lock_from_ancestor(group)} end def ancestor_locked_so_ask_the_owner(group) - s_("GroupSettings|This setting is applied on %{ancestor_group}. To share projects in this group with another group, ask the owner to override the setting or %{remove_ancestor_share_with_group_lock}.").html_safe % { ancestor_group: ancestor_group(group), remove_ancestor_share_with_group_lock: remove_the_share_with_group_lock_from_ancestor(group) } + s_("GroupSettings|This setting is applied on %{ancestor_group}. To share projects in this group with another group, ask the owner to override the setting or %{remove_ancestor_share_with_group_lock}.").html_safe % {ancestor_group: ancestor_group(group), remove_ancestor_share_with_group_lock: remove_the_share_with_group_lock_from_ancestor(group)} end def ancestor_locked_and_has_been_overridden(group) - s_("GroupSettings|This setting is applied on %{ancestor_group} and has been overridden on this subgroup.").html_safe % { ancestor_group: ancestor_group(group) } + s_("GroupSettings|This setting is applied on %{ancestor_group} and has been overridden on this subgroup.").html_safe % {ancestor_group: ancestor_group(group)} end end diff --git a/app/helpers/hooks_helper.rb b/app/helpers/hooks_helper.rb index c4b39939192..ca3e5097d5b 100644 --- a/app/helpers/hooks_helper.rb +++ b/app/helpers/hooks_helper.rb @@ -8,11 +8,11 @@ module HooksHelper test_project_hook_path(project, hook, trigger: trigger) when SystemHook test_admin_hook_path(hook, trigger: trigger) - end + end - trigger_human_name = trigger.to_s.tr('_', ' ').camelize + trigger_human_name = trigger.to_s.tr("_", " ").camelize - link_to path, rel: 'nofollow', method: :post do + link_to path, rel: "nofollow", method: :post do content_tag(:span, trigger_human_name) end end diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb index 4e11772b252..2726c8a0f0f 100644 --- a/app/helpers/icons_helper.rb +++ b/app/helpers/icons_helper.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'json' +require "json" module IconsHelper extend self @@ -14,8 +14,8 @@ module IconsHelper def icon(names, options = {}) if (options.keys & %w[aria-hidden aria-label data-hidden]).empty? # Add 'aria-hidden' and 'data-hidden' if they are not set in options. - options['aria-hidden'] = true - options['data-hidden'] = true + options["aria-hidden"] = true + options["data-hidden"] = true end options.include?(:base) ? fa_stacked_icon(names, options) : fa_icon(names, options) @@ -31,14 +31,14 @@ module IconsHelper # SVG Sprites currently don't work across domains, so in the case of a CDN # we have to set the current path deliberately to prevent addition of asset_host sprite_base_url = Gitlab.config.gitlab.url if ActionController::Base.asset_host - ActionController::Base.helpers.image_path('icons.svg', host: sprite_base_url) + ActionController::Base.helpers.image_path("icons.svg", host: sprite_base_url) end def sprite_file_icons_path # SVG Sprites currently don't work across domains, so in the case of a CDN # we have to set the current path deliberately to prevent addition of asset_host sprite_base_url = Gitlab.config.gitlab.url if ActionController::Base.asset_host - ActionController::Base.helpers.image_path('file_icons.svg', host: sprite_base_url) + ActionController::Base.helpers.image_path("file_icons.svg", host: sprite_base_url) end def sprite_icon(icon_name, size: nil, css_class: nil) @@ -51,8 +51,8 @@ module IconsHelper css_classes = [] css_classes << "s#{size}" if size - css_classes << "#{css_class}" unless css_class.blank? - content_tag(:svg, content_tag(:use, "", { "xlink:href" => "#{sprite_icon_path}##{icon_name}" } ), class: css_classes.empty? ? nil : css_classes.join(' ')) + css_classes << css_class.to_s unless css_class.blank? + content_tag(:svg, content_tag(:use, "", {"xlink:href" => "#{sprite_icon_path}##{icon_name}"}), class: css_classes.empty? ? nil : css_classes.join(" ")) end def external_snippet_icon(name) @@ -73,19 +73,19 @@ module IconsHelper end def spinner(text = nil, visible = false) - css_class = ['loading'] - css_class << 'hide' unless visible + css_class = ["loading"] + css_class << "hide" unless visible - content_tag :div, class: css_class.join(' ') do - icon('spinner spin') + text + content_tag :div, class: css_class.join(" ") do + icon("spinner spin") + text end end def boolean_to_icon(value) if value - icon('circle', class: 'cgreen') + icon("circle", class: "cgreen") else - icon('power-off', class: 'clgray') + icon("power-off", class: "clgray") end end @@ -93,59 +93,59 @@ module IconsHelper name = case level when Gitlab::VisibilityLevel::PRIVATE - 'lock' + "lock" when Gitlab::VisibilityLevel::INTERNAL - 'shield' + "shield" else # Gitlab::VisibilityLevel::PUBLIC - 'globe' + "globe" end name = [name] name << "fw" if fw - icon(name.join(' '), options) + icon(name.join(" "), options) end def file_type_icon_class(type, mode, name) - if type == 'folder' - icon_class = 'folder' - elsif type == 'archive' - icon_class = 'archive' - elsif mode == '120000' - icon_class = 'share' + if type == "folder" + icon_class = "folder" + elsif type == "archive" + icon_class = "archive" + elsif mode == "120000" + icon_class = "share" else # Guess which icon to choose based on file extension. # If you think a file extension is missing, feel free to add it on PR case File.extname(name).downcase - when '.pdf' - icon_class = 'file-pdf-o' - when '.jpg', '.jpeg', '.jif', '.jfif', - '.jp2', '.jpx', '.j2k', '.j2c', - '.png', '.gif', '.tif', '.tiff', - '.svg', '.ico', '.bmp' - icon_class = 'file-image-o' - when '.zip', '.zipx', '.tar', '.gz', '.bz', '.bzip', - '.xz', '.rar', '.7z' - icon_class = 'file-archive-o' - when '.mp3', '.wma', '.ogg', '.oga', '.wav', '.flac', '.aac' - icon_class = 'file-audio-o' - when '.mp4', '.m4p', '.m4v', - '.mpg', '.mp2', '.mpeg', '.mpe', '.mpv', - '.mpg', '.mpeg', '.m2v', - '.avi', '.mkv', '.flv', '.ogv', '.mov', - '.3gp', '.3g2' - icon_class = 'file-video-o' - when '.doc', '.dot', '.docx', '.docm', '.dotx', '.dotm', '.docb' - icon_class = 'file-word-o' - when '.xls', '.xlt', '.xlm', '.xlsx', '.xlsm', '.xltx', '.xltm', - '.xlsb', '.xla', '.xlam', '.xll', '.xlw' - icon_class = 'file-excel-o' - when '.ppt', '.pot', '.pps', '.pptx', '.pptm', '.potx', '.potm', - '.ppam', '.ppsx', '.ppsm', '.sldx', '.sldm' - icon_class = 'file-powerpoint-o' + when ".pdf" + icon_class = "file-pdf-o" + when ".jpg", ".jpeg", ".jif", ".jfif", + ".jp2", ".jpx", ".j2k", ".j2c", + ".png", ".gif", ".tif", ".tiff", + ".svg", ".ico", ".bmp" + icon_class = "file-image-o" + when ".zip", ".zipx", ".tar", ".gz", ".bz", ".bzip", + ".xz", ".rar", ".7z" + icon_class = "file-archive-o" + when ".mp3", ".wma", ".ogg", ".oga", ".wav", ".flac", ".aac" + icon_class = "file-audio-o" + when ".mp4", ".m4p", ".m4v", + ".mpg", ".mp2", ".mpeg", ".mpe", ".mpv", + ".mpg", ".mpeg", ".m2v", + ".avi", ".mkv", ".flv", ".ogv", ".mov", + ".3gp", ".3g2" + icon_class = "file-video-o" + when ".doc", ".dot", ".docx", ".docm", ".dotx", ".dotm", ".docb" + icon_class = "file-word-o" + when ".xls", ".xlt", ".xlm", ".xlsx", ".xlsm", ".xltx", ".xltm", + ".xlsb", ".xla", ".xlam", ".xll", ".xlw" + icon_class = "file-excel-o" + when ".ppt", ".pot", ".pps", ".pptx", ".pptm", ".potx", ".potm", + ".ppam", ".ppsx", ".ppsm", ".sldx", ".sldm" + icon_class = "file-powerpoint-o" else - icon_class = 'file-text-o' + icon_class = "file-text-o" end end @@ -155,6 +155,6 @@ module IconsHelper private def known_sprites - @known_sprites ||= JSON.parse(File.read(Rails.root.join('node_modules/@gitlab/svgs/dist/icons.json')))['icons'] + @known_sprites ||= JSON.parse(File.read(Rails.root.join("node_modules/@gitlab/svgs/dist/icons.json")))["icons"] end end diff --git a/app/helpers/ide_helper.rb b/app/helpers/ide_helper.rb index 8e50bbc6c04..4c6c449c2c8 100644 --- a/app/helpers/ide_helper.rb +++ b/app/helpers/ide_helper.rb @@ -3,14 +3,14 @@ module IdeHelper def ide_data { - "empty-state-svg-path" => image_path('illustrations/multi_file_editor_empty.svg'), - "no-changes-state-svg-path" => image_path('illustrations/multi-editor_no_changes_empty.svg'), - "committed-state-svg-path" => image_path('illustrations/multi-editor_all_changes_committed_empty.svg'), - "pipelines-empty-state-svg-path": image_path('illustrations/pipelines_empty.svg'), - "promotion-svg-path": image_path('illustrations/web-ide_promotion.svg'), - "ci-help-page-path" => help_page_path('ci/quick_start/README'), - "web-ide-help-page-path" => help_page_path('user/project/web_ide/index.html'), - "clientside-preview-enabled": Gitlab::CurrentSettings.current_application_settings.web_ide_clientside_preview_enabled.to_s + "empty-state-svg-path" => image_path("illustrations/multi_file_editor_empty.svg"), + "no-changes-state-svg-path" => image_path("illustrations/multi-editor_no_changes_empty.svg"), + "committed-state-svg-path" => image_path("illustrations/multi-editor_all_changes_committed_empty.svg"), + :"pipelines-empty-state-svg-path" => image_path("illustrations/pipelines_empty.svg"), + :"promotion-svg-path" => image_path("illustrations/web-ide_promotion.svg"), + "ci-help-page-path" => help_page_path("ci/quick_start/README"), + "web-ide-help-page-path" => help_page_path("user/project/web_ide/index.html"), + :"clientside-preview-enabled" => Gitlab::CurrentSettings.current_application_settings.web_ide_clientside_preview_enabled.to_s, } end end diff --git a/app/helpers/import_helper.rb b/app/helpers/import_helper.rb index 3d494c3de6a..8469a091d31 100644 --- a/app/helpers/import_helper.rb +++ b/app/helpers/import_helper.rb @@ -10,7 +10,7 @@ module ImportHelper def sanitize_project_name(name) # For personal projects in Bitbucket in the form ~username, we can # just drop that leading tilde. - name.gsub(/\A~+/, '').gsub(/[^\w\-]/, '-') + name.gsub(/\A~+/, "").gsub(/[^\w\-]/, "-") end def import_project_target(owner, name) @@ -24,47 +24,47 @@ module ImportHelper def import_will_timeout_message(_ci_cd_only) timeout = time_interval_in_words(Gitlab.config.gitlab_shell.git_timeout) - _('The import will time out after %{timeout}. For repositories that take longer, use a clone/push combination.') % { timeout: timeout } + _("The import will time out after %{timeout}. For repositories that take longer, use a clone/push combination.") % {timeout: timeout} end def import_svn_message(_ci_cd_only) - svn_link = link_to _('this document'), help_page_path('user/project/import/svn') - _('To import an SVN repository, check out %{svn_link}.').html_safe % { svn_link: svn_link } + svn_link = link_to _("this document"), help_page_path("user/project/import/svn") + _("To import an SVN repository, check out %{svn_link}.").html_safe % {svn_link: svn_link} end def import_in_progress_title if @project.forked? - _('Forking in progress') + _("Forking in progress") else - _('Import in progress') + _("Import in progress") end end def import_wait_and_refresh_message - _('Please wait while we import the repository for you. Refresh at will.') + _("Please wait while we import the repository for you. Refresh at will.") end def import_github_authorize_message - _('To import GitHub repositories, you first need to authorize GitLab to access the list of your GitHub repositories:') + _("To import GitHub repositories, you first need to authorize GitLab to access the list of your GitHub repositories:") end def import_github_personal_access_token_message - personal_access_token_link = link_to _('Personal Access Token'), 'https://github.com/settings/tokens' + personal_access_token_link = link_to _("Personal Access Token"), "https://github.com/settings/tokens" if github_import_configured? - _('Alternatively, you can use a %{personal_access_token_link}. When you create your Personal Access Token, you will need to select the <code>repo</code> scope, so we can display a list of your public and private repositories which are available to import.').html_safe % { personal_access_token_link: personal_access_token_link } + _("Alternatively, you can use a %{personal_access_token_link}. When you create your Personal Access Token, you will need to select the <code>repo</code> scope, so we can display a list of your public and private repositories which are available to import.").html_safe % {personal_access_token_link: personal_access_token_link} else - _('To import GitHub repositories, you can use a %{personal_access_token_link}. When you create your Personal Access Token, you will need to select the <code>repo</code> scope, so we can display a list of your public and private repositories which are available to import.').html_safe % { personal_access_token_link: personal_access_token_link } + _("To import GitHub repositories, you can use a %{personal_access_token_link}. When you create your Personal Access Token, you will need to select the <code>repo</code> scope, so we can display a list of your public and private repositories which are available to import.").html_safe % {personal_access_token_link: personal_access_token_link} end end def import_configure_github_admin_message - github_integration_link = link_to 'GitHub integration', help_page_path('integration/github') + github_integration_link = link_to "GitHub integration", help_page_path("integration/github") if current_user.admin? - _('Note: As an administrator you may like to configure %{github_integration_link}, which will allow login via GitHub and allow importing repositories without generating a Personal Access Token.').html_safe % { github_integration_link: github_integration_link } + _("Note: As an administrator you may like to configure %{github_integration_link}, which will allow login via GitHub and allow importing repositories without generating a Personal Access Token.").html_safe % {github_integration_link: github_integration_link} else - _('Note: Consider asking your GitLab administrator to configure %{github_integration_link}, which will allow login via GitHub and allow importing repositories without generating a Personal Access Token.').html_safe % { github_integration_link: github_integration_link } + _("Note: Consider asking your GitLab administrator to configure %{github_integration_link}, which will allow login via GitHub and allow importing repositories without generating a Personal Access Token.").html_safe % {github_integration_link: github_integration_link} end end end diff --git a/app/helpers/instance_configuration_helper.rb b/app/helpers/instance_configuration_helper.rb index f695be32743..6aeddb82090 100644 --- a/app/helpers/instance_configuration_helper.rb +++ b/app/helpers/instance_configuration_helper.rb @@ -2,7 +2,7 @@ module InstanceConfigurationHelper def instance_configuration_cell_html(value, &block) - return '-' unless value.to_s.presence + return "-" unless value.to_s.presence block_given? ? yield(value) : value end diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb index af28e6fcb93..72a726001a5 100644 --- a/app/helpers/issuables_helper.rb +++ b/app/helpers/issuables_helper.rb @@ -4,29 +4,29 @@ module IssuablesHelper include GitlabRoutingHelper def sidebar_gutter_toggle_icon - sidebar_gutter_collapsed? ? icon('angle-double-left', { 'aria-hidden': 'true' }) : icon('angle-double-right', { 'aria-hidden': 'true' }) + sidebar_gutter_collapsed? ? icon("angle-double-left", {'aria-hidden': "true"}) : icon("angle-double-right", {'aria-hidden': "true"}) end def sidebar_gutter_collapsed_class - "right-sidebar-#{sidebar_gutter_collapsed? ? 'collapsed' : 'expanded'}" + "right-sidebar-#{sidebar_gutter_collapsed? ? "collapsed" : "expanded"}" end def sidebar_gutter_tooltip_text - sidebar_gutter_collapsed? ? _('Expand sidebar') : _('Collapse sidebar') + sidebar_gutter_collapsed? ? _("Expand sidebar") : _("Collapse sidebar") end def sidebar_assignee_tooltip_label(issuable) if issuable.assignee issuable.assignee.name else - issuable.allows_multiple_assignees? ? _('Assignee(s)') : _('Assignee') + issuable.allows_multiple_assignees? ? _("Assignee(s)") : _("Assignee") end end def sidebar_milestone_tooltip_label(milestone) - return _('Milestone') unless milestone.present? + return _("Milestone") unless milestone.present? - [milestone[:title], sidebar_milestone_remaining_days(milestone) || _('Milestone')].join('<br/>') + [milestone[:title], sidebar_milestone_remaining_days(milestone) || _("Milestone")].join("<br/>") end def sidebar_milestone_remaining_days(milestone) @@ -34,7 +34,7 @@ module IssuablesHelper end def sidebar_due_date_tooltip_label(due_date) - [_('Due date'), due_date_with_remaining_days(due_date)].compact.join('<br/>') + [_("Due date"), due_date_with_remaining_days(due_date)].compact.join("<br/>") end def due_date_with_remaining_days(due_date, start_date = nil) @@ -44,7 +44,7 @@ module IssuablesHelper end def sidebar_label_filter_path(base_path, label_name) - query_params = { label_name: [label_name] }.to_query + query_params = {label_name: [label_name]}.to_query "#{base_path}?#{query_params}" end @@ -77,7 +77,7 @@ module IssuablesHelper IssueSerializer when MergeRequest MergeRequestSerializer - end + end serializer_klass .new(current_user: current_user, project: issuable.project) @@ -88,18 +88,18 @@ module IssuablesHelper def template_dropdown_tag(issuable, &block) title = selected_template(issuable) || "Choose a template" options = { - toggle_class: 'js-issuable-selector', + toggle_class: "js-issuable-selector", title: title, filter: true, - placeholder: 'Filter', + placeholder: "Filter", footer_content: true, data: { data: issuable_templates(issuable), - field_name: 'issuable_template', + field_name: "issuable_template", selected: selected_template(issuable), project_path: ref_project.path, - namespace_path: ref_project.namespace.full_path - } + namespace_path: ref_project.namespace.full_path, + }, } dropdown_tag(title, options: options) do @@ -189,18 +189,18 @@ module IssuablesHelper output = [] output << "Opened #{time_ago_with_tooltip(issuable.created_at)} by ".html_safe - output << content_tag(:strong) do + output << content_tag(:strong) { author_output = link_to_member(project, issuable.author, size: 24, mobile_classes: "d-none d-sm-inline") author_output << link_to_member(project, issuable.author, size: 24, by_username: true, avatar: false, mobile_classes: "d-block d-sm-none") if status = user_status(issuable.author) - author_output << "#{status}".html_safe + author_output << status.to_s.html_safe end author_output - end + } - output << content_tag(:span, (issuable_first_contribution_icon if issuable.first_contribution?), class: 'has-tooltip prepend-left-4', title: _('1st contribution!')) + output << content_tag(:span, (issuable_first_contribution_icon if issuable.first_contribution?), class: "has-tooltip prepend-left-4", title: _("1st contribution!")) output << content_tag(:span, (issuable.task_status if issuable.tasks?), id: "task_status", class: "d-none d-sm-none d-md-inline-block prepend-left-8") output << content_tag(:span, (issuable.task_status_short if issuable.tasks?), id: "task_status_short", class: "d-md-none") @@ -211,11 +211,11 @@ module IssuablesHelper def issuable_labels_tooltip(labels, limit: 5) first, last = labels.partition.with_index { |_, i| i < limit } - if labels && labels.any? + if labels&.any? label_names = first.collect { |label| label.fetch(:title) } label_names << "and #{last.size} more" unless last.empty? - label_names.join(', ') + label_names.join(", ") else _("Labels") end @@ -223,7 +223,7 @@ module IssuablesHelper def issuables_state_counter_text(issuable_type, state, display_count) titles = { - opened: "Open" + opened: "Open", } state_title = titles[state] || state.to_s.humanize @@ -231,16 +231,16 @@ module IssuablesHelper if display_count count = issuables_count_for_state(issuable_type, state) - html << " " << content_tag(:span, number_with_delimiter(count), class: 'badge badge-pill') + html << " " << content_tag(:span, number_with_delimiter(count), class: "badge badge-pill") end html.html_safe end def issuable_first_contribution_icon - content_tag(:span, class: 'fa-stack') do - concat(icon('certificate', class: "fa-stack-2x")) - concat(content_tag(:strong, '1', class: 'fa-inverse fa-stack-1x')) + content_tag(:span, class: "fa-stack") do + concat(icon("certificate", class: "fa-stack-2x")) + concat(content_tag(:strong, "1", class: "fa-inverse fa-stack-1x")) end end @@ -267,20 +267,21 @@ module IssuablesHelper canDestroy: can?(current_user, :"destroy_#{issuable.to_ability_name}", issuable), issuableRef: issuable.to_reference, markdownPreviewPath: preview_markdown_path(parent), - markdownDocsPath: help_page_path('user/markdown'), + markdownDocsPath: help_page_path("user/markdown"), lockVersion: issuable.lock_version, issuableTemplates: issuable_templates(issuable), initialTitleHtml: markdown_field(issuable, :title), initialTitleText: issuable.title, initialDescriptionHtml: markdown_field(issuable, :description), initialDescriptionText: issuable.description, - initialTaskStatus: issuable.task_status + initialTaskStatus: issuable.task_status, } if parent.is_a?(Group) data[:groupPath] = parent.path else - data.merge!(projectPath: ref_project.path, projectNamespace: ref_project.namespace.full_path) + data[:projectPath] = ref_project.path + data[:projectNamespace] = ref_project.namespace.full_path end data.merge!(updated_at_by(issuable)) @@ -295,8 +296,8 @@ module IssuablesHelper updatedAt: issuable.last_edited_at.to_time.iso8601, updatedBy: { name: issuable.last_edited_by.name, - path: user_path(issuable.last_edited_by) - } + path: user_path(issuable.last_edited_by), + }, } end @@ -330,7 +331,7 @@ module IssuablesHelper end def issuable_button_visibility(issuable, closed) - return 'hidden' if issuable_button_hidden?(issuable, closed) + return "hidden" if issuable_button_hidden?(issuable, closed) end def issuable_button_hidden?(issuable, closed) @@ -345,9 +346,9 @@ module IssuablesHelper def issuable_close_reopen_button_method(issuable) case issuable when Issue - '' + "" when MergeRequest - 'put' + "put" end end @@ -366,7 +367,7 @@ module IssuablesHelper private def sidebar_gutter_collapsed? - cookies[:collapsed_gutter] == 'true' + cookies[:collapsed_gutter] == "true" end def issuable_templates(issuable) @@ -385,24 +386,24 @@ module IssuablesHelper def issuable_todo_button_data(issuable, is_collapsed) { - todo_text: _('Add todo'), - mark_text: _('Mark todo as done'), - todo_icon: sprite_icon('todo-add'), - mark_icon: sprite_icon('todo-done', css_class: 'todo-undone'), + todo_text: _("Add todo"), + mark_text: _("Mark todo as done"), + todo_icon: sprite_icon("todo-add"), + mark_icon: sprite_icon("todo-done", css_class: "todo-undone"), issuable_id: issuable[:id], issuable_type: issuable[:type], create_path: issuable[:create_todo_path], delete_path: issuable.dig(:current_user, :todo, :delete_path), - placement: is_collapsed ? 'left' : nil, - container: is_collapsed ? 'body' : nil, - boundary: 'viewport', - is_collapsed: is_collapsed + placement: is_collapsed ? "left" : nil, + container: is_collapsed ? "body" : nil, + boundary: "viewport", + is_collapsed: is_collapsed, } end def close_reopen_params(issuable, action) { - issuable.model_name.to_s.underscore => { state_event: action } + issuable.model_name.to_s.underscore => {state_event: action}, }.tap do |params| params[:format] = :json if issuable.is_a?(Issue) end @@ -425,7 +426,7 @@ module IssuablesHelper editable: issuable.dig(:current_user, :can_edit), currentUser: issuable[:current_user], rootPath: root_path, - fullPath: issuable[:project_full_path] + fullPath: issuable[:project_full_path], } end diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 957ab06b0ca..b2e90612b9a 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -5,18 +5,18 @@ module IssuesHelper classes = ["issue"] classes << "closed" if issue.closed? classes << "today" if issue.today? - classes.join(' ') + classes.join(" ") end # Returns an OpenStruct object suitable for use by <tt>options_from_collection_for_select</tt> # to allow filtering issues by an unassigned User or Milestone def unassigned_filter # Milestone uses :title, Issue uses :name - OpenStruct.new(id: 0, title: 'None (backlog)', name: 'Unassigned') + OpenStruct.new(id: 0, title: "None (backlog)", name: "Unassigned") end def url_for_issue(issue_iid, project = @project, options = {}) - return '' if project.nil? + return "" if project.nil? url = if options[:internal] @@ -28,7 +28,7 @@ module IssuesHelper # Ensure we return a valid URL to prevent possible XSS. URI.parse(url).to_s rescue URI::InvalidURIError - '' + "" end def url_for_tracker_issue(issue_iid, project, options) @@ -51,20 +51,20 @@ module IssuesHelper def status_box_class(item) if item.try(:expired?) - 'status-box-expired' + "status-box-expired" elsif item.try(:merged?) - 'status-box-mr-merged' + "status-box-mr-merged" elsif item.closed? - 'status-box-mr-closed' + "status-box-mr-closed" elsif item.try(:upcoming?) - 'status-box-upcoming' + "status-box-upcoming" else - 'status-box-open' + "status-box-open" end end def issue_button_visibility(issue, closed) - return 'hidden' if issue_button_hidden?(issue, closed) + return "hidden" if issue_button_hidden?(issue, closed) end def issue_button_hidden?(issue, closed) @@ -72,15 +72,15 @@ module IssuesHelper end def confidential_icon(issue) - icon('eye-slash') if issue.confidential? + icon("eye-slash") if issue.confidential? end def award_user_list(awards, current_user, limit: 10) - names = awards.map do |award| - award.user == current_user ? 'You' : award.user.name - end + names = awards.map { |award| + award.user == current_user ? "You" : award.user.name + } - current_user_name = names.delete('You') + current_user_name = names.delete("You") names = names.insert(0, current_user_name).compact.first(limit) names << "#{awards.size - names.size} more." if awards.size > names.size @@ -99,7 +99,7 @@ module IssuesHelper end def awards_sort(awards) - awards.sort_by do |award, award_emojis| + awards.sort_by { |award, award_emojis| if award == "thumbsup" 0 elsif award == "thumbsdown" @@ -107,7 +107,7 @@ module IssuesHelper else 2 end - end.to_h + }.to_h end def link_to_discussions_to_resolve(merge_request, single_discussion = nil) @@ -115,13 +115,13 @@ module IssuesHelper link_text << "(discussion #{single_discussion.first_note.id})" if single_discussion path = if single_discussion - Gitlab::UrlBuilder.build(single_discussion.first_note) - else - project = merge_request.project - project_merge_request_path(project, merge_request) - end + Gitlab::UrlBuilder.build(single_discussion.first_note) + else + project = merge_request.project + project_merge_request_path(project, merge_request) + end - link_to link_text.join(' '), path + link_to link_text.join(" "), path end def show_new_issue_link?(project) diff --git a/app/helpers/labels_helper.rb b/app/helpers/labels_helper.rb index bd53add80ca..1b9ff1bd095 100644 --- a/app/helpers/labels_helper.rb +++ b/app/helpers/labels_helper.rb @@ -54,13 +54,13 @@ module LabelsHelper case subject when Group send("#{type.to_s.pluralize}_group_path", # rubocop:disable GitlabSecurity/PublicSend - subject, - label_name: [label.name]) + subject, + label_name: [label.name]) when Project send("namespace_project_#{type.to_s.pluralize}_path", # rubocop:disable GitlabSecurity/PublicSend - subject.namespace, - subject, - label_name: [label.name]) + subject.namespace, + subject, + label_name: [label.name]) end end @@ -78,7 +78,7 @@ module LabelsHelper end end - def render_colored_label(label, label_suffix = '', tooltip: true) + def render_colored_label(label, label_suffix = "", tooltip: true) text_color = text_color_for_bg(label.color) # Intentionally not using content_tag here so that this method can be called @@ -93,27 +93,27 @@ module LabelsHelper def suggested_colors [ - '#0033CC', - '#428BCA', - '#44AD8E', - '#A8D695', - '#5CB85C', - '#69D100', - '#004E00', - '#34495E', - '#7F8C8D', - '#A295D6', - '#5843AD', - '#8E44AD', - '#FFECDB', - '#AD4363', - '#D10069', - '#CC0033', - '#FF0000', - '#D9534F', - '#D1D100', - '#F0AD4E', - '#AD8D43' + "#0033CC", + "#428BCA", + "#44AD8E", + "#A8D695", + "#5CB85C", + "#69D100", + "#004E00", + "#34495E", + "#7F8C8D", + "#A295D6", + "#5843AD", + "#8E44AD", + "#FFECDB", + "#AD4363", + "#D10069", + "#CC0033", + "#FF0000", + "#D9534F", + "#D1D100", + "#F0AD4E", + "#AD8D43", ] end @@ -125,9 +125,9 @@ module LabelsHelper end if (r + g + b) > 500 - '#333333' + "#333333" else - '#FFFFFF' + "#FFFFFF" end end @@ -159,70 +159,70 @@ module LabelsHelper end def label_subscription_status(label, project) - return 'group-level' if label.subscribed?(current_user) - return 'project-level' if label.subscribed?(current_user, project) + return "group-level" if label.subscribed?(current_user) + return "project-level" if label.subscribed?(current_user, project) - 'unsubscribed' + "unsubscribed" end def toggle_subscription_label_path(label, project) return toggle_subscription_group_label_path(label.group, label) unless project case label_subscription_status(label, project) - when 'group-level' then toggle_subscription_group_label_path(label.group, label) - when 'project-level' then toggle_subscription_project_label_path(project, label) - when 'unsubscribed' then toggle_subscription_project_label_path(project, label) + when "group-level" then toggle_subscription_group_label_path(label.group, label) + when "project-level" then toggle_subscription_project_label_path(project, label) + when "unsubscribed" then toggle_subscription_project_label_path(project, label) end end def label_subscription_toggle_button_text(label, project = nil) - label.subscribed?(current_user, project) ? 'Unsubscribe' : 'Subscribe' + label.subscribed?(current_user, project) ? "Unsubscribe" : "Subscribe" end def label_deletion_confirm_text(label) case label - when GroupLabel then 'Remove this label? This will affect all projects within the group. Are you sure?' - when ProjectLabel then 'Remove this label? Are you sure?' + when GroupLabel then "Remove this label? This will affect all projects within the group. Are you sure?" + when ProjectLabel then "Remove this label? Are you sure?" end end def create_label_title(subject) case subject when Group - _('Create group label') + _("Create group label") when Project - _('Create project label') + _("Create project label") else - _('Create new label') + _("Create new label") end end def manage_labels_title(subject) case subject when Group - _('Manage group labels') + _("Manage group labels") when Project - _('Manage project labels') + _("Manage project labels") else - _('Manage labels') + _("Manage labels") end end def view_labels_title(subject) case subject when Group - _('View group labels') + _("View group labels") when Project - _('View project labels') + _("View project labels") else - _('View labels') + _("View labels") end end def label_status_tooltip(label, status) - type = label.is_a?(ProjectLabel) ? 'project' : 'group' - level = status.unsubscribed? ? type : status.sub('-level', '') - action = status.unsubscribed? ? 'Subscribe' : 'Unsubscribe' + type = label.is_a?(ProjectLabel) ? "project" : "group" + level = status.unsubscribed? ? type : status.sub("-level", "") + action = status.unsubscribed? ? "Subscribe" : "Unsubscribe" "#{action} at #{level} level" end diff --git a/app/helpers/lazy_image_tag_helper.rb b/app/helpers/lazy_image_tag_helper.rb index ac987a04895..30b9e7d7b2a 100644 --- a/app/helpers/lazy_image_tag_helper.rb +++ b/app/helpers/lazy_image_tag_helper.rb @@ -17,7 +17,7 @@ module LazyImageTagHelper klass_opts = Array.wrap(options[:class]) klass_opts << "lazy" - options[:class] = klass_opts.join(' ') + options[:class] = klass_opts.join(" ") source = placeholder_image end diff --git a/app/helpers/markup_helper.rb b/app/helpers/markup_helper.rb index 66f4b7b3f30..7eb193bd087 100644 --- a/app/helpers/markup_helper.rb +++ b/app/helpers/markup_helper.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'nokogiri' +require "nokogiri" module MarkupHelper include ActionView::Helpers::TagHelper @@ -24,7 +24,7 @@ module MarkupHelper # Use this in places where you would normally use link_to(gfm(...), ...). def link_to_markdown(body, url, html_options = {}) - return '' if body.blank? + return "" if body.blank? link_to_html(markdown(body, pipeline: :single_line), url, html_options) end @@ -45,7 +45,7 @@ module MarkupHelper def link_to_html(redacted, url, html_options = {}) fragment = Nokogiri::HTML::DocumentFragment.parse(redacted) - if fragment.children.size == 1 && fragment.children[0].name == 'a' + if fragment.children.size == 1 && fragment.children[0].name == "a" # Fragment has only one node, and it's a link generated by `gfm`. # Replace it with our requested link. text = fragment.children[0].text @@ -62,7 +62,7 @@ module MarkupHelper # Add any custom CSS classes to the GFM-generated reference links if html_options[:class] - fragment.css('a.gfm').add_class(html_options[:class]) + fragment.css("a.gfm").add_class(html_options[:class]) end fragment.to_html.html_safe @@ -76,14 +76,14 @@ module MarkupHelper md = markdown_field(object, attribute, options) return nil unless md.present? - tags = %w(a gl-emoji b pre code p span) - tags << 'img' if options[:allow_images] + tags = %w[a gl-emoji b pre code p span] + tags << "img" if options[:allow_images] text = truncate_visible(md, max_chars || md.length) text = sanitize( text, tags: tags, - attributes: Rails::Html::WhiteListSanitizer.allowed_attributes + ['style', 'data-src', 'data-name', 'data-unicode-version'] + attributes: Rails::Html::WhiteListSanitizer.allowed_attributes + ["style", "data-src", "data-name", "data-unicode-version"] ) # since <img> tags are stripped, this can leave empty <a> tags hanging around @@ -92,7 +92,7 @@ module MarkupHelper end def markdown(text, context = {}) - return '' unless text.present? + return "" unless text.present? context[:project] ||= @project context[:group] ||= @group @@ -105,7 +105,7 @@ module MarkupHelper object = object.for_display if object.respond_to?(:for_display) redacted_field_html = object.try(:"redacted_#{field}_html") - return '' unless object.present? + return "" unless object.present? return redacted_field_html if redacted_field_html html = Banzai.render_field(object, field, context) @@ -122,7 +122,7 @@ module MarkupHelper def render_wiki_content(wiki_page, context = {}) text = wiki_page.content - return '' unless text.present? + return "" unless text.present? context.merge!( pipeline: :wiki, @@ -146,14 +146,14 @@ module MarkupHelper end def markup_unsafe(file_name, text, context = {}) - return '' unless text.present? + return "" unless text.present? if gitlab_markdown?(file_name) markdown_unsafe(text, context) elsif asciidoc?(file_name) asciidoc_unsafe(text, context) elsif plain?(file_name) - content_tag :pre, class: 'plain-readme' do + content_tag :pre, class: "plain-readme" do text end else @@ -181,7 +181,7 @@ module MarkupHelper if entity.respond_to?(:to_reference) entity.to_reference(project, full: true) else - '' + "" end end @@ -228,7 +228,7 @@ module MarkupHelper def truncate_if_block(node, truncated) return true if truncated - if node.element? && (node.description&.block? || node.matches?('pre > code > .line')) + if node.element? && (node.description&.block? || node.matches?("pre > code > .line")) node.inner_html = "#{node.inner_html}..." if node.next_sibling true else @@ -237,9 +237,9 @@ module MarkupHelper end def strip_empty_link_tags(text) - scrubber = Loofah::Scrubber.new do |node| - node.remove if node.name == 'a' && node.content.blank? - end + scrubber = Loofah::Scrubber.new { |node| + node.remove if node.name == "a" && node.content.blank? + } # Use `Loofah` directly instead of `sanitize` # as we still use the `rails-deprecated_sanitizer` gem @@ -247,14 +247,14 @@ module MarkupHelper end def markdown_toolbar_button(options = {}) - data = options[:data].merge({ container: 'body' }) + data = options[:data].merge({container: "body"}) content_tag :button, - type: 'button', - class: 'toolbar-btn js-md has-tooltip', + type: "button", + class: "toolbar-btn js-md has-tooltip", tabindex: -1, data: data, title: options[:title], - aria: { label: options[:title] } do + aria: {label: options[:title]} do sprite_icon(options[:icon]) end end @@ -272,15 +272,15 @@ module MarkupHelper end def prepare_for_rendering(html, context = {}) - return '' unless html.present? + return "" unless html.present? context.merge!( current_user: (current_user if defined?(current_user)), # RelativeLinkFilter - commit: @commit, - project_wiki: @project_wiki, - ref: @ref, + commit: @commit, + project_wiki: @project_wiki, + ref: @ref, requested_path: @path ) diff --git a/app/helpers/mattermost_helper.rb b/app/helpers/mattermost_helper.rb index b211fe5076a..6d400971ae1 100644 --- a/app/helpers/mattermost_helper.rb +++ b/app/helpers/mattermost_helper.rb @@ -3,7 +3,7 @@ module MattermostHelper def mattermost_teams_options(teams) teams.map do |team| - [team['display_name'] || team['name'], team['id']] + [team["display_name"] || team["name"], team["id"]] end end end diff --git a/app/helpers/members_helper.rb b/app/helpers/members_helper.rb index 11d5591d509..90ae44f4205 100644 --- a/app/helpers/members_helper.rb +++ b/app/helpers/members_helper.rb @@ -3,12 +3,12 @@ module MembersHelper def remove_member_message(member, user: nil) user = current_user if defined?(current_user) - text = 'Are you sure you want to' + text = "Are you sure you want to" action = if member.request? if member.user == user - 'withdraw your access request for' + "withdraw your access request for" else "deny #{member.user.name}'s request to join" end @@ -22,7 +22,7 @@ module MembersHelper end def remove_member_title(member) - action = member.request? ? 'Deny access request' : 'Remove user' + action = member.request? ? "Deny access request" : "Remove user" "#{action} from #{source_text(member)}" end @@ -42,8 +42,8 @@ module MembersHelper def source_text(member) type = member.real_source_type.humanize(capitalize: false) - return type if member.request? || member.invite? || type != 'group' + return type if member.request? || member.invite? || type != "group" - 'group and any subresources' + "group and any subresources" end end diff --git a/app/helpers/merge_requests_helper.rb b/app/helpers/merge_requests_helper.rb index 23d7aa427bb..a921ed566d5 100644 --- a/app/helpers/merge_requests_helper.rb +++ b/app/helpers/merge_requests_helper.rb @@ -15,8 +15,8 @@ module MergeRequestsHelper source_project_id: event.project.id, target_project_id: target_project.id, source_branch: event.branch_name, - target_branch: target_project.repository.root_ref - } + target_branch: target_project.repository.root_ref, + }, } end @@ -24,7 +24,7 @@ module MergeRequestsHelper classes = ["merge-request"] classes << "closed" if mr.closed? classes << "merged" if mr.merged? - classes.join(' ') + classes.join(" ") end def ci_build_details_path(merge_request) @@ -34,7 +34,7 @@ module MergeRequestsHelper parsed_url = URI.parse(build_url) unless parsed_url.userinfo.blank? - parsed_url.userinfo = '' + parsed_url.userinfo = "" end parsed_url.to_s @@ -55,7 +55,7 @@ module MergeRequestsHelper source_project_id: merge_request.source_project_id, target_project_id: merge_request.target_project_id, source_branch: merge_request.source_branch, - target_branch: merge_request.target_branch + target_branch: merge_request.target_branch, }, change_branches: true ) @@ -80,7 +80,7 @@ module MergeRequestsHelper end def merge_request_button_visibility(merge_request, closed) - return 'hidden' if merge_request_button_hidden?(merge_request, closed) + return "hidden" if merge_request_button_hidden?(merge_request, closed) end def merge_request_button_hidden?(merge_request, closed) @@ -106,7 +106,7 @@ module MergeRequestsHelper merge_when_pipeline_succeeds: true, should_remove_source_branch: true, sha: merge_request.diff_head_sha, - squash: merge_request.squash + squash: merge_request.squash, } end @@ -114,12 +114,12 @@ module MergeRequestsHelper data_attrs = { action: tab.to_s, target: "##{tab}", - toggle: options.fetch(:force_link, false) ? '' : 'tabvue' + toggle: options.fetch(:force_link, false) ? "" : "tabvue", } url = case tab when :show - data_attrs[:target] = '#notes' + data_attrs[:target] = "#notes" method(:project_merge_request_path) when :commits method(:commits_project_merge_request_path) @@ -129,7 +129,7 @@ module MergeRequestsHelper method(:diffs_project_merge_request_path) else raise "Cannot create tab #{tab}." - end + end link_to(url[merge_request.project, merge_request], data: data_attrs, &block) end @@ -138,12 +138,12 @@ module MergeRequestsHelper return if merge_request.can_allow_collaboration?(current_user) minimum_visibility = [merge_request.target_project.visibility_level, - merge_request.source_project.visibility_level].min + merge_request.source_project.visibility_level,].min if minimum_visibility < Gitlab::VisibilityLevel::INTERNAL - _('Not available for private projects') + _("Not available for private projects") elsif ProtectedBranch.protected?(merge_request.source_project, merge_request.source_branch) - _('Not available for protected branches') + _("Not available for protected branches") end end diff --git a/app/helpers/milestones_helper.rb b/app/helpers/milestones_helper.rb index 50aec83b867..7ce0f65478a 100644 --- a/app/helpers/milestones_helper.rb +++ b/app/helpers/milestones_helper.rb @@ -25,7 +25,7 @@ module MilestonesHelper end def milestones_browse_issuables_path(milestone, state: nil, type:) - opts = { milestone_title: milestone.title, state: state } + opts = {milestone_title: milestone.title, state: state} if @project polymorphic_path([@project.namespace.becomes(Namespace), @project, type], opts) @@ -59,9 +59,9 @@ module MilestonesHelper counts = milestones.reorder(nil).group(:state).count { - opened: counts['active'] || 0, - closed: counts['closed'] || 0, - all: counts.values.sum || 0 + opened: counts["active"] || 0, + closed: counts["closed"] || 0, + all: counts.values.sum || 0, } end # rubocop: enable CodeReuse/ActiveRecord @@ -71,9 +71,9 @@ module MilestonesHelper # Could be refactored to be simpler but that may make it harder to read def milestone_class_for_state(param, check, match_blank_param = false) if match_blank_param - 'active' if param.blank? || param == check + "active" if param.blank? || param == check elsif param == check - 'active' + "active" else check end @@ -84,21 +84,21 @@ module MilestonesHelper if has_issues [ - _('Progress'), - _("%{percent}%% complete") % { percent: milestone.percent_complete(current_user) } - ].join('<br />') + _("Progress"), + _("%{percent}%% complete") % {percent: milestone.percent_complete(current_user)}, + ].join("<br />") else - _('Progress') + _("Progress") end end def milestone_progress_bar(milestone) options = { - class: 'progress-bar bg-success', - style: "width: #{milestone.percent_complete(current_user)}%;" + class: "progress-bar bg-success", + style: "width: #{milestone.percent_complete(current_user)}%;", } - content_tag :div, class: 'progress' do + content_tag :div, class: "progress" do content_tag :div, nil, options end end @@ -120,16 +120,16 @@ module MilestonesHelper if date time_ago = time_ago_in_words(date).sub("about ", "") state = if date.past? - "ago" - else - "remaining" - end + "ago" + else + "remaining" + end content = [ title, "<br />", date.to_s(:medium), - "(#{time_ago} #{state})" + "(#{time_ago} #{state})", ].join(" ") content.html_safe @@ -148,7 +148,7 @@ module MilestonesHelper content << n_("1 open issue", "%d open issues", issues["opened"]) % issues["opened"] if issues["opened"] content << n_("1 closed issue", "%d closed issues", issues["closed"]) % issues["closed"] if issues["closed"] - content.join('<br />').html_safe + content.join("<br />").html_safe end def milestone_merge_requests_tooltip_text(milestone) @@ -162,14 +162,14 @@ module MilestonesHelper content << n_("1 closed merge request", "%d closed merge requests", merge_requests.closed.count) % merge_requests.closed.count if merge_requests.closed.any? content << n_("1 merged merge request", "%d merged merge requests", merge_requests.merged.count) % merge_requests.merged.count if merge_requests.merged.any? - content.join('<br />').html_safe + content.join("<br />").html_safe end def milestone_tooltip_due_date(milestone) if milestone.due_date "#{milestone.due_date.to_s(:medium)} (#{remaining_days_in_words(milestone.due_date, milestone.start_date)})" else - _('Milestone') + _("Milestone") end end @@ -234,9 +234,9 @@ module MilestonesHelper def group_or_project_milestone_path(milestone) params = if milestone.group_milestone? - { milestone: { title: milestone.title } } + {milestone: {title: milestone.title}} else - { title: milestone.title } + {title: milestone.title} end milestone_path(milestone.milestone, params) diff --git a/app/helpers/mirror_helper.rb b/app/helpers/mirror_helper.rb index 65c7cd82832..4e26b9a5e5f 100644 --- a/app/helpers/mirror_helper.rb +++ b/app/helpers/mirror_helper.rb @@ -4,7 +4,7 @@ module MirrorHelper def mirrors_form_data_attributes { project_mirror_ssh_endpoint: ssh_host_keys_project_mirror_path(@project, :json), - project_mirror_endpoint: project_mirror_path(@project, :json) + project_mirror_endpoint: project_mirror_path(@project, :json), } end end diff --git a/app/helpers/namespaces_helper.rb b/app/helpers/namespaces_helper.rb index ea3bcfc791a..44b58b702d9 100644 --- a/app/helpers/namespaces_helper.rb +++ b/app/helpers/namespaces_helper.rb @@ -11,10 +11,10 @@ module NamespacesHelper selected_id = selected unless extra_group.nil? || extra_group.is_a?(Group) - extra_group = Group.find(extra_group) if Namespace.find(extra_group).kind == 'group' + extra_group = Group.find(extra_group) if Namespace.find(extra_group).kind == "group" end - if extra_group && extra_group.is_a?(Group) + if extra_group&.is_a?(Group) extra_group = dedup_extra_group(extra_group) if Ability.allowed?(current_user, :read_group, extra_group) @@ -28,10 +28,10 @@ module NamespacesHelper end options = [] - options << options_for_group(groups, display_path: display_path, type: 'group') + options << options_for_group(groups, display_path: display_path, type: "group") unless groups_only - options << options_for_group(users, display_path: display_path, type: 'user') + options << options_for_group(users, display_path: display_path, type: "user") if selected == :current_user && current_user.namespace selected_id = current_user.namespace.id @@ -66,17 +66,17 @@ module NamespacesHelper def options_for_group(namespaces, display_path:, type:) group_label = type.pluralize - elements = namespaces.sort_by(&:human_name).map! do |n| + elements = namespaces.sort_by(&:human_name).map! { |n| [display_path ? n.full_path : n.human_name, n.id, data: { options_parent: group_label, visibility_level: n.visibility_level_value, visibility: n.visibility, name: n.name, - show_path: (type == 'group') ? group_path(n) : user_path(n), - edit_path: (type == 'group') ? edit_group_path(n) : nil - }] - end + show_path: type == "group" ? group_path(n) : user_path(n), + edit_path: type == "group" ? edit_group_path(n) : nil, + },] + } [group_label.camelize, elements] end diff --git a/app/helpers/nav_helper.rb b/app/helpers/nav_helper.rb index 05da5ebdb22..f30e8c8c2c0 100644 --- a/app/helpers/nav_helper.rb +++ b/app/helpers/nav_helper.rb @@ -11,9 +11,9 @@ module NavHelper def page_with_sidebar_class class_name = page_gutter_class - class_name << 'page-with-contextual-sidebar' if defined?(@left_sidebar) && @left_sidebar - class_name << 'page-with-icon-sidebar' if collapsed_sidebar? && @left_sidebar - class_name -= ['right-sidebar-expanded'] if defined?(@right_sidebar) && !@right_sidebar + class_name << "page-with-contextual-sidebar" if defined?(@left_sidebar) && @left_sidebar + class_name << "page-with-icon-sidebar" if collapsed_sidebar? && @left_sidebar + class_name -= ["right-sidebar-expanded"] if defined?(@right_sidebar) && !@right_sidebar class_name end @@ -21,14 +21,14 @@ module NavHelper def page_gutter_class if page_has_markdown? - if cookies[:collapsed_gutter] == 'true' + if cookies[:collapsed_gutter] == "true" %w[page-gutter right-sidebar-collapsed] else %w[page-gutter right-sidebar-expanded] end - elsif current_path?('jobs#show') + elsif current_path?("jobs#show") %w[page-gutter build-sidebar right-sidebar-expanded] - elsif current_controller?('wikis') && current_action?('show', 'create', 'edit', 'update', 'history', 'git_access', 'destroy') + elsif current_controller?("wikis") && current_action?("show", "create", "edit", "update", "history", "git_access", "destroy") %w[page-gutter wiki-sidebar right-sidebar-expanded] else [] @@ -41,8 +41,8 @@ module NavHelper def user_dropdown_class class_names = [] - class_names << 'header-user-dropdown-toggle' - class_names << 'impersonated-user' if session[:impersonator_id] + class_names << "header-user-dropdown-toggle" + class_names << "impersonated-user" if session[:impersonator_id] class_names end @@ -52,20 +52,20 @@ module NavHelper end def page_has_markdown? - current_path?('merge_requests#show') || - current_path?('projects/merge_requests/conflicts#show') || - current_path?('issues#show') || - current_path?('milestones#show') + current_path?("merge_requests#show") || + current_path?("projects/merge_requests/conflicts#show") || + current_path?("issues#show") || + current_path?("milestones#show") end private def get_header_links links = if current_user - [:user_dropdown] - else - [:sign_in] - end + [:user_dropdown] + else + [:sign_in] + end if can?(current_user, :read_cross_project) links += [:issues, :merge_requests, :todos] if current_user.present? diff --git a/app/helpers/notes_helper.rb b/app/helpers/notes_helper.rb index aaf38cbfe70..7efeb19ddb0 100644 --- a/app/helpers/notes_helper.rb +++ b/app/helpers/notes_helper.rb @@ -17,7 +17,7 @@ module NotesHelper id: noteable.id, class: noteable.class.name, resources: noteable.class.table_name, - project_id: noteable.project.id + project_id: noteable.project.id, }.to_json end @@ -32,7 +32,7 @@ module NotesHelper data = { line_code: line_code, - line_type: line_type + line_type: line_type, } if @use_legacy_diff_notes @@ -48,12 +48,12 @@ module NotesHelper def add_diff_note_button(line_code, position, line_type) return if @diff_notes_disabled - button_tag '', - class: 'add-diff-note js-add-diff-note-button', - type: 'submit', name: 'button', + button_tag "", + class: "add-diff-note js-add-diff-note-button", + type: "submit", name: "button", data: diff_view_line_data(line_code, position, line_type), - title: 'Add a comment to this line' do - icon('comment-o') + title: "Add a comment to this line" do + icon("comment-o") end end @@ -63,11 +63,11 @@ module NotesHelper data = { discussion_id: discussion.reply_id, discussion_project_id: discussion.project&.id, - line_type: line_type + line_type: line_type, } - button_tag 'Reply...', class: 'btn btn-text-field js-discussion-reply-button', - data: data, title: 'Add a reply' + button_tag "Reply...", class: "btn btn-text-field js-discussion-reply-button", + data: data, title: "Add a reply" end def note_max_access_for_user(note) @@ -95,7 +95,8 @@ module NotesHelper if @snippet.is_a?(PersonalSnippet) snippet_notes_path(@snippet, params) else - params.merge!(target_id: @noteable.id, target_type: @noteable.class.name.underscore) + params[:target_id] = @noteable.id + params[:target_type] = @noteable.class.name.underscore project_noteable_notes_path(@project, params) end @@ -152,8 +153,8 @@ module NotesHelper mergeRequests: autocomplete, epics: autocomplete, milestones: autocomplete, - labels: autocomplete - } + labels: autocomplete, + }, } end @@ -168,20 +169,20 @@ module NotesHelper def notes_data(issuable) { discussionsPath: discussions_path(issuable), - registerPath: new_session_path(:user, redirect_to_referer: 'yes', anchor: 'register-pane'), - newSessionPath: new_session_path(:user, redirect_to_referer: 'yes'), - markdownDocsPath: help_page_path('user/markdown'), - quickActionsDocsPath: help_page_path('user/project/quick_actions'), + registerPath: new_session_path(:user, redirect_to_referer: "yes", anchor: "register-pane"), + newSessionPath: new_session_path(:user, redirect_to_referer: "yes"), + markdownDocsPath: help_page_path("user/markdown"), + quickActionsDocsPath: help_page_path("user/project/quick_actions"), closePath: close_issuable_path(issuable), reopenPath: reopen_issuable_path(issuable), notesPath: notes_url, totalNotes: issuable.discussions.length, - lastFetchedAt: Time.now.to_i + lastFetchedAt: Time.now.to_i, } end def discussion_resolved_intro(discussion) - discussion.resolved_by_push? ? 'Automatically resolved' : 'Resolved' + discussion.resolved_by_push? ? "Automatically resolved" : "Resolved" end def rendered_for_merge_request? @@ -189,6 +190,6 @@ module NotesHelper end def serialize_notes? - rendered_for_merge_request? || params['html'].nil? + rendered_for_merge_request? || params["html"].nil? end end diff --git a/app/helpers/notifications_helper.rb b/app/helpers/notifications_helper.rb index 5318ab4ddef..400d83c8790 100644 --- a/app/helpers/notifications_helper.rb +++ b/app/helpers/notifications_helper.rb @@ -6,15 +6,15 @@ module NotificationsHelper def notification_icon_class(level) case level.to_sym when :disabled - 'microphone-slash' + "microphone-slash" when :participating - 'volume-up' + "volume-up" when :watch - 'eye' + "eye" when :mention - 'at' + "at" when :global - 'globe' + "globe" end end @@ -26,14 +26,14 @@ module NotificationsHelper # Can be anything in `NotificationSetting.level: case level.to_sym when :participating - s_('NotificationLevel|Participate') + s_("NotificationLevel|Participate") when :mention - s_('NotificationLevel|On mention') + s_("NotificationLevel|On mention") else - N_('NotificationLevel|Global') - N_('NotificationLevel|Watch') - N_('NotificationLevel|Disabled') - N_('NotificationLevel|Custom') + N_("NotificationLevel|Global") + N_("NotificationLevel|Watch") + N_("NotificationLevel|Disabled") + N_("NotificationLevel|Custom") level = "NotificationLevel|#{level.to_s.humanize}" s_(level) end @@ -42,17 +42,17 @@ module NotificationsHelper def notification_description(level) case level.to_sym when :participating - _('You will only receive notifications for threads you have participated in') + _("You will only receive notifications for threads you have participated in") when :mention - _('You will receive notifications only for comments in which you were @mentioned') + _("You will receive notifications only for comments in which you were @mentioned") when :watch - _('You will receive notifications for any activity') + _("You will receive notifications for any activity") when :disabled - _('You will not get any notifications via email') + _("You will not get any notifications via email") when :global - _('Use your global notification setting') + _("Use your global notification setting") when :custom - _('You will only receive notifications for the events you choose') + _("You will only receive notifications for the events you choose") end end @@ -61,13 +61,13 @@ module NotificationsHelper data = { notification_level: level, - notification_title: title + notification_title: title, } content_tag(:li, role: "menuitem") do - link_to '#', class: "update-notification #{('is-active' if setting.level == level)}", data: data do - link_output = content_tag(:strong, title, class: 'dropdown-menu-inner-title') - link_output << content_tag(:span, notification_description(level), class: 'dropdown-menu-inner-content') + link_to "#", class: "update-notification #{("is-active" if setting.level == level)}", data: data do + link_output = content_tag(:strong, title, class: "dropdown-menu-inner-title") + link_output << content_tag(:span, notification_description(level), class: "dropdown-menu-inner-content") end end end @@ -88,7 +88,7 @@ module NotificationsHelper # All values from NotificationSetting.email_events case event when :success_pipeline - s_('NotificationEvent|Successful pipeline') + s_("NotificationEvent|Successful pipeline") else s_(event.to_s.humanize) end diff --git a/app/helpers/numbers_helper.rb b/app/helpers/numbers_helper.rb index 3c0b11c4d32..862cc032e5a 100644 --- a/app/helpers/numbers_helper.rb +++ b/app/helpers/numbers_helper.rb @@ -6,7 +6,7 @@ module NumbersHelper limit = options.fetch(:limit, 1000).to_i count = resource.limit(limit + 1).count(:all) if count > limit - number_with_delimiter(count - 1, options) + '+' + number_with_delimiter(count - 1, options) + "+" else number_with_delimiter(count, options) end diff --git a/app/helpers/page_layout_helper.rb b/app/helpers/page_layout_helper.rb index 5038dcf9746..bb57ad65050 100644 --- a/app/helpers/page_layout_helper.rb +++ b/app/helpers/page_layout_helper.rb @@ -45,7 +45,7 @@ module PageLayoutHelper end def page_image - default = image_url('gitlab_logo.png') + default = image_url("gitlab_logo.png") subject = @project || @user || @group @@ -59,7 +59,7 @@ module PageLayoutHelper # # Raises ArgumentError if given more than two attributes def page_card_attributes(map = {}) - raise ArgumentError, 'cannot provide more than two attributes' if map.length > 2 + raise ArgumentError, "cannot provide more than two attributes" if map.length > 2 @page_card_attributes ||= {} @page_card_attributes = map.reject { |_, v| v.blank? } if map.present? @@ -127,6 +127,6 @@ module PageLayoutHelper css_class << "container-blank" end - css_class.join(' ') + css_class.join(" ") end end diff --git a/app/helpers/pagination_helper.rb b/app/helpers/pagination_helper.rb index d05153c9d4b..8586bfdb700 100644 --- a/app/helpers/pagination_helper.rb +++ b/app/helpers/pagination_helper.rb @@ -11,13 +11,13 @@ module PaginationHelper def paginate_without_count(collection) render( - 'kaminari/gitlab/without_count', + "kaminari/gitlab/without_count", previous_path: path_to_prev_page(collection), next_path: path_to_next_page(collection) ) end def paginate_with_count(collection, remote: nil) - paginate(collection, remote: remote, theme: 'gitlab') + paginate(collection, remote: remote, theme: "gitlab") end end diff --git a/app/helpers/pipeline_schedules_helper.rb b/app/helpers/pipeline_schedules_helper.rb index 0e166106b32..6d2dccfd38a 100644 --- a/app/helpers/pipeline_schedules_helper.rb +++ b/app/helpers/pipeline_schedules_helper.rb @@ -6,7 +6,7 @@ module PipelineSchedulesHelper { name: timezone.name, offset: timezone.now.utc_offset, - identifier: timezone.tzinfo.identifier + identifier: timezone.tzinfo.identifier, } end end diff --git a/app/helpers/preferences_helper.rb b/app/helpers/preferences_helper.rb index eed529f93db..7890cd0ab64 100644 --- a/app/helpers/preferences_helper.rb +++ b/app/helpers/preferences_helper.rb @@ -4,22 +4,22 @@ module PreferencesHelper def layout_choices [ - ['Fixed', :fixed], - ['Fluid', :fluid] + ["Fixed", :fixed], + ["Fluid", :fluid], ] end # Maps `dashboard` values to more user-friendly option text DASHBOARD_CHOICES = { projects: _("Your Projects (default)"), - stars: _("Starred Projects"), + stars: _("Starred Projects"), project_activity: _("Your Projects' Activity"), starred_project_activity: _("Starred Projects' Activity"), groups: _("Your Groups"), todos: _("Your Todos"), issues: _("Assigned Issues"), merge_requests: _("Assigned Merge Requests"), - operations: _("Operations Dashboard") + operations: _("Operations Dashboard"), }.with_indifferent_access.freeze # Returns an Array usable by a select field for more user-friendly option text @@ -37,21 +37,21 @@ module PreferencesHelper def project_view_choices [ - ['Files and Readme (default)', :files], - ['Activity', :activity], - ['Readme', :readme] + ["Files and Readme (default)", :files], + ["Activity", :activity], + ["Readme", :readme], ] end def first_day_of_week_choices [ - [_('Sunday'), 0], - [_('Monday'), 1] + [_("Sunday"), 0], + [_("Monday"), 1], ] end def first_day_of_week_choices_with_default - first_day_of_week_choices.unshift([_('System default (%{default})') % { default: default_first_day_of_week }, nil]) + first_day_of_week_choices.unshift([_("System default (%{default})") % {default: default_first_day_of_week}, nil]) end def user_application_theme @@ -79,7 +79,7 @@ module PreferencesHelper # List of dashboard choice to be excluded from CE. # EE would override this. def excluded_dashboard_choices - ['operations'] + ["operations"] end def default_first_day_of_week diff --git a/app/helpers/profiles_helper.rb b/app/helpers/profiles_helper.rb index 5a42e581867..6451c29cffc 100644 --- a/app/helpers/profiles_helper.rb +++ b/app/helpers/profiles_helper.rb @@ -6,8 +6,8 @@ module ProfilesHelper verified_emails = user.verified_emails - [private_email] [ - [s_("Profiles|Use a private email - %{email}").html_safe % { email: private_email }, Gitlab::PrivateCommitEmail::TOKEN], - *verified_emails + [s_("Profiles|Use a private email - %{email}").html_safe % {email: private_email}, Gitlab::PrivateCommitEmail::TOKEN], + *verified_emails, ] end @@ -21,12 +21,12 @@ module ProfilesHelper if user_synced_attributes_metadata.provider Gitlab::Auth::OAuth::Provider.label_for(user_synced_attributes_metadata.provider) else - 'LDAP' + "LDAP" end end end def user_profile? - params[:controller] == 'users' + params[:controller] == "users" end end diff --git a/app/helpers/projects/error_tracking_helper.rb b/app/helpers/projects/error_tracking_helper.rb index 6daf2e21ca2..20f0a3930c8 100644 --- a/app/helpers/projects/error_tracking_helper.rb +++ b/app/helpers/projects/error_tracking_helper.rb @@ -5,11 +5,11 @@ module Projects::ErrorTrackingHelper error_tracking_enabled = !!project.error_tracking_setting&.enabled? { - 'index-path' => project_error_tracking_index_path(project, - format: :json), - 'enable-error-tracking-link' => project_settings_operations_path(project), - 'error-tracking-enabled' => error_tracking_enabled.to_s, - 'illustration-path' => image_path('illustrations/cluster_popover.svg') + "index-path" => project_error_tracking_index_path(project, + format: :json), + "enable-error-tracking-link" => project_settings_operations_path(project), + "error-tracking-enabled" => error_tracking_enabled.to_s, + "illustration-path" => image_path("illustrations/cluster_popover.svg"), } end end diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index c400302cda3..0fc31cab03a 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -3,10 +3,10 @@ module ProjectsHelper def link_to_project(project) link_to namespace_project_path(namespace_id: project.namespace, id: project), title: h(project.name) do - title = content_tag(:span, project.name, class: 'project-name') + title = content_tag(:span, project.name, class: "project-name") if project.namespace - namespace = content_tag(:span, "#{project.namespace.human_name} / ", class: 'namespace-name') + namespace = content_tag(:span, "#{project.namespace.human_name} / ", class: "namespace-name") title = namespace + title end @@ -15,7 +15,7 @@ module ProjectsHelper end def link_to_member_avatar(author, opts = {}) - default_opts = { size: 16, lazy_load: false } + default_opts = {size: 16, lazy_load: false} opts = default_opts.merge(opts) classes = %W[avatar avatar-inline s#{opts[:size]}] @@ -24,22 +24,22 @@ module ProjectsHelper avatar = avatar_icon_for_user(author, opts[:size]) src = opts[:lazy_load] ? nil : avatar - image_tag(src, width: opts[:size], class: classes, alt: '', "data-src" => avatar) + image_tag(src, :width => opts[:size], :class => classes, :alt => "", "data-src" => avatar) end def author_content_tag(author, opts = {}) - default_opts = { author_class: 'author', tooltip: false, by_username: false } + default_opts = {author_class: "author", tooltip: false, by_username: false} opts = default_opts.merge(opts) has_tooltip = !opts[:by_username] && opts[:tooltip] username = opts[:by_username] ? author.to_reference : author.name - name_tag_options = { class: [opts[:author_class]] } + name_tag_options = {class: [opts[:author_class]]} if has_tooltip name_tag_options[:title] = author.to_reference - name_tag_options[:data] = { placement: 'top' } - name_tag_options[:class] << 'has-tooltip' + name_tag_options[:data] = {placement: "top"} + name_tag_options[:class] << "has-tooltip" end # NOTE: ActionView::Helpers::TagHelper#content_tag HTML escapes username @@ -47,13 +47,13 @@ module ProjectsHelper end def link_to_member(project, author, opts = {}, &block) - default_opts = { avatar: true, name: true, title: ":name" } + default_opts = {avatar: true, name: true, title: ":name"} opts = default_opts.merge(opts) data_attrs = { user_id: author.id, username: author.username, - name: author.name + name: author.name, } return "(deleted)" unless author @@ -71,10 +71,10 @@ module ProjectsHelper author_html = author_html.join.html_safe if opts[:name] - link_to(author_html, user_path(author), class: "author-link js-user-link #{"#{opts[:extra_class]}" if opts[:extra_class]} #{"#{opts[:mobile_classes]}" if opts[:mobile_classes]}", data: data_attrs).html_safe + link_to(author_html, user_path(author), class: "author-link js-user-link #{(opts[:extra_class]).to_s if opts[:extra_class]} #{(opts[:mobile_classes]).to_s if opts[:mobile_classes]}", data: data_attrs).html_safe else title = opts[:title].sub(":name", sanitize(author.name)) - link_to(author_html, user_path(author), class: "author-link has-tooltip", title: title, data: { container: 'body' }).html_safe + link_to(author_html, user_path(author), class: "author-link has-tooltip", title: title, data: {container: "body"}).html_safe end end @@ -88,7 +88,7 @@ module ProjectsHelper end project_link = link_to project_path(project) do - icon = project_icon(project, alt: project.name, class: 'avatar-tile', width: 15, height: 15) if project.avatar_url && !Rails.env.test? + icon = project_icon(project, alt: project.name, class: "avatar-tile", width: 15, height: 15) if project.avatar_url && !Rails.env.test? [icon, content_tag("span", simple_sanitize(project.name), class: "breadcrumb-item-text js-breadcrumb-item-text")].join.html_safe end @@ -100,17 +100,17 @@ module ProjectsHelper def remove_project_message(project) _("You are going to remove %{project_full_name}. Removed project CANNOT be restored! Are you ABSOLUTELY sure?") % - { project_full_name: project.full_name } + {project_full_name: project.full_name} end def transfer_project_message(project) _("You are going to transfer %{project_full_name} to another owner. Are you ABSOLUTELY sure?") % - { project_full_name: project.full_name } + {project_full_name: project.full_name} end def remove_fork_project_message(project) _("You are going to remove the fork relationship to source project %{forked_from_project}. Are you ABSOLUTELY sure?") % - { forked_from_project: fork_source_name(project) } + {forked_from_project: fork_source_name(project)} end def fork_source_name(project) @@ -160,12 +160,12 @@ module ProjectsHelper end def link_to_autodeploy_doc - link_to _('About auto deploy'), help_page_path('ci/autodeploy/index'), target: '_blank' + link_to _("About auto deploy"), help_page_path("ci/autodeploy/index"), target: "_blank" end def autodeploy_flash_notice(branch_name) translation = _("Branch <strong>%{branch_name}</strong> was created. To set up auto deploy, choose a GitLab CI Yaml template and commit your changes. %{link_to_autodeploy_doc}") % - { branch_name: truncate(sanitize(branch_name)), link_to_autodeploy_doc: link_to_autodeploy_doc } + {branch_name: truncate(sanitize(branch_name)), link_to_autodeploy_doc: link_to_autodeploy_doc} translation.html_safe end @@ -179,7 +179,7 @@ module ProjectsHelper Gitlab::CurrentSettings.cache_key, "cross-project:#{can?(current_user, :read_cross_project)}", max_project_member_access_cache_key(project), - 'v2.6' + "v2.6", ] key << pipeline_status_cache_key(project.pipeline_status) if project.pipeline_status.has_status? @@ -212,9 +212,9 @@ module ProjectsHelper def link_to_set_password if current_user.require_password_creation_for_git? - link_to s_('SetPasswordToCloneLink|set a password'), edit_profile_password_path + link_to s_("SetPasswordToCloneLink|set a password"), edit_profile_password_path else - link_to s_('CreateTokenToCloneLink|create a personal access token'), profile_personal_access_tokens_path + link_to s_("CreateTokenToCloneLink|create a personal access token"), profile_personal_access_tokens_path end end @@ -244,7 +244,7 @@ module ProjectsHelper def push_to_create_project_command(user = current_user) repository_url = - if Gitlab::CurrentSettings.current_application_settings.enabled_git_access_protocol == 'http' + if Gitlab::CurrentSettings.current_application_settings.enabled_git_access_protocol == "http" user_url(user) else Gitlab.config.gitlab_shell.ssh_path_prefix + user.username @@ -262,7 +262,7 @@ module ProjectsHelper end def link_to_bfg - link_to 'BFG', 'https://rtyley.github.io/bfg-repo-cleaner/', target: '_blank', rel: 'noopener noreferrer' + link_to "BFG", "https://rtyley.github.io/bfg-repo-cleaner/", target: "_blank", rel: "noopener noreferrer" end def explore_projects_tab? @@ -330,38 +330,38 @@ module ProjectsHelper def tab_ability_map { - environments: :read_environment, - milestones: :read_milestone, - snippets: :read_project_snippet, - settings: :admin_project, - builds: :read_build, - clusters: :read_cluster, - serverless: :read_cluster, - error_tracking: :read_sentry_issue, - labels: :read_label, - issues: :read_issue, - project_members: :read_project_member, - wiki: :read_wiki + environments: :read_environment, + milestones: :read_milestone, + snippets: :read_project_snippet, + settings: :admin_project, + builds: :read_build, + clusters: :read_cluster, + serverless: :read_cluster, + error_tracking: :read_sentry_issue, + labels: :read_label, + issues: :read_issue, + project_members: :read_project_member, + wiki: :read_wiki, } end def search_tab_ability_map @search_tab_ability_map ||= tab_ability_map.merge( - blobs: :download_code, - commits: :download_code, + blobs: :download_code, + commits: :download_code, merge_requests: :read_merge_request, - notes: [:read_merge_request, :download_code, :read_issue, :read_project_snippet] + notes: [:read_merge_request, :download_code, :read_issue, :read_project_snippet] ) end def project_lfs_status(project) if project.lfs_enabled? - content_tag(:span, class: 'lfs-enabled') do - s_('LFSStatus|Enabled') + content_tag(:span, class: "lfs-enabled") do + s_("LFSStatus|Enabled") end else - content_tag(:span, class: 'lfs-disabled') do - s_('LFSStatus|Disabled') + content_tag(:span, class: "lfs-disabled") do + s_("LFSStatus|Disabled") end end end @@ -384,7 +384,7 @@ module ProjectsHelper def default_url_to_repo(project = @project) case default_clone_protocol - when 'ssh' + when "ssh" project.ssh_url_to_repo else project.http_url_to_repo @@ -392,7 +392,7 @@ module ProjectsHelper end def default_clone_label - _("Copy %{protocol} clone URL") % { protocol: default_clone_protocol.upcase } + _("Copy %{protocol} clone URL") % {protocol: default_clone_protocol.upcase} end def default_clone_protocol @@ -407,7 +407,7 @@ module ProjectsHelper if !current_user || current_user.require_ssh_key? gitlab_config.protocol else - 'ssh' + "ssh" end end @@ -417,14 +417,14 @@ module ProjectsHelper def project_last_activity(project) if project.last_activity_at - time_ago_with_tooltip(project.last_activity_at, placement: 'bottom', html_class: 'last_activity_time_ago') + time_ago_with_tooltip(project.last_activity_at, placement: "bottom", html_class: "last_activity_time_ago") else s_("ProjectLastActivity|Never") end end def project_wiki_path_with_version(proj, page, version, is_newest) - url_params = is_newest ? {} : { version_id: version } + url_params = is_newest ? {} : {version_id: version} project_wiki_path(proj, page, url_params) end @@ -440,8 +440,8 @@ module ProjectsHelper end def readme_cache_key - sha = @project.commit.try(:sha) || 'nil' - [@project.full_path, sha, "readme"].join('-') + sha = @project.commit.try(:sha) || "nil" + [@project.full_path, sha, "readme"].join("-") end def current_ref @@ -475,7 +475,7 @@ module ProjectsHelper snippetsAccessLevel: feature.snippets_access_level, pagesAccessLevel: feature.pages_access_level, containerRegistryEnabled: !!project.container_registry_enabled, - lfsEnabled: !!project.lfs_enabled + lfsEnabled: !!project.lfs_enabled, } end @@ -484,14 +484,14 @@ module ProjectsHelper currentSettings: project_permissions_settings(project), canChangeVisibilityLevel: can_change_visibility_level?(project, current_user), allowedVisibilityOptions: project_allowed_visibility_levels(project), - visibilityHelpPath: help_page_path('public_access/public_access'), + visibilityHelpPath: help_page_path("public_access/public_access"), registryAvailable: Gitlab.config.registry.enabled, - registryHelpPath: help_page_path('user/project/container_registry'), + registryHelpPath: help_page_path("user/project/container_registry"), lfsAvailable: Gitlab.config.lfs.enabled, - lfsHelpPath: help_page_path('workflow/lfs/manage_large_binaries_with_git_lfs'), + lfsHelpPath: help_page_path("workflow/lfs/manage_large_binaries_with_git_lfs"), pagesAvailable: Gitlab.config.pages.enabled, pagesAccessControlEnabled: Gitlab.config.pages.access_control, - pagesHelpPath: help_page_path('user/project/pages/introduction', anchor: 'gitlab-pages-access-control-core-only') + pagesHelpPath: help_page_path("user/project/pages/introduction", anchor: "gitlab-pages-access-control-core-only"), } end diff --git a/app/helpers/repository_languages_helper.rb b/app/helpers/repository_languages_helper.rb index cf7eee7fff3..b64ce165aea 100644 --- a/app/helpers/repository_languages_helper.rb +++ b/app/helpers/repository_languages_helper.rb @@ -4,7 +4,7 @@ module RepositoryLanguagesHelper def repository_languages_bar(languages) return if languages.none? - content_tag :div, class: 'progress repository-languages-bar' do + content_tag :div, class: "progress repository-languages-bar" do safe_join(languages.map { |lang| language_progress(lang) }) end end @@ -13,7 +13,7 @@ module RepositoryLanguagesHelper content_tag :div, nil, class: "progress-bar has-tooltip", style: "width: #{lang.share}%; background-color:#{lang.color}", - data: { html: true }, + data: {html: true}, title: "<span class=\"repository-language-bar-tooltip-language\">#{escape_javascript(lang.name)}</span> <span class=\"repository-language-bar-tooltip-share\">#{lang.share.round(1)}%</span>" end end diff --git a/app/helpers/rss_helper.rb b/app/helpers/rss_helper.rb index 67c7d244f11..e50db812e33 100644 --- a/app/helpers/rss_helper.rb +++ b/app/helpers/rss_helper.rb @@ -2,6 +2,6 @@ module RssHelper def rss_url_options - { format: :atom, feed_token: current_user.try(:feed_token) } + {format: :atom, feed_token: current_user.try(:feed_token)} end end diff --git a/app/helpers/runners_helper.rb b/app/helpers/runners_helper.rb index 0d880c38a7b..2ebbd9ba86c 100644 --- a/app/helpers/runners_helper.rb +++ b/app/helpers/runners_helper.rb @@ -6,13 +6,13 @@ module RunnersHelper case status when :not_connected content_tag :i, nil, - class: "fa fa-warning", - title: "New runner. Has not connected yet" + class: "fa fa-warning", + title: "New runner. Has not connected yet" when :online, :offline, :paused content_tag :i, nil, - class: "fa fa-circle runner-status-#{status}", - title: "Runner is #{status}, last contact was #{time_ago_in_words(runner.contacted_at)} ago" + class: "fa fa-circle runner-status-#{status}", + title: "Runner is #{status}, last contact was #{time_ago_in_words(runner.contacted_at)} ago" end end @@ -20,7 +20,7 @@ module RunnersHelper display_name = truncate(runner.display_name, length: 15) id = "\##{runner.id}" - if current_user && current_user.admin + if current_user&.admin link_to admin_runner_path(runner) do display_name + id end @@ -32,7 +32,7 @@ module RunnersHelper # Due to inability of performing sorting of runners by cached "contacted_at" values we have to show uncached values if sorting by "contacted_asc" is requested. # Please refer to the following issue for more details: https://gitlab.com/gitlab-org/gitlab-ce/issues/55920 def runner_contacted_at(runner) - if params[:sort] == 'contacted_asc' + if params[:sort] == "contacted_asc" runner.uncached_contacted_at else runner.contacted_at diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index 0ee76a51f7d..6cd8bded0f4 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_helper.rb @@ -6,7 +6,7 @@ module SearchHelper resources_results = [ groups_autocomplete(term), - projects_autocomplete(term) + projects_autocomplete(term), ].flatten search_pattern = Regexp.new(Regexp.escape(term), "i") @@ -17,7 +17,7 @@ module SearchHelper [ resources_results, - generic_results + generic_results, ].flatten.uniq do |item| item[:label] end @@ -50,50 +50,50 @@ module SearchHelper # Autocomplete results for various settings pages def default_autocomplete [ - { category: "Settings", label: "User settings", url: profile_path }, - { category: "Settings", label: "SSH Keys", url: profile_keys_path }, - { category: "Settings", label: "Dashboard", url: root_path } + {category: "Settings", label: "User settings", url: profile_path}, + {category: "Settings", label: "SSH Keys", url: profile_keys_path}, + {category: "Settings", label: "Dashboard", url: root_path}, ] end # Autocomplete results for settings pages, for admins def default_autocomplete_admin [ - { category: "Settings", label: "Admin Section", url: admin_root_path } + {category: "Settings", label: "Admin Section", url: admin_root_path}, ] end # Autocomplete results for internal help pages def help_autocomplete [ - { category: "Help", label: "API Help", url: help_page_path("api/README") }, - { category: "Help", label: "Markdown Help", url: help_page_path("user/markdown") }, - { category: "Help", label: "Permissions Help", url: help_page_path("user/permissions") }, - { category: "Help", label: "Public Access Help", url: help_page_path("public_access/public_access") }, - { category: "Help", label: "Rake Tasks Help", url: help_page_path("raketasks/README") }, - { category: "Help", label: "SSH Keys Help", url: help_page_path("ssh/README") }, - { category: "Help", label: "System Hooks Help", url: help_page_path("system_hooks/system_hooks") }, - { category: "Help", label: "Webhooks Help", url: help_page_path("user/project/integrations/webhooks") }, - { category: "Help", label: "Workflow Help", url: help_page_path("workflow/README") } + {category: "Help", label: "API Help", url: help_page_path("api/README")}, + {category: "Help", label: "Markdown Help", url: help_page_path("user/markdown")}, + {category: "Help", label: "Permissions Help", url: help_page_path("user/permissions")}, + {category: "Help", label: "Public Access Help", url: help_page_path("public_access/public_access")}, + {category: "Help", label: "Rake Tasks Help", url: help_page_path("raketasks/README")}, + {category: "Help", label: "SSH Keys Help", url: help_page_path("ssh/README")}, + {category: "Help", label: "System Hooks Help", url: help_page_path("system_hooks/system_hooks")}, + {category: "Help", label: "Webhooks Help", url: help_page_path("user/project/integrations/webhooks")}, + {category: "Help", label: "Workflow Help", url: help_page_path("workflow/README")}, ] end # Autocomplete results for the current project, if it's defined def project_autocomplete - if @project && @project.repository.exists? && @project.repository.root_ref + if @project&.repository&.exists? && @project.repository.root_ref ref = @ref || @project.repository.root_ref [ - { category: "In this project", label: "Files", url: project_tree_path(@project, ref) }, - { category: "In this project", label: "Commits", url: project_commits_path(@project, ref) }, - { category: "In this project", label: "Network", url: project_network_path(@project, ref) }, - { category: "In this project", label: "Graph", url: project_graph_path(@project, ref) }, - { category: "In this project", label: "Issues", url: project_issues_path(@project) }, - { category: "In this project", label: "Merge Requests", url: project_merge_requests_path(@project) }, - { category: "In this project", label: "Milestones", url: project_milestones_path(@project) }, - { category: "In this project", label: "Snippets", url: project_snippets_path(@project) }, - { category: "In this project", label: "Members", url: project_project_members_path(@project) }, - { category: "In this project", label: "Wiki", url: project_wikis_path(@project) } + {category: "In this project", label: "Files", url: project_tree_path(@project, ref)}, + {category: "In this project", label: "Commits", url: project_commits_path(@project, ref)}, + {category: "In this project", label: "Network", url: project_network_path(@project, ref)}, + {category: "In this project", label: "Graph", url: project_graph_path(@project, ref)}, + {category: "In this project", label: "Issues", url: project_issues_path(@project)}, + {category: "In this project", label: "Merge Requests", url: project_merge_requests_path(@project)}, + {category: "In this project", label: "Milestones", url: project_milestones_path(@project)}, + {category: "In this project", label: "Snippets", url: project_snippets_path(@project)}, + {category: "In this project", label: "Members", url: project_project_members_path(@project)}, + {category: "In this project", label: "Wiki", url: project_wikis_path(@project)}, ] else [] @@ -107,9 +107,9 @@ module SearchHelper { category: "Groups", id: group.id, - label: "#{search_result_sanitize(group.full_name)}", + label: search_result_sanitize(group.full_name).to_s, url: group_path(group), - avatar_url: group.avatar_url || '' + avatar_url: group.avatar_url || "", } end end @@ -123,10 +123,10 @@ module SearchHelper { category: "Projects", id: p.id, - value: "#{search_result_sanitize(p.name)}", - label: "#{search_result_sanitize(p.full_name)}", + value: search_result_sanitize(p.name).to_s, + label: search_result_sanitize(p.full_name).to_s, url: project_path(p), - avatar_url: p.avatar_url || '' + avatar_url: p.avatar_url || "", } end end @@ -142,7 +142,7 @@ module SearchHelper project_id: params[:project_id], group_id: params[:group_id], scope: params[:scope], - repository_ref: params[:repository_ref] + repository_ref: params[:repository_ref], } options = exist_opts.merge(options) @@ -153,21 +153,21 @@ module SearchHelper opts = { id: "filtered-search-#{type}", - placeholder: 'Search or filter results...', + placeholder: "Search or filter results...", data: { - 'username-params' => UserSerializer.new.represent(@users) + "username-params" => UserSerializer.new.represent(@users), }, - autocomplete: 'off' + autocomplete: "off", } if @project.present? - opts[:data]['project-id'] = @project.id - opts[:data]['base-endpoint'] = project_path(@project) + opts[:data]["project-id"] = @project.id + opts[:data]["base-endpoint"] = project_path(@project) elsif @group.present? - opts[:data]['group-id'] = @group.id - opts[:data]['base-endpoint'] = group_canonical_path(@group) + opts[:data]["group-id"] = @group.id + opts[:data]["base-endpoint"] = group_canonical_path(@group) else - opts[:data]['base-endpoint'] = root_dashboard_path + opts[:data]["base-endpoint"] = root_dashboard_path end opts @@ -179,7 +179,7 @@ module SearchHelper elsif @group.present? @group.full_path else - 'dashboard' + "dashboard" end end @@ -195,7 +195,7 @@ module SearchHelper ) # Truncato's filtered_tags and filtered_attributes are not quite the same - sanitize(html, tags: %w(a p ol ul li pre code)) + sanitize(html, tags: %w[a p ol ul li pre code]) end def limited_count(count, limit = 1000) diff --git a/app/helpers/selects_helper.rb b/app/helpers/selects_helper.rb index 2f802e4eab8..f433ee56ab3 100644 --- a/app/helpers/selects_helper.rb +++ b/app/helpers/selects_helper.rb @@ -5,20 +5,20 @@ module SelectsHelper css_class = ["ajax-users-select"] css_class << "multiselect" if opts[:multiple] css_class << "skip_ldap" if opts[:skip_ldap] - css_class << (opts[:class] || '') - value = opts[:selected] || '' + css_class << (opts[:class] || "") + value = opts[:selected] || "" html = { - class: css_class.join(' '), - data: users_select_data_attributes(opts) + class: css_class.join(" "), + data: users_select_data_attributes(opts), } unless opts[:scope] == :all project = opts[:project] || @project if project - html['data-project-id'] = project.id + html["data-project-id"] = project.id elsif @group - html['data-group-id'] = @group.id + html["data-group-id"] = @group.id end end @@ -27,36 +27,36 @@ module SelectsHelper def groups_select_tag(id, opts = {}) classes = Array.wrap(opts[:class]) - classes << 'ajax-groups-select' + classes << "ajax-groups-select" # EE requires this line to be present, but there is no easy way of injecting # this into EE without causing merge conflicts. Given this line is very # simple and not really EE specific on its own, we just include it in CE. - classes << 'multiselect' if opts[:multiple] + classes << "multiselect" if opts[:multiple] - opts[:class] = classes.join(' ') + opts[:class] = classes.join(" ") select2_tag(id, opts) end def namespace_select_tag(id, opts = {}) - opts[:class] = [*opts[:class], 'ajax-namespace-select'].join(' ') + opts[:class] = [*opts[:class], "ajax-namespace-select"].join(" ") select2_tag(id, opts) end def project_select_tag(id, opts = {}) - opts[:class] = [*opts[:class], 'ajax-project-select'].join(' ') + opts[:class] = [*opts[:class], "ajax-project-select"].join(" ") unless opts.delete(:scope) == :all if @group - opts['data-group-id'] = @group.id + opts["data-group-id"] = @group.id end end with_feature_enabled_data_attribute = case opts.delete(:with_feature_enabled) - when 'issues' then 'data-with-issues-enabled' - when 'merge_requests' then 'data-with-merge-requests-enabled' + when "issues" then "data-with-issues-enabled" + when "merge_requests" then "data-with-merge-requests-enabled" end opts[with_feature_enabled_data_attribute] = true @@ -66,10 +66,10 @@ module SelectsHelper def select2_tag(id, opts = {}) klass_opts = [opts[:class]] - klass_opts << 'multiselect' if opts[:multiple] + klass_opts << "multiselect" if opts[:multiple] - opts[:class] = klass_opts.join(' ') - value = opts[:selected] || '' + opts[:class] = klass_opts.join(" ") + value = opts[:selected] || "" hidden_field_tag(id, value, opts) end @@ -78,14 +78,14 @@ module SelectsHelper def users_select_data_attributes(opts) { - placeholder: opts[:placeholder] || 'Search for a user', + placeholder: opts[:placeholder] || "Search for a user", null_user: opts[:null_user] || false, any_user: opts[:any_user] || false, email_user: opts[:email_user] || false, first_user: opts[:first_user] && current_user ? current_user.username : false, current_user: opts[:current_user] || false, - author_id: opts[:author_id] || '', - skip_users: opts[:skip_users] ? opts[:skip_users].map(&:id) : nil + author_id: opts[:author_id] || "", + skip_users: opts[:skip_users] ? opts[:skip_users].map(&:id) : nil, } end end diff --git a/app/helpers/services_helper.rb b/app/helpers/services_helper.rb index d4b50b7ecfb..4fe2b7e4c0e 100644 --- a/app/helpers/services_helper.rb +++ b/app/helpers/services_helper.rb @@ -32,9 +32,9 @@ module ServicesHelper end def service_save_button(service) - button_tag(class: 'btn btn-success', type: 'submit', disabled: service.deprecated?) do - icon('spinner spin', class: 'hidden js-btn-spinner') + - content_tag(:span, 'Save changes', class: 'js-btn-label') + button_tag(class: "btn btn-success", type: "submit", disabled: service.deprecated?) do + icon("spinner spin", class: "hidden js-btn-spinner") + + content_tag(:span, "Save changes", class: "js-btn-label") end end diff --git a/app/helpers/sidekiq_helper.rb b/app/helpers/sidekiq_helper.rb index 32bf3526571..156d69c5420 100644 --- a/app/helpers/sidekiq_helper.rb +++ b/app/helpers/sidekiq_helper.rb @@ -12,6 +12,6 @@ module SidekiqHelper def parse_sidekiq_ps(line) match = line.strip.match(SIDEKIQ_PS_REGEXP) - match ? match[1..6] : Array.new(6, '?') + match ? match[1..6] : Array.new(6, "?") end end diff --git a/app/helpers/snippets_helper.rb b/app/helpers/snippets_helper.rb index ecb2b2d707b..37870e88086 100644 --- a/app/helpers/snippets_helper.rb +++ b/app/helpers/snippets_helper.rb @@ -46,12 +46,14 @@ module SnippetsHelper def matching_lines(lined_content, surrounding_lines, query) used_lines = [] lined_content.each_with_index do |line, line_number| - used_lines.concat bounded_line_numbers( - line_number, - 0, - lined_content.size, - surrounding_lines - ) if line.downcase.include?(query.downcase) + if line.downcase.include?(query.downcase) + used_lines.concat bounded_line_numbers( + line_number, + 0, + lined_content.size, + surrounding_lines + ) + end end used_lines.uniq.sort @@ -84,7 +86,7 @@ module SnippetsHelper # Non-consecutive line, add chunk to chunk array. snippet_chunks << { data: snippet_chunk.join("\n"), - start_line: snippet_start_line + 1 + start_line: snippet_start_line + 1, } # Start a new chunk. @@ -97,11 +99,11 @@ module SnippetsHelper # Add final chunk to chunk array snippet_chunks << { data: snippet_chunk.join("\n"), - start_line: snippet_start_line + 1 + start_line: snippet_start_line + 1, } # Return snippet with chunk array - { snippet_object: snippet, snippet_chunks: snippet_chunks } + {snippet_object: snippet, snippet_chunks: snippet_chunks} end def snippet_embed @@ -113,21 +115,21 @@ module SnippetsHelper return if blob.empty? || blob.binary? || blob.stored_externally? snippet_raw_url = if @snippet.is_a?(PersonalSnippet) - raw_snippet_url(@snippet) - else - raw_project_snippet_url(@snippet.project, @snippet) - end + raw_snippet_url(@snippet) + else + raw_project_snippet_url(@snippet.project, @snippet) + end - link_to external_snippet_icon('doc-code'), snippet_raw_url, class: 'btn', target: '_blank', rel: 'noopener noreferrer', title: 'Open raw' + link_to external_snippet_icon("doc-code"), snippet_raw_url, class: "btn", target: "_blank", rel: "noopener noreferrer", title: "Open raw" end def embedded_snippet_download_button download_url = if @snippet.is_a?(PersonalSnippet) - raw_snippet_url(@snippet, inline: false) - else - raw_project_snippet_url(@snippet.project, @snippet, inline: false) - end + raw_snippet_url(@snippet, inline: false) + else + raw_project_snippet_url(@snippet.project, @snippet, inline: false) + end - link_to external_snippet_icon('download'), download_url, class: 'btn', target: '_blank', title: 'Download', rel: 'noopener noreferrer' + link_to external_snippet_icon("download"), download_url, class: "btn", target: "_blank", title: "Download", rel: "noopener noreferrer" end end diff --git a/app/helpers/sorting_helper.rb b/app/helpers/sorting_helper.rb index 07ec129dea3..3322e0e5dd8 100644 --- a/app/helpers/sorting_helper.rb +++ b/app/helpers/sorting_helper.rb @@ -3,43 +3,43 @@ module SortingHelper def sort_options_hash { - sort_value_created_date => sort_title_created_date, - sort_value_downvotes => sort_title_downvotes, - sort_value_due_date => sort_title_due_date, - sort_value_due_date_later => sort_title_due_date_later, - sort_value_due_date_soon => sort_title_due_date_soon, - sort_value_label_priority => sort_title_label_priority, - sort_value_largest_group => sort_title_largest_group, - sort_value_largest_repo => sort_title_largest_repo, - sort_value_milestone => sort_title_milestone, - sort_value_milestone_later => sort_title_milestone_later, - sort_value_milestone_soon => sort_title_milestone_soon, - sort_value_name => sort_title_name, - sort_value_name_desc => sort_title_name_desc, - sort_value_oldest_created => sort_title_oldest_created, - sort_value_oldest_signin => sort_title_oldest_signin, - sort_value_oldest_updated => sort_title_oldest_updated, + sort_value_created_date => sort_title_created_date, + sort_value_downvotes => sort_title_downvotes, + sort_value_due_date => sort_title_due_date, + sort_value_due_date_later => sort_title_due_date_later, + sort_value_due_date_soon => sort_title_due_date_soon, + sort_value_label_priority => sort_title_label_priority, + sort_value_largest_group => sort_title_largest_group, + sort_value_largest_repo => sort_title_largest_repo, + sort_value_milestone => sort_title_milestone, + sort_value_milestone_later => sort_title_milestone_later, + sort_value_milestone_soon => sort_title_milestone_soon, + sort_value_name => sort_title_name, + sort_value_name_desc => sort_title_name_desc, + sort_value_oldest_created => sort_title_oldest_created, + sort_value_oldest_signin => sort_title_oldest_signin, + sort_value_oldest_updated => sort_title_oldest_updated, sort_value_recently_created => sort_title_recently_created, - sort_value_recently_signin => sort_title_recently_signin, + sort_value_recently_signin => sort_title_recently_signin, sort_value_recently_updated => sort_title_recently_updated, - sort_value_popularity => sort_title_popularity, - sort_value_priority => sort_title_priority, - sort_value_upvotes => sort_title_upvotes, - sort_value_contacted_date => sort_title_contacted_date + sort_value_popularity => sort_title_popularity, + sort_value_priority => sort_title_priority, + sort_value_upvotes => sort_title_upvotes, + sort_value_contacted_date => sort_title_contacted_date, } end def projects_sort_options_hash options = { - sort_value_latest_activity => sort_title_latest_activity, - sort_value_name => sort_title_name, - sort_value_oldest_activity => sort_title_oldest_activity, - sort_value_oldest_created => sort_title_oldest_created, + sort_value_latest_activity => sort_title_latest_activity, + sort_value_name => sort_title_name, + sort_value_oldest_activity => sort_title_oldest_activity, + sort_value_oldest_created => sort_title_oldest_created, sort_value_recently_created => sort_title_recently_created, - sort_value_most_stars => sort_title_most_stars + sort_value_most_stars => sort_title_most_stars, } - if current_controller?('admin/projects') + if current_controller?("admin/projects") options[sort_value_largest_repo] = sort_title_largest_repo end @@ -48,12 +48,12 @@ module SortingHelper def groups_sort_options_hash { - sort_value_name => sort_title_name, - sort_value_name_desc => sort_title_name_desc, + sort_value_name => sort_title_name, + sort_value_name_desc => sort_title_name_desc, sort_value_recently_created => sort_title_recently_created, - sort_value_oldest_created => sort_title_oldest_created, + sort_value_oldest_created => sort_title_oldest_created, sort_value_recently_updated => sort_title_recently_updated, - sort_value_oldest_updated => sort_title_oldest_updated + sort_value_oldest_updated => sort_title_oldest_updated, } end @@ -71,41 +71,41 @@ module SortingHelper def member_sort_options_hash { - sort_value_access_level_asc => sort_title_access_level_asc, + sort_value_access_level_asc => sort_title_access_level_asc, sort_value_access_level_desc => sort_title_access_level_desc, - sort_value_last_joined => sort_title_last_joined, - sort_value_name => sort_title_name_asc, - sort_value_name_desc => sort_title_name_desc, - sort_value_oldest_joined => sort_title_oldest_joined, - sort_value_oldest_signin => sort_title_oldest_signin, - sort_value_recently_signin => sort_title_recently_signin + sort_value_last_joined => sort_title_last_joined, + sort_value_name => sort_title_name_asc, + sort_value_name_desc => sort_title_name_desc, + sort_value_oldest_joined => sort_title_oldest_joined, + sort_value_oldest_signin => sort_title_oldest_signin, + sort_value_recently_signin => sort_title_recently_signin, } end def milestone_sort_options_hash { - sort_value_name => sort_title_name_asc, - sort_value_name_desc => sort_title_name_desc, - sort_value_due_date_later => sort_title_due_date_later, - sort_value_due_date_soon => sort_title_due_date_soon, + sort_value_name => sort_title_name_asc, + sort_value_name_desc => sort_title_name_desc, + sort_value_due_date_later => sort_title_due_date_later, + sort_value_due_date_soon => sort_title_due_date_soon, sort_value_start_date_later => sort_title_start_date_later, - sort_value_start_date_soon => sort_title_start_date_soon + sort_value_start_date_soon => sort_title_start_date_soon, } end def branches_sort_options_hash { - sort_value_name => sort_title_name, - sort_value_oldest_updated => sort_title_oldest_updated, - sort_value_recently_updated => sort_title_recently_updated + sort_value_name => sort_title_name, + sort_value_oldest_updated => sort_title_oldest_updated, + sort_value_recently_updated => sort_title_recently_updated, } end def tags_sort_options_hash { - sort_value_name => sort_title_name, - sort_value_oldest_updated => sort_title_oldest_updated, - sort_value_recently_updated => sort_title_recently_updated + sort_value_name => sort_title_name, + sort_value_oldest_updated => sort_title_oldest_updated, + sort_value_recently_updated => sort_title_recently_updated, } end @@ -116,7 +116,7 @@ module SortingHelper sort_value_recently_created => sort_title_recently_created, sort_value_oldest_created => sort_title_oldest_created, sort_value_recently_updated => sort_title_recently_updated, - sort_value_oldest_updated => sort_title_oldest_updated + sort_value_oldest_updated => sort_title_oldest_updated, } end @@ -130,19 +130,19 @@ module SortingHelper sort_value_recently_updated => sort_title_recently_updated, sort_value_oldest_updated => sort_title_oldest_updated, sort_value_recently_last_activity => sort_title_recently_last_activity, - sort_value_oldest_last_activity => sort_title_oldest_last_activity + sort_value_oldest_last_activity => sort_title_oldest_last_activity, } end def sortable_item(item, path, sorted_by) - link_to item, path, class: sorted_by == item ? 'is-active' : '' + link_to item, path, class: sorted_by == item ? "is-active" : "" end def issuable_sort_option_overrides { sort_value_oldest_created => sort_value_created_date, sort_value_oldest_updated => sort_value_recently_updated, - sort_value_milestone_later => sort_value_milestone + sort_value_milestone_later => sort_value_milestone, } end @@ -151,7 +151,7 @@ module SortingHelper sort_value_created_date => sort_value_oldest_created, sort_value_recently_created => sort_value_oldest_created, sort_value_recently_updated => sort_value_oldest_updated, - sort_value_milestone => sort_value_milestone_later + sort_value_milestone => sort_value_milestone_later, }.merge(issuable_sort_option_overrides) end @@ -164,303 +164,303 @@ module SortingHelper def issuable_sort_icon_suffix(sort_value) case sort_value when sort_value_milestone, sort_value_due_date, /_asc\z/ - 'lowest' + "lowest" else - 'highest' + "highest" end end def issuable_sort_direction_button(sort_value) - link_class = 'btn btn-default has-tooltip reverse-sort-btn qa-reverse-sort' + link_class = "btn btn-default has-tooltip reverse-sort-btn qa-reverse-sort" reverse_sort = issuable_reverse_sort_order_hash[sort_value] if reverse_sort reverse_url = page_filter_path(sort: reverse_sort) else - reverse_url = '#' - link_class += ' disabled' + reverse_url = "#" + link_class += " disabled" end - link_to(reverse_url, type: 'button', class: link_class, title: 'Sort direction') do + link_to(reverse_url, type: "button", class: link_class, title: "Sort direction") do sprite_icon("sort-#{issuable_sort_icon_suffix(sort_value)}", size: 16) end end # Titles. def sort_title_access_level_asc - s_('SortOptions|Access level, ascending') + s_("SortOptions|Access level, ascending") end def sort_title_access_level_desc - s_('SortOptions|Access level, descending') + s_("SortOptions|Access level, descending") end def sort_title_created_date - s_('SortOptions|Created date') + s_("SortOptions|Created date") end def sort_title_downvotes - s_('SortOptions|Least popular') + s_("SortOptions|Least popular") end def sort_title_due_date - s_('SortOptions|Due date') + s_("SortOptions|Due date") end def sort_title_due_date_later - s_('SortOptions|Due later') + s_("SortOptions|Due later") end def sort_title_due_date_soon - s_('SortOptions|Due soon') + s_("SortOptions|Due soon") end def sort_title_label_priority - s_('SortOptions|Label priority') + s_("SortOptions|Label priority") end def sort_title_largest_group - s_('SortOptions|Largest group') + s_("SortOptions|Largest group") end def sort_title_largest_repo - s_('SortOptions|Largest repository') + s_("SortOptions|Largest repository") end def sort_title_last_joined - s_('SortOptions|Last joined') + s_("SortOptions|Last joined") end def sort_title_latest_activity - s_('SortOptions|Last updated') + s_("SortOptions|Last updated") end def sort_title_milestone - s_('SortOptions|Milestone due date') + s_("SortOptions|Milestone due date") end def sort_title_milestone_later - s_('SortOptions|Milestone due later') + s_("SortOptions|Milestone due later") end def sort_title_milestone_soon - s_('SortOptions|Milestone due soon') + s_("SortOptions|Milestone due soon") end def sort_title_name - s_('SortOptions|Name') + s_("SortOptions|Name") end def sort_title_name_asc - s_('SortOptions|Name, ascending') + s_("SortOptions|Name, ascending") end def sort_title_name_desc - s_('SortOptions|Name, descending') + s_("SortOptions|Name, descending") end def sort_title_oldest_activity - s_('SortOptions|Oldest updated') + s_("SortOptions|Oldest updated") end def sort_title_oldest_created - s_('SortOptions|Oldest created') + s_("SortOptions|Oldest created") end def sort_title_oldest_joined - s_('SortOptions|Oldest joined') + s_("SortOptions|Oldest joined") end def sort_title_oldest_signin - s_('SortOptions|Oldest sign in') + s_("SortOptions|Oldest sign in") end def sort_title_oldest_updated - s_('SortOptions|Oldest updated') + s_("SortOptions|Oldest updated") end def sort_title_popularity - s_('SortOptions|Popularity') + s_("SortOptions|Popularity") end def sort_title_priority - s_('SortOptions|Priority') + s_("SortOptions|Priority") end def sort_title_recently_created - s_('SortOptions|Last created') + s_("SortOptions|Last created") end def sort_title_recently_signin - s_('SortOptions|Recent sign in') + s_("SortOptions|Recent sign in") end def sort_title_recently_updated - s_('SortOptions|Last updated') + s_("SortOptions|Last updated") end def sort_title_start_date_later - s_('SortOptions|Start later') + s_("SortOptions|Start later") end def sort_title_start_date_soon - s_('SortOptions|Start soon') + s_("SortOptions|Start soon") end def sort_title_upvotes - s_('SortOptions|Most popular') + s_("SortOptions|Most popular") end def sort_title_contacted_date - s_('SortOptions|Last Contact') + s_("SortOptions|Last Contact") end def sort_title_most_stars - s_('SortOptions|Most stars') + s_("SortOptions|Most stars") end def sort_title_oldest_last_activity - s_('SortOptions|Oldest last activity') + s_("SortOptions|Oldest last activity") end def sort_title_recently_last_activity - s_('SortOptions|Recent last activity') + s_("SortOptions|Recent last activity") end # Values. def sort_value_access_level_asc - 'access_level_asc' + "access_level_asc" end def sort_value_access_level_desc - 'access_level_desc' + "access_level_desc" end def sort_value_created_date - 'created_date' + "created_date" end def sort_value_downvotes - 'downvotes_desc' + "downvotes_desc" end def sort_value_due_date - 'due_date' + "due_date" end def sort_value_due_date_later - 'due_date_desc' + "due_date_desc" end def sort_value_due_date_soon - 'due_date_asc' + "due_date_asc" end def sort_value_label_priority - 'label_priority' + "label_priority" end def sort_value_largest_group - 'storage_size_desc' + "storage_size_desc" end def sort_value_largest_repo - 'storage_size_desc' + "storage_size_desc" end def sort_value_last_joined - 'last_joined' + "last_joined" end def sort_value_latest_activity - 'latest_activity_desc' + "latest_activity_desc" end def sort_value_milestone - 'milestone' + "milestone" end def sort_value_milestone_later - 'milestone_due_desc' + "milestone_due_desc" end def sort_value_milestone_soon - 'milestone_due_asc' + "milestone_due_asc" end def sort_value_name - 'name_asc' + "name_asc" end def sort_value_name_desc - 'name_desc' + "name_desc" end def sort_value_oldest_activity - 'latest_activity_asc' + "latest_activity_asc" end def sort_value_oldest_created - 'created_asc' + "created_asc" end def sort_value_oldest_signin - 'oldest_sign_in' + "oldest_sign_in" end def sort_value_oldest_joined - 'oldest_joined' + "oldest_joined" end def sort_value_oldest_updated - 'updated_asc' + "updated_asc" end def sort_value_popularity - 'popularity' + "popularity" end def sort_value_priority - 'priority' + "priority" end def sort_value_recently_created - 'created_desc' + "created_desc" end def sort_value_recently_signin - 'recent_sign_in' + "recent_sign_in" end def sort_value_recently_updated - 'updated_desc' + "updated_desc" end def sort_value_start_date_later - 'start_date_desc' + "start_date_desc" end def sort_value_start_date_soon - 'start_date_asc' + "start_date_asc" end def sort_value_upvotes - 'upvotes_desc' + "upvotes_desc" end def sort_value_contacted_date - 'contacted_asc' + "contacted_asc" end def sort_value_most_stars - 'stars_desc' + "stars_desc" end def sort_value_oldest_last_activity - 'last_activity_on_asc' + "last_activity_on_asc" end def sort_value_recently_last_activity - 'last_activity_on_desc' + "last_activity_on_desc" end end diff --git a/app/helpers/storage_helper.rb b/app/helpers/storage_helper.rb index be8761db562..0f8df476299 100644 --- a/app/helpers/storage_helper.rb +++ b/app/helpers/storage_helper.rb @@ -4,6 +4,6 @@ module StorageHelper def storage_counter(size_in_bytes) precision = size_in_bytes < 1.megabyte ? 0 : 1 - number_to_human_size(size_in_bytes, delimiter: ',', precision: precision, significant: false) + number_to_human_size(size_in_bytes, delimiter: ",", precision: precision, significant: false) end end diff --git a/app/helpers/submodule_helper.rb b/app/helpers/submodule_helper.rb index 164c69ca50b..3251f4e0444 100644 --- a/app/helpers/submodule_helper.rb +++ b/app/helpers/submodule_helper.rb @@ -9,35 +9,35 @@ module SubmoduleHelper def submodule_links(submodule_item, ref = nil, repository = @repository) url = repository.submodule_url_for(ref, submodule_item.path) - if url == '.' || url == './' + if url == "." || url == "./" url = File.join(Gitlab.config.gitlab.url, repository.project.full_path) end if url =~ %r{([^/:]+)/([^/]+(?:\.git)?)\Z} namespace, project = $1, $2 gitlab_hosts = [Gitlab.config.gitlab.url, - Gitlab.config.gitlab_shell.ssh_path_prefix] + Gitlab.config.gitlab_shell.ssh_path_prefix,] gitlab_hosts.each do |host| if url.start_with?(host) - namespace, _, project = url.sub(host, '').rpartition('/') + namespace, _, project = url.sub(host, "").rpartition("/") break end end - namespace.sub!(%r{\A/}, '') + namespace.sub!(%r{\A/}, "") project.rstrip! - project.sub!(/\.git\z/, '') + project.sub!(/\.git\z/, "") if self_url?(url, namespace, project) [namespace_project_path(namespace, project), - namespace_project_tree_path(namespace, project, submodule_item.id)] + namespace_project_tree_path(namespace, project, submodule_item.id),] elsif relative_self_url?(url) relative_self_links(url, submodule_item.id, repository.project) elsif github_dot_com_url?(url) - standard_links('github.com', namespace, project, submodule_item.id) + standard_links("github.com", namespace, project, submodule_item.id) elsif gitlab_dot_com_url?(url) - standard_links('gitlab.com', namespace, project, submodule_item.id) + standard_links("gitlab.com", namespace, project, submodule_item.id) else [sanitize_submodule_url(url), nil] end @@ -57,21 +57,21 @@ module SubmoduleHelper end def self_url?(url, namespace, project) - url_no_dotgit = url.chomp('.git') - return true if url_no_dotgit == [Gitlab.config.gitlab.url, '/', namespace, '/', - project].join('') + url_no_dotgit = url.chomp(".git") + return true if url_no_dotgit == [Gitlab.config.gitlab.url, "/", namespace, "/", + project,].join("") - url_with_dotgit = url_no_dotgit + '.git' - url_with_dotgit == Gitlab::Shell.new.url_to_repo([namespace, '/', project].join('')) + url_with_dotgit = url_no_dotgit + ".git" + url_with_dotgit == Gitlab::Shell.new.url_to_repo([namespace, "/", project].join("")) end def relative_self_url?(url) - url.start_with?('../', './') + url.start_with?("../", "./") end def standard_links(host, namespace, project, commit) - base = ['https://', host, '/', namespace, '/', project].join('') - [base, [base, '/tree/', commit].join('')] + base = ["https://", host, "/", namespace, "/", project].join("") + [base, [base, "/tree/", commit].join("")] end def relative_self_links(relative_path, commit, project) @@ -86,17 +86,17 @@ module SubmoduleHelper submodule_project_path = File.absolute_path(relative_path, absolute_project_path) target_namespace_path = File.dirname(submodule_project_path) - if target_namespace_path == '/' || target_namespace_path.start_with?(absolute_project_path) + if target_namespace_path == "/" || target_namespace_path.start_with?(absolute_project_path) return [nil, nil] end - target_namespace_path.sub!(%r{^/}, '') - submodule_base = File.basename(submodule_project_path, '.git') + target_namespace_path.sub!(%r{^/}, "") + submodule_base = File.basename(submodule_project_path, ".git") begin [ namespace_project_path(target_namespace_path, submodule_base), - namespace_project_tree_path(target_namespace_path, submodule_base, commit) + namespace_project_tree_path(target_namespace_path, submodule_base, commit), ] rescue ActionController::UrlGenerationError [nil, nil] @@ -108,8 +108,6 @@ module SubmoduleHelper if uri.scheme.in?(VALID_SUBMODULE_PROTOCOLS) uri.to_s - else - nil end rescue URI::InvalidURIError nil diff --git a/app/helpers/system_note_helper.rb b/app/helpers/system_note_helper.rb index ac4e8f54260..d886712b522 100644 --- a/app/helpers/system_note_helper.rb +++ b/app/helpers/system_note_helper.rb @@ -2,29 +2,29 @@ module SystemNoteHelper ICON_NAMES_BY_ACTION = { - 'commit' => 'commit', - 'description' => 'pencil-square', - 'merge' => 'git-merge', - 'merged' => 'git-merge', - 'opened' => 'issue-open', - 'closed' => 'issue-close', - 'time_tracking' => 'timer', - 'assignee' => 'user', - 'title' => 'pencil-square', - 'task' => 'task-done', - 'label' => 'label', - 'cross_reference' => 'comment-dots', - 'branch' => 'fork', - 'confidential' => 'eye-slash', - 'visible' => 'eye', - 'milestone' => 'clock', - 'discussion' => 'comment', - 'moved' => 'arrow-right', - 'outdated' => 'pencil-square', - 'duplicate' => 'issue-duplicate', - 'locked' => 'lock', - 'unlocked' => 'lock-open', - 'due_date' => 'calendar' + "commit" => "commit", + "description" => "pencil-square", + "merge" => "git-merge", + "merged" => "git-merge", + "opened" => "issue-open", + "closed" => "issue-close", + "time_tracking" => "timer", + "assignee" => "user", + "title" => "pencil-square", + "task" => "task-done", + "label" => "label", + "cross_reference" => "comment-dots", + "branch" => "fork", + "confidential" => "eye-slash", + "visible" => "eye", + "milestone" => "clock", + "discussion" => "comment", + "moved" => "arrow-right", + "outdated" => "pencil-square", + "duplicate" => "issue-duplicate", + "locked" => "lock", + "unlocked" => "lock-open", + "due_date" => "calendar", }.freeze def system_note_icon_name(note) diff --git a/app/helpers/tab_helper.rb b/app/helpers/tab_helper.rb index d91f0f78db7..c1d823cb151 100644 --- a/app/helpers/tab_helper.rb +++ b/app/helpers/tab_helper.rb @@ -58,12 +58,12 @@ module TabHelper # # Returns a list item element String def nav_link(options = {}, &block) - klass = active_nav_link?(options) ? 'active' : '' + klass = active_nav_link?(options) ? "active" : "" # Add our custom class into the html_options, which may or may not exist # and which may or may not already have a :class key o = options.delete(:html_options) || {} - o[:class] = [*o[:class], klass].join(' ').strip + o[:class] = [*o[:class], klass].join(" ").strip if block_given? content_tag(:li, capture(&block), o) @@ -104,16 +104,16 @@ module TabHelper end def current_path?(path) - c, a, _ = path.split('#') + c, a, _ = path.split("#") current_controller?(c) && current_action?(a) end def project_tab_class - if controller.controller_path.start_with?('projects') - return 'active' + if controller.controller_path.start_with?("projects") + return "active" end - if %w(services hooks deploy_keys protected_branches).include? controller.controller_name + if %w[services hooks deploy_keys protected_branches].include? controller.controller_name "active" end end @@ -122,15 +122,15 @@ module TabHelper if current_controller?(:protected_branches) || current_controller?(:branches) || current_page?(project_repository_path(@project)) - 'active' + "active" end end def profile_tab_class - if controller.controller_path.start_with?('profiles') - return 'active' + if controller.controller_path.start_with?("profiles") + return "active" end - 'active' if current_controller?('oauth/applications') + "active" if current_controller?("oauth/applications") end end diff --git a/app/helpers/tags_helper.rb b/app/helpers/tags_helper.rb index de0b92b6fd7..e065f152a7f 100644 --- a/app/helpers/tags_helper.rb +++ b/app/helpers/tags_helper.rb @@ -8,7 +8,7 @@ module TagsHelper def filter_tags_path(options = {}) exist_opts = { search: params[:search], - sort: params[:sort] + sort: params[:sort], } options = exist_opts.merge(options) diff --git a/app/helpers/todos_helper.rb b/app/helpers/todos_helper.rb index 6bd78336ed3..39178b77ac6 100644 --- a/app/helpers/todos_helper.rb +++ b/app/helpers/todos_helper.rb @@ -6,7 +6,7 @@ module TodosHelper end def todos_count_format(count) - count > 99 ? '99+' : count.to_s + count > 99 ? "99+" : count.to_s end def todos_done_count @@ -15,12 +15,12 @@ module TodosHelper def todo_action_name(todo) case todo.action - when Todo::ASSIGNED then todo.self_added? ? 'assigned' : 'assigned you' + when Todo::ASSIGNED then todo.self_added? ? "assigned" : "assigned you" when Todo::MENTIONED then "mentioned #{todo_action_subject(todo)} on" - when Todo::BUILD_FAILED then 'The build failed for' - when Todo::MARKED then 'added a todo for' + when Todo::BUILD_FAILED then "The build failed for" + when Todo::MARKED then "added a todo for" when Todo::APPROVAL_REQUIRED then "set #{todo_action_subject(todo)} as an approver for" - when Todo::UNMERGEABLE then 'Could not merge' + when Todo::UNMERGEABLE then "Could not merge" when Todo::DIRECTLY_ADDRESSED then "directly addressed #{todo_action_subject(todo)} on" end end @@ -28,12 +28,12 @@ module TodosHelper def todo_target_link(todo) text = raw("#{todo.target_type.titleize.downcase} ") + if todo.for_commit? - content_tag(:span, todo.target_reference, class: 'commit-sha') + content_tag(:span, todo.target_reference, class: "commit-sha") else todo.target_reference end - link_to text, todo_target_path(todo), class: 'has-tooltip', title: todo.target.title + link_to text, todo_target_path(todo), class: "has-tooltip", title: todo.target.title end def todo_target_path(todo) @@ -43,7 +43,7 @@ module TodosHelper if todo.for_commit? project_commit_path(todo.project, - todo.target, anchor: anchor) + todo.target, anchor: anchor) else path = [todo.parent, todo.target] @@ -59,12 +59,12 @@ module TodosHelper type = case todo.target when MergeRequest - 'mr' + "mr" when Issue - 'issue' + "issue" end - content_tag(:span, nil, class: 'target-status') do + content_tag(:span, nil, class: "target-status") do content_tag(:span, nil, class: "status-box status-box-#{type}-#{todo.target.state.dasherize}") do todo.target.state.capitalize end @@ -73,11 +73,11 @@ module TodosHelper def todos_filter_params { - state: params[:state], + state: params[:state], project_id: params[:project_id], - author_id: params[:author_id], - type: params[:type], - action_id: params[:action_id] + author_id: params[:author_id], + type: params[:type], + action_id: params[:action_id], } end @@ -101,30 +101,30 @@ module TodosHelper def todo_actions_options [ - { id: '', text: 'Any Action' }, - { id: Todo::ASSIGNED, text: 'Assigned' }, - { id: Todo::MENTIONED, text: 'Mentioned' }, - { id: Todo::MARKED, text: 'Added' }, - { id: Todo::BUILD_FAILED, text: 'Pipelines' }, - { id: Todo::DIRECTLY_ADDRESSED, text: 'Directly addressed' } + {id: "", text: "Any Action"}, + {id: Todo::ASSIGNED, text: "Assigned"}, + {id: Todo::MENTIONED, text: "Mentioned"}, + {id: Todo::MARKED, text: "Added"}, + {id: Todo::BUILD_FAILED, text: "Pipelines"}, + {id: Todo::DIRECTLY_ADDRESSED, text: "Directly addressed"}, ] end def todo_projects_options projects = current_user.authorized_projects.sorted_by_activity.non_archived.with_route - projects = projects.map do |project| - { id: project.id, text: project.full_name } - end + projects = projects.map { |project| + {id: project.id, text: project.full_name} + } - projects.unshift({ id: '', text: 'Any Project' }).to_json + projects.unshift({id: "", text: "Any Project"}).to_json end def todo_types_options [ - { id: '', text: 'Any Type' }, - { id: 'Issue', text: 'Issue' }, - { id: 'MergeRequest', text: 'Merge Request' } + {id: "", text: "Any Type"}, + {id: "Issue", text: "Issue"}, + {id: "MergeRequest", text: "Merge Request"}, ] end @@ -134,7 +134,7 @@ module TodosHelper end def todo_types_dropdown_label(selected_type, default_type) - selected_type = todo_types_options.find { |type| type[:id] == selected_type && type[:id] != '' } + selected_type = todo_types_options.find { |type| type[:id] == selected_type && type[:id] != "" } selected_type ? selected_type[:text] : default_type end @@ -145,16 +145,16 @@ module TodosHelper is_overdue = todo.target.overdue? css_class = if is_due_today - 'text-warning' + "text-warning" elsif is_overdue - 'text-danger' + "text-danger" else - '' + "" end - content = content_tag(:span, class: css_class) do + content = content_tag(:span, class: css_class) { "Due #{is_due_today ? "today" : todo.target.due_date.to_s(:medium)}" - end + } "· #{content}".html_safe end @@ -162,18 +162,18 @@ module TodosHelper private def todo_action_subject(todo) - todo.self_added? ? 'yourself' : 'you' + todo.self_added? ? "yourself" : "you" end def show_todo_state?(todo) - (todo.target.is_a?(MergeRequest) || todo.target.is_a?(Issue)) && %w(closed merged).include?(todo.target.state) + (todo.target.is_a?(MergeRequest) || todo.target.is_a?(Issue)) && %w[closed merged].include?(todo.target.state) end def todo_group_options - groups = current_user.authorized_groups.map do |group| - { id: group.id, text: group.full_name } - end + groups = current_user.authorized_groups.map { |group| + {id: group.id, text: group.full_name} + } - groups.unshift({ id: '', text: 'Any Group' }).to_json + groups.unshift({id: "", text: "Any Group"}).to_json end end diff --git a/app/helpers/tree_helper.rb b/app/helpers/tree_helper.rb index e2879bfdcf1..8eed6664e38 100644 --- a/app/helpers/tree_helper.rb +++ b/app/helpers/tree_helper.rb @@ -15,12 +15,12 @@ module TreeHelper items = (folders + submodules).sort_by(&:name) + files if items.size > FILE_LIMIT - tree << render(partial: 'projects/tree/truncated_notice_tree_row', - locals: { limit: FILE_LIMIT, total: items.size }) + tree << render(partial: "projects/tree/truncated_notice_tree_row", + locals: {limit: FILE_LIMIT, total: items.size}) items = items.take(FILE_LIMIT) end - tree << render(partial: 'projects/tree/tree_row', collection: items) if items.present? + tree << render(partial: "projects/tree/tree_row", collection: items) if items.present? tree.join.html_safe end # rubocop: enable CodeReuse/ActiveRecord @@ -31,20 +31,20 @@ module TreeHelper # mode - File unix mode # name - File name def tree_icon(type, mode, name) - icon([file_type_icon_class(type, mode, name), 'fw']) + icon([file_type_icon_class(type, mode, name), "fw"]) end # Using Rails `*_path` methods can be slow, especially when generating # many paths, as with a repository tree that has thousands of items. def fast_project_blob_path(project, blob_path) ActionDispatch::Journey::Router::Utils.escape_path( - File.join(relative_url_root, project.path_with_namespace, 'blob', blob_path) + File.join(relative_url_root, project.path_with_namespace, "blob", blob_path) ) end def fast_project_tree_path(project, tree_path) ActionDispatch::Journey::Router::Utils.escape_path( - File.join(relative_url_root, project.path_with_namespace, 'tree', tree_path) + File.join(relative_url_root, project.path_with_namespace, "tree", tree_path) ) end @@ -73,14 +73,14 @@ module TreeHelper ref else project = tree_edit_project(project) - project.repository.next_branch('patch') + project.repository.next_branch("patch") end end def tree_edit_project(project = @project) if can?(current_user, :push_code, project) project - elsif current_user && current_user.already_forked?(project) + elsif current_user&.already_forked?(project) current_user.fork_of(project) end end @@ -107,7 +107,7 @@ module TreeHelper branch_name = ERB::Util.html_escape(selected_branch) message = _("Your changes can be committed to %{branch_name} because a merge "\ - "request is open.") % { branch_name: "<strong>#{branch_name}</strong>" } + "request is open.") % {branch_name: "<strong>#{branch_name}</strong>"} message.html_safe end @@ -115,9 +115,9 @@ module TreeHelper def path_breadcrumbs(max_links = 6) if @path.present? part_path = "" - parts = @path.split('/') + parts = @path.split("/") - yield('..', File.join(*parts.first(parts.count - 2))) if parts.count > max_links + yield("..", File.join(*parts.first(parts.count - 2))) if parts.count > max_links parts.each do |part| part_path = File.join(part_path, part) unless part_path.empty? @@ -138,7 +138,7 @@ module TreeHelper # returns the relative path of the first subdir that doesn't have only one directory descendant # rubocop: disable CodeReuse/ActiveRecord def flatten_tree(root_path, tree) - return tree.flat_path.sub(%r{\A#{Regexp.escape(root_path)}/}, '') if tree.flat_path.present? + return tree.flat_path.sub(%r{\A#{Regexp.escape(root_path)}/}, "") if tree.flat_path.present? subtree = Gitlab::Git::Tree.where(@repository, @commit.id, tree.path) if subtree.count == 1 && subtree.first.dir? @@ -154,6 +154,6 @@ module TreeHelper end def relative_url_root - Gitlab.config.gitlab.relative_url_root.presence || '/' + Gitlab.config.gitlab.relative_url_root.presence || "/" end end diff --git a/app/helpers/user_callouts_helper.rb b/app/helpers/user_callouts_helper.rb index 1ad7bb81784..667ad4ba825 100644 --- a/app/helpers/user_callouts_helper.rb +++ b/app/helpers/user_callouts_helper.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true module UserCalloutsHelper - GKE_CLUSTER_INTEGRATION = 'gke_cluster_integration'.freeze - GCP_SIGNUP_OFFER = 'gcp_signup_offer'.freeze + GKE_CLUSTER_INTEGRATION = "gke_cluster_integration" + GCP_SIGNUP_OFFER = "gcp_signup_offer" def show_gke_cluster_integration_callout?(project) can?(current_user, :create_cluster, project) && @@ -14,7 +14,7 @@ module UserCalloutsHelper end def render_flash_user_callout(flash_type, message, feature_name) - render 'shared/flash_user_callout', flash_type: flash_type, message: message, feature_name: feature_name + render "shared/flash_user_callout", flash_type: flash_type, message: message, feature_name: feature_name end private diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 73ca17c6605..79ecc45bb2e 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -3,17 +3,17 @@ module UsersHelper def user_link(user) link_to(user.name, user_path(user), - title: user.email, - class: 'has-tooltip commit-committer-link') + title: user.email, + class: "has-tooltip commit-committer-link") end def user_email_help_text(user) - return 'We also use email for avatar detection if no avatar is uploaded' unless user.unconfirmed_email.present? + return "We also use email for avatar detection if no avatar is uploaded" unless user.unconfirmed_email.present? - confirmation_link = link_to 'Resend confirmation e-mail', user_confirmation_path(user: { email: @user.unconfirmed_email }), method: :post + confirmation_link = link_to "Resend confirmation e-mail", user_confirmation_path(user: {email: @user.unconfirmed_email}), method: :post - h('Please click the link in the confirmation email before continuing. It was sent to ') + - content_tag(:strong) { user.unconfirmed_email } + h('.') + + h("Please click the link in the confirmation email before continuing. It was sent to ") + + content_tag(:strong) { user.unconfirmed_email } + h(".") + content_tag(:p) { confirmation_link } end @@ -29,11 +29,11 @@ module UsersHelper settings = Gitlab::CurrentSettings.current_application_settings pattern, options = if settings.user_default_internal_regex_enabled? - regex = settings.user_default_internal_regex_instance - JsRegex.new(regex).to_h.slice(:source, :options).values - end + regex = settings.user_default_internal_regex_instance + JsRegex.new(regex).to_h.slice(:source, :options).values + end - { user_internal_regex_pattern: pattern, user_internal_regex_options: options } + {user_internal_regex_pattern: pattern, user_internal_regex_options: options} end def current_user_menu_items @@ -57,15 +57,15 @@ module UsersHelper unless user.association(:status).loaded? exception = RuntimeError.new("Status was not preloaded") - Gitlab::Sentry.track_exception(exception, extra: { user: user.inspect }) + Gitlab::Sentry.track_exception(exception, extra: {user: user.inspect}) end return unless user.status content_tag :span, - class: 'user-status-emoji has-tooltip', - title: user.status.message_html, - data: { html: true, placement: 'top' } do + class: "user-status-emoji has-tooltip", + title: user.status.message_html, + data: {html: true, placement: "top"} do emoji_icon user.status.emoji end end @@ -76,10 +76,10 @@ module UsersHelper def user_badges_in_admin_section(user) [].tap do |badges| - badges << { text: s_('AdminUsers|Blocked'), variant: 'danger' } if user.blocked? - badges << { text: s_('AdminUsers|Admin'), variant: 'success' } if user.admin? - badges << { text: s_('AdminUsers|External'), variant: 'secondary' } if user.external? - badges << { text: s_("AdminUsers|It's you!"), variant: nil } if current_user == user + badges << {text: s_("AdminUsers|Blocked"), variant: "danger"} if user.blocked? + badges << {text: s_("AdminUsers|Admin"), variant: "success"} if user.admin? + badges << {text: s_("AdminUsers|External"), variant: "secondary"} if user.external? + badges << {text: s_("AdminUsers|It's you!"), variant: nil} if current_user == user end end diff --git a/app/helpers/version_check_helper.rb b/app/helpers/version_check_helper.rb index 5e519cf5c19..a947dfa2c7d 100644 --- a/app/helpers/version_check_helper.rb +++ b/app/helpers/version_check_helper.rb @@ -6,19 +6,19 @@ module VersionCheckHelper return unless Gitlab::CurrentSettings.version_check_enabled return if User.single_user&.requires_usage_stats_consent? - image_tag VersionCheck.url, class: 'js-version-status-badge' + image_tag VersionCheck.url, class: "js-version-status-badge" end def link_to_version if Gitlab.pre_release? - commit_link = link_to(Gitlab.revision, Gitlab::COM_URL + namespace_project_commits_path('gitlab-org', source_code_project, Gitlab.revision)) - [Gitlab::VERSION, content_tag(:small, commit_link)].join(' ').html_safe + commit_link = link_to(Gitlab.revision, Gitlab::COM_URL + namespace_project_commits_path("gitlab-org", source_code_project, Gitlab.revision)) + [Gitlab::VERSION, content_tag(:small, commit_link)].join(" ").html_safe else - link_to Gitlab::VERSION, Gitlab::COM_URL + namespace_project_tag_path('gitlab-org', source_code_project, "v#{Gitlab::VERSION}") + link_to Gitlab::VERSION, Gitlab::COM_URL + namespace_project_tag_path("gitlab-org", source_code_project, "v#{Gitlab::VERSION}") end end def source_code_project - 'gitlab-ce' + "gitlab-ce" end end diff --git a/app/helpers/visibility_level_helper.rb b/app/helpers/visibility_level_helper.rb index 712f0f808dd..0a00beca8d5 100644 --- a/app/helpers/visibility_level_helper.rb +++ b/app/helpers/visibility_level_helper.rb @@ -4,11 +4,11 @@ module VisibilityLevelHelper def visibility_level_color(level) case level when Gitlab::VisibilityLevel::PRIVATE - 'vs-private' + "vs-private" when Gitlab::VisibilityLevel::INTERNAL - 'vs-internal' + "vs-internal" when Gitlab::VisibilityLevel::PUBLIC - 'vs-public' + "vs-public" end end @@ -97,7 +97,7 @@ module VisibilityLevelHelper instructions << errors[:instruction] end - reasons = reasons.any? ? ' because ' + reasons.to_sentence : '' + reasons = reasons.any? ? " because " + reasons.to_sentence : "" "This project cannot be #{level_name}#{reasons}.#{instructions.join}".html_safe end @@ -123,7 +123,7 @@ module VisibilityLevelHelper instructions << errors[:instruction] end - reasons = reasons.any? ? ' because ' + reasons.to_sentence : '' + reasons = reasons.any? ? " because " + reasons.to_sentence : "" "This group cannot be #{level_name}#{reasons}.#{instructions.join}".html_safe end @@ -155,9 +155,9 @@ module VisibilityLevelHelper Gitlab::CurrentSettings.restricted_visibility_levels || [] end - delegate :default_project_visibility, - :default_group_visibility, - to: :'Gitlab::CurrentSettings.current_application_settings' + delegate :default_project_visibility, + :default_group_visibility, + to: :'Gitlab::CurrentSettings.current_application_settings' def disallowed_visibility_level?(form_model, level) return false unless form_model.respond_to?(:visibility_level_allowed?) @@ -169,9 +169,9 @@ module VisibilityLevelHelper def visibility_level_errors_for_group(group, level_name) group_name = link_to group.name, group_path(group) - change_visiblity = link_to 'change the visibility', edit_group_path(group) + change_visiblity = link_to "change the visibility", edit_group_path(group) - { reason: "the visibility of #{group_name} is #{group.visibility}", - instruction: " To make this group #{level_name}, you must first #{change_visiblity} of the parent group." } + {reason: "the visibility of #{group_name} is #{group.visibility}", + instruction: " To make this group #{level_name}, you must first #{change_visiblity} of the parent group.",} end end diff --git a/app/helpers/webpack_helper.rb b/app/helpers/webpack_helper.rb index 345ddcf023a..7f6a3f775cd 100644 --- a/app/helpers/webpack_helper.rb +++ b/app/helpers/webpack_helper.rb @@ -9,17 +9,17 @@ module WebpackHelper chunks = [] action = case controller.action_name - when 'create' then 'new' - when 'update' then 'edit' + when "create" then "new" + when "update" then "edit" else controller.action_name - end + end - route = [*controller.controller_path.split('/'), action].compact + route = [*controller.controller_path.split("/"), action].compact until chunks.any? || route.empty? - entrypoint = "pages.#{route.join('.')}" + entrypoint = "pages.#{route.join(".")}" begin - chunks = webpack_entrypoint_paths(entrypoint, extension: 'js') + chunks = webpack_entrypoint_paths(entrypoint, extension: "js") rescue Gitlab::Webpack::Manifest::AssetMissingError # no bundle exists for this path end @@ -27,7 +27,7 @@ module WebpackHelper end if chunks.empty? - chunks = webpack_entrypoint_paths("default", extension: 'js') + chunks = webpack_entrypoint_paths("default", extension: "js") end javascript_include_tag(*chunks) @@ -60,16 +60,16 @@ module WebpackHelper if Rails.env.test? && Rails.configuration.webpack.dev_server.enabled host = Rails.configuration.webpack.dev_server.host port = Rails.configuration.webpack.dev_server.port - protocol = Rails.configuration.webpack.dev_server.https ? 'https' : 'http' + protocol = Rails.configuration.webpack.dev_server.https ? "https" : "http" "#{protocol}://#{host}:#{port}" else - ActionController::Base.asset_host.try(:chomp, '/') + ActionController::Base.asset_host.try(:chomp, "/") end end def webpack_public_path relative_path = Rails.application.config.relative_url_root webpack_path = Rails.application.config.webpack.public_path - File.join(webpack_public_host.to_s, relative_path.to_s, webpack_path.to_s, '') + File.join(webpack_public_host.to_s, relative_path.to_s, webpack_path.to_s, "") end end diff --git a/app/helpers/wiki_helper.rb b/app/helpers/wiki_helper.rb index 647f34e57ed..9f346f1c818 100644 --- a/app/helpers/wiki_helper.rb +++ b/app/helpers/wiki_helper.rb @@ -10,13 +10,13 @@ module WikiHelper # Returns a String composed of the capitalized name of each directory and the # capitalized name of the page itself. def breadcrumb(page_slug) - page_slug.split('/') + page_slug.split("/") .map { |dir_or_page| WikiPage.unhyphenize(dir_or_page).capitalize } - .join(' / ') + .join(" / ") end def wiki_breadcrumb_dropdown_links(page_slug) - page_slug_split = page_slug.split('/') + page_slug_split = page_slug.split("/") page_slug_split.pop(1) current_slug = "" page_slug_split @@ -29,12 +29,12 @@ module WikiHelper def wiki_page_errors(error) return unless error - content_tag(:div, class: 'alert alert-danger') do + content_tag(:div, class: "alert alert-danger") do case error when WikiPage::PageChangedError page_link = link_to s_("WikiPageConflictMessage|the page"), project_wiki_path(@project, @page), target: "_blank" concat( - (s_("WikiPageConflictMessage|Someone edited the page the same time you did. Please check out %{page_link} and make sure your changes will not unintentionally remove theirs.") % { page_link: page_link }).html_safe + (s_("WikiPageConflictMessage|Someone edited the page the same time you did. Please check out %{page_link} and make sure your changes will not unintentionally remove theirs.") % {page_link: page_link}).html_safe ) when WikiPage::PageRenameError s_("WikiEdit|There is already a page with the same title in that path.") diff --git a/app/helpers/workhorse_helper.rb b/app/helpers/workhorse_helper.rb index bb5b1555dc4..6259946168f 100644 --- a/app/helpers/workhorse_helper.rb +++ b/app/helpers/workhorse_helper.rb @@ -7,7 +7,7 @@ module WorkhorseHelper def send_git_blob(repository, blob, inline: true) headers.store(*Gitlab::Workhorse.send_git_blob(repository, blob)) - headers['Content-Disposition'] = inline ? 'inline' : 'attachment' + headers["Content-Disposition"] = inline ? "inline" : "attachment" # If enabled, this will override the values set above workhorse_set_content_type! @@ -18,14 +18,14 @@ module WorkhorseHelper # Send a Git diff through Workhorse def send_git_diff(repository, diff_refs) headers.store(*Gitlab::Workhorse.send_git_diff(repository, diff_refs)) - headers['Content-Disposition'] = 'inline' + headers["Content-Disposition"] = "inline" head :ok end # Send a Git patch through Workhorse def send_git_patch(repository, diff_refs) headers.store(*Gitlab::Workhorse.send_git_patch(repository, diff_refs)) - headers['Content-Disposition'] = 'inline' + headers["Content-Disposition"] = "inline" head :ok end @@ -42,7 +42,7 @@ module WorkhorseHelper end def set_workhorse_internal_api_content_type - headers['Content-Type'] = Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE + headers["Content-Type"] = Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE end def workhorse_set_content_type! |