lib/rubocop/cop/performance/delete_suffix.rb in rubocop-performance-1.11.5 vs lib/rubocop/cop/performance/delete_suffix.rb in rubocop-performance-1.12.0
- old
+ new
@@ -5,18 +5,20 @@
module Performance
# In Ruby 2.5, `String#delete_suffix` has been added.
#
# This cop identifies places where `gsub(/suffix\z/, '')` and `sub(/suffix\z/, '')`
# can be replaced by `delete_suffix('suffix')`.
- # It is marked as unsafe by default because `Pathname` has `sub` but not `delete_suffix`.
#
# This cop has `SafeMultiline` configuration option that `true` by default because
# `suffix$` is unsafe as it will behave incompatible with `delete_suffix?`
# for receiver is multiline string.
#
# The `delete_suffix('suffix')` method is faster than `gsub(/suffix\z/, '')`.
#
+ # @safety
+ # This cop is unsafe because `Pathname` has `sub` but not `delete_suffix`.
+ #
# @example
#
# # bad
# str.gsub(/suffix\z/, '')
# str.gsub!(/suffix\z/, '')
@@ -45,12 +47,9 @@
# str.sub!(/suffix$/, '')
#
class DeleteSuffix < Base
include RegexpMetacharacter
extend AutoCorrector
- extend TargetRubyVersion
-
- minimum_target_ruby_version 2.5
MSG = 'Use `%<prefer>s` instead of `%<current>s`.'
RESTRICT_ON_SEND = %i[gsub gsub! sub sub!].freeze
PREFERRED_METHODS = {