rf-stylez 0.11.1 → 0.12.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: 73102c0596ce3354435f37083348b38db9d7def32d14e8d6c14ecc5c7869a9fe
4
- data.tar.gz: 8f272dd380d4bde12f56fbc15e3edd68d7fce16504d4920629fe415b0e326508
3
+ metadata.gz: 379e37d37df24166deb38eef0b97d0373a6734aeb738b8bfb80637bf118bc012
4
+ data.tar.gz: b6b1d14e28ae49b27e9e25f766d729b8bddea43b5227010b129690bbb58e19db
5
5
  SHA512:
6
- metadata.gz: 7cbb8cf428fe5d4f743dc571a947826114885369f614af81edd6ea3de3f6f36a498653db5bad394974731eb2d97693a09e5feb59d9ffd2e717405ed78d8f65e0
7
- data.tar.gz: 077d3802422b789e01fc1101e011499ec0bdce6f651af4e31c0ecef7427b2c7c7f1354036a00dca45ac21a000eb018f92a087276acfee4beb1af5d85e68849f4
6
+ metadata.gz: 6cba253d02a644530d184380ba14d9bc716190866c8e891f547bd791d08d016b8ecbe82ff6bf366a89af79fac879c71b6d58643b8eb4fe1968c793c6bc29bd93
7
+ data.tar.gz: 2dbb03b8a502241e7ff0494414753281bf5a5d8352c9e781a3803fcecefdb3a3addf94e399939f0946681cfa904a41f6fca1c104920a827304ba171cfa82801c
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Rf
4
4
  module Stylez
5
- VERSION = '0.11.1'
5
+ VERSION = '0.12.0'
6
6
  end
7
7
  end
data/lib/rf/stylez.rb CHANGED
@@ -9,6 +9,7 @@ require 'rubocop/cop/lint/obscure'
9
9
  require 'rubocop/cop/lint/no_grape_api'
10
10
  require 'rubocop/cop/lint/use_positive_int32_validator'
11
11
  require 'rubocop/cop/lint/no_untyped_raise'
12
+ require 'rubocop/cop/lint/no_vcr_recording'
12
13
 
13
14
  module Rf
14
15
  module Stylez
@@ -0,0 +1,74 @@
1
+ # frozen_string_literal: true
2
+ require 'unparser'
3
+
4
+ module RuboCop
5
+ module Cop
6
+ module Lint
7
+ # @example
8
+ # # bad
9
+ # vcr: { record_mode: :once, tag: :foo }
10
+ # vcr: { record_mode: :none }
11
+ #
12
+ # # good
13
+ # vcr: { tag: :foo }
14
+ # vcr: true
15
+ class NoVCRRecording < RuboCop::Cop::Base
16
+ extend AutoCorrector
17
+
18
+ MSG = 'Do not set :record option in VCR'.freeze
19
+
20
+ def_node_search :is_only_setting_record_option?, <<~PATTERN
21
+ (pair
22
+ (sym :vcr)
23
+ (hash
24
+ (pair
25
+ (sym :record)
26
+ ...
27
+ )
28
+ )
29
+ )
30
+ PATTERN
31
+ def_node_search :is_setting_record_option?, <<~PATTERN
32
+ (pair
33
+ (sym :vcr)
34
+ (hash
35
+ <
36
+ (pair
37
+ (sym :record)
38
+ ...
39
+ )
40
+ ...
41
+ >
42
+ )
43
+ )
44
+ PATTERN
45
+
46
+ def on_pair(node)
47
+ return unless is_only_setting_record_option?(node) || is_setting_record_option?(node)
48
+
49
+ add_offense(node) do |corrector|
50
+ if is_only_setting_record_option?(node)
51
+ corrector.replace(node, 'vcr: true')
52
+ elsif is_setting_record_option?(node)
53
+ corrector.replace(node, remove_record_option(node))
54
+ end
55
+ end
56
+ end
57
+
58
+ private
59
+
60
+ def remove_record_option(top_pair_node)
61
+ extend AST::Sexp
62
+
63
+ _vcr_key, hash = top_pair_node.children
64
+ other_options = hash.children.reject do |pair|
65
+ key, _value = pair.children
66
+ key == s(:sym, :record)
67
+ end
68
+
69
+ Unparser.unparse(s(:pair, s(:sym, :vcr), s(:hash, *other_options)))
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
data/rf-stylez.gemspec CHANGED
@@ -19,11 +19,12 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = ['rf-stylez']
20
20
  spec.require_paths = ['lib']
21
21
 
22
- spec.add_runtime_dependency 'rubocop', '1.12'
23
- spec.add_runtime_dependency 'rubocop-rails', '2.9.1'
22
+ spec.add_runtime_dependency 'rubocop', '1.15.0'
23
+ spec.add_runtime_dependency 'rubocop-rails', '2.10.1'
24
24
  spec.add_runtime_dependency 'rubocop-rspec', '2.3.0'
25
25
  spec.add_runtime_dependency 'get_env', '~> 0.2.0'
26
26
  spec.add_runtime_dependency 'semantic_versioning', '~> 0.2'
27
+ spec.add_runtime_dependency 'unparser', '~> 0.6'
27
28
 
28
29
  spec.add_development_dependency 'bundler', '~> 2.1'
29
30
  spec.add_development_dependency 'rake', '~> 13.0'
data/ruby/rubocop.yml CHANGED
@@ -34,6 +34,10 @@ Lint/UsePositiveInt32Validator:
34
34
  Enabled: true
35
35
  Lint/NoJSON:
36
36
  Enabled: true
37
+ Lint/NoVCRRecording:
38
+ Enabled: true
39
+ Include:
40
+ - spec/**/*
37
41
 
38
42
  # Good style cops
39
43
  Layout/BlockAlignment:
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rf-stylez
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.1
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emanuel Evans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-14 00:00:00.000000000 Z
11
+ date: 2021-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: '1.12'
19
+ version: 1.15.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: '1.12'
26
+ version: 1.15.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rubocop-rails
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 2.9.1
33
+ version: 2.10.1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 2.9.1
40
+ version: 2.10.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rubocop-rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0.2'
83
+ - !ruby/object:Gem::Dependency
84
+ name: unparser
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.6'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.6'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: bundler
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -178,6 +192,7 @@ files:
178
192
  - lib/rubocop/cop/lint/no_http_party.rb
179
193
  - lib/rubocop/cop/lint/no_json.rb
180
194
  - lib/rubocop/cop/lint/no_untyped_raise.rb
195
+ - lib/rubocop/cop/lint/no_vcr_recording.rb
181
196
  - lib/rubocop/cop/lint/obscure.rb
182
197
  - lib/rubocop/cop/lint/use_positive_int32_validator.rb
183
198
  - rails/rubocop.yml