Class: RuboCop::Cop::Discourse::NoURIEscapeEncode
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::Discourse::NoURIEscapeEncode
- Defined in:
- lib/rubocop/cop/discourse/no_uri_escape_encode.rb
Overview
Do not use URI.escape and its ilk, they are deprecated with a warning in the ruby source. Instead use Addressable::URI, which has encode, encode_component, and unencode methods. UrlHelper has helper methods for this.
# @example
# bad
URI.encode("https://a%20a.com?a='a%22")
# good
UrlHelper.encode("https://a%20a.com?a='a%22")
Addressable::URI.encode("https://a%20a.com?a='a%22")
Constant Summary collapse
- MSG =
"URI.escape, URI.encode, URI.unescape, URI.decode are deprecated and should not be used."
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/rubocop/cop/discourse/no_uri_escape_encode.rb', line 37 def on_send(node) return if [ using_uri_escape?(node), using_uri_encode?(node), using_uri_unescape?(node), using_uri_decode?(node) ].none? add_offense(node, message: MSG) end |