From 71670596e0c94af9c7ba6994cef74e65eebebc7d Mon Sep 17 00:00:00 2001 From: Siddharth Asthana Date: Tue, 20 Sep 2022 21:50:27 +0530 Subject: [PATCH 1/2] RuboCop: Enable previously disabled Style/StringLiteralsInInterpolation Changelog: other --- .../style/string_literals_in_interpolation.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.rubocop_todo/style/string_literals_in_interpolation.yml b/.rubocop_todo/style/string_literals_in_interpolation.yml index cded81afa7f223..fc90e1ce6a6a66 100644 --- a/.rubocop_todo/style/string_literals_in_interpolation.yml +++ b/.rubocop_todo/style/string_literals_in_interpolation.yml @@ -1,9 +1,7 @@ --- # Cop supports --auto-correct. Style/StringLiteralsInInterpolation: - # Offense count: 119 - # Temporarily disabled due to too many offenses - Enabled: false + Details: grace period Exclude: - 'app/graphql/mutations/base_mutation.rb' - 'app/helpers/colors_helper.rb' @@ -23,11 +21,16 @@ Style/StringLiteralsInInterpolation: - 'ee/app/helpers/ee/merge_requests_helper.rb' - 'ee/app/models/license.rb' - 'ee/app/services/epics/tree_reorder_service.rb' + - 'ee/lib/ee/api/helpers/issues_helpers.rb' - 'ee/lib/gitlab/elastic/helper.rb' + - 'ee/lib/tasks/gitlab/elastic.rake' - 'ee/spec/features/admin/admin_settings_spec.rb' + - 'ee/spec/features/subscriptions/expiring_subscription_message_spec.rb' + - 'ee/spec/lib/gitlab/expiring_subscription_message_spec.rb' - 'lib/api/helpers/snippets_helpers.rb' - 'lib/api/validations/validators/check_assignees_count.rb' - 'lib/banzai/filter/references/abstract_reference_filter.rb' + - 'lib/banzai/filter/syntax_highlight_filter.rb' - 'lib/generators/gitlab/usage_metric_definition_generator.rb' - 'lib/gitlab/background_migration/fix_projects_without_prometheus_service.rb' - 'lib/gitlab/ci/config/entry/job.rb' @@ -36,6 +39,7 @@ Style/StringLiteralsInInterpolation: - 'lib/gitlab/database/query_analyzers/prevent_cross_database_modification.rb' - 'lib/gitlab/doctor/secrets.rb' - 'lib/gitlab/endpoint_attributes/config.rb' + - 'lib/gitlab/gitaly_client/ref_service.rb' - 'lib/gitlab/graphql/queries.rb' - 'lib/gitlab/quick_actions/extractor.rb' - 'lib/gitlab/sanitizers/exif.rb' @@ -43,13 +47,11 @@ Style/StringLiteralsInInterpolation: - 'lib/gitlab/tracking/destinations/snowplow.rb' - 'lib/tasks/gitlab/info.rake' - 'lib/tasks/gitlab/sidekiq.rake' - - 'lib/tasks/gitlab/tw/codeowners.rake' - 'qa/qa/ee/page/component/secure_report.rb' - 'qa/qa/ee/page/group/secure/show.rb' - 'qa/qa/resource/events/base.rb' - 'qa/qa/service/cluster_provider/base.rb' - 'qa/qa/service/cluster_provider/gcloud.rb' - - 'qa/qa/service/docker_run/gitlab_runner.rb' - 'qa/qa/specs/helpers/context_selector.rb' - 'qa/qa/tools/generate_perf_testdata.rb' - 'rubocop/cop/migration/prevent_index_creation.rb' @@ -59,9 +61,12 @@ Style/StringLiteralsInInterpolation: - 'spec/finders/serverless_domain_finder_spec.rb' - 'spec/lib/banzai/filter/references/commit_reference_filter_spec.rb' - 'spec/lib/banzai/filter/references/issue_reference_filter_spec.rb' + - 'spec/lib/gitlab/background_migration/batched_migration_job_spec.rb' - 'spec/lib/gitlab/ci/parsers/security/validators/schema_validator_spec.rb' - 'spec/lib/gitlab/database/partitioning_migration_helpers/table_management_helpers_spec.rb' + - 'spec/lib/gitlab/gitaly_client/ref_service_spec.rb' - 'spec/lib/object_storage/direct_upload_spec.rb' - 'spec/models/serverless/domain_spec.rb' - 'spec/requests/api/keys_spec.rb' - 'spec/support/database/prevent_cross_joins.rb' + - 'spec/views/notify/import_issues_csv_email.html.haml_spec.rb' -- GitLab From cf82682e8d210267c0bd69172c35b06c78574ef6 Mon Sep 17 00:00:00 2001 From: Siddharth Asthana Date: Wed, 21 Sep 2022 10:27:42 +0530 Subject: [PATCH 2/2] Fix RuboCop offenses for Style/StringLiteralsInInterpolation in HAML Changelog: other EE: true --- app/views/devise/shared/_tabs_ldap.html.haml | 2 +- app/views/layouts/header/_new_dropdown.html.haml | 2 +- app/views/layouts/notify.html.haml | 2 +- app/views/notify/repository_push_email.text.haml | 2 +- app/views/projects/buttons/_download_links.html.haml | 2 +- app/views/projects/commit/_signature.html.haml | 2 +- app/views/projects/commit/_signature_badge.html.haml | 2 +- app/views/projects/commits/_commit.html.haml | 2 +- ee/app/views/notify/mirror_was_disabled_email.html.haml | 2 +- ee/app/views/notify/mirror_was_hard_failed_email.html.haml | 2 +- ee/app/views/notify/project_mirror_user_changed_email.html.haml | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/views/devise/shared/_tabs_ldap.html.haml b/app/views/devise/shared/_tabs_ldap.html.haml index e81a5928983b98..76c4cf41a2de3d 100644 --- a/app/views/devise/shared/_tabs_ldap.html.haml +++ b/app/views/devise/shared/_tabs_ldap.html.haml @@ -1,7 +1,7 @@ - show_password_form = local_assigns.fetch(:show_password_form, password_authentication_enabled_for_web?) - render_signup_link = local_assigns.fetch(:render_signup_link, true) -%ul.nav-links.new-session-tabs.nav-tabs.nav{ class: "#{"custom-provider-tabs" if any_form_based_providers_enabled?} #{"nav-links-unboxed" if Feature.enabled?(:restyle_login_page, @project)}" } +%ul.nav-links.new-session-tabs.nav-tabs.nav{ class: "#{'custom-provider-tabs' if any_form_based_providers_enabled?} #{'nav-links-unboxed' if Feature.enabled?(:restyle_login_page, @project)}" } - if crowd_enabled? %li.nav-item = link_to _("Crowd"), "#crowd", class: "nav-link #{active_when(form_based_auth_provider_has_active_class?(:crowd))}", 'data-toggle' => 'tab', role: 'tab' diff --git a/app/views/layouts/header/_new_dropdown.html.haml b/app/views/layouts/header/_new_dropdown.html.haml index e5b03acbe3b30f..9801b0cc0552df 100644 --- a/app/views/layouts/header/_new_dropdown.html.haml +++ b/app/views/layouts/header/_new_dropdown.html.haml @@ -24,4 +24,4 @@ = menu_item.fetch(:title) - if menu_item.fetch(:emoji) -# We need to insert a space between the title and emoji - = " #{emoji_icon(menu_item.fetch(:emoji), 'aria-hidden': true, class: "gl-font-base gl-vertical-align-baseline")}".html_safe + = " #{emoji_icon(menu_item.fetch(:emoji), 'aria-hidden': true, class: 'gl-font-base gl-vertical-align-baseline')}".html_safe diff --git a/app/views/layouts/notify.html.haml b/app/views/layouts/notify.html.haml index d05b6951fbf0eb..c557dc365341df 100644 --- a/app/views/layouts/notify.html.haml +++ b/app/views/layouts/notify.html.haml @@ -24,7 +24,7 @@ - if @reply_by_email = _('Reply to this email directly or %{view_it_on_gitlab}.').html_safe % { view_it_on_gitlab: link_to(_("view it on GitLab"), @target_url) } - else - #{link_to _("View it on GitLab"), @target_url}. + #{link_to _('View it on GitLab'), @target_url}. %br = notification_reason_text(reason: @reason, show_manage_notifications_link: !@labels_url, show_help_link: true, manage_label_subscriptions_url: @labels_url, unsubscribe_url: @unsubscribe_url, format: :html) diff --git a/app/views/notify/repository_push_email.text.haml b/app/views/notify/repository_push_email.text.haml index 895d8807e47e40..2ba0a2cf4abb4d 100644 --- a/app/views/notify/repository_push_email.text.haml +++ b/app/views/notify/repository_push_email.text.haml @@ -13,7 +13,7 @@ \- - - - - \ \ - #{pluralize @message.diffs_count, "changed file"}: + #{pluralize @message.diffs_count, 'changed file'}: \ - @message.diffs.each do |diff_file| - if diff_file.deleted_file? diff --git a/app/views/projects/buttons/_download_links.html.haml b/app/views/projects/buttons/_download_links.html.haml index f6084cfcde8661..d36aed44e18a05 100644 --- a/app/views/projects/buttons/_download_links.html.haml +++ b/app/views/projects/buttons/_download_links.html.haml @@ -1,4 +1,4 @@ .btn-group.ml-0.w-100 - Gitlab::Workhorse::ARCHIVE_FORMATS.each_with_index do |fmt, index| - archive_path = project_archive_path(project, id: tree_join(ref, archive_prefix), path: path, format: fmt) - = link_to fmt, external_storage_url_or_path(archive_path), rel: 'nofollow', download: '', class: "gl-button btn btn-sm #{index == 0 ? "btn-confirm" : "btn-default"}" + = link_to fmt, external_storage_url_or_path(archive_path), rel: 'nofollow', download: '', class: "gl-button btn btn-sm #{index == 0 ? 'btn-confirm' : 'btn-default'}" diff --git a/app/views/projects/commit/_signature.html.haml b/app/views/projects/commit/_signature.html.haml index fb31ac44118d2f..978d83bf2b4a9d 100644 --- a/app/views/projects/commit/_signature.html.haml +++ b/app/views/projects/commit/_signature.html.haml @@ -1,3 +1,3 @@ - if signature - - uri = "projects/commit/#{"x509/" if x509_signature?(signature)}" + - uri = "projects/commit/#{'x509/' if x509_signature?(signature)}" = render partial: "#{uri}#{signature.verification_status}_signature_badge", locals: { signature: signature } diff --git a/app/views/projects/commit/_signature_badge.html.haml b/app/views/projects/commit/_signature_badge.html.haml index 7c896cd71efdc4..fb30bfc2953975 100644 --- a/app/views/projects/commit/_signature_badge.html.haml +++ b/app/views/projects/commit/_signature_badge.html.haml @@ -17,7 +17,7 @@ - content = capture do - if show_user .clearfix - - uri_signature_badge_user = "projects/commit/#{"x509/" if x509_signature?(signature)}signature_badge_user" + - uri_signature_badge_user = "projects/commit/#{'x509/' if x509_signature?(signature)}signature_badge_user" = render partial: "#{uri_signature_badge_user}", locals: { signature: signature } - if x509_signature?(signature) diff --git a/app/views/projects/commits/_commit.html.haml b/app/views/projects/commits/_commit.html.haml index 6f44c13060357d..511d017f0237ac 100644 --- a/app/views/projects/commits/_commit.html.haml +++ b/app/views/projects/commits/_commit.html.haml @@ -29,7 +29,7 @@ - if view_details && merge_request = link_to commit.title, project_commit_path(project, commit.id, merge_request_iid: merge_request.iid), class: ["commit-row-message item-title js-onboarding-commit-item", ("font-italic" if commit.message.empty?)] - else - = link_to_markdown_field(commit, :title, link, class: "commit-row-message item-title js-onboarding-commit-item #{"font-italic" if commit.message.empty?}", data: link_data_attrs) + = link_to_markdown_field(commit, :title, link, class: "commit-row-message item-title js-onboarding-commit-item #{'font-italic' if commit.message.empty?}", data: link_data_attrs) %span.commit-row-message.d-inline.d-sm-none · = commit.short_id diff --git a/ee/app/views/notify/mirror_was_disabled_email.html.haml b/ee/app/views/notify/mirror_was_disabled_email.html.haml index 05f1abb09a8e9c..55daf5becbe6d6 100644 --- a/ee/app/views/notify/mirror_was_disabled_email.html.haml +++ b/ee/app/views/notify/mirror_was_disabled_email.html.haml @@ -2,4 +2,4 @@ Repository mirroring on #{@project.full_path} was disabled because the mirror user #{sanitize_name(@deleted_user_name)} was deleted. %p - To re-enable mirroring, update your #{link_to("repository mirroring settings", project_settings_repository_url(@project))}. + To re-enable mirroring, update your #{link_to('repository mirroring settings', project_settings_repository_url(@project))}. diff --git a/ee/app/views/notify/mirror_was_hard_failed_email.html.haml b/ee/app/views/notify/mirror_was_hard_failed_email.html.haml index 1023463d6fb26a..903fbde713e1c3 100644 --- a/ee/app/views/notify/mirror_was_hard_failed_email.html.haml +++ b/ee/app/views/notify/mirror_was_hard_failed_email.html.haml @@ -5,4 +5,4 @@ = @project.import_state.last_error %p - To resume mirroring update your #{link_to("repository mirroring settings", project_settings_repository_url(@project))}. + To resume mirroring update your #{link_to('repository mirroring settings', project_settings_repository_url(@project))}. diff --git a/ee/app/views/notify/project_mirror_user_changed_email.html.haml b/ee/app/views/notify/project_mirror_user_changed_email.html.haml index 8d99013de2c8b6..ca18342cadc06d 100644 --- a/ee/app/views/notify/project_mirror_user_changed_email.html.haml +++ b/ee/app/views/notify/project_mirror_user_changed_email.html.haml @@ -2,4 +2,4 @@ The mirror user for #{@project.full_path} has been changed from #{sanitize_name(@deleted_user_name)} to yourself because their account was deleted. %p - You can change this setting from the #{link_to("repository settings page", project_settings_repository_url(@project))}. + You can change this setting from the #{link_to('repository settings page', project_settings_repository_url(@project))}. -- GitLab