rubocop-vendor 0.7.0 → 0.7.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5c7f95e01811c3177f6f45897a3637053eb5b511e374551b97d1130e4032ad6d
4
- data.tar.gz: eba723e710aee712fe9fb0772b723f816868e949ad011d42285e7c0229250731
3
+ metadata.gz: 75fb6f80f777001ae08fb11275a2489740ea2477d14c0e76ddae6ad8ab7f7132
4
+ data.tar.gz: 7fda8672d9cd813640f0361d4f10815dc0e534a1e2df220331e042c84e7d098c
5
5
  SHA512:
6
- metadata.gz: b669cc4e4852b7c56a3206ac1c90557c56ea43f7c717ff01a7445af3e305e5a4f3c55349381d2ac3840e5a05955fa2364b7bef10c446659ecc73b72e04751f52
7
- data.tar.gz: f3c87ffe11f4e0e496ab9975e015c0ec1ed780c600712834403896e871826e5ede0e5798c3f39e16cf543d2c2eacff64e124c1660f35fdfbbfc608da2db104d7
6
+ metadata.gz: 558ad8d98baaa0611ff368bbfd297364e0d84c0cc491c1e8194c11c77cd56fd43fca48671dc24ecc6ed7d41f2d3853b780835850853c4cd732973333e8a2bcc8
7
+ data.tar.gz: 6aae9c4d1b9ff948e392c328f84efa230283aa292d85cc294f59adaddd1e96b2a1341d287907061c798e88f746c24eb5e0bee8265a27c79bbc670c11a603e711
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Vendor
6
+ class Base < Rubocop::Cop::Base
7
+ end
8
+ end
9
+ end
10
+ end
@@ -44,7 +44,7 @@ module RuboCop
44
44
  # test_double = double
45
45
  # allow(test_double).to receive(:a).and_return('b')
46
46
  #
47
- class RecursiveOpenStructUse < Cop
47
+ class RecursiveOpenStructUse < Base
48
48
  MSG = <<~MSG.strip
49
49
  Avoid using `RecursiveOpenStruct`; use `Struct`, `Hash`, a class or test doubles instead.
50
50
  MSG
@@ -29,7 +29,7 @@ module RuboCop
29
29
  # end
30
30
  # end
31
31
  #
32
- class RollbarInsideRescue < Cop
32
+ class RollbarInsideRescue < Base
33
33
  MSG = 'Only call Rollbar when handling errors inside a `rescue` block.'
34
34
 
35
35
  # @!method rollbar?(node)
@@ -48,7 +48,7 @@ module RuboCop
48
48
  return unless rollbar?(node)
49
49
  return if in_rescue_block?(node)
50
50
 
51
- add_offense(node, location: node.children[0].loc.expression)
51
+ add_offense(node.children[0].loc.expression)
52
52
  end
53
53
 
54
54
  def in_rescue_block?(node)
@@ -16,7 +16,7 @@ module RuboCop
16
16
  # # good
17
17
  # Rollbar.error(e, "Unable to sync account", account_id: account.id)
18
18
  #
19
- class RollbarInterpolation < Cop
19
+ class RollbarInterpolation < Base
20
20
  MSG = 'Send extra fields as hash parameter instead of interpolated message.'
21
21
 
22
22
  # @!method bad_method?(node)
@@ -15,8 +15,9 @@ module RuboCop
15
15
  # # good
16
16
  # Rollbar.info('Stale message')
17
17
  #
18
- class RollbarLog < Cop
18
+ class RollbarLog < Base
19
19
  include RangeHelp
20
+ extend AutoCorrector
20
21
 
21
22
  MSG = 'Use `Rollbar.%<method>s` instead of `Rollbar.log`.'
22
23
 
@@ -30,13 +31,11 @@ module RuboCop
30
31
  def on_send(node)
31
32
  return unless bad_method?(node)
32
33
 
33
- add_offense(node, location: offending_range(node))
34
- end
35
-
36
- def autocorrect(node)
37
34
  range = offending_range(node)
38
- replacement = "#{node.children[2].value}#{range.source.include?('(') ? '(' : ' '}"
39
- lambda do |corrector|
35
+ method = node.children[2].value
36
+
37
+ add_offense(range, message: format(MSG, method: method)) do |corrector|
38
+ replacement = "#{method}#{range.source.include?('(') ? '(' : ' '}"
40
39
  corrector.replace(range, replacement)
41
40
  end
42
41
  end
@@ -49,10 +48,6 @@ module RuboCop
49
48
  node.children[3].loc.column
50
49
  )
51
50
  end
52
-
53
- def message(node)
54
- format(MSG, method: node.children[2].value)
55
- end
56
51
  end
57
52
  end
58
53
  end
@@ -17,7 +17,9 @@ module RuboCop
17
17
  # # good
18
18
  # Rails.logger.info("Stale message")
19
19
  #
20
- class RollbarLogger < Cop
20
+ class RollbarLogger < Base
21
+ extend AutoCorrector
22
+
21
23
  MSG = 'Use `Rails.logger` for `debug`, `info` or `warning` calls.'
22
24
 
23
25
  # @!method bad_method?(node)
@@ -28,12 +30,10 @@ module RuboCop
28
30
  def on_send(node)
29
31
  return unless bad_method?(node)
30
32
 
31
- add_offense(node, location: node.children[0].loc.expression)
32
- end
33
+ offending_node = node.children.first
33
34
 
34
- def autocorrect(node)
35
- lambda do |corrector|
36
- corrector.replace(node.children[0].loc.expression, 'Rails.logger')
35
+ add_offense(offending_node) do |corrector|
36
+ corrector.replace(offending_node.loc.expression, 'Rails.logger')
37
37
  end
38
38
  end
39
39
  end
@@ -19,7 +19,7 @@ module RuboCop
19
19
  # # good
20
20
  # Rollbar.error(exception, "Unable to sync account")
21
21
  #
22
- class RollbarWithException < Cop
22
+ class RollbarWithException < Base
23
23
  include RangeHelp
24
24
 
25
25
  MSG = 'Send exception as first parameter when calling `error` or `critical`.'
@@ -37,7 +37,8 @@ module RuboCop
37
37
  return unless first_param
38
38
 
39
39
  begin_pos = first_param.loc.expression.begin.begin_pos
40
- add_offense(first_param, location: range_between(begin_pos, begin_pos + 1))
40
+
41
+ add_offense(range_between(begin_pos, begin_pos + 1))
41
42
  end
42
43
  end
43
44
  end
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Vendor
5
5
  module Version
6
- STRING = '0.7.0'
6
+ STRING = '0.7.1'
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.7.0
4
+ version: 0.7.1
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: 2021-12-06 00:00:00.000000000 Z
13
+ date: 2021-12-07 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/base.rb
85
86
  - lib/rubocop/cop/vendor/recursive_open_struct_gem.rb
86
87
  - lib/rubocop/cop/vendor/recursive_open_struct_use.rb
87
88
  - lib/rubocop/cop/vendor/rollbar_inside_rescue.rb
@@ -102,6 +103,7 @@ metadata:
102
103
  source_code_uri: https://github.com/wealthsimple/rubocop-vendor/
103
104
  documentation_uri: https://rubocop-vendor.readthedocs.io/
104
105
  bug_tracker_uri: https://github.com/wealthsimple/rubocop-vendor/issues
106
+ rubygems_mfa_required: 'true'
105
107
  post_install_message:
106
108
  rdoc_options: []
107
109
  require_paths: