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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cfa5c71a43d700d91d855e340c1518a5f56158557a2d67043deb8dc1659ef581
4
- data.tar.gz: 03d35e4c72b4b5f6f22a14ac8b407d9c5214daebdaaeadb3b63071f1bdf908d3
3
+ metadata.gz: df0960a7f70d9595e65685ba09c4ff6483eaa7f35039942d9e17522806852a05
4
+ data.tar.gz: 034c31c0811ab28653b3b86526032f9b681cd0154f61faa080ac08916c020c34
5
5
  SHA512:
6
- metadata.gz: 171f091f8d6bd081c0a669b12ec4610b8e3b8874b32cfd69d8325b094dfd6c5f841d93b14aacf61567c9ab70ca988ecf2244b7350f69db83b6c1e1d6becffbdb
7
- data.tar.gz: fc669e34d8d27b3d8ced74cf5852baf94067ae9cec52263aa82ba1b1fecd8d42716716e3bfbd75ec84c7c658f08e49bac0c1b4afbedd840d92733506b5e05764
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 = node.parent
37
- until current_node.nil?
38
- return if current_node.rescue_type?
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
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Vendor
5
5
  module Version
6
- STRING = '0.4.0'
6
+ STRING = '0.5.0'
7
7
  end
8
8
  end
9
9
  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.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 00:00:00.000000000 Z
13
+ date: 2019-05-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rubocop