rf-stylez 0.11.0 → 0.14.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7ccc61a83003b3de44d1bfc278492c425bd472dc04ffcfc5b3553b79b0fdaf30
4
- data.tar.gz: 3c04bc697ecec80f69431996caab873691e86a028490c84727cbab7cec7922c0
3
+ metadata.gz: 61997bdfb767ee58340845830dd03f1a71f9432318818ddca2c511f70d570dbb
4
+ data.tar.gz: 96b7a3c0213e4980736a2a32f45827776b9eb376399f2ca2a32fcff468da1f28
5
5
  SHA512:
6
- metadata.gz: c5986cd858419d5f000158dc8ca19d0d7c407259bfcd6b7e7fbf7abeb17166f2debedca2983ec1a8af75fbb522892f923401c233acc5b2626565300c1f7cc997
7
- data.tar.gz: 89ea291297ee107387ea9cbb2bd8a29864c180e0dbf2d53608c337c7c3914eef6bcb9a8da7567a0a04cf4b75ca8ab18564a3a6efd72c7c1374a2a73603e64fa6
6
+ metadata.gz: f9f9830783fc1680ff00cbcc316f324e330815d59f603c2c539830f76df2fd12b887d44a3f53c22d560450533860bb5209fdb79c00b827e5c0ec3f6c1a0623c8
7
+ data.tar.gz: 042cff1fe645245641e7cdd34250f343b9853c53939de469106794fb4021aefc83f2572b495efc01630b6ca2b8a9aa82b89b521c968c1b6b46edcf7a6e781dbc
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Rf
4
4
  module Stylez
5
- VERSION = '0.11.0'
5
+ VERSION = '0.14.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:
@@ -50,6 +54,7 @@ Layout/TrailingWhitespace:
50
54
  Enabled: true
51
55
  Layout/EmptyLineBetweenDefs:
52
56
  Enabled: true
57
+ EmptyLineBetweenClassDefs: false
53
58
  Layout/IndentationWidth:
54
59
  Enabled: true
55
60
  Layout/AccessModifierIndentation:
@@ -130,7 +135,18 @@ Style/MethodCallWithoutArgsParentheses:
130
135
  Style/InfiniteLoop:
131
136
  Enabled: true
132
137
  Style/StringLiterals:
133
- Enabled: true
138
+ Description: 'Checks if uses of quotes match the configured preference.'
139
+ StyleGuide: '#consistent-string-literals'
140
+ Enabled: true
141
+ VersionAdded: '0.9'
142
+ VersionChanged: '0.36'
143
+ EnforcedStyle: double_quotes
144
+ SupportedStyles:
145
+ - single_quotes
146
+ - double_quotes
147
+ # If `true`, strings which span multiple lines using `\` for continuation must
148
+ # use the same type of quotes on each line.
149
+ ConsistentQuotesInMultiline: true
134
150
  Style/AndOr:
135
151
  Enabled: true
136
152
  Style/Not:
@@ -160,12 +176,18 @@ Style/SymbolProc:
160
176
  Enabled: true
161
177
  Style/RegexpLiteral:
162
178
  Enabled: true
179
+ Style/Documentation:
180
+ Enabled: true
181
+ Style/DocumentationMethod:
182
+ Enabled: false
163
183
 
164
184
  Layout/LineLength:
165
185
  Enabled: true
166
186
  Max: 120
167
187
  AllowHeredoc: true
168
188
  AllowURI: true
189
+ Layout/EmptyLineAfterMagicComment:
190
+ Enabled: true
169
191
 
170
192
  # Dumb lint cops
171
193
  Lint/AmbiguousOperator:
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.0
4
+ version: 0.14.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: 2022-02-08 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