rubocop-vendor 0.1.0 → 0.2.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/config/default.yml +5 -0
- data/lib/rubocop/cop/vendor/rollbar_log.rb +42 -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: 5072a6d34dc157a8067353787c18de1f0d29391bcd444200db28663b207a69ba
|
4
|
+
data.tar.gz: 13f6b9f89c3f88aff7933d52d3f62eaa52e6ced21a90a25add5321a20083ea96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5850e36f8d60e097beffbea26dd32453a3201ec49447dbec1e033eb200f99b54af2ebdc63557ed45e6741a09d0413c346134717b6b786f27a9dec22e22843ee1
|
7
|
+
data.tar.gz: f38f8b445d42bd1eef44dfd270a9a3c89d8093e9572de51acb0bbe1cfaba50bfa57444eda0b3aadd11fc1047e79d46ef2b43be5d4dc4b923d54230411029cf6d
|
data/config/default.yml
CHANGED
@@ -5,6 +5,11 @@ Vendor/RollbarInterpolation:
|
|
5
5
|
Enabled: true
|
6
6
|
VersionAdded: '0.1.0'
|
7
7
|
|
8
|
+
Vendor/RollbarLog:
|
9
|
+
Description: 'Avoid calls to `Rollbar.log`.'
|
10
|
+
Enabled: true
|
11
|
+
VersionAdded: '0.2.0'
|
12
|
+
|
8
13
|
Vendor/RollbarLogger:
|
9
14
|
Description: 'Use logger instead of `Rollbar.debug`, `info` or `warning` calls.'
|
10
15
|
Enabled: true
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Vendor
|
6
|
+
# This cop checks for `Rollbar.log` usage and suggests specialized
|
7
|
+
# method calls instead.
|
8
|
+
#
|
9
|
+
# The main reason for this suggestion is consistency.
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
# # bad
|
13
|
+
# Rollbar.log('info', 'Stale message')
|
14
|
+
#
|
15
|
+
# # good
|
16
|
+
# Rollbar.info('Stale message')
|
17
|
+
#
|
18
|
+
class RollbarLog < Cop
|
19
|
+
MSG = 'Use `Rollbar.%<method>s` instead of `Rollbar.log`.'
|
20
|
+
|
21
|
+
def_node_matcher :bad_method?, <<-PATTERN
|
22
|
+
(send
|
23
|
+
(const nil? :Rollbar) :log
|
24
|
+
$({str sym} _) ...)
|
25
|
+
PATTERN
|
26
|
+
|
27
|
+
def on_send(node)
|
28
|
+
level = bad_method?(node)
|
29
|
+
return unless level
|
30
|
+
|
31
|
+
add_offense(level)
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def message(node)
|
37
|
+
format(MSG, method: node.value)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
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.2.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-04-
|
13
|
+
date: 2019-04-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rubocop
|
@@ -55,6 +55,7 @@ files:
|
|
55
55
|
- config/default.yml
|
56
56
|
- lib/rubocop-vendor.rb
|
57
57
|
- lib/rubocop/cop/vendor/rollbar_interpolation.rb
|
58
|
+
- lib/rubocop/cop/vendor/rollbar_log.rb
|
58
59
|
- lib/rubocop/cop/vendor/rollbar_logger.rb
|
59
60
|
- lib/rubocop/cop/vendor/rollbar_with_exception.rb
|
60
61
|
- lib/rubocop/cop/vendor_cops.rb
|