Merge pull request #6613 from reitermarkus/match-nil
Fix `#match?` on `nil`.
This commit is contained in:
commit
2bf8015bc4
@ -15,9 +15,15 @@ module RuboCop
|
|||||||
|
|
||||||
def on_homepage_stanza(stanza)
|
def on_homepage_stanza(stanza)
|
||||||
url_node = stanza.stanza_node.first_argument
|
url_node = stanza.stanza_node.first_argument
|
||||||
url = url_node.str_content
|
|
||||||
|
|
||||||
return unless url.match?(%r{^.+://[^/]+$})
|
url = if url_node.dstr_type?
|
||||||
|
# Remove quotes from interpolated string.
|
||||||
|
url_node.source[1..-2]
|
||||||
|
else
|
||||||
|
url_node.str_content
|
||||||
|
end
|
||||||
|
|
||||||
|
return unless url&.match?(%r{^.+://[^/]+$})
|
||||||
|
|
||||||
add_offense(url_node, location: :expression,
|
add_offense(url_node, location: :expression,
|
||||||
message: format(MSG_NO_SLASH, url: url))
|
message: format(MSG_NO_SLASH, url: url))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user