Commit a82be040 authored by Nikola Milojevic's avatar Nikola Milojevic

Merge branch...

Merge branch '327490-fix-cop-remaining-cop-offenses-for-style-regexpliteralmixedpreserve-p2' into 'master'

Fix offenses for Style/RegexpLiteralMixedPreserve part2

See merge request gitlab-org/gitlab!65362
parents 79ed8f31 0b3169ad
......@@ -2459,12 +2459,6 @@ Style/RegexpLiteralMixedPreserve:
- 'ee/app/presenters/vulnerability_presenter.rb'
- 'ee/lib/api/geo_nodes.rb'
- 'ee/lib/gitlab/vulnerabilities/standard_vulnerability.rb'
- 'ee/spec/controllers/concerns/ee/routable_actions/sso_enforcement_redirect_spec.rb'
- 'ee/spec/controllers/concerns/routable_actions_spec.rb'
- 'ee/spec/controllers/groups/groups_controller_spec.rb'
- 'ee/spec/features/groups/saml_enforcement_spec.rb'
- 'ee/spec/features/markdown/metrics_spec.rb'
- 'ee/spec/services/jira/requests/issues/list_service_spec.rb'
- 'lib/api/invitations.rb'
- 'lib/gitlab/ci/pipeline/expression/lexeme/pattern.rb'
- 'lib/gitlab/metrics/requests_rack_middleware.rb'
......@@ -2472,24 +2466,3 @@ Style/RegexpLiteralMixedPreserve:
- 'lib/gitlab/regex.rb'
- 'lib/gitlab/utils.rb'
- 'lib/product_analytics/tracker.rb'
- 'qa/qa/page/project/settings/advanced.rb'
- 'qa/spec/service/docker_run/gitlab_runner_spec.rb'
- 'rubocop/cop/gitlab/duplicate_spec_location.rb'
- 'spec/features/clusters/cluster_health_dashboard_spec.rb'
- 'spec/features/markdown/metrics_spec.rb'
- 'spec/features/search/user_searches_for_code_spec.rb'
- 'spec/features/snippets/embedded_snippet_spec.rb'
- 'spec/helpers/diff_helper_spec.rb'
- 'spec/helpers/releases_helper_spec.rb'
- 'spec/lib/gitlab/ci/reports/test_case_spec.rb'
- 'spec/lib/gitlab/consul/internal_spec.rb'
- 'spec/lib/gitlab/import_export/shared_spec.rb'
- 'spec/lib/gitlab/utils/usage_data_spec.rb'
- 'spec/presenters/ci/build_runner_presenter_spec.rb'
- 'spec/requests/api/projects_spec.rb'
- 'spec/services/jira/requests/projects/list_service_spec.rb'
- 'spec/support/capybara.rb'
- 'spec/support/helpers/grafana_api_helpers.rb'
- 'spec/support/helpers/query_recorder.rb'
- 'spec/support/helpers/require_migration.rb'
- 'spec/views/layouts/_head.html.haml_spec.rb'
......@@ -83,7 +83,7 @@ RSpec.describe EE::RoutableActions::SsoEnforcementRedirect do
it 'returns the SSO url for the root group' do
redirect_url = CGI.escape("/#{subject.routable.full_path}")
expect(subject.sso_redirect_url).to match(/groups\/#{root_group.to_param}\/-\/saml\/sso\?redirect=#{redirect_url}&token=/)
expect(subject.sso_redirect_url).to match(%r{groups/#{root_group.to_param}/-/saml/sso\?redirect=#{redirect_url}&token=})
end
end
......
......@@ -43,7 +43,7 @@ RSpec.describe RoutableActions do
get :show, params: request_params(routable)
expect(response).to have_gitlab_http_status(:found)
expect(response.location).to match(/groups\/.*\/-\/saml\/sso\?redirect=.+&token=/)
expect(response.location).to match(%r{groups/.*/-/saml/sso\?redirect=.+&token=})
end
it 'does not redirect on POST requests' do
......
......@@ -90,7 +90,7 @@ RSpec.describe GroupsController do
get :show, params: { id: group }
expect(response).to have_gitlab_http_status(:found)
expect(response.location).to match(/groups\/#{group.to_param}\/-\/saml\/sso\?redirect=.+&token=/)
expect(response.location).to match(%r{groups/#{group.to_param}/-/saml/sso\?redirect=.+&token=})
end
end
......
......@@ -26,7 +26,7 @@ RSpec.describe 'SAML access enforcement' do
it 'prevents access to resource via SSO redirect' do
expect(page).to have_content("SAML SSO Sign in to \"#{group.name}\"")
expect(current_url).to match(/groups\/#{group.to_param}\/-\/saml\/sso\?redirect=.+&token=/)
expect(current_url).to match(%r{groups/#{group.to_param}/-/saml/sso\?redirect=.+&token=})
end
end
......
......@@ -81,7 +81,7 @@ RSpec.describe 'Metrics rendering', :js, :kubeclient, :use_clean_rails_memory_st
create(:clusters_integrations_prometheus, cluster: cluster)
stub_kubeclient_discover(cluster.platform.api_url)
stub_prometheus_request(/prometheus-prometheus-server/, body: prometheus_values_body)
stub_prometheus_request(/prometheus\/api\/v1/, body: prometheus_values_body)
stub_prometheus_request(%r{prometheus/api/v1}, body: prometheus_values_body)
end
let_it_be(:cluster) { create(:cluster, :provided_by_gcp, :project, projects: [project], user: user) }
......
......@@ -38,7 +38,7 @@ RSpec.describe Jira::Requests::Issues::ListService do
let(:jira_integration) { create(:jira_integration, url: 'https://jira.example.com') }
let(:response_body) { '' }
let(:response_headers) { { 'content-type' => 'application/json' } }
let(:expected_url_pattern) { /.*jira.example.com\/rest\/api\/2\/search.*/ }
let(:expected_url_pattern) { %r{.*jira.example.com/rest/api/2/search.*} }
before do
stub_request(:get, expected_url_pattern).to_return(status: 200, body: response_body, headers: response_headers)
......@@ -57,7 +57,7 @@ RSpec.describe Jira::Requests::Issues::ListService do
context 'when jira runs on a subpath' do
let(:jira_integration) { create(:jira_integration, url: 'http://jira.example.com/jira') }
let(:expected_url_pattern) { /.*jira.example.com\/jira\/rest\/api\/2\/search.*/ }
let(:expected_url_pattern) { %r{.*jira.example.com/jira/rest/api/2/search.*} }
it 'takes the subpath into account' do
expect(subject.success?).to be_truthy
......
......@@ -51,7 +51,7 @@ module QA
# Workaround for a failure to search when there are no spaces around the /
# https://gitlab.com/gitlab-org/gitlab/-/issues/218965
search_and_select(namespace.gsub(/([^\s])\/([^\s])/, '\1 / \2'))
search_and_select(namespace.gsub(%r{([^\s])/([^\s])}, '\1 / \2'))
click_element(:transfer_button)
fill_confirmation_text(project_name)
......
......@@ -130,7 +130,7 @@ module QA
end
it 'mounts the docker socket to the host runner' do
expect(subject).to have_received(:shell).with(/-v \/var\/run\/docker.sock:\/var\/run\/docker.sock /)
expect(subject).to have_received(:shell).with(%r{-v /var/run/docker.sock:/var/run/docker.sock })
end
it 'runs in privileged mode' do
......
......@@ -25,7 +25,7 @@ module RuboCop
MSG = 'Duplicate spec location in `%<path>s`.'
def on_top_level_describe(node, _args)
path = file_path_for_node(node).sub(/\A#{rails_root}\//, '')
path = file_path_for_node(node).sub(%r{\A#{rails_root}/}, '')
duplicate_path = find_duplicate_path(path)
if duplicate_path && File.exist?(File.join(rails_root, duplicate_path))
......
......@@ -176,7 +176,7 @@ RSpec.describe 'Metrics rendering', :js, :kubeclient, :use_clean_rails_memory_st
create(:clusters_integrations_prometheus, cluster: cluster)
stub_kubeclient_discover(cluster.platform.api_url)
stub_prometheus_request(/prometheus-prometheus-server/, body: prometheus_values_body)
stub_prometheus_request(/prometheus\/api\/v1/, body: prometheus_values_body)
stub_prometheus_request(%r{prometheus/api/v1}, body: prometheus_values_body)
end
let_it_be(:cluster) { create(:cluster, :provided_by_gcp, :project, projects: [project], user: user) }
......
......@@ -21,7 +21,7 @@ RSpec.describe 'User searches for code' do
expect(page).to have_selector('.results', text: 'application.js')
expect(page).to have_selector('.file-content .code')
expect(page).to have_selector("span.line[lang='javascript']")
expect(page).to have_link('application.js', href: /master\/files\/js\/application.js/)
expect(page).to have_link('application.js', href: %r{master/files/js/application.js})
end
context 'when on a project page', :js do
......@@ -45,7 +45,7 @@ RSpec.describe 'User searches for code' do
expect(page).to have_selector('.results', text: 'Update capybara, rspec-rails, poltergeist to recent versions')
find("#L3").click
expect(current_url).to match(/master\/.gitignore#L3/)
expect(current_url).to match(%r{master/.gitignore#L3})
end
it 'search mutiple words with refs switching' do
......@@ -63,7 +63,7 @@ RSpec.describe 'User searches for code' do
expect(page).to have_selector('.results', text: expected_result)
expect(find_field('dashboard_search').value).to eq(search)
expect(find("#L1502")[:href]).to match(/v1.0.0\/files\/markdown\/ruby-style-guide.md#L1502/)
expect(find("#L1502")[:href]).to match(%r{v1.0.0/files/markdown/ruby-style-guide.md#L1502})
end
end
......
......@@ -28,8 +28,8 @@ RSpec.describe 'Embedded Snippets' do
blobs.each do |blob|
expect(page).to have_content(blob.path)
expect(page.find(".snippet-file-content .blob-content[data-blob-id='#{blob.id}'] code")).to have_content(blob.data.squish)
expect(page).to have_link('Open raw', href: /-\/snippets\/#{snippet.id}\/raw\/master\/#{blob.path}/)
expect(page).to have_link('Download', href: /-\/snippets\/#{snippet.id}\/raw\/master\/#{blob.path}\?inline=false/)
expect(page).to have_link('Open raw', href: %r{-/snippets/#{snippet.id}/raw/master/#{blob.path}})
expect(page).to have_link('Download', href: %r{-/snippets/#{snippet.id}/raw/master/#{blob.path}\?inline=false})
end
end
end
......
......@@ -404,7 +404,7 @@ RSpec.describe DiffHelper do
it "returns a valid URL" do
allow(helper).to receive(:safe_params).and_return(params)
expect(subject).to match(/foo\/bar\/-\/commit\/#{commit.sha}\/diff_for_path/)
expect(subject).to match(%r{foo/bar/-/commit/#{commit.sha}/diff_for_path})
end
end
......
......@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe ReleasesHelper do
describe '#illustration' do
it 'returns the correct image path' do
expect(helper.illustration).to match(/illustrations\/releases-(\w+)\.svg/)
expect(helper.illustration).to match(%r{illustrations/releases-(\w+)\.svg})
end
end
......
......@@ -66,7 +66,7 @@ RSpec.describe Gitlab::Ci::Reports::TestCase, :aggregate_failures do
end
it '#attachment_url' do
expect(attachment_test_case.attachment_url).to match(/file\/some\/path.png/)
expect(attachment_test_case.attachment_url).to match(%r{file/some/path.png})
end
end
......
......@@ -134,6 +134,6 @@ RSpec.describe Gitlab::Consul::Internal do
end
def stub_consul_discover_prometheus
stub_request(:get, /v1\/catalog\/service\/prometheus/)
stub_request(:get, %r{v1/catalog/service/prometheus})
end
end
......@@ -26,7 +26,7 @@ RSpec.describe Gitlab::ImportExport::Shared do
describe '#export_path' do
it 'uses a random hash relative to project path' do
expect(subject.export_path).to match(/#{base_path}\h{32}\/\h{32}/)
expect(subject.export_path).to match(%r{#{base_path}\h{32}/\h{32}})
end
it 'memoizes the path' do
......@@ -44,7 +44,7 @@ RSpec.describe Gitlab::ImportExport::Shared do
subject = described_class.new(group)
base_path = %(/tmp/gitlab_exports/@groups/)
expect(subject.base_path).to match(/#{base_path}\h{2}\/\h{2}\/\h{64}/)
expect(subject.base_path).to match(%r{#{base_path}\h{2}/\h{2}/\h{64}})
end
end
end
......
......@@ -377,7 +377,7 @@ RSpec.describe Gitlab::Utils::UsageData do
shared_examples 'try to query Prometheus with given address' do
context 'Prometheus is ready' do
before do
stub_request(:get, /\/-\/ready/)
stub_request(:get, %r{/-/ready})
.to_return(status: 200, body: 'Prometheus is Ready.\n')
end
......@@ -387,7 +387,7 @@ RSpec.describe Gitlab::Utils::UsageData do
context 'Prometheus is not reachable through HTTPS' do
before do
stub_request(:get, /https:\/\/.*/).to_raise(Errno::ECONNREFUSED)
stub_request(:get, %r{https://.*}).to_raise(Errno::ECONNREFUSED)
end
context 'Prometheus is reachable through HTTP' do
......@@ -396,7 +396,7 @@ RSpec.describe Gitlab::Utils::UsageData do
context 'Prometheus is not reachable through HTTP' do
before do
stub_request(:get, /http:\/\/.*/).to_raise(Errno::ECONNREFUSED)
stub_request(:get, %r{http://.*}).to_raise(Errno::ECONNREFUSED)
end
it_behaves_like 'does not query data from Prometheus'
......@@ -406,7 +406,7 @@ RSpec.describe Gitlab::Utils::UsageData do
context 'Prometheus is not ready' do
before do
stub_request(:get, /\/-\/ready/)
stub_request(:get, %r{/-/ready})
.to_return(status: 503, body: 'Service Unavailable')
end
......
......@@ -177,7 +177,7 @@ RSpec.describe Ci::BuildRunnerPresenter do
end
it 'uses a SHA in the persistent refspec' do
expect(subject[0]).to match(/^\+[0-9a-f]{40}:refs\/pipelines\/[0-9]+$/)
expect(subject[0]).to match(%r{^\+[0-9a-f]{40}:refs/pipelines/[0-9]+$})
end
context 'when ref is tag' do
......
......@@ -877,7 +877,7 @@ RSpec.describe API::Projects do
get api(url, current_user), params: params
link = response.header['Link']
url = link&.match(/<[^>]+(\/projects\?[^>]+)>; rel="next"/) do |match|
url = link&.match(%r{<[^>]+(/projects\?[^>]+)>; rel="next"}) do |match|
match[1]
end
......
......@@ -37,7 +37,7 @@ RSpec.describe Jira::Requests::Projects::ListService do
context 'when validations and params are ok' do
let(:response_headers) { { 'content-type' => 'application/json' } }
let(:response_body) { [].to_json }
let(:expected_url_pattern) { /.*jira.example.com\/rest\/api\/2\/project/ }
let(:expected_url_pattern) { %r{.*jira.example.com/rest/api/2/project} }
before do
stub_request(:get, expected_url_pattern).to_return(status: 200, body: response_body, headers: response_headers)
......@@ -60,7 +60,7 @@ RSpec.describe Jira::Requests::Projects::ListService do
context 'when jira runs on a subpath' do
let(:jira_integration) { create(:jira_integration, url: 'http://jira.example.com/jira') }
let(:expected_url_pattern) { /.*jira.example.com\/jira\/rest\/api\/2\/project/ }
let(:expected_url_pattern) { %r{.*jira.example.com/jira/rest/api/2/project} }
it 'takes the subpath into account' do
expect(subject.success?).to be_truthy
......
......@@ -197,7 +197,7 @@ RSpec.configure do |config|
raise JSConsoleError, message
end
rescue Selenium::WebDriver::Error::WebDriverError => error
if error.message =~ /unknown command: session\/[0-9a-zA-Z]+(?:\/se)?\/log/
if error.message =~ %r{unknown command: session/[0-9a-zA-Z]+(?:/se)?/log}
message = "Unable to access Chrome javascript console logs. You may be using an outdated version of ChromeDriver."
raise JSConsoleError, message
else
......
......@@ -31,7 +31,7 @@ module GrafanaApiHelpers
end
def stub_all_grafana_proxy_requests(base_url)
stub_request(:any, /#{base_url}\/api\/datasources\/proxy/)
stub_request(:any, %r{#{base_url}/api/datasources/proxy})
.to_return(
status: 200,
body: fixture_file('grafana/proxy_response.json'),
......
......@@ -15,7 +15,7 @@ class RequireMigration
end
MIGRATION_FOLDERS = %w[db/migrate db/post_migrate].freeze
SPEC_FILE_PATTERN = /.+\/(?<file_name>.+)_spec\.rb/.freeze
SPEC_FILE_PATTERN = %r{.+/(?<file_name>.+)_spec\.rb}.freeze
class << self
def require_migration!(file_name)
......
......@@ -100,7 +100,7 @@ RSpec.describe 'layouts/_head' do
it 'add a Matomo Javascript' do
render
expect(rendered).to match(/<script.*>.*var u="\/\/#{matomo_host}\/".*<\/script>/m)
expect(rendered).to match(%r{<script.*>.*var u="//#{matomo_host}/".*</script>}m)
expect(rendered).to match(%r(<noscript>.*<img src="//#{matomo_host}/matomo.php.*</noscript>))
expect(rendered).not_to include('_paq.push(["disableCookies"])')
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment