rubocops/homepage: don't attempt to auto-correct an empty string.

Fixes #10232
This commit is contained in:
Mike McQuaid 2021-01-06 13:53:15 +00:00
parent dad7dc6a14
commit 051fba341f
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70

View File

@ -90,6 +90,8 @@ module RuboCop
return if node.nil? return if node.nil?
homepage = string_content(node).dup homepage = string_content(node).dup
return if homepage.nil? || homepage.empty?
homepage.sub!("readthedocs.org", "readthedocs.io") homepage.sub!("readthedocs.org", "readthedocs.io")
homepage.delete_suffix!(".git") if homepage.start_with?("https://github.com") homepage.delete_suffix!(".git") if homepage.start_with?("https://github.com")
corrector.replace(node.source_range, "\"#{homepage}\"") corrector.replace(node.source_range, "\"#{homepage}\"")