diff options
author | Rémy Coutable <remy@rymai.me> | 2016-09-28 09:40:17 +0200 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-09-28 09:40:17 +0200 |
commit | 1171ac63c258a1e69ab3387a7664f02e67555e51 (patch) | |
tree | c3f6c3fdf96f9a0eb4fe15783b525ad5987d236d | |
parent | 9a28756c07f0f73bd134385bf11b44527ee81631 (diff) | |
download | gitlab-ce-enable-style-percentLiteral_delimiters-cop.tar.gz |
Enable the Style/PercentLiteralDelimiters cop and autocorrect offensesenable-style-percentLiteral_delimiters-cop
Signed-off-by: Rémy Coutable <remy@rymai.me>
148 files changed, 309 insertions, 302 deletions
diff --git a/.rubocop.yml b/.rubocop.yml index 5bd31ccf329..f4377757696 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -338,6 +338,19 @@ Style/OpMethod: Style/ParenthesesAroundCondition: Enabled: true +Style/PercentLiteralDelimiters: + Enabled: true + PreferredDelimiters: + '%': '()' + '%i': '[]' + '%q': '()' + '%Q': '()' + '%r': '{}' + '%s': '()' + '%w': '[]' + '%W': '[]' + '%x': '()' + # Checks for parentheses that seem not to serve any purpose. Style/RedundantParentheses: Enabled: true diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 87520c67dd5..bbd34c946dc 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -259,12 +259,6 @@ Style/NumericPredicate: Style/ParallelAssignment: Enabled: false -# Offense count: 264 -# Cop supports --auto-correct. -# Configuration parameters: PreferredDelimiters. -Style/PercentLiteralDelimiters: - Enabled: false - # Offense count: 11 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. diff --git a/app/controllers/abuse_reports_controller.rb b/app/controllers/abuse_reports_controller.rb index 2eac0cabf7a..006373b3e2f 100644 --- a/app/controllers/abuse_reports_controller.rb +++ b/app/controllers/abuse_reports_controller.rb @@ -22,9 +22,9 @@ class AbuseReportsController < ApplicationController private def report_params - params.require(:abuse_report).permit(%i( + params.require(:abuse_report).permit(%i[ message user_id - )) + ]) end end diff --git a/app/controllers/admin/background_jobs_controller.rb b/app/controllers/admin/background_jobs_controller.rb index 338496013a0..35db4dc8b1e 100644 --- a/app/controllers/admin/background_jobs_controller.rb +++ b/app/controllers/admin/background_jobs_controller.rb @@ -1,6 +1,6 @@ class Admin::BackgroundJobsController < Admin::ApplicationController def show - ps_output, _ = Gitlab::Popen.popen(%W(ps -U #{Gitlab.config.gitlab.user} -o pid,pcpu,pmem,stat,start,command)) + ps_output, _ = Gitlab::Popen.popen(%W[ps -U #{Gitlab.config.gitlab.user} -o pid,pcpu,pmem,stat,start,command]) @sidekiq_processes = ps_output.split("\n").grep(/sidekiq/) end end diff --git a/app/controllers/admin/broadcast_messages_controller.rb b/app/controllers/admin/broadcast_messages_controller.rb index 82055006ac0..2b63703b02a 100644 --- a/app/controllers/admin/broadcast_messages_controller.rb +++ b/app/controllers/admin/broadcast_messages_controller.rb @@ -47,12 +47,12 @@ class Admin::BroadcastMessagesController < Admin::ApplicationController end def broadcast_message_params - params.require(:broadcast_message).permit(%i( + params.require(:broadcast_message).permit(%i[ color ends_at font message starts_at - )) + ]) end end diff --git a/app/controllers/profiles/passwords_controller.rb b/app/controllers/profiles/passwords_controller.rb index 6217ec5ecef..4d404cbcf29 100644 --- a/app/controllers/profiles/passwords_controller.rb +++ b/app/controllers/profiles/passwords_controller.rb @@ -37,7 +37,7 @@ class Profiles::PasswordsController < Profiles::ApplicationController def update password_attributes = user_params.select do |key, value| - %w(password password_confirmation).include?(key.to_s) + %w[password password_confirmation].include?(key.to_s) end password_attributes[:password_automatically_set] = false diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index d01e0dedf52..fddee5a9715 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -25,20 +25,20 @@ class SearchController < ApplicationController @search_results = if @project - unless %w(blobs notes issues merge_requests milestones wiki_blobs - commits).include?(@scope) + unless %w[blobs notes issues merge_requests milestones wiki_blobs + commits].include?(@scope) @scope = 'blobs' end Search::ProjectService.new(@project, current_user, params).execute elsif @show_snippets - unless %w(snippet_blobs snippet_titles).include?(@scope) + unless %w[snippet_blobs snippet_titles].include?(@scope) @scope = 'snippet_blobs' end Search::SnippetService.new(current_user, params).execute else - unless %w(projects issues merge_requests milestones).include?(@scope) + unless %w[projects issues merge_requests milestones].include?(@scope) @scope = 'projects' end Search::GlobalService.new(current_user, params).execute diff --git a/app/controllers/uploads_controller.rb b/app/controllers/uploads_controller.rb index 509f4f412ca..729517baca1 100644 --- a/app/controllers/uploads_controller.rb +++ b/app/controllers/uploads_controller.rb @@ -63,7 +63,7 @@ class UploadsController < ApplicationController end def upload_mount - upload_mounts = %w(avatar attachment file logo header_logo) + upload_mounts = %w[avatar attachment file logo header_logo] if upload_mounts.include?(params[:mounted_as]) params[:mounted_as] diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 1df430e6279..2d1b6daba03 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -126,7 +126,7 @@ module ApplicationHelper end def simple_sanitize(str) - sanitize(str, tags: %w(a span)) + sanitize(str, tags: %w[a span]) end def body_data_page diff --git a/app/helpers/auth_helper.rb b/app/helpers/auth_helper.rb index cd4d778e508..92af2e95d99 100644 --- a/app/helpers/auth_helper.rb +++ b/app/helpers/auth_helper.rb @@ -1,5 +1,5 @@ module AuthHelper - PROVIDERS_WITH_ICONS = %w(twitter github gitlab bitbucket google_oauth2 facebook azure_oauth2).freeze + PROVIDERS_WITH_ICONS = %w[twitter github gitlab bitbucket google_oauth2 facebook azure_oauth2].freeze FORM_BASED_PROVIDERS = [/\Aldap/, 'crowd'].freeze def ldap_enabled? diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index e13b7cdd707..4997d201311 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -5,7 +5,7 @@ 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_link(project = @project, ref = @ref, path = @path, options = {}) diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb index 33dcee49aee..923cfd6d611 100644 --- a/app/helpers/commits_helper.rb +++ b/app/helpers/commits_helper.rb @@ -192,7 +192,7 @@ module CommitsHelper text = if options[:avatar] - %Q{<span class="commit-#{options[:source]}-name">#{person_name}</span>} + %Q(<span class="commit-#{options[:source]}-name">#{person_name}</span>) else person_name end diff --git a/app/helpers/diff_helper.rb b/app/helpers/diff_helper.rb index 0725c3f4c56..ea306eb8d39 100644 --- a/app/helpers/diff_helper.rb +++ b/app/helpers/diff_helper.rb @@ -14,7 +14,7 @@ module DiffHelper def diff_view @diff_view ||= begin - diff_views = %w(inline parallel) + diff_views = %w[inline parallel] diff_view = cookies[:diff_view] diff_view = diff_views.first unless diff_views.include?(diff_view) diff_view.to_sym diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb index bfedcb1c42b..640985c453f 100644 --- a/app/helpers/events_helper.rb +++ b/app/helpers/events_helper.rb @@ -150,7 +150,7 @@ module EventsHelper def event_note(text, options = {}) text = first_line_in_markdown(text, 150, options) - sanitize(text, tags: %w(a img b pre code p span)) + sanitize(text, tags: %w[a img b pre code p span]) end def event_commit_title(message) diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index 8a7446b7cc7..805198ddbdd 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_helper.rb @@ -155,6 +155,6 @@ module SearchHelper # Sanitize html generated after parsing markdown from issue description or comment def search_md_sanitize(html) - sanitize(html, tags: %w(a p ol ul li pre code)) + sanitize(html, tags: %w[a p ol ul li pre code]) end end diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index 55d2e07de08..73a1f207387 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -72,7 +72,7 @@ class ApplicationSetting < ActiveRecord::Base inclusion: { in: ->(_object) { Gitlab.config.repositories.storages.keys } } validates :enabled_git_access_protocol, - inclusion: { in: %w(ssh http), allow_blank: true, allow_nil: true } + inclusion: { in: %w[ssh http], allow_blank: true, allow_nil: true } validates :domain_blacklist, presence: { message: 'Domain blacklist cannot be empty if Blacklist is enabled.' }, diff --git a/app/models/commit.rb b/app/models/commit.rb index e64fd1e0c1b..76eb02a928a 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -251,7 +251,7 @@ class Commit end def revert_message - %Q{Revert "#{title.strip}"\n\n#{revert_description}} + %Q(Revert "#{title.strip}"\n\n#{revert_description}) end def reverts_commit?(commit) diff --git a/app/models/cycle_analytics/summary.rb b/app/models/cycle_analytics/summary.rb index b46db449bf3..79a7cb20c0a 100644 --- a/app/models/cycle_analytics/summary.rb +++ b/app/models/cycle_analytics/summary.rb @@ -30,7 +30,7 @@ class CycleAnalytics repository = @project.repository.raw_repository sha = @project.repository.commit(ref).sha - cmd = %W(git --git-dir=#{repository.path} log) + cmd = %W[git --git-dir=#{repository.path} log] cmd << '--format=%H' cmd << "--after=#{@from.iso8601}" cmd << sha diff --git a/app/models/project.rb b/app/models/project.rb index 7265cb55594..639520a308c 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1219,7 +1219,7 @@ class Project < ActiveRecord::Base end def remove_exports - _, status = Gitlab::Popen.popen(%W(find #{export_path} -not -path #{export_path} -delete)) + _, status = Gitlab::Popen.popen(%W[find #{export_path} -not -path #{export_path} -delete]) status.zero? end diff --git a/app/models/project_feature.rb b/app/models/project_feature.rb index 8c9534c3565..c66e9c12bc5 100644 --- a/app/models/project_feature.rb +++ b/app/models/project_feature.rb @@ -18,7 +18,7 @@ class ProjectFeature < ActiveRecord::Base PRIVATE = 10 ENABLED = 20 - FEATURES = %i(issues merge_requests wiki snippets builds) + FEATURES = %i[issues merge_requests wiki snippets builds] belongs_to :project diff --git a/app/models/project_services/asana_service.rb b/app/models/project_services/asana_service.rb index 7c23b766763..f779108c890 100644 --- a/app/models/project_services/asana_service.rb +++ b/app/models/project_services/asana_service.rb @@ -45,7 +45,7 @@ http://app.asana.com/-/account_api' end def supported_events - %w(push) + %w[push] end def client diff --git a/app/models/project_services/assembla_service.rb b/app/models/project_services/assembla_service.rb index d839221d315..6bc1c94ce24 100644 --- a/app/models/project_services/assembla_service.rb +++ b/app/models/project_services/assembla_service.rb @@ -24,7 +24,7 @@ class AssemblaService < Service end def supported_events - %w(push) + %w[push] end def execute(data) diff --git a/app/models/project_services/bamboo_service.rb b/app/models/project_services/bamboo_service.rb index b5c76e4d4fe..3eb2994b645 100644 --- a/app/models/project_services/bamboo_service.rb +++ b/app/models/project_services/bamboo_service.rb @@ -55,7 +55,7 @@ class BambooService < CiService end def supported_events - %w(push) + %w[push] end def build_info(sha) diff --git a/app/models/project_services/buildkite_service.rb b/app/models/project_services/buildkite_service.rb index 86a06321e21..ca6ed78da45 100644 --- a/app/models/project_services/buildkite_service.rb +++ b/app/models/project_services/buildkite_service.rb @@ -22,7 +22,7 @@ class BuildkiteService < CiService end def supported_events - %w(push) + %w[push] end def execute(data) diff --git a/app/models/project_services/builds_email_service.rb b/app/models/project_services/builds_email_service.rb index fa66e5864b8..311addfd36f 100644 --- a/app/models/project_services/builds_email_service.rb +++ b/app/models/project_services/builds_email_service.rb @@ -24,7 +24,7 @@ class BuildsEmailService < Service end def supported_events - %w(build) + %w[build] end def execute(push_data) diff --git a/app/models/project_services/campfire_service.rb b/app/models/project_services/campfire_service.rb index 5af93860d09..983ad46b46f 100644 --- a/app/models/project_services/campfire_service.rb +++ b/app/models/project_services/campfire_service.rb @@ -25,7 +25,7 @@ class CampfireService < Service end def supported_events - %w(push) + %w[push] end def execute(data) diff --git a/app/models/project_services/ci_service.rb b/app/models/project_services/ci_service.rb index 596c00705ad..2e769e3eede 100644 --- a/app/models/project_services/ci_service.rb +++ b/app/models/project_services/ci_service.rb @@ -9,7 +9,7 @@ class CiService < Service end def supported_events - %w(push) + %w[push] end def merge_request_page(iid, sha, ref) diff --git a/app/models/project_services/drone_ci_service.rb b/app/models/project_services/drone_ci_service.rb index 5e4dd101c53..f58ca3460a3 100644 --- a/app/models/project_services/drone_ci_service.rb +++ b/app/models/project_services/drone_ci_service.rb @@ -30,7 +30,7 @@ class DroneCiService < CiService end def supported_events - %w(push merge_request tag_push) + %w[push merge_request tag_push] end def merge_request_status_path(iid, sha = nil, ref = nil) diff --git a/app/models/project_services/emails_on_push_service.rb b/app/models/project_services/emails_on_push_service.rb index e0083c43adb..b9688628ef1 100644 --- a/app/models/project_services/emails_on_push_service.rb +++ b/app/models/project_services/emails_on_push_service.rb @@ -17,7 +17,7 @@ class EmailsOnPushService < Service end def supported_events - %w(push tag_push) + %w[push tag_push] end def execute(push_data) diff --git a/app/models/project_services/flowdock_service.rb b/app/models/project_services/flowdock_service.rb index dd00275187f..7a207e500b1 100644 --- a/app/models/project_services/flowdock_service.rb +++ b/app/models/project_services/flowdock_service.rb @@ -23,7 +23,7 @@ class FlowdockService < Service end def supported_events - %w(push) + %w[push] end def execute(data) diff --git a/app/models/project_services/gemnasium_service.rb b/app/models/project_services/gemnasium_service.rb index 598aca5e06d..8e7babbeded 100644 --- a/app/models/project_services/gemnasium_service.rb +++ b/app/models/project_services/gemnasium_service.rb @@ -24,7 +24,7 @@ class GemnasiumService < Service end def supported_events - %w(push) + %w[push] end def execute(data) diff --git a/app/models/project_services/hipchat_service.rb b/app/models/project_services/hipchat_service.rb index afebd3b6a12..3d898b0b429 100644 --- a/app/models/project_services/hipchat_service.rb +++ b/app/models/project_services/hipchat_service.rb @@ -39,7 +39,7 @@ class HipchatService < Service end def supported_events - %w(push issue confidential_issue merge_request note tag_push build) + %w[push issue confidential_issue merge_request note tag_push build] end def execute(data) diff --git a/app/models/project_services/irker_service.rb b/app/models/project_services/irker_service.rb index ce7d1c5d5b1..2834bda3bd2 100644 --- a/app/models/project_services/irker_service.rb +++ b/app/models/project_services/irker_service.rb @@ -21,7 +21,7 @@ class IrkerService < Service end def supported_events - %w(push) + %w[push] end def execute(data) diff --git a/app/models/project_services/issue_tracker_service.rb b/app/models/project_services/issue_tracker_service.rb index d1df6d0292f..210df69edab 100644 --- a/app/models/project_services/issue_tracker_service.rb +++ b/app/models/project_services/issue_tracker_service.rb @@ -48,7 +48,7 @@ class IssueTrackerService < Service end def supported_events - %w(push) + %w[push] end def execute(data) diff --git a/app/models/project_services/jira_service.rb b/app/models/project_services/jira_service.rb index 97bcbacf2b9..03ce38fe479 100644 --- a/app/models/project_services/jira_service.rb +++ b/app/models/project_services/jira_service.rb @@ -182,7 +182,7 @@ class JiraService < IssueTrackerService project_name = data[:project][:name] message = { - body: %Q{[#{user_name}|#{user_url}] mentioned this issue in [a #{entity_name} of #{project_name}|#{entity_url}]:\n'#{entity_title}'} + body: %Q([#{user_name}|#{user_url}] mentioned this issue in [a #{entity_name} of #{project_name}|#{entity_url}]:\n'#{entity_title}') } unless existing_comment?(issue_name, message[:body]) diff --git a/app/models/project_services/pivotaltracker_service.rb b/app/models/project_services/pivotaltracker_service.rb index 5301f9fa0ff..a1dab7dace0 100644 --- a/app/models/project_services/pivotaltracker_service.rb +++ b/app/models/project_services/pivotaltracker_service.rb @@ -35,7 +35,7 @@ class PivotaltrackerService < Service end def supported_events - %w(push) + %w[push] end def execute(data) diff --git a/app/models/project_services/pushover_service.rb b/app/models/project_services/pushover_service.rb index 3dd878e4c7d..2a5639cbdcb 100644 --- a/app/models/project_services/pushover_service.rb +++ b/app/models/project_services/pushover_service.rb @@ -62,7 +62,7 @@ class PushoverService < Service end def supported_events - %w(push) + %w[push] end def execute(data) diff --git a/app/models/project_services/teamcity_service.rb b/app/models/project_services/teamcity_service.rb index a4a967c9bc9..7a6f8821d04 100644 --- a/app/models/project_services/teamcity_service.rb +++ b/app/models/project_services/teamcity_service.rb @@ -46,7 +46,7 @@ class TeamcityService < CiService end def supported_events - %w(push) + %w[push] end def fields diff --git a/app/models/repository.rb b/app/models/repository.rb index 51557228ab9..1e04c363415 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -5,7 +5,7 @@ class Repository # Files to use as a project avatar in case no avatar was uploaded via the web # UI. - AVATAR_FILES = %w{logo.png logo.jpg logo.gif} + AVATAR_FILES = %w[logo.png logo.jpg logo.gif] include Gitlab::ShellAdapter @@ -112,8 +112,8 @@ class Repository ref ||= root_ref # Limited to 1000 commits for now, could be parameterized? - args = %W(#{Gitlab.config.git.bin_path} log #{ref} --pretty=%H --skip #{offset} --max-count #{limit} --grep=#{query}) - args = args.concat(%W(-- #{path})) if path.present? + args = %W[#{Gitlab.config.git.bin_path} log #{ref} --pretty=%H --skip #{offset} --max-count #{limit} --grep=#{query}] + args = args.concat(%W[-- #{path}]) if path.present? git_log_results = Gitlab::Popen.popen(args, path_to_repo).first.lines.map(&:chomp) commits = git_log_results.map { |c| commit(c) } @@ -303,14 +303,14 @@ class Repository # Keys for data that can be affected for any commit push. def cache_keys - %i(size commit_count + %i[size commit_count readme version contribution_guide changelog - license_blob license_key gitignore koding_yml) + license_blob license_key gitignore koding_yml] end # Keys for data on branch/tag operations. def cache_keys_for_branches_and_tags - %i(branch_names tag_names branch_count tag_count) + %i[branch_names tag_names branch_count tag_count] end def build_cache @@ -648,7 +648,7 @@ class Repository end def last_commit_for_path(sha, path) - args = %W(#{Gitlab.config.git.bin_path} rev-list --max-count=1 #{sha} -- #{path}) + args = %W[#{Gitlab.config.git.bin_path} rev-list --max-count=1 #{sha} -- #{path}] sha = Gitlab::Popen.popen(args, path_to_repo).first.strip commit(sha) end @@ -718,7 +718,7 @@ class Repository end def refs_contains_sha(ref_type, sha) - args = %W(#{Gitlab.config.git.bin_path} #{ref_type} --contains #{sha}) + args = %W[#{Gitlab.config.git.bin_path} #{ref_type} --contains #{sha}] names = Gitlab::Popen.popen(args, path_to_repo).first if names.respond_to?(:split) @@ -988,12 +988,12 @@ class Repository def search_files(query, ref) offset = 2 - args = %W(#{Gitlab.config.git.bin_path} grep -i -I -n --before-context #{offset} --after-context #{offset} -E -e #{Regexp.escape(query)} #{ref || root_ref}) + args = %W[#{Gitlab.config.git.bin_path} grep -i -I -n --before-context #{offset} --after-context #{offset} -E -e #{Regexp.escape(query)} #{ref || root_ref}] Gitlab::Popen.popen(args, path_to_repo).first.scrub.split(/^--$/) end def fetch_ref(source_path, source_ref, target_ref) - args = %W(#{Gitlab.config.git.bin_path} fetch --no-tags -f #{source_path} #{source_ref}:#{target_ref}) + args = %W[#{Gitlab.config.git.bin_path} fetch --no-tags -f #{source_path} #{source_ref}:#{target_ref}] Gitlab::Popen.popen(args, path_to_repo) end diff --git a/app/models/service.rb b/app/models/service.rb index 80de7175565..c9dfbea78ce 100644 --- a/app/models/service.rb +++ b/app/models/service.rb @@ -103,7 +103,7 @@ class Service < ActiveRecord::Base end def supported_events - %w(push tag_push issue confidential_issue merge_request wiki_page) + %w[push tag_push issue confidential_issue merge_request wiki_page] end def execute(data) @@ -195,7 +195,7 @@ class Service < ActiveRecord::Base end def self.available_services_names - %w( + %w[ asana assembla bamboo @@ -217,7 +217,7 @@ class Service < ActiveRecord::Base redmine slack teamcity - ) + ] end def self.create_from_template(project_id, template) diff --git a/app/models/user.rb b/app/models/user.rb index 6996740eebd..ea977479399 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -559,7 +559,7 @@ class User < ActiveRecord::Base end def sanitize_attrs - %w(name username skype linkedin twitter).each do |attr| + %w[name username skype linkedin twitter].each do |attr| value = self.send(attr) self.send("#{attr}=", Sanitize.clean(value)) if value.present? end diff --git a/app/policies/ci/build_policy.rb b/app/policies/ci/build_policy.rb index 2232e231cf8..8b25332b73c 100644 --- a/app/policies/ci/build_policy.rb +++ b/app/policies/ci/build_policy.rb @@ -5,7 +5,7 @@ module Ci # If we can't read build we should also not have that # ability when looking at this in context of commit_status - %w(read create update admin).each do |rule| + %w[read create update admin].each do |rule| cannot! :"#{rule}_commit_status" unless can? :"#{rule}_build" end end diff --git a/app/services/auth/container_registry_authentication_service.rb b/app/services/auth/container_registry_authentication_service.rb index 8ea88da8a53..6eb96bdd07c 100644 --- a/app/services/auth/container_registry_authentication_service.rb +++ b/app/services/auth/container_registry_authentication_service.rb @@ -24,7 +24,7 @@ module Auth token.expire_time = token_expire_at token[:access] = names.map do |name| - { type: 'repository', name: name, actions: %w(*) } + { type: 'repository', name: name, actions: %w[*] } end token.encoded diff --git a/app/services/git_hooks_service.rb b/app/services/git_hooks_service.rb index 172bd85dade..b66d67d50d5 100644 --- a/app/services/git_hooks_service.rb +++ b/app/services/git_hooks_service.rb @@ -8,7 +8,7 @@ class GitHooksService @newrev = newrev @ref = ref - %w(pre-receive update).each do |hook_name| + %w[pre-receive update].each do |hook_name| status, message = run_hook(hook_name) unless status diff --git a/app/services/import_export_clean_up_service.rb b/app/services/import_export_clean_up_service.rb index 6442406d77e..9c0aa73913a 100644 --- a/app/services/import_export_clean_up_service.rb +++ b/app/services/import_export_clean_up_service.rb @@ -19,6 +19,6 @@ class ImportExportCleanUpService private def clean_up_export_files - Gitlab::Popen.popen(%W(find #{path} -not -path #{path} -mmin +#{mmin} -delete)) + Gitlab::Popen.popen(%W[find #{path} -not -path #{path} -mmin +#{mmin} -delete]) end end diff --git a/app/services/issuable/bulk_update_service.rb b/app/services/issuable/bulk_update_service.rb index 60891cbb255..6411fc21c91 100644 --- a/app/services/issuable/bulk_update_service.rb +++ b/app/services/issuable/bulk_update_service.rb @@ -7,7 +7,7 @@ module Issuable ids = params.delete(:issuable_ids).split(",") items = model_class.where(id: ids) - %i(state_event milestone_id assignee_id add_label_ids remove_label_ids subscription_event).each do |key| + %i[state_event milestone_id assignee_id add_label_ids remove_label_ids subscription_event].each do |key| params.delete(key) unless params[key].present? end diff --git a/app/services/repository_archive_clean_up_service.rb b/app/services/repository_archive_clean_up_service.rb index aa84d36a206..4627f08fffc 100644 --- a/app/services/repository_archive_clean_up_service.rb +++ b/app/services/repository_archive_clean_up_service.rb @@ -20,11 +20,11 @@ class RepositoryArchiveCleanUpService private def clean_up_old_archives - run(%W(find #{path} -not -path #{path} -type f \( -name \*.tar -o -name \*.bz2 -o -name \*.tar.gz -o -name \*.zip \) -maxdepth 2 -mmin +#{mmin} -delete)) + run(%W[find #{path} -not -path #{path} -type f \( -name \*.tar -o -name \*.bz2 -o -name \*.tar.gz -o -name \*.zip \) -maxdepth 2 -mmin +#{mmin} -delete]) end def clean_up_empty_directories - run(%W(find #{path} -not -path #{path} -type d -empty -name \*.git -maxdepth 1 -delete)) + run(%W[find #{path} -not -path #{path} -type d -empty -name \*.git -maxdepth 1 -delete]) end def run(cmd) diff --git a/app/validators/addressable_url_validator.rb b/app/validators/addressable_url_validator.rb index 09bfa613cbe..6e9fd29e002 100644 --- a/app/validators/addressable_url_validator.rb +++ b/app/validators/addressable_url_validator.rb @@ -18,7 +18,7 @@ # end # class AddressableUrlValidator < ActiveModel::EachValidator - DEFAULT_OPTIONS = { protocols: %w(http https ssh git) } + DEFAULT_OPTIONS = { protocols: %w[http https ssh git] } def validate_each(record, attribute, value) unless valid_url?(value) diff --git a/app/validators/namespace_validator.rb b/app/validators/namespace_validator.rb index 7a35958cc5f..70e18c9d454 100644 --- a/app/validators/namespace_validator.rb +++ b/app/validators/namespace_validator.rb @@ -5,7 +5,7 @@ # Values are checked for formatting and exclusion from a list of reserved path # names. class NamespaceValidator < ActiveModel::EachValidator - RESERVED = %w( + RESERVED = %w[ admin all assets @@ -31,7 +31,7 @@ class NamespaceValidator < ActiveModel::EachValidator u unsubscribes users - ).freeze + ].freeze def validate_each(record, attribute, value) unless value =~ Gitlab::Regex.namespace_regex diff --git a/app/validators/url_validator.rb b/app/validators/url_validator.rb index a77beb2683d..e8c0a94fa2c 100644 --- a/app/validators/url_validator.rb +++ b/app/validators/url_validator.rb @@ -25,7 +25,7 @@ class UrlValidator < ActiveModel::EachValidator private def default_options - @default_options ||= { protocols: %w(http https) } + @default_options ||= { protocols: %w[http https] } end def valid_url?(value) diff --git a/app/workers/irker_worker.rb b/app/workers/irker_worker.rb index 19f38358eb5..9acb56b5482 100644 --- a/app/workers/irker_worker.rb +++ b/app/workers/irker_worker.rb @@ -12,7 +12,7 @@ class IrkerWorker repo_name = push_data['repository']['name'] committer = push_data['user_name'] - branch = push_data['ref'].gsub(%r'refs/[^/]*/', '') + branch = push_data['ref'].gsub(%r{refs/[^/]*/}, '') if @colors repo_name = "\x0304#{repo_name}\x0f" diff --git a/app/workers/repository_check/single_repository_worker.rb b/app/workers/repository_check/single_repository_worker.rb index 98ddf5d0688..91a4c8a4d41 100644 --- a/app/workers/repository_check/single_repository_worker.rb +++ b/app/workers/repository_check/single_repository_worker.rb @@ -34,7 +34,7 @@ module RepositoryCheck def git_fsck(repository) path = repository.path_to_repo - cmd = %W(nice git --git-dir=#{path} fsck) + cmd = %W[nice git --git-dir=#{path} fsck] output, status = Gitlab::Popen.popen(cmd) if status.zero? diff --git a/config/application.rb b/config/application.rb index 4792f6670a8..639628e0b13 100644 --- a/config/application.rb +++ b/config/application.rb @@ -20,11 +20,11 @@ module Gitlab # https://github.com/rails/rails/blob/v4.2.6/railties/lib/rails/engine.rb#L687 # This is a nice reference article on autoloading/eager loading: # http://blog.arkency.com/2014/11/dont-forget-about-eager-load-when-extending-autoload - config.eager_load_paths.push(*%W(#{config.root}/lib + config.eager_load_paths.push(*%W[#{config.root}/lib #{config.root}/app/models/ci #{config.root}/app/models/hooks #{config.root}/app/models/members - #{config.root}/app/models/project_services)) + #{config.root}/app/models/project_services]) config.generators.templates.push("#{config.root}/generator_templates") @@ -52,7 +52,7 @@ module Gitlab # - Webhook URLs (:hook) # - Sentry DSN (:sentry_dsn) # - Deploy keys (:key) - config.filter_parameters += %i( + config.filter_parameters += %i[ certificate encrypted_key hook @@ -64,7 +64,7 @@ module Gitlab private_token sentry_dsn variables - ) + ] # Enable escaping HTML in JSON. config.active_support.escape_html_entities_in_json = true @@ -97,7 +97,7 @@ module Gitlab # Version of your assets, change this if you want to expire all your assets config.assets.version = '1.0' - config.action_view.sanitized_allowed_protocols = %w(smb) + config.action_view.sanitized_allowed_protocols = %w[smb] config.middleware.use Rack::Attack diff --git a/config/environments/production.rb b/config/environments/production.rb index a9d8ac4b6d4..e74a44f5962 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -39,7 +39,7 @@ Rails.application.configure do # Suppress 'Rendered template ...' messages in the log # source: http://stackoverflow.com/a/16369363 - %w{render_template render_partial render_collection}.each do |event| + %w[render_template render_partial render_collection].each do |event| ActiveSupport::Notifications.unsubscribe "#{event}.action_view" end diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index 195108b921b..80e7ffe9195 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -382,7 +382,7 @@ Settings['extra'] ||= Settingslogic.new({}) Settings['rack_attack'] ||= Settingslogic.new({}) Settings.rack_attack['git_basic_auth'] ||= Settingslogic.new({}) Settings.rack_attack.git_basic_auth['enabled'] = true if Settings.rack_attack.git_basic_auth['enabled'].nil? -Settings.rack_attack.git_basic_auth['ip_whitelist'] ||= %w{127.0.0.1} +Settings.rack_attack.git_basic_auth['ip_whitelist'] ||= %w[127.0.0.1] Settings.rack_attack.git_basic_auth['maxretry'] ||= 10 Settings.rack_attack.git_basic_auth['findtime'] ||= 1.minute Settings.rack_attack.git_basic_auth['bantime'] ||= 1.hour diff --git a/config/initializers/2_app.rb b/config/initializers/2_app.rb index bd74f90e7d2..074bf591aa7 100644 --- a/config/initializers/2_app.rb +++ b/config/initializers/2_app.rb @@ -4,5 +4,5 @@ module Gitlab end VERSION = File.read(Rails.root.join("VERSION")).strip.freeze - REVISION = Gitlab::Popen.popen(%W(#{config.git.bin_path} log --pretty=format:%h -n 1)).first.chomp.freeze + REVISION = Gitlab::Popen.popen(%W[#{config.git.bin_path} log --pretty=format:%h -n 1]).first.chomp.freeze end diff --git a/config/initializers/doorkeeper.rb b/config/initializers/doorkeeper.rb index fc4b0a72add..205e2b04683 100644 --- a/config/initializers/doorkeeper.rb +++ b/config/initializers/doorkeeper.rb @@ -84,7 +84,7 @@ Doorkeeper.configure do # # If not specified, Doorkeeper enables all the four grant flows. # - grant_flows %w(authorization_code password client_credentials) + grant_flows %w[authorization_code password client_credentials] # Under some circumstances you might want to have applications auto-approved, # so that the user skips the authorization step. diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index 3d1a41a4652..78b2327d383 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -10,5 +10,5 @@ # end # ActiveSupport::Inflector.inflections do |inflect| - inflect.uncountable %w(award_emoji) + inflect.uncountable %w[award_emoji] end diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb index 5e3e4c966cb..4e59b1ca59d 100644 --- a/config/initializers/mime_types.rb +++ b/config/initializers/mime_types.rb @@ -14,4 +14,4 @@ Mime::Type.register "video/webm", :webm Mime::Type.register "video/ogg", :ogv Mime::Type.unregister :json -Mime::Type.register 'application/json', :json, %w(application/vnd.git-lfs+json application/json) +Mime::Type.register 'application/json', :json, %w[application/vnd.git-lfs+json application/json] diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb index f7e714cd6bc..7692039100e 100644 --- a/config/initializers/sidekiq.rb +++ b/config/initializers/sidekiq.rb @@ -15,7 +15,7 @@ Sidekiq.configure_server do |config| # UGLY Hack to get nested hash from settingslogic cron_jobs = JSON.parse(Gitlab.config.cron_jobs.to_json) # UGLY hack: Settingslogic doesn't allow 'class' key - cron_jobs_required_keys = %w(job_class cron) + cron_jobs_required_keys = %w[job_class cron] cron_jobs.each do |k, v| if cron_jobs[k] && cron_jobs_required_keys.all? { |s| cron_jobs[k].key?(s) } cron_jobs[k]['class'] = cron_jobs[k].delete('job_class') diff --git a/features/steps/group/milestones.rb b/features/steps/group/milestones.rb index f5fddab357d..1277f4f1b3e 100644 --- a/features/steps/group/milestones.rb +++ b/features/steps/group/milestones.rb @@ -103,7 +103,7 @@ class Spinach::Features::GroupMilestones < Spinach::FeatureSteps def group_milestone group = owned_group - %w(gitlabhq gitlab-ci cookbook-gitlab).each do |path| + %w[gitlabhq gitlab-ci cookbook-gitlab].each do |path| project = create :project, path: path, group: group milestone = create :milestone, title: "Version 7.2", project: project diff --git a/features/support/env.rb b/features/support/env.rb index 569fd444e86..1b6f20b8276 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -15,7 +15,7 @@ if ENV['CI'] Knapsack::Adapters::SpinachAdapter.bind end -%w(select2_helper test_env repo_helpers).each do |f| +%w[select2_helper test_env repo_helpers].each do |f| require Rails.root.join('spec', 'support', f) end diff --git a/lib/api/deploy_keys.rb b/lib/api/deploy_keys.rb index 825e05fbae3..f743cbb5cca 100644 --- a/lib/api/deploy_keys.rb +++ b/lib/api/deploy_keys.rb @@ -19,7 +19,7 @@ module API # Routing "projects/:id/keys/..." is DEPRECATED and WILL BE REMOVED in version 9.0 # Use "projects/:id/deploy_keys/..." instead. # - %w(keys deploy_keys).each do |path| + %w[keys deploy_keys].each do |path| desc "Get a specific project's deploy keys" do success Entities::SSHKey end diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index 714d4ea3dc6..f00937ce94c 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -338,7 +338,7 @@ module API end def project_order_by - order_fields = %w(id name path created_at updated_at last_activity_at) + order_fields = %w[id name path created_at updated_at last_activity_at] if order_fields.include?(params['order_by']) params['order_by'] @@ -367,7 +367,7 @@ module API # sanitize file paths # this requires all paths to exist - required_attributes! %W(#{field}.path) + required_attributes! %W[#{field}.path] uploads_path = File.realpath(uploads_path) file_path = File.realpath(params["#{field}.path"]) bad_request!('Bad file path') unless file_path.start_with?(uploads_path) diff --git a/lib/banzai/filter/autolink_filter.rb b/lib/banzai/filter/autolink_filter.rb index 799b83b1069..475ea86a999 100644 --- a/lib/banzai/filter/autolink_filter.rb +++ b/lib/banzai/filter/autolink_filter.rb @@ -29,7 +29,7 @@ module Banzai LINK_PATTERN = %r{([a-z][a-z0-9\+\.-]+://\S+)(?<!,|\.)} # Text matching LINK_PATTERN inside these elements will not be linked - IGNORE_PARENTS = %w(a code kbd pre script style).to_set + IGNORE_PARENTS = %w[a code kbd pre script style].to_set # The XPath query to use for finding text nodes to parse. TEXT_QUERY = %Q(descendant-or-self::text()[ diff --git a/lib/banzai/filter/emoji_filter.rb b/lib/banzai/filter/emoji_filter.rb index 2492b5213ac..5f665964f48 100644 --- a/lib/banzai/filter/emoji_filter.rb +++ b/lib/banzai/filter/emoji_filter.rb @@ -8,7 +8,7 @@ module Banzai # :asset_root # :asset_host class EmojiFilter < HTML::Pipeline::Filter - IGNORED_ANCESTOR_TAGS = %w(pre code tt).to_set + IGNORED_ANCESTOR_TAGS = %w[pre code tt].to_set def call search_text_nodes(doc).each do |node| diff --git a/lib/banzai/filter/gollum_tags_filter.rb b/lib/banzai/filter/gollum_tags_filter.rb index d08267a9d6c..696cffc77b0 100644 --- a/lib/banzai/filter/gollum_tags_filter.rb +++ b/lib/banzai/filter/gollum_tags_filter.rb @@ -133,7 +133,7 @@ module Banzai end def url?(path) - path.start_with?(*%w(http https)) + path.start_with?(*%w[http https]) end # Attempt to process the tag as a page link tag. diff --git a/lib/banzai/filter/inline_diff_filter.rb b/lib/banzai/filter/inline_diff_filter.rb index beb21b19ab3..8744e8063d1 100644 --- a/lib/banzai/filter/inline_diff_filter.rb +++ b/lib/banzai/filter/inline_diff_filter.rb @@ -1,7 +1,7 @@ module Banzai module Filter class InlineDiffFilter < HTML::Pipeline::Filter - IGNORED_ANCESTOR_TAGS = %w(pre code tt).to_set + IGNORED_ANCESTOR_TAGS = %w[pre code tt].to_set def call search_text_nodes(doc).each do |node| diff --git a/lib/banzai/filter/reference_filter.rb b/lib/banzai/filter/reference_filter.rb index 2d221290f7e..686f76b124d 100644 --- a/lib/banzai/filter/reference_filter.rb +++ b/lib/banzai/filter/reference_filter.rb @@ -40,7 +40,7 @@ module Banzai def ignore_ancestor_query @ignore_ancestor_query ||= begin - parents = %w(pre code a style) + parents = %w[pre code a style] parents << 'blockquote' if context[:ignore_blockquotes] parents.map { |n| "ancestor::#{n}" }.join(' or ') diff --git a/lib/banzai/filter/sanitization_filter.rb b/lib/banzai/filter/sanitization_filter.rb index 2470362e019..419ba27ba15 100644 --- a/lib/banzai/filter/sanitization_filter.rb +++ b/lib/banzai/filter/sanitization_filter.rb @@ -4,7 +4,7 @@ module Banzai # # Extends HTML::Pipeline::SanitizationFilter with a custom whitelist. class SanitizationFilter < HTML::Pipeline::SanitizationFilter - UNSAFE_PROTOCOLS = %w(data javascript vbscript).freeze + UNSAFE_PROTOCOLS = %w[data javascript vbscript].freeze def whitelist whitelist = super @@ -25,19 +25,19 @@ module Banzai return if customized?(whitelist[:transformers]) # Allow code highlighting - whitelist[:attributes]['pre'] = %w(class) - whitelist[:attributes]['span'] = %w(class) + whitelist[:attributes]['pre'] = %w[class] + whitelist[:attributes]['span'] = %w[class] # Allow table alignment - whitelist[:attributes]['th'] = %w(style) - whitelist[:attributes]['td'] = %w(style) + whitelist[:attributes]['th'] = %w[style] + whitelist[:attributes]['td'] = %w[style] # Allow span elements whitelist[:elements].push('span') # Allow abbr elements with title attribute whitelist[:elements].push('abbr') - whitelist[:attributes]['abbr'] = %w(title) + whitelist[:attributes]['abbr'] = %w[title] # Allow any protocol in `a` elements... whitelist[:protocols].delete('a') diff --git a/lib/banzai/filter/table_of_contents_filter.rb b/lib/banzai/filter/table_of_contents_filter.rb index a4eda6fdf76..36e19ea24e3 100644 --- a/lib/banzai/filter/table_of_contents_filter.rb +++ b/lib/banzai/filter/table_of_contents_filter.rb @@ -41,7 +41,7 @@ module Banzai end end - result[:toc] = %Q{<ul class="section-nav">\n#{result[:toc]}</ul>} unless result[:toc].empty? + result[:toc] = %Q(<ul class="section-nav">\n#{result[:toc]}</ul>) unless result[:toc].empty? doc end @@ -49,11 +49,11 @@ module Banzai private def anchor_tag(href) - %Q{<a id="#{href}" class="anchor" href="##{href}" aria-hidden="true"></a>} + %Q(<a id="#{href}" class="anchor" href="##{href}" aria-hidden="true"></a>) end def push_toc(href, text) - result[:toc] << %Q{<li><a href="##{href}">#{text}</a></li>\n} + result[:toc] << %Q(<li><a href="##{href}">#{text}</a></li>\n) end end end diff --git a/lib/banzai/pipeline/base_pipeline.rb b/lib/banzai/pipeline/base_pipeline.rb index 321fd5bbe14..88b73a846a1 100644 --- a/lib/banzai/pipeline/base_pipeline.rb +++ b/lib/banzai/pipeline/base_pipeline.rb @@ -14,7 +14,7 @@ module Banzai end class << self - %i(call to_document to_html).each do |meth| + %i[call to_document to_html].each do |meth| define_method(meth) do |text, context| context = transform_context(context) diff --git a/lib/banzai/pipeline/description_pipeline.rb b/lib/banzai/pipeline/description_pipeline.rb index 042fb2e6e14..e1301943b3c 100644 --- a/lib/banzai/pipeline/description_pipeline.rb +++ b/lib/banzai/pipeline/description_pipeline.rb @@ -2,7 +2,7 @@ module Banzai module Pipeline class DescriptionPipeline < FullPipeline WHITELIST = Banzai::Filter::SanitizationFilter::LIMITED.deep_dup.merge( - elements: Banzai::Filter::SanitizationFilter::LIMITED[:elements] - %w(pre code img ol ul li) + elements: Banzai::Filter::SanitizationFilter::LIMITED[:elements] - %w[pre code img ol ul li] ) def self.transform_context(context) diff --git a/lib/ci/ansi2html.rb b/lib/ci/ansi2html.rb index 229050151d3..12d5eeaf4ad 100644 --- a/lib/ci/ansi2html.rb +++ b/lib/ci/ansi2html.rb @@ -170,13 +170,13 @@ module Ci return if css_classes.empty? - @out << %{<span class="#{css_classes.join(' ')}">} + @out << %(<span class="#{css_classes.join(' ')}">) @n_open_tags += 1 end def close_open_tags while @n_open_tags > 0 - @out << %{</span>} + @out << %(</span>) @n_open_tags -= 1 end end diff --git a/lib/event_filter.rb b/lib/event_filter.rb index 668d2fa41b3..a6e07be76a2 100644 --- a/lib/event_filter.rb +++ b/lib/event_filter.rb @@ -3,7 +3,7 @@ class EventFilter class << self def default_filter - %w{ push issues merge_requests team} + %w[push issues merge_requests team] end def push diff --git a/lib/gitlab/backend/shell.rb b/lib/gitlab/backend/shell.rb index 79eac66b364..b836d72f59d 100644 --- a/lib/gitlab/backend/shell.rb +++ b/lib/gitlab/backend/shell.rb @@ -124,7 +124,7 @@ module Gitlab # Ex. # batch_add_keys { |adder| adder.add_key("key-42", "sha-rsa ...") } def batch_add_keys(&block) - IO.popen(%W(#{gitlab_shell_path}/bin/gitlab-keys batch-add-keys), 'w') do |io| + IO.popen(%W[#{gitlab_shell_path}/bin/gitlab-keys batch-add-keys], 'w') do |io| block.call(KeyAdder.new(io)) end end diff --git a/lib/gitlab/bitbucket_import/importer.rb b/lib/gitlab/bitbucket_import/importer.rb index f4b5097adb1..d57daffea5d 100644 --- a/lib/gitlab/bitbucket_import/importer.rb +++ b/lib/gitlab/bitbucket_import/importer.rb @@ -73,7 +73,7 @@ module Gitlab project.issues.create!( description: body, title: issue["title"], - state: %w(resolved invalid duplicate wontfix closed).include?(issue["status"]) ? 'closed' : 'opened', + state: %w[resolved invalid duplicate wontfix closed].include?(issue["status"]) ? 'closed' : 'opened', author_id: gitlab_user_id(project, reporter) ) end diff --git a/lib/gitlab/checks/force_push.rb b/lib/gitlab/checks/force_push.rb index 5fe86553bd0..7ea197e4d81 100644 --- a/lib/gitlab/checks/force_push.rb +++ b/lib/gitlab/checks/force_push.rb @@ -8,7 +8,7 @@ module Gitlab if Gitlab::Git.blank_ref?(oldrev) || Gitlab::Git.blank_ref?(newrev) false else - missed_ref, _ = Gitlab::Popen.popen(%W(#{Gitlab.config.git.bin_path} --git-dir=#{project.repository.path_to_repo} rev-list --max-count=1 #{oldrev} ^#{newrev})) + missed_ref, _ = Gitlab::Popen.popen(%W[#{Gitlab.config.git.bin_path} --git-dir=#{project.repository.path_to_repo} rev-list --max-count=1 #{oldrev} ^#{newrev}]) missed_ref.present? end end diff --git a/lib/gitlab/closing_issue_extractor.rb b/lib/gitlab/closing_issue_extractor.rb index 58f86abc5c4..71e619f434b 100644 --- a/lib/gitlab/closing_issue_extractor.rb +++ b/lib/gitlab/closing_issue_extractor.rb @@ -1,7 +1,7 @@ module Gitlab class ClosingIssueExtractor ISSUE_CLOSING_REGEX = begin - link_pattern = URI.regexp(%w(http https)) + link_pattern = URI.regexp(%w[http https]) pattern = Gitlab.config.gitlab.issue_closing_pattern pattern = pattern.sub('%{issue_ref}', "(?:(?:#{link_pattern})|(?:#{Issue.reference_pattern}))") diff --git a/lib/gitlab/diff/line.rb b/lib/gitlab/diff/line.rb index 80a146b4a5a..425cf4d33b1 100644 --- a/lib/gitlab/diff/line.rb +++ b/lib/gitlab/diff/line.rb @@ -16,7 +16,7 @@ module Gitlab end def serialize_keys - @serialize_keys ||= %i(text type index old_pos new_pos) + @serialize_keys ||= %i[text type index old_pos new_pos] end def to_hash diff --git a/lib/gitlab/email/reply_parser.rb b/lib/gitlab/email/reply_parser.rb index 3411eb1d9ce..904fb19f545 100644 --- a/lib/gitlab/email/reply_parser.rb +++ b/lib/gitlab/email/reply_parser.rb @@ -51,7 +51,7 @@ module Gitlab nil end - REPLYING_HEADER_LABELS = %w(From Sent To Subject Reply To Cc Bcc Date) + REPLYING_HEADER_LABELS = %w[From Sent To Subject Reply To Cc Bcc Date] REPLYING_HEADER_REGEX = Regexp.union(REPLYING_HEADER_LABELS.map { |label| "#{label}:" }) def discourse_email_trimmer(body) diff --git a/lib/gitlab/git.rb b/lib/gitlab/git.rb index 3cd515e4a3a..b6572137413 100644 --- a/lib/gitlab/git.rb +++ b/lib/gitlab/git.rb @@ -50,7 +50,7 @@ module Gitlab end def version - Gitlab::VersionInfo.parse(Gitlab::Popen.popen(%W(#{Gitlab.config.git.bin_path} --version)).first) + Gitlab::VersionInfo.parse(Gitlab::Popen.popen(%W[#{Gitlab.config.git.bin_path} --version]).first) end end end diff --git a/lib/gitlab/git_access.rb b/lib/gitlab/git_access.rb index 799794c0171..ba90ee4d336 100644 --- a/lib/gitlab/git_access.rb +++ b/lib/gitlab/git_access.rb @@ -2,8 +2,8 @@ # class return an instance of `GitlabAccessStatus` module Gitlab class GitAccess - DOWNLOAD_COMMANDS = %w{ git-upload-pack git-upload-archive } - PUSH_COMMANDS = %w{ git-receive-pack } + DOWNLOAD_COMMANDS = %w[git-upload-pack git-upload-archive] + PUSH_COMMANDS = %w[git-receive-pack] attr_reader :actor, :project, :protocol, :user_access, :authentication_abilities diff --git a/lib/gitlab/git_ref_validator.rb b/lib/gitlab/git_ref_validator.rb index 4d83d8e72a8..7b18c04c799 100644 --- a/lib/gitlab/git_ref_validator.rb +++ b/lib/gitlab/git_ref_validator.rb @@ -6,7 +6,7 @@ module Gitlab # Returns true for a valid reference name, false otherwise def validate(ref_name) Gitlab::Utils.system_silent( - %W(#{Gitlab.config.git.bin_path} check-ref-format refs/#{ref_name})) + %W[#{Gitlab.config.git.bin_path} check-ref-format refs/#{ref_name}]) end end end diff --git a/lib/gitlab/import_export/command_line_util.rb b/lib/gitlab/import_export/command_line_util.rb index e522a0fc8f6..d03615f413e 100644 --- a/lib/gitlab/import_export/command_line_util.rb +++ b/lib/gitlab/import_export/command_line_util.rb @@ -10,25 +10,25 @@ module Gitlab end def git_bundle(repo_path:, bundle_path:) - execute(%W(#{git_bin_path} --git-dir=#{repo_path} bundle create #{bundle_path} --all)) + execute(%W[#{git_bin_path} --git-dir=#{repo_path} bundle create #{bundle_path} --all]) end def git_unbundle(repo_path:, bundle_path:) - execute(%W(#{git_bin_path} clone --bare #{bundle_path} #{repo_path})) + execute(%W[#{git_bin_path} clone --bare #{bundle_path} #{repo_path}]) end def git_restore_hooks - execute(%W(#{Gitlab.config.gitlab_shell.path}/bin/create-hooks) + repository_storage_paths_args) + execute(%W[#{Gitlab.config.gitlab_shell.path}/bin/create-hooks] + repository_storage_paths_args) end private def tar_with_options(archive:, dir:, options:) - execute(%W(tar -#{options} #{archive} -C #{dir} .)) + execute(%W[tar -#{options} #{archive} -C #{dir} .]) end def untar_with_options(archive:, dir:, options:) - execute(%W(tar -#{options} #{archive} -C #{dir})) + execute(%W[tar -#{options} #{archive} -C #{dir}]) end def execute(cmd) diff --git a/lib/gitlab/key_fingerprint.rb b/lib/gitlab/key_fingerprint.rb index b75ae512d92..4d132f59627 100644 --- a/lib/gitlab/key_fingerprint.rb +++ b/lib/gitlab/key_fingerprint.rb @@ -39,7 +39,7 @@ module Gitlab # OpenSSH 6.8 introduces a new default output format for fingerprints. # Check the version and decide which command to use. - version_output, version_status = popen(%w(ssh -V)) + version_output, version_status = popen(%w[ssh -V]) return false unless version_status.zero? version_matches = version_output.match(/OpenSSH_(?<major>\d+)\.(?<minor>\d+)/) diff --git a/lib/gitlab/ldap/adapter.rb b/lib/gitlab/ldap/adapter.rb index 82cb8cef754..1a423729021 100644 --- a/lib/gitlab/ldap/adapter.rb +++ b/lib/gitlab/ldap/adapter.rb @@ -42,7 +42,7 @@ module Gitlab ldap_search(base: dn, filter: filter, scope: Net::LDAP::SearchScope_BaseObject, - attributes: %w{dn}).any? + attributes: %w[dn]).any? end def ldap_search(*args) @@ -100,7 +100,7 @@ module Gitlab end def user_attributes - %W(#{config.uid} cn mail dn) + %W[#{config.uid} cn mail dn] end end end diff --git a/lib/gitlab/logger.rb b/lib/gitlab/logger.rb index 59b21149a9a..e3dd271fb11 100644 --- a/lib/gitlab/logger.rb +++ b/lib/gitlab/logger.rb @@ -15,13 +15,13 @@ module Gitlab def self.read_latest path = Rails.root.join("log", file_name) self.build unless File.exist?(path) - tail_output, _ = Gitlab::Popen.popen(%W(tail -n 2000 #{path})) + tail_output, _ = Gitlab::Popen.popen(%W[tail -n 2000 #{path}]) tail_output.split("\n") end def self.read_latest_for(filename) path = Rails.root.join("log", filename) - tail_output, _ = Gitlab::Popen.popen(%W(tail -n 2000 #{path})) + tail_output, _ = Gitlab::Popen.popen(%W[tail -n 2000 #{path}]) tail_output.split("\n") end diff --git a/lib/gitlab/markdown/pipeline.rb b/lib/gitlab/markdown/pipeline.rb index 699d8b9fc07..afaa503c113 100644 --- a/lib/gitlab/markdown/pipeline.rb +++ b/lib/gitlab/markdown/pipeline.rb @@ -19,7 +19,7 @@ module Gitlab end class << self - %i(call to_document to_html).each do |meth| + %i[call to_document to_html].each do |meth| define_method(meth) do |text, context| context = transform_context(context) diff --git a/lib/gitlab/markup_helper.rb b/lib/gitlab/markup_helper.rb index dda371e6554..1582ea52cd7 100644 --- a/lib/gitlab/markup_helper.rb +++ b/lib/gitlab/markup_helper.rb @@ -10,8 +10,8 @@ module Gitlab def markup?(filename) gitlab_markdown?(filename) || asciidoc?(filename) || - filename.downcase.end_with?(*%w(.textile .rdoc .org .creole .wiki - .mediawiki .rst)) + filename.downcase.end_with?(*%w[.textile .rdoc .org .creole .wiki + .mediawiki .rst]) end # Public: Determines if a given filename is compatible with @@ -21,7 +21,7 @@ module Gitlab # # Returns boolean def gitlab_markdown?(filename) - filename.downcase.end_with?(*%w(.mdown .mkd .mkdn .md .markdown)) + filename.downcase.end_with?(*%w[.mdown .mkd .mkdn .md .markdown]) end # Public: Determines if the given filename has AsciiDoc extension. @@ -30,7 +30,7 @@ module Gitlab # # Returns boolean def asciidoc?(filename) - filename.downcase.end_with?(*%w(.adoc .ad .asciidoc)) + filename.downcase.end_with?(*%w[.adoc .ad .asciidoc]) end # Public: Determines if the given filename is plain text. diff --git a/lib/gitlab/reference_extractor.rb b/lib/gitlab/reference_extractor.rb index 11c0b01f0dc..0a0b1f76c6e 100644 --- a/lib/gitlab/reference_extractor.rb +++ b/lib/gitlab/reference_extractor.rb @@ -1,7 +1,7 @@ module Gitlab # Extract possible GFM references from an arbitrary String for further processing. class ReferenceExtractor < Banzai::ReferenceExtractor - REFERABLES = %i(user issue label milestone merge_request snippet commit commit_range) + REFERABLES = %i[user issue label milestone merge_request snippet commit commit_range] attr_accessor :project, :current_user, :author def initialize(project, current_user = nil) diff --git a/lib/gitlab/sidekiq_middleware/memory_killer.rb b/lib/gitlab/sidekiq_middleware/memory_killer.rb index 104280f520a..7ce33f59fe3 100644 --- a/lib/gitlab/sidekiq_middleware/memory_killer.rb +++ b/lib/gitlab/sidekiq_middleware/memory_killer.rb @@ -44,7 +44,7 @@ module Gitlab private def get_rss - output, status = Gitlab::Popen.popen(%W(ps -o rss= -p #{Process.pid})) + output, status = Gitlab::Popen.popen(%W[ps -o rss= -p #{Process.pid}]) return 0 unless status.zero? output.to_i diff --git a/spec/controllers/profiles/two_factor_auths_controller_spec.rb b/spec/controllers/profiles/two_factor_auths_controller_spec.rb index d08d0018b35..88c2281ad3c 100644 --- a/spec/controllers/profiles/two_factor_auths_controller_spec.rb +++ b/spec/controllers/profiles/two_factor_auths_controller_spec.rb @@ -48,11 +48,11 @@ describe Profiles::TwoFactorAuthsController do end it 'presents plaintext codes for the user to save' do - expect(user).to receive(:generate_otp_backup_codes!).and_return(%w(a b c)) + expect(user).to receive(:generate_otp_backup_codes!).and_return(%w[a b c]) go - expect(assigns[:codes]).to match_array %w(a b c) + expect(assigns[:codes]).to match_array %w[a b c] end it 'renders create' do @@ -90,10 +90,10 @@ describe Profiles::TwoFactorAuthsController do let(:user) { create(:user, :two_factor) } it 'presents plaintext codes for the user to save' do - expect(user).to receive(:generate_otp_backup_codes!).and_return(%w(a b c)) + expect(user).to receive(:generate_otp_backup_codes!).and_return(%w[a b c]) post :codes - expect(assigns[:codes]).to match_array %w(a b c) + expect(assigns[:codes]).to match_array %w[a b c] end it 'persists the generated codes' do diff --git a/spec/features/expand_collapse_diffs_spec.rb b/spec/features/expand_collapse_diffs_spec.rb index 8863554ee91..3b06bd9afa6 100644 --- a/spec/features/expand_collapse_diffs_spec.rb +++ b/spec/features/expand_collapse_diffs_spec.rb @@ -186,7 +186,7 @@ feature 'Expand and collapse diffs', js: true, feature: true do expect(page).to have_selector('.diff-content', count: 105) expect(page).to have_selector('.diff-collapsed', count: 5) - %w(file-95.txt file-96.txt file-97.txt file-98.txt file-99.txt).each do |filename| + %w[file-95.txt file-96.txt file-97.txt file-98.txt file-99.txt].each do |filename| expect(find("[data-blob-diff-path*='#{filename}']")).to have_selector('.diff-collapsed') end end @@ -202,7 +202,7 @@ feature 'Expand and collapse diffs', js: true, feature: true do expect(page).to have_selector('.diff-content', count: 6) expect(page).to have_selector('.diff-collapsed', count: 2) - %w(file-4.txt file-5.txt).each do |filename| + %w[file-4.txt file-5.txt].each do |filename| expect(find("[data-blob-diff-path*='#{filename}']")).to have_selector('.diff-collapsed') end end diff --git a/spec/features/markdown_spec.rb b/spec/features/markdown_spec.rb index 32159559c37..0f920e95f0c 100644 --- a/spec/features/markdown_spec.rb +++ b/spec/features/markdown_spec.rb @@ -151,13 +151,13 @@ describe 'GitLab Markdown', feature: true do it 'allows markup inside link elements' do aggregate_failures do expect(doc.at_css('a[href="#link-emphasis"]').to_html). - to eq %{<a href="#link-emphasis"><em>text</em></a>} + to eq %(<a href="#link-emphasis"><em>text</em></a>) expect(doc.at_css('a[href="#link-strong"]').to_html). - to eq %{<a href="#link-strong"><strong>text</strong></a>} + to eq %(<a href="#link-strong"><strong>text</strong></a>) expect(doc.at_css('a[href="#link-code"]').to_html). - to eq %{<a href="#link-code"><code>text</code></a>} + to eq %(<a href="#link-code"><code>text</code></a>) end end end diff --git a/spec/helpers/diff_helper_spec.rb b/spec/helpers/diff_helper_spec.rb index 9c7c79f57c6..211d12f0003 100644 --- a/spec/helpers/diff_helper_spec.rb +++ b/spec/helpers/diff_helper_spec.rb @@ -73,8 +73,8 @@ describe DiffHelper do end describe "#mark_inline_diffs" do - let(:old_line) { %{abc 'def'} } - let(:new_line) { %{abc "def"} } + let(:old_line) { %(abc 'def') } + let(:new_line) { %(abc "def") } it "returns strings with marked inline diffs" do marked_old_line, marked_new_line = mark_inline_diffs(old_line, new_line) diff --git a/spec/helpers/page_layout_helper_spec.rb b/spec/helpers/page_layout_helper_spec.rb index dc07657e101..47b8ab630d5 100644 --- a/spec/helpers/page_layout_helper_spec.rb +++ b/spec/helpers/page_layout_helper_spec.rb @@ -45,7 +45,7 @@ describe PageLayoutHelper do expect(helper.page_image).to end_with 'assets/gitlab_logo.png' end - %w(project user group).each do |type| + %w[project user group].each do |type| context "with @#{type} assigned" do it "uses #{type.titlecase} avatar if available" do object = double(avatar_url: 'http://example.com/uploads/avatar.png') @@ -100,11 +100,11 @@ describe PageLayoutHelper do it 'escapes content' do allow(helper).to receive(:page_card_attributes) - .and_return(foo: %q{foo" http-equiv="refresh}.html_safe) + .and_return(foo: %q(foo" http-equiv="refresh).html_safe) tags = helper.page_card_meta_tags - expect(tags).to include(%q{content="foo" http-equiv="refresh"}) + expect(tags).to include(%q(content="foo" http-equiv="refresh")) end end end diff --git a/spec/lib/banzai/filter/commit_range_reference_filter_spec.rb b/spec/lib/banzai/filter/commit_range_reference_filter_spec.rb index e6c90ad87ee..68f7b9996be 100644 --- a/spec/lib/banzai/filter/commit_range_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/commit_range_reference_filter_spec.rb @@ -14,7 +14,7 @@ describe Banzai::Filter::CommitRangeReferenceFilter, lib: true do expect { described_class.call('') }.to raise_error(ArgumentError, /:project/) end - %w(pre code a style).each do |elem| + %w[pre code a style].each do |elem| it "ignores valid references contained inside '#{elem}' element" do exp = act = "<#{elem}>Commit Range #{range.to_reference}</#{elem}>" expect(reference_filter(act).to_html).to eq exp @@ -95,7 +95,7 @@ describe Banzai::Filter::CommitRangeReferenceFilter, lib: true do doc = reference_filter("See #{reference}", only_path: true) link = doc.css('a').first.attr('href') - expect(link).not_to match %r(https?://) + expect(link).not_to match %r{https?://} expect(link).to eq urls.namespace_project_compare_url(project.namespace, project, from: commit1.id, to: commit2.id, only_path: true) end end diff --git a/spec/lib/banzai/filter/commit_reference_filter_spec.rb b/spec/lib/banzai/filter/commit_reference_filter_spec.rb index e0f08282551..e1363b65a61 100644 --- a/spec/lib/banzai/filter/commit_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/commit_reference_filter_spec.rb @@ -10,7 +10,7 @@ describe Banzai::Filter::CommitReferenceFilter, lib: true do expect { described_class.call('') }.to raise_error(ArgumentError, /:project/) end - %w(pre code a style).each do |elem| + %w[pre code a style].each do |elem| it "ignores valid references contained inside '#{elem}' element" do exp = act = "<#{elem}>Commit #{commit.id}</#{elem}>" expect(reference_filter(act).to_html).to eq exp @@ -59,7 +59,7 @@ describe Banzai::Filter::CommitReferenceFilter, lib: true do end it 'escapes the title attribute' do - allow_any_instance_of(Commit).to receive(:title).and_return(%{"></a>whatever<a title="}) + allow_any_instance_of(Commit).to receive(:title).and_return(%("></a>whatever<a title=")) doc = reference_filter("See #{reference}") expect(doc.text).to eq "See #{commit.short_id}" @@ -90,7 +90,7 @@ describe Banzai::Filter::CommitReferenceFilter, lib: true do doc = reference_filter("See #{reference}", only_path: true) link = doc.css('a').first.attr('href') - expect(link).not_to match %r(https?://) + expect(link).not_to match %r{https?://} expect(link).to eq urls.namespace_project_commit_url(project.namespace, project, reference, only_path: true) end end diff --git a/spec/lib/banzai/filter/external_issue_reference_filter_spec.rb b/spec/lib/banzai/filter/external_issue_reference_filter_spec.rb index 7116c09fb21..680f522bcc3 100644 --- a/spec/lib/banzai/filter/external_issue_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/external_issue_reference_filter_spec.rb @@ -17,7 +17,7 @@ describe Banzai::Filter::ExternalIssueReferenceFilter, lib: true do expect { described_class.call('') }.to raise_error(ArgumentError, /:project/) end - %w(pre code a style).each do |elem| + %w[pre code a style].each do |elem| it "ignores valid references contained inside '#{elem}' element" do exp = act = "<#{elem}>Issue #{reference}</#{elem}>" expect(filter(act).to_html).to eq exp @@ -56,7 +56,7 @@ describe Banzai::Filter::ExternalIssueReferenceFilter, lib: true do it 'escapes the title attribute' do allow(project.external_issue_tracker).to receive(:title). - and_return(%{"></a>whatever<a title="}) + and_return(%("></a>whatever<a title=")) doc = filter("Issue #{reference}") expect(doc.text).to eq "Issue #{reference}" diff --git a/spec/lib/banzai/filter/issue_reference_filter_spec.rb b/spec/lib/banzai/filter/issue_reference_filter_spec.rb index fce86a9b6ad..230ded555cc 100644 --- a/spec/lib/banzai/filter/issue_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/issue_reference_filter_spec.rb @@ -14,7 +14,7 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do expect { described_class.call('') }.to raise_error(ArgumentError, /:project/) end - %w(pre code a style).each do |elem| + %w[pre code a style].each do |elem| it "ignores valid references contained inside '#{elem}' element" do exp = act = "<#{elem}>Issue #{issue.to_reference}</#{elem}>" expect(reference_filter(act).to_html).to eq exp @@ -58,7 +58,7 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do end it 'escapes the title attribute' do - issue.update_attribute(:title, %{"></a>whatever<a title="}) + issue.update_attribute(:title, %("></a>whatever<a title=")) doc = reference_filter("Issue #{reference}") expect(doc.text).to eq "Issue #{reference}" @@ -89,7 +89,7 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do doc = reference_filter("Issue #{reference}", only_path: true) link = doc.css('a').first.attr('href') - expect(link).not_to match %r(https?://) + expect(link).not_to match %r{https?://} expect(link).to eq helper.url_for_issue(issue.iid, project, only_path: true) end @@ -165,7 +165,7 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do let(:namespace) { create(:namespace, name: 'cross-reference') } let(:project2) { create(:empty_project, :public, namespace: namespace) } let(:issue) { create(:issue, project: project2) } - let(:reference) { %Q{<a href="#{issue.to_reference(project)}">Reference</a>} } + let(:reference) { %Q(<a href="#{issue.to_reference(project)}">Reference</a>) } it 'links to a valid reference' do doc = reference_filter("See #{reference}") @@ -184,7 +184,7 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do let(:namespace) { create(:namespace, name: 'cross-reference') } let(:project2) { create(:empty_project, :public, namespace: namespace) } let(:issue) { create(:issue, project: project2) } - let(:reference) { %Q{<a href="#{helper.url_for_issue(issue.iid, project2) + "#note_123"}">Reference</a>} } + let(:reference) { %Q(<a href="#{helper.url_for_issue(issue.iid, project2) + "#note_123"}">Reference</a>) } it 'links to a valid reference' do doc = reference_filter("See #{reference}") diff --git a/spec/lib/banzai/filter/label_reference_filter_spec.rb b/spec/lib/banzai/filter/label_reference_filter_spec.rb index 908ccebbf87..515742add09 100644 --- a/spec/lib/banzai/filter/label_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/label_reference_filter_spec.rb @@ -12,7 +12,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do expect { described_class.call('') }.to raise_error(ArgumentError, /:project/) end - %w(pre code a style).each do |elem| + %w[pre code a style].each do |elem| it "ignores valid references contained inside '#{elem}' element" do exp = act = "<#{elem}>Label #{reference}</#{elem}>" expect(reference_filter(act).to_html).to eq exp @@ -44,7 +44,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do doc = reference_filter("Label #{reference}", only_path: true) link = doc.css('a').first.attr('href') - expect(link).not_to match %r(https?://) + expect(link).not_to match %r{https?://} expect(link).to eq urls.namespace_project_issues_path(project.namespace, project, label_name: label.name) end @@ -70,7 +70,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links with adjacent text' do doc = reference_filter("Label (#{reference}.)") - expect(doc.to_html).to match(%r(\(<a.+><span.+>#{label.name}</span></a>\.\))) + expect(doc.to_html).to match(%r{\(<a.+><span.+>#{label.name}</span></a>\.\)}) end it 'ignores invalid label IDs' do @@ -94,7 +94,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links with adjacent text' do doc = reference_filter("Label (#{reference}).") - expect(doc.to_html).to match(%r(\(<a.+><span.+>#{label.name}</span></a>\)\.)) + expect(doc.to_html).to match(%r{\(<a.+><span.+>#{label.name}</span></a>\)\.}) end it 'ignores invalid label names' do @@ -118,7 +118,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links with adjacent text' do doc = reference_filter("Label (#{reference}).") - expect(doc.to_html).to match(%r(\(<a.+><span.+>#{label.name}</span></a>\)\.)) + expect(doc.to_html).to match(%r{\(<a.+><span.+>#{label.name}</span></a>\)\.}) end it 'ignores invalid label names' do @@ -142,7 +142,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links with adjacent text' do doc = reference_filter("Label (#{reference}).") - expect(doc.to_html).to match(%r(\(<a.+><span.+>\?g\.fm&</span></a>\)\.)) + expect(doc.to_html).to match(%r{\(<a.+><span.+>\?g\.fm&</span></a>\)\.}) end it 'ignores invalid label names' do @@ -167,7 +167,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links with adjacent text' do doc = reference_filter("Label (#{reference}.)") - expect(doc.to_html).to match(%r(\(<a.+><span.+>#{label.name}</span></a>\.\))) + expect(doc.to_html).to match(%r{\(<a.+><span.+>#{label.name}</span></a>\.\)}) end it 'ignores invalid label names' do @@ -191,7 +191,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links with adjacent text' do doc = reference_filter("Label (#{reference}.)") - expect(doc.to_html).to match(%r(\(<a.+><span.+>#{label.name}</span></a>\.\))) + expect(doc.to_html).to match(%r{\(<a.+><span.+>#{label.name}</span></a>\.\)}) end it 'ignores invalid label names' do @@ -215,7 +215,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links with adjacent text' do doc = reference_filter("Label (#{reference}.)") - expect(doc.to_html).to match(%r(\(<a.+><span.+>g\.fm & references\?</span></a>\.\))) + expect(doc.to_html).to match(%r{\(<a.+><span.+>g\.fm & references\?</span></a>\.\)}) end it 'ignores invalid label names' do @@ -274,7 +274,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do end describe 'referencing a label in a link href' do - let(:reference) { %Q{<a href="#{label.to_reference}">Label</a>} } + let(:reference) { %Q(<a href="#{label.to_reference}">Label</a>) } it 'links to a valid reference' do doc = reference_filter("See #{reference}") @@ -285,7 +285,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links with adjacent text' do doc = reference_filter("Label (#{reference}.)") - expect(doc.to_html).to match(%r(\(<a.+>Label</a>\.\))) + expect(doc.to_html).to match(%r{\(<a.+>Label</a>\.\)}) end it 'includes a data-project attribute' do diff --git a/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb b/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb index 274258a045c..257b23fd270 100644 --- a/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb @@ -10,7 +10,7 @@ describe Banzai::Filter::MergeRequestReferenceFilter, lib: true do expect { described_class.call('') }.to raise_error(ArgumentError, /:project/) end - %w(pre code a style).each do |elem| + %w[pre code a style].each do |elem| it "ignores valid references contained inside '#{elem}' element" do exp = act = "<#{elem}>Merge #{merge.to_reference}</#{elem}>" expect(reference_filter(act).to_html).to eq exp @@ -50,7 +50,7 @@ describe Banzai::Filter::MergeRequestReferenceFilter, lib: true do end it 'escapes the title attribute' do - merge.update_attribute(:title, %{"></a>whatever<a title="}) + merge.update_attribute(:title, %("></a>whatever<a title=")) doc = reference_filter("Merge #{reference}") expect(doc.text).to eq "Merge #{reference}" @@ -81,7 +81,7 @@ describe Banzai::Filter::MergeRequestReferenceFilter, lib: true do doc = reference_filter("Merge #{reference}", only_path: true) link = doc.css('a').first.attr('href') - expect(link).not_to match %r(https?://) + expect(link).not_to match %r{https?://} expect(link).to eq urls.namespace_project_merge_request_url(project.namespace, project, merge, only_path: true) end end diff --git a/spec/lib/banzai/filter/milestone_reference_filter_spec.rb b/spec/lib/banzai/filter/milestone_reference_filter_spec.rb index 7419863d848..26e4888b32d 100644 --- a/spec/lib/banzai/filter/milestone_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/milestone_reference_filter_spec.rb @@ -11,7 +11,7 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do expect { described_class.call('') }.to raise_error(ArgumentError, /:project/) end - %w(pre code a style).each do |elem| + %w[pre code a style].each do |elem| it "ignores valid references contained inside '#{elem}' element" do exp = act = "<#{elem}>milestone #{milestone.to_reference}</#{elem}>" expect(reference_filter(act).to_html).to eq exp @@ -43,7 +43,7 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do doc = reference_filter("Milestone #{reference}", only_path: true) link = doc.css('a').first.attr('href') - expect(link).not_to match %r(https?://) + expect(link).not_to match %r{https?://} expect(link).to eq urls. namespace_project_milestone_path(project.namespace, project, milestone) end @@ -58,7 +58,7 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do it 'links with adjacent text' do doc = reference_filter("Milestone (#{reference}.)") - expect(doc.to_html).to match(%r(\(<a.+>#{milestone.name}</a>\.\))) + expect(doc.to_html).to match(%r{\(<a.+>#{milestone.name}</a>\.\)}) end it 'ignores invalid milestone IIDs' do @@ -82,7 +82,7 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do it 'links with adjacent text' do doc = reference_filter("Milestone (#{reference}.)") - expect(doc.to_html).to match(%r(\(<a.+>#{milestone.name}</a>\.\))) + expect(doc.to_html).to match(%r{\(<a.+>#{milestone.name}</a>\.\)}) end it 'ignores invalid milestone names' do @@ -106,7 +106,7 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do it 'links with adjacent text' do doc = reference_filter("Milestone (#{reference}.)") - expect(doc.to_html).to match(%r(\(<a.+>#{milestone.name}</a>\.\))) + expect(doc.to_html).to match(%r{\(<a.+>#{milestone.name}</a>\.\)}) end it 'ignores invalid milestone names' do @@ -117,7 +117,7 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do end describe 'referencing a milestone in a link href' do - let(:reference) { %Q{<a href="#{milestone.to_reference}">Milestone</a>} } + let(:reference) { %Q(<a href="#{milestone.to_reference}">Milestone</a>) } it 'links to a valid reference' do doc = reference_filter("See #{reference}") @@ -128,7 +128,7 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do it 'links with adjacent text' do doc = reference_filter("Milestone (#{reference}.)") - expect(doc.to_html).to match(%r(\(<a.+>Milestone</a>\.\))) + expect(doc.to_html).to match(%r{\(<a.+>Milestone</a>\.\)}) end it 'includes a data-project attribute' do @@ -168,7 +168,7 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do end it 'escapes the name attribute' do - allow_any_instance_of(Milestone).to receive(:title).and_return(%{"></a>whatever<a title="}) + allow_any_instance_of(Milestone).to receive(:title).and_return(%("></a>whatever<a title=")) doc = reference_filter("See #{reference}") expect(doc.css('a').first.text).to eq "#{milestone.name} in #{project_path}" end diff --git a/spec/lib/banzai/filter/sanitization_filter_spec.rb b/spec/lib/banzai/filter/sanitization_filter_spec.rb index b38e3b17e64..48e10853677 100644 --- a/spec/lib/banzai/filter/sanitization_filter_spec.rb +++ b/spec/lib/banzai/filter/sanitization_filter_spec.rb @@ -5,14 +5,14 @@ describe Banzai::Filter::SanitizationFilter, lib: true do describe 'default whitelist' do it 'sanitizes tags that are not whitelisted' do - act = %q{<textarea>no inputs</textarea> and <blink>no blinks</blink>} + act = %q(<textarea>no inputs</textarea> and <blink>no blinks</blink>) exp = 'no inputs and no blinks' expect(filter(act).to_html).to eq exp end it 'sanitizes tag attributes' do - act = %q{<a href="http://example.com/bar.html" onclick="bar">Text</a>} - exp = %q{<a href="http://example.com/bar.html">Text</a>} + act = %q(<a href="http://example.com/bar.html" onclick="bar">Text</a>) + exp = %q(<a href="http://example.com/bar.html">Text</a>) expect(filter(act).to_html).to eq exp end @@ -34,13 +34,13 @@ describe Banzai::Filter::SanitizationFilter, lib: true do end it 'sanitizes `class` attribute on any element' do - act = %q{<strong class="foo">Strong</strong>} - expect(filter(act).to_html).to eq %q{<strong>Strong</strong>} + act = %q(<strong class="foo">Strong</strong>) + expect(filter(act).to_html).to eq %q(<strong>Strong</strong>) end it 'sanitizes `id` attribute on any element' do - act = %q{<em id="foo">Emphasis</em>} - expect(filter(act).to_html).to eq %q{<em>Emphasis</em>} + act = %q(<em id="foo">Emphasis</em>) + expect(filter(act).to_html).to eq %q(<em>Emphasis</em>) end end @@ -53,13 +53,13 @@ describe Banzai::Filter::SanitizationFilter, lib: true do end it 'allows syntax highlighting' do - exp = act = %q{<pre class="code highlight white c"><code><span class="k">def</span></code></pre>} + exp = act = %q(<pre class="code highlight white c"><code><span class="k">def</span></code></pre>) expect(filter(act).to_html).to eq exp end it 'sanitizes `class` attribute from non-highlight spans' do - act = %q{<span class="k">def</span>} - expect(filter(act).to_html).to eq %q{<span>def</span>} + act = %q(<span class="k">def</span>) + expect(filter(act).to_html).to eq %q(<span>def</span>) end it 'allows `style` attribute on table elements' do @@ -77,18 +77,18 @@ describe Banzai::Filter::SanitizationFilter, lib: true do end it 'allows `span` elements' do - exp = act = %q{<span>Hello</span>} + exp = act = %q(<span>Hello</span>) expect(filter(act).to_html).to eq exp end it 'allows `abbr` elements' do - exp = act = %q{<abbr title="HyperText Markup Language">HTML</abbr>} + exp = act = %q(<abbr title="HyperText Markup Language">HTML</abbr>) expect(filter(act).to_html).to eq exp end it 'removes `rel` attribute from `a` elements' do - act = %q{<a href="#" rel="nofollow">Link</a>} - exp = %q{<a href="#">Link</a>} + act = %q(<a href="#" rel="nofollow">Link</a>) + exp = %q(<a href="#">Link</a>) expect(filter(act).to_html).to eq exp end @@ -204,14 +204,14 @@ describe Banzai::Filter::SanitizationFilter, lib: true do end it 'allows non-standard anchor schemes' do - exp = %q{<a href="irc://irc.freenode.net/git">IRC</a>} + exp = %q(<a href="irc://irc.freenode.net/git">IRC</a>) act = filter(exp) expect(act.to_html).to eq exp end it 'allows relative links' do - exp = %q{<a href="foo/bar.md">foo/bar.md</a>} + exp = %q(<a href="foo/bar.md">foo/bar.md</a>) act = filter(exp) expect(act.to_html).to eq exp diff --git a/spec/lib/banzai/filter/snippet_reference_filter_spec.rb b/spec/lib/banzai/filter/snippet_reference_filter_spec.rb index 9b92d1a3926..981759e962c 100644 --- a/spec/lib/banzai/filter/snippet_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/snippet_reference_filter_spec.rb @@ -11,7 +11,7 @@ describe Banzai::Filter::SnippetReferenceFilter, lib: true do expect { described_class.call('') }.to raise_error(ArgumentError, /:project/) end - %w(pre code a style).each do |elem| + %w[pre code a style].each do |elem| it "ignores valid references contained inside '#{elem}' element" do exp = act = "<#{elem}>Snippet #{reference}</#{elem}>" expect(reference_filter(act).to_html).to eq exp @@ -43,7 +43,7 @@ describe Banzai::Filter::SnippetReferenceFilter, lib: true do end it 'escapes the title attribute' do - snippet.update_attribute(:title, %{"></a>whatever<a title="}) + snippet.update_attribute(:title, %("></a>whatever<a title=")) doc = reference_filter("Snippet #{reference}") expect(doc.text).to eq "Snippet #{reference}" @@ -74,7 +74,7 @@ describe Banzai::Filter::SnippetReferenceFilter, lib: true do doc = reference_filter("Snippet #{reference}", only_path: true) link = doc.css('a').first.attr('href') - expect(link).not_to match %r(https?://) + expect(link).not_to match %r{https?://} expect(link).to eq urls.namespace_project_snippet_url(project.namespace, project, snippet, only_path: true) end end diff --git a/spec/lib/banzai/filter/user_reference_filter_spec.rb b/spec/lib/banzai/filter/user_reference_filter_spec.rb index fdbdb21eac1..4f34b21eee0 100644 --- a/spec/lib/banzai/filter/user_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/user_reference_filter_spec.rb @@ -16,7 +16,7 @@ describe Banzai::Filter::UserReferenceFilter, lib: true do expect(reference_filter(act).to_html).to eq(exp) end - %w(pre code a style).each do |elem| + %w[pre code a style].each do |elem| it "ignores valid references contained inside '#{elem}' element" do exp = act = "<#{elem}>Hey #{reference}</#{elem}>" expect(reference_filter(act).to_html).to eq exp @@ -111,12 +111,12 @@ describe Banzai::Filter::UserReferenceFilter, lib: true do doc = reference_filter("Hey #{reference}", only_path: true) link = doc.css('a').first.attr('href') - expect(link).not_to match %r(https?://) + expect(link).not_to match %r{https?://} expect(link).to eq urls.user_path(user) end context 'referencing a user in a link href' do - let(:reference) { %Q{<a href="#{user.to_reference}">User</a>} } + let(:reference) { %Q(<a href="#{user.to_reference}">User</a>) } it 'links to a User' do doc = reference_filter("Hey #{reference}") diff --git a/spec/lib/banzai/filter_array_spec.rb b/spec/lib/banzai/filter_array_spec.rb index ea84005e7f8..2ba2bd18937 100644 --- a/spec/lib/banzai/filter_array_spec.rb +++ b/spec/lib/banzai/filter_array_spec.rb @@ -3,37 +3,37 @@ require 'spec_helper' describe Banzai::FilterArray do describe '#insert_after' do it 'inserts an element after a provided element' do - filters = described_class.new(%w(a b c)) + filters = described_class.new(%w[a b c]) filters.insert_after('b', '1') - expect(filters).to eq %w(a b 1 c) + expect(filters).to eq %w[a b 1 c] end it 'inserts an element at the end when the provided element does not exist' do - filters = described_class.new(%w(a b c)) + filters = described_class.new(%w[a b c]) filters.insert_after('d', '1') - expect(filters).to eq %w(a b c 1) + expect(filters).to eq %w[a b c 1] end end describe '#insert_before' do it 'inserts an element before a provided element' do - filters = described_class.new(%w(a b c)) + filters = described_class.new(%w[a b c]) filters.insert_before('b', '1') - expect(filters).to eq %w(a 1 b c) + expect(filters).to eq %w[a 1 b c] end it 'inserts an element at the beginning when the provided element does not exist' do - filters = described_class.new(%w(a b c)) + filters = described_class.new(%w[a b c]) filters.insert_before('d', '1') - expect(filters).to eq %w(1 a b c) + expect(filters).to eq %w[1 a b c] end end end diff --git a/spec/lib/banzai/pipeline/description_pipeline_spec.rb b/spec/lib/banzai/pipeline/description_pipeline_spec.rb index 76f42071810..87b23cf04ca 100644 --- a/spec/lib/banzai/pipeline/description_pipeline_spec.rb +++ b/spec/lib/banzai/pipeline/description_pipeline_spec.rb @@ -19,7 +19,7 @@ describe Banzai::Pipeline::DescriptionPipeline do expect(doc.strip).to eq 'Description' end - %w(pre code img ol ul li).each do |elem| + %w[pre code img ol ul li].each do |elem| it "removes '#{elem}' elements" do act = "<#{elem}>Description</#{elem}>" @@ -27,7 +27,7 @@ describe Banzai::Pipeline::DescriptionPipeline do end end - %w(b i strong em a ins del sup sub p).each do |elem| + %w[b i strong em a ins del sup sub p].each do |elem| it "still allows '#{elem}' elements" do exp = act = "<#{elem}>Description</#{elem}>" diff --git a/spec/lib/banzai/reference_parser/commit_parser_spec.rb b/spec/lib/banzai/reference_parser/commit_parser_spec.rb index 0b76d29fce0..92cf90f14dd 100644 --- a/spec/lib/banzai/reference_parser/commit_parser_spec.rb +++ b/spec/lib/banzai/reference_parser/commit_parser_spec.rb @@ -100,14 +100,14 @@ describe Banzai::ReferenceParser::CommitParser, lib: true do expect(project).to receive(:commit).with('123').and_return(commit) expect(project).to receive(:valid_repo?).and_return(true) - expect(subject.find_commits(project, %w{123})).to eq([commit]) + expect(subject.find_commits(project, %w[123])).to eq([commit]) end it 'skips commit IDs for which no commit could be found' do expect(project).to receive(:commit).with('123').and_return(nil) expect(project).to receive(:valid_repo?).and_return(true) - expect(subject.find_commits(project, %w{123})).to eq([]) + expect(subject.find_commits(project, %w[123])).to eq([]) end end end diff --git a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb index 6dedd25e9d3..b0961434840 100644 --- a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb +++ b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb @@ -592,7 +592,7 @@ module Ci end describe "When" do - %w(on_success on_failure always).each do |when_state| + %w[on_success on_failure always].each do |when_state| it "returns #{when_state} when defined" do config = YAML.dump({ rspec: { script: "rspec", when: when_state } diff --git a/spec/lib/gitlab/diff/highlight_spec.rb b/spec/lib/gitlab/diff/highlight_spec.rb index 1c2ddeed692..efe92290ba3 100644 --- a/spec/lib/gitlab/diff/highlight_spec.rb +++ b/spec/lib/gitlab/diff/highlight_spec.rb @@ -28,13 +28,13 @@ describe Gitlab::Diff::Highlight, lib: true do end it 'highlights and marks removed lines' do - code = %Q{-<span id="LC9" class="line"> <span class="k">raise</span> <span class="s2">"System commands must be given as an array of strings"</span></span>\n} + code = %Q(-<span id="LC9" class="line"> <span class="k">raise</span> <span class="s2">"System commands must be given as an array of strings"</span></span>\n) expect(subject[4].text).to eq(code) end it 'highlights and marks added lines' do - code = %Q{+<span id="LC9" class="line"> <span class="k">raise</span> <span class="no"><span class='idiff left'>RuntimeError</span></span><span class="p"><span class='idiff'>,</span></span><span class='idiff right'> </span><span class="s2">"System commands must be given as an array of strings"</span></span>\n} + code = %Q(+<span id="LC9" class="line"> <span class="k">raise</span> <span class="no"><span class='idiff left'>RuntimeError</span></span><span class="p"><span class='idiff'>,</span></span><span class='idiff right'> </span><span class="s2">"System commands must be given as an array of strings"</span></span>\n) expect(subject[5].text).to eq(code) end @@ -60,14 +60,14 @@ describe Gitlab::Diff::Highlight, lib: true do end it 'marks removed lines' do - code = %Q{- raise "System commands must be given as an array of strings"} + code = %Q(- raise "System commands must be given as an array of strings") expect(subject[4].text).to eq(code) expect(subject[4].text).not_to be_html_safe end it 'marks added lines' do - code = %Q{+ raise <span class='idiff left right'>RuntimeError, </span>"System commands must be given as an array of strings"} + code = %Q(+ raise <span class='idiff left right'>RuntimeError, </span>"System commands must be given as an array of strings") expect(subject[5].text).to eq(code) expect(subject[5].text).to be_html_safe diff --git a/spec/lib/gitlab/diff/inline_diff_marker_spec.rb b/spec/lib/gitlab/diff/inline_diff_marker_spec.rb index 198ff977f24..313735fdc0c 100644 --- a/spec/lib/gitlab/diff/inline_diff_marker_spec.rb +++ b/spec/lib/gitlab/diff/inline_diff_marker_spec.rb @@ -4,12 +4,12 @@ describe Gitlab::Diff::InlineDiffMarker, lib: true do describe '#inline_diffs' do context "when the rich text is html safe" do let(:raw) { "abc 'def'" } - let(:rich) { %{<span class="abc">abc</span><span class="space"> </span><span class="def">'def'</span>}.html_safe } + let(:rich) { %(<span class="abc">abc</span><span class="space"> </span><span class="def">'def'</span>).html_safe } let(:inline_diffs) { [2..5] } let(:subject) { Gitlab::Diff::InlineDiffMarker.new(raw, rich).mark(inline_diffs) } it 'marks the inline diffs' do - expect(subject).to eq(%{<span class="abc">ab<span class='idiff left'>c</span></span><span class="space"><span class='idiff'> </span></span><span class="def"><span class='idiff right'>'d</span>ef'</span>}) + expect(subject).to eq(%(<span class="abc">ab<span class='idiff left'>c</span></span><span class="space"><span class='idiff'> </span></span><span class="def"><span class='idiff right'>'d</span>ef'</span>)) expect(subject).to be_html_safe end end @@ -20,7 +20,7 @@ describe Gitlab::Diff::InlineDiffMarker, lib: true do let(:subject) { Gitlab::Diff::InlineDiffMarker.new(raw).mark(inline_diffs) } it 'marks the inline diffs' do - expect(subject).to eq(%{ab<span class='idiff left right'>c 'd</span>ef'}) + expect(subject).to eq(%(ab<span class='idiff left right'>c 'd</span>ef')) expect(subject).to be_html_safe end end diff --git a/spec/lib/gitlab/gfm/reference_rewriter_spec.rb b/spec/lib/gitlab/gfm/reference_rewriter_spec.rb index 0af249d8690..e705c8b5667 100644 --- a/spec/lib/gitlab/gfm/reference_rewriter_spec.rb +++ b/spec/lib/gitlab/gfm/reference_rewriter_spec.rb @@ -68,12 +68,12 @@ describe Gitlab::Gfm::ReferenceRewriter do context 'label referenced by id' do let(:text) { '#1 and ~123' } - it { is_expected.to eq %Q{#{project_ref}#1 and #{project_ref}~123} } + it { is_expected.to eq %Q(#{project_ref}#1 and #{project_ref}~123) } end context 'label referenced by text' do let(:text) { '#1 and ~"test"' } - it { is_expected.to eq %Q{#{project_ref}#1 and #{project_ref}~123} } + it { is_expected.to eq %Q(#{project_ref}#1 and #{project_ref}~123) } end end end diff --git a/spec/lib/gitlab/google_code_import/importer_spec.rb b/spec/lib/gitlab/google_code_import/importer_spec.rb index 54f85f8cffc..3d5c3aa3f31 100644 --- a/spec/lib/gitlab/google_code_import/importer_spec.rb +++ b/spec/lib/gitlab/google_code_import/importer_spec.rb @@ -22,7 +22,7 @@ describe Gitlab::GoogleCodeImport::Importer, lib: true do it "imports status labels" do subject.execute - %w(New NeedInfo Accepted Wishlist Started Fixed Invalid Duplicate WontFix Incomplete).each do |status| + %w[New NeedInfo Accepted Wishlist Started Fixed Invalid Duplicate WontFix Incomplete].each do |status| expect(project.labels.find_by(name: "Status: #{status}")).not_to be_nil end end @@ -30,12 +30,12 @@ describe Gitlab::GoogleCodeImport::Importer, lib: true do it "imports labels" do subject.execute - %w( + %w[ Type-Defect Type-Enhancement Type-Task Type-Review Type-Other Milestone-0.12 Priority-Critical Priority-High Priority-Medium Priority-Low OpSys-All OpSys-Windows OpSys-Linux OpSys-OSX Security Performance Usability Maintainability Component-Panel Component-Taskbar Component-Battery Component-Systray Component-Clock Component-Launcher Component-Tint2conf Component-Docs Component-New - ).each do |label| + ].each do |label| label.sub!("-", ": ") expect(project.labels.find_by(name: label)).not_to be_nil end diff --git a/spec/lib/gitlab/highlight_spec.rb b/spec/lib/gitlab/highlight_spec.rb index fc021416d92..87dc3792416 100644 --- a/spec/lib/gitlab/highlight_spec.rb +++ b/spec/lib/gitlab/highlight_spec.rb @@ -13,9 +13,9 @@ describe Gitlab::Highlight, lib: true do end it 'should properly highlight all the lines' do - expect(lines[4]).to eq(%Q{<span id="LC5" class="line"> <span class="kp">extend</span> <span class="nb">self</span></span>\n}) + expect(lines[4]).to eq(%Q(<span id="LC5" class="line"> <span class="kp">extend</span> <span class="nb">self</span></span>\n)) expect(lines[21]).to eq(%Q{<span id="LC22" class="line"> <span class="k">unless</span> <span class="no">File</span><span class="p">.</span><span class="nf">directory?</span><span class="p">(</span><span class="n">path</span><span class="p">)</span></span>\n}) - expect(lines[26]).to eq(%Q{<span id="LC27" class="line"> <span class="vi">@cmd_status</span> <span class="o">=</span> <span class="mi">0</span></span>\n}) + expect(lines[26]).to eq(%Q(<span id="LC27" class="line"> <span class="vi">@cmd_status</span> <span class="o">=</span> <span class="mi">0</span></span>\n)) end describe 'with CRLF' do diff --git a/spec/lib/gitlab/ldap/adapter_spec.rb b/spec/lib/gitlab/ldap/adapter_spec.rb index 0600893f4cf..458d6f5cc24 100644 --- a/spec/lib/gitlab/ldap/adapter_spec.rb +++ b/spec/lib/gitlab/ldap/adapter_spec.rb @@ -16,7 +16,7 @@ describe Gitlab::LDAP::Adapter, lib: true do expect(adapter).to receive(:ldap_search) do |arg| expect(arg[:filter].to_s).to eq('(uid=johndoe)') expect(arg[:base]).to eq('dc=example,dc=com') - expect(arg[:attributes]).to match(%w{uid cn mail dn}) + expect(arg[:attributes]).to match(%w[uid cn mail dn]) end.and_return({}) adapter.users('uid', 'johndoe') @@ -26,7 +26,7 @@ describe Gitlab::LDAP::Adapter, lib: true do expect(adapter).to receive(:ldap_search).with( base: 'uid=johndoe,ou=users,dc=example,dc=com', scope: Net::LDAP::SearchScope_BaseObject, - attributes: %w{uid cn mail dn}, + attributes: %w[uid cn mail dn], filter: nil ).and_return({}) @@ -63,7 +63,7 @@ describe Gitlab::LDAP::Adapter, lib: true do it 'uses the right uid attribute when non-default' do stub_ldap_config(uid: 'sAMAccountName') expect(adapter).to receive(:ldap_search).with( - hash_including(attributes: %w{sAMAccountName cn mail dn}) + hash_including(attributes: %w[sAMAccountName cn mail dn]) ).and_return({}) adapter.users('sAMAccountName', 'johndoe') diff --git a/spec/lib/gitlab/markup_helper_spec.rb b/spec/lib/gitlab/markup_helper_spec.rb index 93b91b849f2..6af6d50439c 100644 --- a/spec/lib/gitlab/markup_helper_spec.rb +++ b/spec/lib/gitlab/markup_helper_spec.rb @@ -2,8 +2,8 @@ require 'spec_helper' describe Gitlab::MarkupHelper, lib: true do describe '#markup?' do - %w(textile rdoc org creole wiki - mediawiki rst adoc ad asciidoc mdown md markdown).each do |type| + %w[textile rdoc org creole wiki + mediawiki rst adoc ad asciidoc mdown md markdown].each do |type| it "returns true for #{type} files" do expect(Gitlab::MarkupHelper.markup?("README.#{type}")).to be_truthy end @@ -15,7 +15,7 @@ describe Gitlab::MarkupHelper, lib: true do end describe '#gitlab_markdown?' do - %w(mdown mkd mkdn md markdown).each do |type| + %w[mdown mkd mkdn md markdown].each do |type| it "returns true for #{type} files" do expect(Gitlab::MarkupHelper.gitlab_markdown?("README.#{type}")).to be_truthy end @@ -27,7 +27,7 @@ describe Gitlab::MarkupHelper, lib: true do end describe '#asciidoc?' do - %w(adoc ad asciidoc ADOC).each do |type| + %w[adoc ad asciidoc ADOC].each do |type| it "returns true for #{type} files" do expect(Gitlab::MarkupHelper.asciidoc?("README.#{type}")).to be_truthy end diff --git a/spec/lib/gitlab/o_auth/user_spec.rb b/spec/lib/gitlab/o_auth/user_spec.rb index 78c669e8fa5..2582c71ec1f 100644 --- a/spec/lib/gitlab/o_auth/user_spec.rb +++ b/spec/lib/gitlab/o_auth/user_spec.rb @@ -129,7 +129,7 @@ describe Gitlab::OAuth::User, lib: true do end context "and at least one LDAP provider is defined" do - before { stub_ldap_config(providers: %w(ldapmain)) } + before { stub_ldap_config(providers: %w[ldapmain]) } context "and a corresponding LDAP person" do before do diff --git a/spec/lib/gitlab/popen_spec.rb b/spec/lib/gitlab/popen_spec.rb index 4ae216d55b0..f0a4f6a35a8 100644 --- a/spec/lib/gitlab/popen_spec.rb +++ b/spec/lib/gitlab/popen_spec.rb @@ -10,7 +10,7 @@ describe 'Gitlab::Popen', lib: true, no_db: true do context 'zero status' do before do - @output, @status = @klass.new.popen(%w(ls), path) + @output, @status = @klass.new.popen(%w[ls], path) end it { expect(@status).to be_zero } @@ -19,7 +19,7 @@ describe 'Gitlab::Popen', lib: true, no_db: true do context 'non-zero status' do before do - @output, @status = @klass.new.popen(%w(cat NOTHING), path) + @output, @status = @klass.new.popen(%w[cat NOTHING], path) end it { expect(@status).to eq(1) } @@ -34,7 +34,7 @@ describe 'Gitlab::Popen', lib: true, no_db: true do context 'without a directory argument' do before do - @output, @status = @klass.new.popen(%w(ls)) + @output, @status = @klass.new.popen(%w[ls]) end it { expect(@status).to be_zero } diff --git a/spec/lib/gitlab/reference_extractor_spec.rb b/spec/lib/gitlab/reference_extractor_spec.rb index 7b4ccc83915..f77519d2401 100644 --- a/spec/lib/gitlab/reference_extractor_spec.rb +++ b/spec/lib/gitlab/reference_extractor_spec.rb @@ -25,7 +25,7 @@ describe Gitlab::ReferenceExtractor, lib: true do project.team << [@u_foo, :reporter] project.team << [@u_bar, :guest] - subject.analyze(%Q{ + subject.analyze(%Q( Inline code: `@foo` Code block: @@ -37,7 +37,7 @@ describe Gitlab::ReferenceExtractor, lib: true do Quote: > @offteam - }) + )) expect(subject.users).to match_array([]) end diff --git a/spec/lib/gitlab/saml/user_spec.rb b/spec/lib/gitlab/saml/user_spec.rb index 02c139f1a0d..cf00cff072c 100644 --- a/spec/lib/gitlab/saml/user_spec.rb +++ b/spec/lib/gitlab/saml/user_spec.rb @@ -5,7 +5,7 @@ describe Gitlab::Saml::User, lib: true do let(:gl_user) { saml_user.gl_user } let(:uid) { 'my-uid' } let(:provider) { 'saml' } - let(:auth_hash) { OmniAuth::AuthHash.new(uid: uid, provider: provider, info: info_hash, extra: { raw_info: OneLogin::RubySaml::Attributes.new({ 'groups' => %w(Developers Freelancers Designers) }) }) } + let(:auth_hash) { OmniAuth::AuthHash.new(uid: uid, provider: provider, info: info_hash, extra: { raw_info: OneLogin::RubySaml::Attributes.new({ 'groups' => %w[Developers Freelancers Designers] }) }) } let(:info_hash) do { name: 'John', @@ -50,14 +50,14 @@ describe Gitlab::Saml::User, lib: true do context 'external groups' do context 'are defined' do it 'marks the user as external' do - stub_saml_group_config(%w(Freelancers)) + stub_saml_group_config(%w[Freelancers]) saml_user.save expect(gl_user).to be_valid expect(gl_user.external).to be_truthy end end - before { stub_saml_group_config(%w(Interns)) } + before { stub_saml_group_config(%w[Interns]) } context 'are defined but the user does not belong there' do it 'does not mark the user as external' do saml_user.save @@ -110,7 +110,7 @@ describe Gitlab::Saml::User, lib: true do context 'external groups' do context 'are defined' do it 'marks the user as external' do - stub_saml_group_config(%w(Freelancers)) + stub_saml_group_config(%w[Freelancers]) saml_user.save expect(gl_user).to be_valid expect(gl_user.external).to be_truthy @@ -119,7 +119,7 @@ describe Gitlab::Saml::User, lib: true do context 'are defined but the user does not belong there' do it 'does not mark the user as external' do - stub_saml_group_config(%w(Interns)) + stub_saml_group_config(%w[Interns]) saml_user.save expect(gl_user).to be_valid expect(gl_user.external).to be_falsey @@ -136,13 +136,13 @@ describe Gitlab::Saml::User, lib: true do before { stub_omniauth_config({ auto_link_ldap_user: true, auto_link_saml_user: false }) } context 'and at least one LDAP provider is defined' do - before { stub_ldap_config(providers: %w(ldapmain)) } + before { stub_ldap_config(providers: %w[ldapmain]) } context 'and a corresponding LDAP person' do before do allow(ldap_user).to receive(:uid) { uid } allow(ldap_user).to receive(:username) { uid } - allow(ldap_user).to receive(:email) { %w(john@mail.com john2@example.com) } + allow(ldap_user).to receive(:email) { %w[john@mail.com john2@example.com] } allow(ldap_user).to receive(:dn) { 'uid=user1,ou=People,dc=example' } allow(Gitlab::LDAP::Person).to receive(:find_by_uid).and_return(ldap_user) allow(Gitlab::LDAP::Person).to receive(:find_by_dn).and_return(ldap_user) diff --git a/spec/lib/gitlab/url_sanitizer_spec.rb b/spec/lib/gitlab/url_sanitizer_spec.rb index 2cb74629da8..e38e2943449 100644 --- a/spec/lib/gitlab/url_sanitizer_spec.rb +++ b/spec/lib/gitlab/url_sanitizer_spec.rb @@ -9,10 +9,10 @@ describe Gitlab::UrlSanitizer, lib: true do describe '.sanitize' do def sanitize_url(url) # We want to try with multi-line content because is how error messages are formatted - described_class.sanitize(%Q{ + described_class.sanitize(%Q( remote: Not Found fatal: repository '#{url}' not found - }) + )) end it 'mask the credentials from HTTP URLs' do diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index 550a890797e..79facdf043d 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -118,7 +118,7 @@ describe Ci::Pipeline, models: true do end it 'return all stages' do - is_expected.to eq(%w(build test)) + is_expected.to eq(%w[build test]) end end diff --git a/spec/models/commit_range_spec.rb b/spec/models/commit_range_spec.rb index c41359b55a3..8438fc600a3 100644 --- a/spec/models/commit_range_spec.rb +++ b/spec/models/commit_range_spec.rb @@ -78,7 +78,7 @@ describe CommitRange, models: true do describe '#to_param' do it 'includes the correct keys' do - expect(range.to_param.keys).to eq %i(from to) + expect(range.to_param.keys).to eq %i[from to] end it 'includes the correct values for a three-dot range' do diff --git a/spec/models/commit_status_spec.rb b/spec/models/commit_status_spec.rb index 2f1baff5d66..584ef978be1 100644 --- a/spec/models/commit_status_spec.rb +++ b/spec/models/commit_status_spec.rb @@ -14,7 +14,7 @@ describe CommitStatus, models: true do it { is_expected.to belong_to(:project) } it { is_expected.to validate_presence_of(:name) } - it { is_expected.to validate_inclusion_of(:status).in_array(%w(pending running failed success canceled)) } + it { is_expected.to validate_inclusion_of(:status).in_array(%w[pending running failed success canceled]) } it { is_expected.to delegate_method(:sha).to(:pipeline) } it { is_expected.to delegate_method(:short_sha).to(:pipeline) } diff --git a/spec/models/concerns/case_sensitivity_spec.rb b/spec/models/concerns/case_sensitivity_spec.rb index 92fdc5cd65d..8ed660dda45 100644 --- a/spec/models/concerns/case_sensitivity_spec.rb +++ b/spec/models/concerns/case_sensitivity_spec.rb @@ -110,7 +110,7 @@ describe CaseSensitivity, models: true do and_return('`foo`') expect(model).to receive(:where). - with(%q{`foo` = :value}, value: 'bar'). + with(%q(`foo` = :value), value: 'bar'). and_return(criteria) expect(model.iwhere(foo: 'bar')).to eq(criteria) @@ -124,7 +124,7 @@ describe CaseSensitivity, models: true do and_return('`foo`.`bar`') expect(model).to receive(:where). - with(%q{`foo`.`bar` = :value}, value: 'bar'). + with(%q(`foo`.`bar` = :value), value: 'bar'). and_return(criteria) expect(model.iwhere('foo.bar'.to_sym => 'bar')). @@ -146,11 +146,11 @@ describe CaseSensitivity, models: true do and_return('`bar`') expect(model).to receive(:where). - with(%q{`foo` = :value}, value: 'bar'). + with(%q(`foo` = :value), value: 'bar'). and_return(initial) expect(initial).to receive(:where). - with(%q{`bar` = :value}, value: 'baz'). + with(%q(`bar` = :value), value: 'baz'). and_return(final) got = model.iwhere(foo: 'bar', bar: 'baz') @@ -171,11 +171,11 @@ describe CaseSensitivity, models: true do and_return('`foo`.`baz`') expect(model).to receive(:where). - with(%q{`foo`.`bar` = :value}, value: 'bar'). + with(%q(`foo`.`bar` = :value), value: 'bar'). and_return(initial) expect(initial).to receive(:where). - with(%q{`foo`.`baz` = :value}, value: 'baz'). + with(%q(`foo`.`baz` = :value), value: 'baz'). and_return(final) got = model.iwhere('foo.bar'.to_sym => 'bar', diff --git a/spec/models/concerns/project_features_compatibility_spec.rb b/spec/models/concerns/project_features_compatibility_spec.rb index 5363aea4d22..cfca0c4c6d4 100644 --- a/spec/models/concerns/project_features_compatibility_spec.rb +++ b/spec/models/concerns/project_features_compatibility_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe ProjectFeaturesCompatibility do let(:project) { create(:project) } - let(:features) { %w(issues wiki builds merge_requests snippets) } + let(:features) { %w[issues wiki builds merge_requests snippets] } # We had issues_enabled, snippets_enabled, builds_enabled, merge_requests_enabled and issues_enabled fields on projects table # All those fields got moved to a new table called project_feature and are now integers instead of booleans diff --git a/spec/models/label_spec.rb b/spec/models/label_spec.rb index 5a5d1a5d60c..f9ef8fa90e7 100644 --- a/spec/models/label_spec.rb +++ b/spec/models/label_spec.rb @@ -64,7 +64,7 @@ describe Label, models: true do end it 'uses id when name contains double quote' do - label = create(:label, name: %q{"irony"}) + label = create(:label, name: %q("irony")) expect(label.to_reference(format: :name)).to eq "~#{label.id}" end end diff --git a/spec/models/project_feature_spec.rb b/spec/models/project_feature_spec.rb index 8d554a01be5..c462cd09730 100644 --- a/spec/models/project_feature_spec.rb +++ b/spec/models/project_feature_spec.rb @@ -5,7 +5,7 @@ describe ProjectFeature do let(:user) { create(:user) } describe '#feature_available?' do - let(:features) { %w(issues wiki builds merge_requests snippets) } + let(:features) { %w[issues wiki builds merge_requests snippets] } context 'when features are disabled' do it "returns false" do @@ -65,7 +65,7 @@ describe ProjectFeature do end describe '#*_enabled?' do - let(:features) { %w(wiki builds merge_requests) } + let(:features) { %w[wiki builds merge_requests] } it "returns false when feature is disabled" do features.each do |feature| diff --git a/spec/models/project_wiki_spec.rb b/spec/models/project_wiki_spec.rb index 58b57bd4fef..d676b4294c0 100644 --- a/spec/models/project_wiki_spec.rb +++ b/spec/models/project_wiki_spec.rb @@ -274,7 +274,7 @@ describe ProjectWiki, models: true do def create_temp_repo(path) FileUtils.mkdir_p path - system(*%W(#{Gitlab.config.git.bin_path} init --quiet --bare -- #{path})) + system(*%W[#{Gitlab.config.git.bin_path} init --quiet --bare -- #{path}]) end def remove_temp_repo(path) diff --git a/spec/requests/api/broadcast_messages_spec.rb b/spec/requests/api/broadcast_messages_spec.rb index 7c9078b2864..cbff9af5395 100644 --- a/spec/requests/api/broadcast_messages_spec.rb +++ b/spec/requests/api/broadcast_messages_spec.rb @@ -27,7 +27,7 @@ describe API::BroadcastMessages, api: true do expect(response).to have_http_status(200) expect(json_response).to be_kind_of(Array) expect(json_response.first.keys) - .to match_array(%w(id message starts_at ends_at color font active)) + .to match_array(%w[id message starts_at ends_at color font active]) end end @@ -52,7 +52,7 @@ describe API::BroadcastMessages, api: true do expect(response).to have_http_status(200) expect(json_response['id']).to eq message.id expect(json_response.keys) - .to match_array(%w(id message starts_at ends_at color font active)) + .to match_array(%w[id message starts_at ends_at color font active]) end end diff --git a/spec/requests/api/internal_spec.rb b/spec/requests/api/internal_spec.rb index 46e8e6f1169..e69667b8544 100644 --- a/spec/requests/api/internal_spec.rb +++ b/spec/requests/api/internal_spec.rb @@ -75,14 +75,14 @@ describe API::API, api: true do it 'returns new recovery codes when the user exists' do allow_any_instance_of(User).to receive(:two_factor_enabled?).and_return(true) allow_any_instance_of(User) - .to receive(:generate_otp_backup_codes!).and_return(%w(119135e5a3ebce8e 34bd7b74adbc8861)) + .to receive(:generate_otp_backup_codes!).and_return(%w[119135e5a3ebce8e 34bd7b74adbc8861]) post api('/internal/two_factor_recovery_codes'), secret_token: secret_token, key_id: key.id expect(json_response['success']).to be_truthy - expect(json_response['recovery_codes']).to match_array(%w(119135e5a3ebce8e 34bd7b74adbc8861)) + expect(json_response['recovery_codes']).to match_array(%w[119135e5a3ebce8e 34bd7b74adbc8861]) end end diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index 192c7d14c13..00a62fefed2 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -232,7 +232,7 @@ describe API::API, api: true do post api('/projects', user), project project.each_pair do |k, v| - next if %i{ issues_enabled merge_requests_enabled wiki_enabled }.include?(k) + next if %i[ issues_enabled merge_requests_enabled wiki_enabled ].include?(k) expect(json_response[k.to_s]).to eq(v) end diff --git a/spec/requests/api/tags_spec.rb b/spec/requests/api/tags_spec.rb index d563883cd47..03aacf18023 100644 --- a/spec/requests/api/tags_spec.rb +++ b/spec/requests/api/tags_spec.rb @@ -109,8 +109,8 @@ describe API::API, api: true do it 'creates a new annotated tag' do # Identity must be set in .gitconfig to create annotated tag. repo_path = project.repository.path_to_repo - system(*%W(#{Gitlab.config.git.bin_path} --git-dir=#{repo_path} config user.name #{user.name})) - system(*%W(#{Gitlab.config.git.bin_path} --git-dir=#{repo_path} config user.email #{user.email})) + system(*%W[#{Gitlab.config.git.bin_path} --git-dir=#{repo_path} config user.name #{user.name}]) + system(*%W[#{Gitlab.config.git.bin_path} --git-dir=#{repo_path} config user.email #{user.email}]) post api("/projects/#{project.id}/repository/tags", user), tag_name: 'v7.1.0', diff --git a/spec/requests/api/triggers_spec.rb b/spec/requests/api/triggers_spec.rb index 82bba1ce8a4..28a9749933b 100644 --- a/spec/requests/api/triggers_spec.rb +++ b/spec/requests/api/triggers_spec.rb @@ -72,7 +72,7 @@ describe API::API do end it 'validates variables needs to be a map of key-valued strings' do - post api("/projects/#{project.id}/trigger/builds"), options.merge(variables: { key: %w(1 2) }, ref: 'master') + post api("/projects/#{project.id}/trigger/builds"), options.merge(variables: { key: %w[1 2] }, ref: 'master') expect(response).to have_http_status(400) expect(json_response['message']).to eq('variables needs to be a map of key-valued strings') end diff --git a/spec/requests/ci/api/builds_spec.rb b/spec/requests/ci/api/builds_spec.rb index df97f1bf7b6..3ef804e46bd 100644 --- a/spec/requests/ci/api/builds_spec.rb +++ b/spec/requests/ci/api/builds_spec.rb @@ -117,7 +117,7 @@ describe Ci::API::API do end end - %w(name version revision platform architecture).each do |param| + %w[name version revision platform architecture].each do |param| context "updates runner #{param}" do let(:value) { "#{param}_value" } diff --git a/spec/requests/ci/api/runners_spec.rb b/spec/requests/ci/api/runners_spec.rb index 43596f07cb5..fba51cb22e5 100644 --- a/spec/requests/ci/api/runners_spec.rb +++ b/spec/requests/ci/api/runners_spec.rb @@ -93,7 +93,7 @@ describe Ci::API::API do end end - %w(name version revision platform architecture).each do |param| + %w[name version revision platform architecture].each do |param| context "creates runner with #{param} saved" do let(:value) { "#{param}_value" } diff --git a/spec/requests/ci/api/triggers_spec.rb b/spec/requests/ci/api/triggers_spec.rb index 0a0f979f57d..bbb4c82038f 100644 --- a/spec/requests/ci/api/triggers_spec.rb +++ b/spec/requests/ci/api/triggers_spec.rb @@ -64,7 +64,7 @@ describe Ci::API::API do end it 'validates variables needs to be a map of key-valued strings' do - post ci_api("/projects/#{project.ci_id}/refs/master/trigger"), options.merge(variables: { key: %w(1 2) }) + post ci_api("/projects/#{project.ci_id}/refs/master/trigger"), options.merge(variables: { key: %w[1 2] }) expect(response).to have_http_status(400) expect(json_response['message']).to eq('variables needs to be a map of key-valued strings') end diff --git a/spec/services/system_note_service_spec.rb b/spec/services/system_note_service_spec.rb index 3d854a959f3..48e76676c60 100644 --- a/spec/services/system_note_service_spec.rb +++ b/spec/services/system_note_service_spec.rb @@ -555,7 +555,7 @@ describe SystemNoteService, services: true do describe "existing reference" do before do - message = %Q{[#{author.name}|http://localhost/u/#{author.username}] mentioned this issue in [a commit of #{project.path_with_namespace}|http://localhost/#{project.path_with_namespace}/commit/#{commit.id}]:\\n'#{commit.title}'} + message = %Q([#{author.name}|http://localhost/u/#{author.username}] mentioned this issue in [a commit of #{project.path_with_namespace}|http://localhost/#{project.path_with_namespace}/commit/#{commit.id}]:\\n'#{commit.title}') WebMock.stub_request(:get, jira_api_comment_url).to_return(body: %Q({"comments":[{"body":"#{message}"}]})) end diff --git a/spec/simplecov_env.rb b/spec/simplecov_env.rb index b507d38f472..3a7cb7d1855 100644 --- a/spec/simplecov_env.rb +++ b/spec/simplecov_env.rb @@ -42,7 +42,7 @@ module SimpleCovEnv add_group 'Models', 'app/models' add_group 'Mailers', 'app/mailers' add_group 'Helpers', 'app/helpers' - add_group 'Workers', %w(app/jobs app/workers) + add_group 'Workers', %w[app/jobs app/workers] add_group 'Libraries', 'lib' add_group 'Services', 'app/services' add_group 'Finders', 'app/finders' diff --git a/spec/support/import_export/export_file_helper.rb b/spec/support/import_export/export_file_helper.rb index be0772d6a4a..599ad1ed944 100644 --- a/spec/support/import_export/export_file_helper.rb +++ b/spec/support/import_export/export_file_helper.rb @@ -52,7 +52,7 @@ module ExportFileHelper def in_directory_with_expanded_export(project) Dir.mktmpdir do |tmpdir| export_file = project.export_project_path - _output, exit_status = Gitlab::Popen.popen(%W{tar -zxf #{export_file} -C #{tmpdir}}) + _output, exit_status = Gitlab::Popen.popen(%W[tar -zxf #{export_file} -C #{tmpdir}]) yield(exit_status, tmpdir) end diff --git a/spec/support/matchers/markdown_matchers.rb b/spec/support/matchers/markdown_matchers.rb index 8c98b1f988c..a260fde249c 100644 --- a/spec/support/matchers/markdown_matchers.rb +++ b/spec/support/matchers/markdown_matchers.rb @@ -60,7 +60,7 @@ module MarkdownMatchers expect(actual).to have_autolink('irc://irc.freenode.net/git') expect(actual).to have_autolink('http://localhost:3000') - %w(code a kbd).each do |elem| + %w[code a kbd].each do |elem| expect(body).not_to have_selector("#{elem} a") end end diff --git a/spec/support/test_env.rb b/spec/support/test_env.rb index 0097dbf8fad..0b31c64a9eb 100644 --- a/spec/support/test_env.rb +++ b/spec/support/test_env.rb @@ -115,13 +115,13 @@ module TestEnv clone_url = "https://gitlab.com/gitlab-org/#{repo_name}.git" unless File.directory?(repo_path) - system(*%W(#{Gitlab.config.git.bin_path} clone -q #{clone_url} #{repo_path})) + system(*%W[#{Gitlab.config.git.bin_path} clone -q #{clone_url} #{repo_path}]) end set_repo_refs(repo_path, branch_sha) # We must copy bare repositories because we will push to them. - system(git_env, *%W(#{Gitlab.config.git.bin_path} clone -q --bare #{repo_path} #{repo_path_bare})) + system(git_env, *%W[#{Gitlab.config.git.bin_path} clone -q --bare #{repo_path} #{repo_path_bare}]) end def copy_repo(project) @@ -162,7 +162,7 @@ module TestEnv end def warm_asset_cache? - cache = Rails.root.join(*%w(tmp cache assets test)) + cache = Rails.root.join(*%w[tmp cache assets test]) Dir.exist?(cache) && Dir.entries(cache).length > 2 end @@ -202,9 +202,9 @@ module TestEnv Dir.chdir(repo_path) do branch_sha.each do |branch, sha| # Try to reset without fetching to avoid using the network. - reset = %W(#{Gitlab.config.git.bin_path} update-ref refs/heads/#{branch} #{sha}) + reset = %W[#{Gitlab.config.git.bin_path} update-ref refs/heads/#{branch} #{sha}] unless system(*reset) - if system(*%W(#{Gitlab.config.git.bin_path} fetch origin)) + if system(*%W[#{Gitlab.config.git.bin_path} fetch origin]) unless system(*reset) raise 'The fetched test seed '\ 'does not contain the required revision.' diff --git a/spec/tasks/gitlab/backup_rake_spec.rb b/spec/tasks/gitlab/backup_rake_spec.rb index 548e7780c36..24b0672e032 100644 --- a/spec/tasks/gitlab/backup_rake_spec.rb +++ b/spec/tasks/gitlab/backup_rake_spec.rb @@ -27,7 +27,7 @@ describe 'gitlab:app namespace rake task' do end def reenable_backup_sub_tasks - %w{db repo uploads builds artifacts lfs registry}.each do |subtask| + %w[db repo uploads builds artifacts lfs registry].each do |subtask| Rake::Task["gitlab:backup:#{subtask}:create"].reenable end end @@ -129,7 +129,7 @@ describe 'gitlab:app namespace rake task' do it 'sets correct permissions on the tar contents' do tar_contents, exit_status = Gitlab::Popen.popen( - %W{tar -tvf #{@backup_tar} db uploads.tar.gz repositories builds.tar.gz artifacts.tar.gz lfs.tar.gz registry.tar.gz} + %W[tar -tvf #{@backup_tar} db uploads.tar.gz repositories builds.tar.gz artifacts.tar.gz lfs.tar.gz registry.tar.gz] ) expect(exit_status).to eq(0) expect(tar_contents).to match('db/') @@ -155,7 +155,7 @@ describe 'gitlab:app namespace rake task' do it 'does not create registry.tar.gz' do tar_contents, exit_status = Gitlab::Popen.popen( - %W{tar -tvf #{@backup_tar}} + %W[tar -tvf #{@backup_tar}] ) expect(exit_status).to eq(0) expect(tar_contents).not_to match('registry.tar.gz') @@ -193,7 +193,7 @@ describe 'gitlab:app namespace rake task' do it 'includes repositories in all repository storages' do tar_contents, exit_status = Gitlab::Popen.popen( - %W{tar -tvf #{@backup_tar} repositories} + %W[tar -tvf #{@backup_tar} repositories] ) expect(exit_status).to eq(0) expect(tar_contents).to match("repositories/#{project_a.path_with_namespace}.bundle") @@ -231,7 +231,7 @@ describe 'gitlab:app namespace rake task' do it "does not contain skipped item" do tar_contents, _exit_status = Gitlab::Popen.popen( - %W{tar -tvf #{@backup_tar} db uploads.tar.gz repositories builds.tar.gz artifacts.tar.gz lfs.tar.gz registry.tar.gz} + %W[tar -tvf #{@backup_tar} db uploads.tar.gz repositories builds.tar.gz artifacts.tar.gz lfs.tar.gz registry.tar.gz] ) expect(tar_contents).to match('db/') diff --git a/spec/views/layouts/_head.html.haml_spec.rb b/spec/views/layouts/_head.html.haml_spec.rb index 3fddfb3b62f..c5df04aae9d 100644 --- a/spec/views/layouts/_head.html.haml_spec.rb +++ b/spec/views/layouts/_head.html.haml_spec.rb @@ -10,7 +10,7 @@ describe 'layouts/_head' do render - expect(rendered).to match(%{content="foo" http-equiv="refresh"}) + expect(rendered).to match(%(content="foo" http-equiv="refresh")) end it 'escapes HTML-safe strings in page_description' do @@ -18,7 +18,7 @@ describe 'layouts/_head' do render - expect(rendered).to match(%{content="foo" http-equiv="refresh"}) + expect(rendered).to match(%(content="foo" http-equiv="refresh")) end it 'escapes HTML-safe strings in page_image' do @@ -26,11 +26,11 @@ describe 'layouts/_head' do render - expect(rendered).to match(%{content="foo" http-equiv="refresh"}) + expect(rendered).to match(%(content="foo" http-equiv="refresh")) end def stub_helper_with_safe_string(method) allow_any_instance_of(PageLayoutHelper).to receive(method) - .and_return(%q{foo" http-equiv="refresh}.html_safe) + .and_return(%q(foo" http-equiv="refresh).html_safe) end end diff --git a/spec/workers/repository_import_worker_spec.rb b/spec/workers/repository_import_worker_spec.rb index f1b1574abf4..7d2403658ff 100644 --- a/spec/workers/repository_import_worker_spec.rb +++ b/spec/workers/repository_import_worker_spec.rb @@ -20,7 +20,7 @@ describe RepositoryImportWorker do context 'when the import has failed' do it 'hide the credentials that were used in the import URL' do - error = %Q{remote: Not Found fatal: repository 'https://user:pass@test.com/root/repoC.git/' not found } + error = %Q(remote: Not Found fatal: repository 'https://user:pass@test.com/root/repoC.git/' not found ) expect_any_instance_of(Projects::ImportService).to receive(:execute). and_return({ status: :error, message: error }) diff --git a/spec/workers/stuck_ci_builds_worker_spec.rb b/spec/workers/stuck_ci_builds_worker_spec.rb index 801fa31b45d..878bd20f4ba 100644 --- a/spec/workers/stuck_ci_builds_worker_spec.rb +++ b/spec/workers/stuck_ci_builds_worker_spec.rb @@ -9,7 +9,7 @@ describe StuckCiBuildsWorker do build.status end - %w(pending running).each do |status| + %w[pending running].each do |status| context "#{status} build" do before do build.update!(status: status) @@ -29,7 +29,7 @@ describe StuckCiBuildsWorker do end end - %w(success failed canceled).each do |status| + %w[success failed canceled].each do |status| context "#{status} build" do before do build.update!(status: status) |