Ruby

Ruby

Made by DeepSource

gsub(/suffix\z/, '') can be replaced by delete_suffix('suffix') RB-PR1027

Performance
Major
Autofix

The delete_suffix('suffix') method is faster than gsub(/suffix\z/, '').

Bad practice

str.gsub(/suffix\z/, '')
str.gsub!(/suffix\z/, '')
str.gsub(/suffix$/, '')
str.gsub!(/suffix$/, '')

Recommended

str.delete_suffix('suffix')
str.delete_suffix!('suffix')