Merge pull request #6613 from reitermarkus/match-nil

Fix `#match?` on `nil`.
This commit is contained in:
Markus Reiter 2019-10-16 20:25:31 +02:00 committed by GitHub
commit 2bf8015bc4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,9 +15,15 @@ module RuboCop
def on_homepage_stanza(stanza)
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,
message: format(MSG_NO_SLASH, url: url))