rubocop-vendor 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/rubocop/cop/vendor/rollbar_inside_rescue.rb +51 -0
- data/lib/rubocop/cop/vendor_cops.rb +1 -0
- data/lib/rubocop/vendor/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cfa5c71a43d700d91d855e340c1518a5f56158557a2d67043deb8dc1659ef581
|
4
|
+
data.tar.gz: 03d35e4c72b4b5f6f22a14ac8b407d9c5214daebdaaeadb3b63071f1bdf908d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 171f091f8d6bd081c0a669b12ec4610b8e3b8874b32cfd69d8325b094dfd6c5f841d93b14aacf61567c9ab70ca988ecf2244b7350f69db83b6c1e1d6becffbdb
|
7
|
+
data.tar.gz: fc669e34d8d27b3d8ced74cf5852baf94067ae9cec52263aa82ba1b1fecd8d42716716e3bfbd75ec84c7c658f08e49bac0c1b4afbedd840d92733506b5e05764
|
data/README.md
CHANGED
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Vendor
|
6
|
+
# This cop checks for Rollbar calls outside `rescue` blocks.
|
7
|
+
#
|
8
|
+
# The main reason for this suggestion is that Rollbar should not be used
|
9
|
+
# as a logger given it has a quota that is often multiple times smaller
|
10
|
+
# than the log quota. By reporting errors outside rescue blocks
|
11
|
+
# the developer is most likely in control of the exceptional flow and
|
12
|
+
# won't need a stack trace.
|
13
|
+
#
|
14
|
+
# @example
|
15
|
+
# # bad
|
16
|
+
# Rollbar.error("Unable to sync account")
|
17
|
+
#
|
18
|
+
# # good
|
19
|
+
# begin
|
20
|
+
# 1 / 0
|
21
|
+
# rescue StandardError => exception
|
22
|
+
# Rollbar.error(exception, "Unable to sync account")
|
23
|
+
# end
|
24
|
+
#
|
25
|
+
class RollbarInsideRescue < Cop
|
26
|
+
MSG = 'Only call Rollbar when handling errors inside a `rescue` block.'
|
27
|
+
|
28
|
+
def_node_matcher :rollbar?, <<-PATTERN
|
29
|
+
(send
|
30
|
+
(const nil? :Rollbar) {:log :debug :info :warning :error :critical} ...)
|
31
|
+
PATTERN
|
32
|
+
|
33
|
+
def on_send(node)
|
34
|
+
return unless rollbar?(node)
|
35
|
+
|
36
|
+
current_node = node.parent
|
37
|
+
until current_node.nil?
|
38
|
+
return if current_node.rescue_type?
|
39
|
+
|
40
|
+
break if current_node.def_type?
|
41
|
+
break if current_node.class_type?
|
42
|
+
|
43
|
+
current_node = current_node.parent
|
44
|
+
end
|
45
|
+
|
46
|
+
add_offense(node, location: node.children[0].loc.expression)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
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.4.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-
|
13
|
+
date: 2019-05-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rubocop
|
@@ -82,6 +82,7 @@ files:
|
|
82
82
|
- README.md
|
83
83
|
- config/default.yml
|
84
84
|
- lib/rubocop-vendor.rb
|
85
|
+
- lib/rubocop/cop/vendor/rollbar_inside_rescue.rb
|
85
86
|
- lib/rubocop/cop/vendor/rollbar_interpolation.rb
|
86
87
|
- lib/rubocop/cop/vendor/rollbar_log.rb
|
87
88
|
- lib/rubocop/cop/vendor/rollbar_logger.rb
|