提交 c07dff72 编写于 作者: R Ryuta Kamizono

Auto-correct for `delete_prefix`/`delete_suffix`

Follow up to #39409.
上级 c2dc793e
......@@ -415,7 +415,7 @@ GEM
rexml
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 2.0)
rubocop-performance (1.6.0)
rubocop-performance (1.6.1)
rubocop (>= 0.71.0)
rubocop-rails (2.5.2)
activesupport
......
......@@ -21,7 +21,7 @@ def array
alias :array? :array
def sql_type
super.sub(/\[\]\z/, "")
super.delete_suffix("[]")
end
def init_with(coder)
......
......@@ -544,7 +544,7 @@ def load_missing_constant(from_mod, const_name)
if file_path
expanded = File.expand_path(file_path)
expanded.sub!(/\.rb\z/, "")
expanded.delete_suffix!(".rb")
if loading.include?(expanded)
raise "Circular dependency detected while autoloading constant #{qualified_name}"
......@@ -733,7 +733,7 @@ def to_constant_name(desc) #:nodoc:
def remove_constant(const) #:nodoc:
# Normalize ::Foo, ::Object::Foo, Object::Foo, Object::Object::Foo, etc. as Foo.
normalized = const.to_s.sub(/\A::/, "")
normalized = const.to_s.delete_prefix("::")
normalized.sub!(/\A(Object::)+/, "")
constants = normalized.split("::")
......@@ -743,7 +743,7 @@ def remove_constant(const) #:nodoc:
file_path = search_for_file(const.underscore)
if file_path
expanded = File.expand_path(file_path)
expanded.sub!(/\.rb\z/, "")
expanded.delete_suffix!(".rb")
loaded.delete(expanded)
end
......
......@@ -160,7 +160,7 @@ def xpath(path)
end
def normalize_extension(ext)
ext.to_s.sub(/\A\./, "")
ext.to_s.delete_prefix(".")
end
# Given a collection of Pathname objects returns the longest subpath
......
......@@ -133,7 +133,7 @@ def humanize(lower_case_and_underscored_word, capitalize: true, keep_id_suffix:
result.sub!(/\A_+/, "")
unless keep_id_suffix
result.sub!(/_id\z/, "")
result.delete_suffix!("_id")
end
result.tr!("_", " ")
......
......@@ -129,7 +129,7 @@ def output_file_for(guide)
if guide.end_with?(".md")
guide.sub(/md\z/, "html")
else
guide.sub(/\.erb\z/, "")
guide.delete_suffix(".erb")
end
end
......
......@@ -82,7 +82,7 @@ def file_type(file_path)
if file_path.end_with? "_test.rb"
:minitest
else
File.extname(file_path).sub(/\A\./, "").downcase.to_sym
File.extname(file_path).delete_prefix(".").downcase.to_sym
end
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册