Commit 6d0654f3 authored by Siddharth Asthana's avatar Siddharth Asthana

Resolve Performance/DeletePrefix rubocop offenses

Changelog: other
EE: true
parent 0e060c73
......@@ -30,7 +30,7 @@ module SubmoduleHelper
end
end
namespace.sub!(%r{\A/}, '')
namespace.delete_prefix!('/')
project.rstrip!
project.delete_suffix!('.git')
......
......@@ -173,7 +173,7 @@ module Gitlab
# https://git-scm.com/book/en/v2/Git-Internals-Transfer-Protocols
#
def remove_upload_pack_http_service_fragment_from(body)
body.gsub(/\A001e# service=git-upload-pack\n0000/, '')
body.delete_prefix("001e# service=git-upload-pack\n0000")
end
# See Uploading Data > HTTP(S) section at:
......@@ -195,7 +195,7 @@ module Gitlab
# https://git-scm.com/book/en/v2/Git-Internals-Transfer-Protocols
#
def remove_receive_pack_http_service_fragment_from(body)
body.gsub(/\A001f# service=git-receive-pack\n0000/, '')
body.delete_prefix("001f# service=git-receive-pack\n0000")
end
def ensure_secondary!
......
......@@ -180,7 +180,7 @@ module Banzai
parts.pop if uri_type(request_path) != :tree
path.sub!(%r{\A\./}, '')
path.delete_prefix!('./')
while path.start_with?('../')
parts.pop
......
......@@ -30,7 +30,7 @@ module Gitlab
def self.normalize_value(given_value)
dummy_dn = "placeholder=#{given_value}"
normalized_dn = new(*dummy_dn).to_normalized_s
normalized_dn.sub(/\Aplaceholder=/, '')
normalized_dn.delete_prefix('placeholder=')
end
##
......
......@@ -37,7 +37,7 @@ module Gitlab
if was_embedded?(markdown)
moved_markdown
else
moved_markdown.sub(/\A!/, "")
moved_markdown.delete_prefix('!')
end
end
end
......
......@@ -24,7 +24,7 @@ module Gitlab
# Ex.
# Ref.extract_branch_name('refs/heads/master') #=> 'master'
def self.extract_branch_name(str)
str.gsub(%r{\Arefs/heads/}, '')
str.delete_prefix('refs/heads/')
end
def initialize(repository, name, target, dereferenced_target)
......
......@@ -29,7 +29,7 @@ module Gitlab
end
def project_path
URI.parse(preview).path.sub(%r{\A/}, '')
URI.parse(preview).path.delete_prefix('/')
end
def uri_encoded_project_path
......
......@@ -98,7 +98,7 @@ module Gitlab
storages << { name: key, path: storage_paths[key] }
end
config = { socket_path: address.sub(/\Aunix:/, '') }
config = { socket_path: address.delete_prefix('unix:') }
if Rails.env.test?
socket_filename = options[:gitaly_socket] || "gitaly.socket"
......
......@@ -8,7 +8,8 @@ module Gitlab
CUSTOM_DAY_AND_MONTH_LENGTH = { hours_per_day: 8, days_per_month: 20 }.freeze
def parse(string)
string = string.sub(/\A-/, '')
negative_time = string.start_with?('-')
string = string.delete_prefix('-')
seconds =
begin
......@@ -19,7 +20,7 @@ module Gitlab
nil
end
seconds *= -1 if seconds && Regexp.last_match
seconds *= -1 if seconds && negative_time
seconds
end
......
......@@ -339,7 +339,7 @@ RSpec.describe Projects::ArtifactsController do
def params
@params ||= begin
base64_params = send_data.sub(/\Aartifacts\-entry:/, '')
base64_params = send_data.delete_prefix('artifacts-entry:')
Gitlab::Json.parse(Base64.urlsafe_decode64(base64_params))
end
end
......
......@@ -67,7 +67,7 @@ RSpec.describe Gitlab::Gfm::UploadsRewriter do
it 'does not rewrite plain links as embedded' do
embedded_link = image_uploader.markdown_link
plain_image_link = embedded_link.sub(/\A!/, "")
plain_image_link = embedded_link.delete_prefix('!')
text = "#{plain_image_link} and #{embedded_link}"
moved_text = described_class.new(text, old_project, user).rewrite(new_project)
......
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