rubocop-vendor 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rubocop/cop/vendor/rollbar_inside_rescue.rb +22 -7
- data/lib/rubocop/vendor/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df0960a7f70d9595e65685ba09c4ff6483eaa7f35039942d9e17522806852a05
|
4
|
+
data.tar.gz: 034c31c0811ab28653b3b86526032f9b681cd0154f61faa080ac08916c020c34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e6122390ff0d267bffa7fc3f91367b0e27522f0ebcc5655b7c142c0a6bd9e76fe9c5cc2f5a14adab999e72c8d2640aad5a88cc2a6f5cabe9e4809f60885cfcd
|
7
|
+
data.tar.gz: faca304ed5502022918f4ed211c0528e4856ccb58311b1b3e092f408fd001913f4c59efd139f0ba6cccad35f7baec76f4a9525ce2339fbaa7c40530cdd2c1b0d
|
@@ -22,6 +22,13 @@ module RuboCop
|
|
22
22
|
# Rollbar.error(exception, "Unable to sync account")
|
23
23
|
# end
|
24
24
|
#
|
25
|
+
# # good
|
26
|
+
# class ApplicationController < ActionController::Base
|
27
|
+
# rescue_from InvalidRecord do |e|
|
28
|
+
# Rollbar.error(e)
|
29
|
+
# end
|
30
|
+
# end
|
31
|
+
#
|
25
32
|
class RollbarInsideRescue < Cop
|
26
33
|
MSG = 'Only call Rollbar when handling errors inside a `rescue` block.'
|
27
34
|
|
@@ -30,20 +37,28 @@ module RuboCop
|
|
30
37
|
(const nil? :Rollbar) {:log :debug :info :warning :error :critical} ...)
|
31
38
|
PATTERN
|
32
39
|
|
40
|
+
def_node_matcher :active_support_rescuable_block?, <<-PATTERN
|
41
|
+
(block
|
42
|
+
(send nil? :rescue_from ...) ...)
|
43
|
+
PATTERN
|
44
|
+
|
33
45
|
def on_send(node)
|
34
46
|
return unless rollbar?(node)
|
47
|
+
return if in_rescue_block?(node)
|
48
|
+
|
49
|
+
add_offense(node, location: node.children[0].loc.expression)
|
50
|
+
end
|
51
|
+
|
52
|
+
def in_rescue_block?(node)
|
53
|
+
current_node = node
|
35
54
|
|
36
|
-
current_node =
|
37
|
-
|
38
|
-
return if current_node
|
55
|
+
while (current_node = current_node.parent)
|
56
|
+
return true if current_node.rescue_type?
|
57
|
+
return true if active_support_rescuable_block?(current_node)
|
39
58
|
|
40
59
|
break if current_node.def_type?
|
41
60
|
break if current_node.class_type?
|
42
|
-
|
43
|
-
current_node = current_node.parent
|
44
61
|
end
|
45
|
-
|
46
|
-
add_offense(node, location: node.children[0].loc.expression)
|
47
62
|
end
|
48
63
|
end
|
49
64
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-vendor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danilo Cabello
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2019-05-
|
13
|
+
date: 2019-05-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rubocop
|