Skip to content

Commit

Permalink
Source can only be valid utf-8, so scrub is useless there
Browse files Browse the repository at this point in the history
  • Loading branch information
marcandre authored and bbatsov committed Jul 21, 2020
1 parent 925ecac commit 343f62e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/rubocop/cop/layout/heredoc_indentation.rb
Expand Up @@ -161,11 +161,11 @@ def indentation_width
end

def heredoc_body(node)
node.loc.heredoc_body.source.scrub
node.loc.heredoc_body.source
end

def heredoc_end(node)
node.loc.heredoc_end.source.scrub
node.loc.heredoc_end.source
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/lint/interpolation_check.rb
Expand Up @@ -23,7 +23,7 @@ class InterpolationCheck < Cop
def on_str(node)
parent = node.parent
return if parent && (parent.dstr_type? || parent.regexp_type?)
return unless /(?<!\\)#\{.*\}/.match?(node.source.scrub)
return unless /(?<!\\)#\{.*\}/.match?(node.source)
return if heredoc?(node)

add_offense(node)
Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/style/percent_literal_delimiters.rb
Expand Up @@ -102,12 +102,12 @@ def contains_delimiter?(node, delimiters)
delimiters_regexp = Regexp.union(delimiters)
node
.children.map { |n| string_source(n) }.compact
.any? { |s| delimiters_regexp.match?(s.scrub) }
.any? { |s| delimiters_regexp.match?(s) }
end

def string_source(node)
if node.is_a?(String)
node
node.scrub
elsif node.respond_to?(:type) && (node.str_type? || node.sym_type?)
node.source
end
Expand Down

0 comments on commit 343f62e

Please sign in to comment.