Skip to content

Commit

Permalink
fixup! fixup! [Fixes rubocop#10439] Add Style/RedundantStringEscape
Browse files Browse the repository at this point in the history
  • Loading branch information
owst committed Sep 28, 2022
1 parent d71ee50 commit df1776e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/rubocop/cop/style/redundant_string_escape.rb
Expand Up @@ -50,14 +50,18 @@ def on_str(node)
each_match_range(str_contents_range, /(\\.)/) do |range|
next if allowed_escape?(node, range.resize(3))

add_offense(range, message: format(MSG, char: range.source.chars.last)) do |corrector|
add_offense(range) do |corrector|
corrector.remove_leading(range, 1)
end
end
end

private

def message(range)
format(MSG, char: range.source.chars.last)
end

def str_contents_range(node)
if heredoc?(node)
node.loc.heredoc_body
Expand Down

0 comments on commit df1776e

Please sign in to comment.