rubocop-discourse 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3c437e92050986771e72b6e93ae779c667a4d4522aa4b8e0d5be0395d99aeae0
4
- data.tar.gz: ae8d57c8f0d17e1d154e18c46d4bb9a5cd687e0494b3b2022870f7f3ad030d2f
3
+ metadata.gz: ce133465e4ca5d05edcf743e5e38d4ad089c385db83920b53e2d517bee97e837
4
+ data.tar.gz: ead5716e3ad77ae268eb91424ff663ed6f060f59fbcf9ca08925d3925e091b9a
5
5
  SHA512:
6
- metadata.gz: feae39850faf8928b55508ed478fa80e600dfe18ba513f2a4f708615645ab310e94dfb6708804da8fbf7131778790126d37550971a1b5b612c84679954182634
7
- data.tar.gz: ca59eb41ee3193287eecc3e58c23f0d53ba3499f73784ecc638afa6623045b487a1a599918fab361e23a10ea96d53b79a92a85c39ef440a1d55dde064ff99cf4
6
+ metadata.gz: f4ea1ecd294f15ea3972f5b9aa385a74be53fe8f1dc146dd335e4487a4075e81ba26a9db64c5ffe3162a28600bfde330d52981c456fb1945e9956c56738e7fbb
7
+ data.tar.gz: 45c3e852541f4cd2eed5b7d7e32b3cdeac7984eebdd636aa3d9349e4cdbac7d394f0444118f3df00d060ed09a61cb4f7085444c9ed67e2a6e2da2936583fd451
@@ -29,6 +29,48 @@ module RuboCop
29
29
  add_offense(node, message: MSG)
30
30
  end
31
31
  end
32
+
33
+ # Do not use URI.escape and its ilk, they are deprecated
34
+ # with a warning in the ruby source. Instead use
35
+ # Addressable::URI, which has encode, encode_component,
36
+ # and unencode methods. UrlHelper has helper methods for this.
37
+ #
38
+ # # @example
39
+ # # bad
40
+ # URI.encode("https://a%20a.com?a='a%22")
41
+ #
42
+ # # good
43
+ # UrlHelper.encode("https://a%20a.com?a='a%22")
44
+ # Addressable::URI.encode("https://a%20a.com?a='a%22")
45
+ class NoURIEscapeEncode < Cop
46
+ MSG = 'URI.escape, URI.encode, URI.unescape, URI.decode are deprecated and should not be used.'
47
+
48
+ def_node_matcher :using_uri_escape?, <<-MATCHER
49
+ (send (const nil? :URI) :escape ...)
50
+ MATCHER
51
+
52
+ def_node_matcher :using_uri_encode?, <<-MATCHER
53
+ (send (const nil? :URI) :encode ...)
54
+ MATCHER
55
+
56
+ def_node_matcher :using_uri_unescape?, <<-MATCHER
57
+ (send (const nil? :URI) :unescape ...)
58
+ MATCHER
59
+
60
+ def_node_matcher :using_uri_decode?, <<-MATCHER
61
+ (send (const nil? :URI) :decode ...)
62
+ MATCHER
63
+
64
+ def on_send(node)
65
+ return if [
66
+ using_uri_escape?(node),
67
+ using_uri_encode?(node),
68
+ using_uri_unescape?(node),
69
+ using_uri_decode?(node)
70
+ ].none?
71
+ add_offense(node, message: MSG)
72
+ end
73
+ end
32
74
  end
33
75
  end
34
76
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-discourse
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Taylor
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-18 00:00:00.000000000 Z
11
+ date: 2019-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -51,7 +51,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
51
51
  - !ruby/object:Gem::Version
52
52
  version: '0'
53
53
  requirements: []
54
- rubygems_version: 3.0.3
54
+ rubygems_version: 3.0.6
55
55
  signing_key:
56
56
  specification_version: 4
57
57
  summary: Custom rubocop cops used by Discourse