lib/rubocop/cop/rails/link_to_blank.rb in rubocop-0.66.0 vs lib/rubocop/cop/rails/link_to_blank.rb in rubocop-0.67.0
- old
+ new
@@ -20,11 +20,11 @@
def_node_matcher :blank_target?, <<-PATTERN
(pair {(sym :target) (str "target")} {(str "_blank") (sym :_blank)})
PATTERN
def_node_matcher :includes_noopener?, <<-PATTERN
- (pair {(sym :rel) (str "rel")} (str #contains_noopener?))
+ (pair {(sym :rel) (str "rel")} ({str sym} #contains_noopener?))
PATTERN
def_node_matcher :rel_node?, <<-PATTERN
(pair {(sym :rel) (str "rel")} (str _))
PATTERN
@@ -70,20 +70,21 @@
)
corrector.replace(str_range, "#{existing_rel} noopener")
end
def add_rel(send_node, offence_node, corrector)
- quote_style = offence_node.children.last.source[0]
- new_rel_exp = ", rel: #{quote_style}noopener#{quote_style}"
+ opening_quote = offence_node.children.last.source[0]
+ closing_quote = opening_quote == ':' ? '' : opening_quote
+ new_rel_exp = ", rel: #{opening_quote}noopener#{closing_quote}"
range = send_node.arguments.last.source_range
corrector.insert_after(range, new_rel_exp)
end
- def contains_noopener?(str)
- return false unless str
+ def contains_noopener?(value)
+ return false unless value
- str.split(' ').include?('noopener')
+ value.to_s.split(' ').include?('noopener')
end
end
end
end
end