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 +4 -4
- data/lib/rf/stylez/version.rb +1 -1
- data/lib/rf/stylez.rb +1 -0
- data/lib/rubocop/cop/lint/no_vcr_recording.rb +74 -0
- data/rf-stylez.gemspec +3 -2
- data/ruby/rubocop.yml +4 -0
- metadata +21 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 379e37d37df24166deb38eef0b97d0373a6734aeb738b8bfb80637bf118bc012
|
4
|
+
data.tar.gz: b6b1d14e28ae49b27e9e25f766d729b8bddea43b5227010b129690bbb58e19db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6cba253d02a644530d184380ba14d9bc716190866c8e891f547bd791d08d016b8ecbe82ff6bf366a89af79fac879c71b6d58643b8eb4fe1968c793c6bc29bd93
|
7
|
+
data.tar.gz: 2dbb03b8a502241e7ff0494414753281bf5a5d8352c9e781a3803fcecefdb3a3addf94e399939f0946681cfa904a41f6fca1c104920a827304ba171cfa82801c
|
data/lib/rf/stylez/version.rb
CHANGED
data/lib/rf/stylez.rb
CHANGED
@@ -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.
|
23
|
-
spec.add_runtime_dependency 'rubocop-rails', '2.
|
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
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.
|
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-
|
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:
|
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:
|
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.
|
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.
|
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
|