Auto-correct for `delete_prefix`/`delete_suffix`

Follow up to #39409.
This commit is contained in:
Ryuta Kamizono 2020-06-05 12:40:39 +09:00
parent c2dc793e59
commit c07dff7227
7 changed files with 9 additions and 9 deletions

View File

@ -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

View File

@ -21,7 +21,7 @@ module ActiveRecord
alias :array? :array
def sql_type
super.sub(/\[\]\z/, "")
super.delete_suffix("[]")
end
def init_with(coder)

View File

@ -544,7 +544,7 @@ module ActiveSupport #:nodoc:
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 @@ module ActiveSupport #: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 @@ module ActiveSupport #: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

View File

@ -160,7 +160,7 @@ module ActiveSupport
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

View File

@ -133,7 +133,7 @@ module ActiveSupport
result.sub!(/\A_+/, "")
unless keep_id_suffix
result.sub!(/_id\z/, "")
result.delete_suffix!("_id")
end
result.tr!("_", " ")

View File

@ -129,7 +129,7 @@ module RailsGuides
if guide.end_with?(".md")
guide.sub(/md\z/, "html")
else
guide.sub(/\.erb\z/, "")
guide.delete_suffix(".erb")
end
end

View File

@ -82,7 +82,7 @@ class CodeStatisticsCalculator #:nodoc:
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