cookstyle 4.0.0 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,53 @@
1
+ #
2
+ # Copyright:: 2016, Chris Henry
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ module RuboCop
18
+ module Cop
19
+ module Chef
20
+ # Use a service resource to start and stop services
21
+ #
22
+ # @example when command starts a service
23
+ #
24
+ # # bad
25
+ # command "/etc/init.d/mysql start"
26
+ # command "/sbin/service/memcached start"
27
+ #
28
+ class ServiceResource < Cop
29
+ MSG = 'Use a service resource to start and stop services'.freeze
30
+
31
+ def_node_matcher :execute_command?, <<-PATTERN
32
+ (send nil :command $str)
33
+ PATTERN
34
+
35
+ def on_send(node)
36
+ execute_command?(node) do |command|
37
+ if starts_service?(command)
38
+ add_offense(command, location: :expression, message: MSG, severity: :warning)
39
+ end
40
+ end
41
+ end
42
+
43
+ def starts_service?(cmd)
44
+ cmd_str = cmd.to_s
45
+ (cmd_str.include?('/etc/init.d') || ['service ', '/sbin/service ',
46
+ 'start ', 'stop ', 'invoke-rc.d '].any? do |service_cmd|
47
+ cmd_str.start_with?(service_cmd)
48
+ end) && %w(start stop restart reload).any? { |a| cmd_str.include?(a) }
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,58 @@
1
+ #
2
+ # Copyright:: 2016, Chris Henry
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ module RuboCop
18
+ module Cop
19
+ module Chef
20
+ # Use file_cache_path rather than hard-coding tmp paths
21
+ #
22
+ # @example downloading a large file into /tmp/
23
+ #
24
+ # # bad
25
+ # remote_file '/tmp/large-file.tar.gz' do
26
+ #
27
+ # # good
28
+ # remote_file "#{Chef::Config[:file_cache_path]}/large-file.tar.gz" do
29
+ #
30
+ #
31
+ class TmpPath < Cop
32
+ MSG = 'Use file_cache_path rather than hard-coding tmp paths'.freeze
33
+
34
+ def_node_matcher :remote_file?, <<-PATTERN
35
+ (send nil :remote_file $str)
36
+ PATTERN
37
+
38
+ def on_send(node)
39
+ remote_file?(node) do |command|
40
+ if hardcoded_tmp?(command) && !file_cache_path?(command)
41
+ add_offense(command, location: :expression, message: MSG, severity: :warning)
42
+ end
43
+ end
44
+ end
45
+
46
+ def hardcoded_tmp?(path)
47
+ path_str = path.to_s.scan(/"(.*)"/)[0][0]
48
+ path_str.start_with?('/tmp/')
49
+ end
50
+
51
+ def file_cache_path?(path)
52
+ path_str = path.to_s.scan(/"(.*)"/)[0][0]
53
+ path_str.start_with?("\#\{Chef::Config[:file_cache_path]\}")
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cookstyle
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thom May
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-01-22 00:00:00.000000000 Z
12
+ date: 2019-07-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -45,14 +45,14 @@ dependencies:
45
45
  requirements:
46
46
  - - '='
47
47
  - !ruby/object:Gem::Version
48
- version: 0.62.0
48
+ version: 0.72.0
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - '='
54
54
  - !ruby/object:Gem::Version
55
- version: 0.62.0
55
+ version: 0.72.0
56
56
  description:
57
57
  email:
58
58
  - thom@chef.io
@@ -68,12 +68,18 @@ files:
68
68
  - config/cookstyle.yml
69
69
  - config/default.yml
70
70
  - config/disable_all.yml
71
- - config/disabled.yml
72
- - config/enabled.yml
73
71
  - config/upstream.yml
74
72
  - cookstyle.gemspec
75
73
  - lib/cookstyle.rb
76
74
  - lib/cookstyle/version.rb
75
+ - lib/rubocop/chef.rb
76
+ - lib/rubocop/chef/cookbook_only.rb
77
+ - lib/rubocop/cop/chef/attribute_keys.rb
78
+ - lib/rubocop/cop/chef/comments_copyright_format.rb
79
+ - lib/rubocop/cop/chef/comments_format.rb
80
+ - lib/rubocop/cop/chef/file_mode.rb
81
+ - lib/rubocop/cop/chef/service_resource.rb
82
+ - lib/rubocop/cop/chef/tmp_path.rb
77
83
  homepage: https://github.com/chef/cookstyle
78
84
  licenses:
79
85
  - Apache-2.0
@@ -93,8 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
99
  - !ruby/object:Gem::Version
94
100
  version: '0'
95
101
  requirements: []
96
- rubyforge_project:
97
- rubygems_version: 2.7.6
102
+ rubygems_version: 3.0.3
98
103
  signing_key:
99
104
  specification_version: 4
100
105
  summary: RuboCop configuration for Chef cookbooks
@@ -1,128 +0,0 @@
1
- # These are all the cops that are disabled in the default configuration.
2
-
3
- Layout/ClassStructure:
4
- Description: 'Enforces a configured order of definitions within a class body.'
5
- StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#consistent-classes'
6
- Enabled: false
7
-
8
- Layout/FirstArrayElementLineBreak:
9
- Description: >-
10
- Checks for a line break before the first element in a
11
- multi-line array.
12
- Enabled: false
13
-
14
- Layout/FirstHashElementLineBreak:
15
- Description: >-
16
- Checks for a line break before the first element in a
17
- multi-line hash.
18
- Enabled: false
19
-
20
- Layout/FirstMethodArgumentLineBreak:
21
- Description: >-
22
- Checks for a line break before the first argument in a
23
- multi-line method call.
24
- Enabled: false
25
-
26
- Layout/FirstMethodParameterLineBreak:
27
- Description: >-
28
- Checks for a line break before the first parameter in a
29
- multi-line method parameter definition.
30
- Enabled: false
31
-
32
- Layout/MultilineAssignmentLayout:
33
- Description: 'Check for a newline after the assignment operator in multi-line assignments.'
34
- StyleGuide: '#indent-conditional-assignment'
35
- Enabled: false
36
-
37
- Lint/NumberConversion:
38
- Description: 'Checks unsafe usage of number conversion methods.'
39
- Enabled: false
40
-
41
- # By default, the rails cops are not run. Override in project or home
42
- # directory .rubocop.yml files, or by giving the -R/--rails option.
43
- Rails:
44
- Enabled: false
45
-
46
- Rails/SaveBang:
47
- Description: 'Identifies possible cases where Active Record save! or related should be used.'
48
- StyleGuide: 'https://github.com/bbatsov/rails-style-guide#save-bang'
49
- Enabled: false
50
-
51
- Style/AutoResourceCleanup:
52
- Description: 'Suggests the usage of an auto resource cleanup version of a method (if available).'
53
- Enabled: false
54
-
55
- Style/CollectionMethods:
56
- Description: 'Preferred collection methods.'
57
- StyleGuide: '#map-find-select-reduce-size'
58
- Enabled: false
59
-
60
- Style/Copyright:
61
- Description: 'Include a copyright notice in each file before any code.'
62
- Enabled: false
63
-
64
- Style/DocumentationMethod:
65
- Description: 'Public methods.'
66
- Enabled: false
67
- Exclude:
68
- - 'spec/**/*'
69
- - 'test/**/*'
70
-
71
- Layout/EmptyLineAfterGuardClause:
72
- Description: 'Add empty line after guard clause.'
73
- Enabled: false
74
-
75
- Style/ImplicitRuntimeError:
76
- Description: >-
77
- Use `raise` or `fail` with an explicit exception class and
78
- message, rather than just a message.
79
- Enabled: false
80
-
81
- Style/InlineComment:
82
- Description: 'Avoid trailing inline comments.'
83
- Enabled: false
84
-
85
- Style/MethodCallWithArgsParentheses:
86
- Description: 'Use parentheses for method calls with arguments.'
87
- StyleGuide: '#method-invocation-parens'
88
- Enabled: false
89
-
90
- Style/MethodCalledOnDoEndBlock:
91
- Description: 'Avoid chaining a method call on a do...end block.'
92
- StyleGuide: '#single-line-blocks'
93
- Enabled: false
94
-
95
- Style/MissingElse:
96
- Description: >-
97
- Require if/case expressions to have an else branches.
98
- If enabled, it is recommended that
99
- Style/UnlessElse and Style/EmptyElse be enabled.
100
- This will conflict with Style/EmptyElse if
101
- Style/EmptyElse is configured to style "both"
102
- Enabled: false
103
-
104
- Style/OptionHash:
105
- Description: "Don't use option hashes when you can use keyword arguments."
106
- Enabled: false
107
-
108
- Style/ReturnNil:
109
- Description: 'Use return instead of return nil.'
110
- Enabled: false
111
-
112
- Style/Send:
113
- Description: 'Prefer `Object#__send__` or `Object#public_send` to `send`, as `send` may overlap with existing methods.'
114
- StyleGuide: '#prefer-public-send'
115
- Enabled: false
116
-
117
- Style/SingleLineBlockParams:
118
- Description: 'Enforces the names of some block params.'
119
- Enabled: false
120
-
121
- Style/StringHashKeys:
122
- Description: 'Prefer symbols instead of strings as hash keys.'
123
- StyleGuide: '#symbols-as-keys'
124
- Enabled: false
125
-
126
- Style/StringMethods:
127
- Description: 'Checks if configured preferred methods are used over non-preferred.'
128
- Enabled: false
@@ -1,2068 +0,0 @@
1
- # These are all the cops that are enabled in the default configuration.
2
-
3
- #################### Bundler ###############################
4
-
5
- Bundler/DuplicatedGem:
6
- Description: 'Checks for duplicate gem entries in Gemfile.'
7
- Enabled: true
8
- Include:
9
- - '**/*.gemfile'
10
- - '**/Gemfile'
11
- - '**/gems.rb'
12
-
13
- Bundler/InsecureProtocolSource:
14
- Description: >-
15
- The source `:gemcutter`, `:rubygems` and `:rubyforge` are deprecated
16
- because HTTP requests are insecure. Please change your source to
17
- 'https://rubygems.org' if possible, or 'http://rubygems.org' if not.
18
- Enabled: true
19
- Include:
20
- - '**/*.gemfile'
21
- - '**/Gemfile'
22
- - '**/gems.rb'
23
-
24
- Bundler/OrderedGems:
25
- Description: >-
26
- Gems within groups in the Gemfile should be alphabetically sorted.
27
- Enabled: true
28
- Include:
29
- - '**/*.gemfile'
30
- - '**/Gemfile'
31
- - '**/gems.rb'
32
-
33
- #################### Gemspec ###############################
34
-
35
- Gemspec/DuplicatedAssignment:
36
- Description: 'An attribute assignment method calls should be listed only once in a gemspec.'
37
- Enabled: true
38
- Include:
39
- - '**/*.gemspec'
40
-
41
- Gemspec/OrderedDependencies:
42
- Description: >-
43
- Dependencies in the gemspec should be alphabetically sorted.
44
- Enabled: true
45
- Include:
46
- - '**/*.gemspec'
47
-
48
- Gemspec/RequiredRubyVersion:
49
- Description: 'Checks that `required_ruby_version` of gemspec and `TargetRubyVersion` of .rubocop.yml are equal.'
50
- Enabled: true
51
- Include:
52
- - '**/*.gemspec'
53
-
54
- #################### Layout ###############################
55
-
56
- Layout/AccessModifierIndentation:
57
- Description: Check indentation of private/protected visibility modifiers.
58
- StyleGuide: '#indent-public-private-protected'
59
- Enabled: true
60
-
61
- Layout/AlignArray:
62
- Description: >-
63
- Align the elements of an array literal if they span more than
64
- one line.
65
- StyleGuide: '#align-multiline-arrays'
66
- Enabled: true
67
-
68
- Layout/AlignHash:
69
- Description: >-
70
- Align the elements of a hash literal if they span more than
71
- one line.
72
- Enabled: true
73
-
74
- Layout/AlignParameters:
75
- Description: >-
76
- Align the parameters of a method call if they span more
77
- than one line.
78
- StyleGuide: '#no-double-indent'
79
- Enabled: true
80
-
81
- Layout/BlockAlignment:
82
- Description: 'Align block ends correctly.'
83
- Enabled: true
84
-
85
- Layout/BlockEndNewline:
86
- Description: 'Put end statement of multiline block on its own line.'
87
- Enabled: true
88
-
89
- Layout/CaseIndentation:
90
- Description: 'Indentation of when in a case/when/[else/]end.'
91
- StyleGuide: '#indent-when-to-case'
92
- Enabled: true
93
-
94
- Layout/ClosingParenthesisIndentation:
95
- Description: 'Checks the indentation of hanging closing parentheses.'
96
- Enabled: true
97
-
98
- Layout/CommentIndentation:
99
- Description: 'Indentation of comments.'
100
- Enabled: true
101
-
102
- Layout/ConditionPosition:
103
- Description: >-
104
- Checks for condition placed in a confusing position relative to
105
- the keyword.
106
- StyleGuide: '#same-line-condition'
107
- Enabled: true
108
-
109
- Layout/DefEndAlignment:
110
- Description: 'Align ends corresponding to defs correctly.'
111
- Enabled: true
112
-
113
- Layout/DotPosition:
114
- Description: 'Checks the position of the dot in multi-line method calls.'
115
- StyleGuide: '#consistent-multi-line-chains'
116
- Enabled: true
117
-
118
- Layout/ElseAlignment:
119
- Description: 'Align elses and elsifs correctly.'
120
- Enabled: true
121
-
122
- Layout/EmptyComment:
123
- Description: 'Checks empty comment.'
124
- Enabled: true
125
-
126
- Layout/EmptyLineAfterMagicComment:
127
- Description: 'Add an empty line after magic comments to separate them from code.'
128
- StyleGuide: '#separate-magic-comments-from-code'
129
- Enabled: true
130
-
131
- Layout/EmptyLineBetweenDefs:
132
- Description: 'Use empty lines between defs.'
133
- StyleGuide: '#empty-lines-between-methods'
134
- Enabled: true
135
-
136
- Layout/EmptyLines:
137
- Description: "Don't use several empty lines in a row."
138
- StyleGuide: '#two-or-more-empty-lines'
139
- Enabled: true
140
-
141
- Layout/EmptyLinesAroundAccessModifier:
142
- Description: "Keep blank lines around access modifiers."
143
- StyleGuide: '#empty-lines-around-access-modifier'
144
- Enabled: true
145
-
146
- Layout/EmptyLinesAroundArguments:
147
- Description: "Keeps track of empty lines around method arguments."
148
- Enabled: true
149
-
150
- Layout/EmptyLinesAroundBeginBody:
151
- Description: "Keeps track of empty lines around begin-end bodies."
152
- StyleGuide: '#empty-lines-around-bodies'
153
- Enabled: true
154
-
155
- Layout/EmptyLinesAroundBlockBody:
156
- Description: "Keeps track of empty lines around block bodies."
157
- StyleGuide: '#empty-lines-around-bodies'
158
- Enabled: true
159
-
160
- Layout/EmptyLinesAroundClassBody:
161
- Description: "Keeps track of empty lines around class bodies."
162
- StyleGuide: '#empty-lines-around-bodies'
163
- Enabled: true
164
-
165
- Layout/EmptyLinesAroundExceptionHandlingKeywords:
166
- Description: "Keeps track of empty lines around exception handling keywords."
167
- StyleGuide: '#empty-lines-around-bodies'
168
- Enabled: true
169
-
170
- Layout/EmptyLinesAroundMethodBody:
171
- Description: "Keeps track of empty lines around method bodies."
172
- StyleGuide: '#empty-lines-around-bodies'
173
- Enabled: true
174
-
175
- Layout/EmptyLinesAroundModuleBody:
176
- Description: "Keeps track of empty lines around module bodies."
177
- StyleGuide: '#empty-lines-around-bodies'
178
- Enabled: true
179
-
180
- Layout/EndAlignment:
181
- Description: 'Align ends correctly.'
182
- Enabled: true
183
-
184
- Layout/EndOfLine:
185
- Description: 'Use Unix-style line endings.'
186
- StyleGuide: '#crlf'
187
- Enabled: true
188
-
189
- Layout/ExtraSpacing:
190
- Description: 'Do not use unnecessary spacing.'
191
- Enabled: true
192
-
193
- Layout/FirstParameterIndentation:
194
- Description: 'Checks the indentation of the first parameter in a method call.'
195
- Enabled: true
196
-
197
- Layout/IndentArray:
198
- Description: >-
199
- Checks the indentation of the first element in an array
200
- literal.
201
- Enabled: true
202
-
203
- Layout/IndentAssignment:
204
- Description: >-
205
- Checks the indentation of the first line of the
206
- right-hand-side of a multi-line assignment.
207
- Enabled: true
208
-
209
- Layout/IndentHash:
210
- Description: 'Checks the indentation of the first key in a hash literal.'
211
- Enabled: true
212
-
213
- Layout/IndentHeredoc:
214
- Description: 'This cops checks the indentation of the here document bodies.'
215
- StyleGuide: '#squiggly-heredocs'
216
- Enabled: true
217
-
218
- Layout/IndentationConsistency:
219
- Description: 'Keep indentation straight.'
220
- StyleGuide: '#spaces-indentation'
221
- Enabled: true
222
-
223
- Layout/IndentationWidth:
224
- Description: 'Use 2 spaces for indentation.'
225
- StyleGuide: '#spaces-indentation'
226
- Enabled: true
227
-
228
- Layout/InitialIndentation:
229
- Description: >-
230
- Checks the indentation of the first non-blank non-comment line in a file.
231
- Enabled: true
232
-
233
- Layout/LeadingCommentSpace:
234
- Description: 'Comments should start with a space.'
235
- StyleGuide: '#hash-space'
236
- Enabled: true
237
-
238
- Layout/MultilineArrayBraceLayout:
239
- Description: >-
240
- Checks that the closing brace in an array literal is
241
- either on the same line as the last array element, or
242
- a new line.
243
- Enabled: true
244
-
245
- Layout/MultilineBlockLayout:
246
- Description: 'Ensures newlines after multiline block do statements.'
247
- Enabled: true
248
-
249
- Layout/MultilineHashBraceLayout:
250
- Description: >-
251
- Checks that the closing brace in a hash literal is
252
- either on the same line as the last hash element, or
253
- a new line.
254
- Enabled: true
255
-
256
- Layout/MultilineMethodCallBraceLayout:
257
- Description: >-
258
- Checks that the closing brace in a method call is
259
- either on the same line as the last method argument, or
260
- a new line.
261
- Enabled: true
262
-
263
- Layout/MultilineMethodCallIndentation:
264
- Description: >-
265
- Checks indentation of method calls with the dot operator
266
- that span more than one line.
267
- Enabled: true
268
-
269
- Layout/MultilineMethodDefinitionBraceLayout:
270
- Description: >-
271
- Checks that the closing brace in a method definition is
272
- either on the same line as the last method parameter, or
273
- a new line.
274
- Enabled: true
275
-
276
- Layout/MultilineOperationIndentation:
277
- Description: >-
278
- Checks indentation of binary operations that span more than
279
- one line.
280
- Enabled: true
281
-
282
- Layout/RescueEnsureAlignment:
283
- Description: 'Align rescues and ensures correctly.'
284
- Enabled: true
285
-
286
- Layout/SpaceAfterColon:
287
- Description: 'Use spaces after colons.'
288
- StyleGuide: '#spaces-operators'
289
- Enabled: true
290
-
291
- Layout/SpaceAfterComma:
292
- Description: 'Use spaces after commas.'
293
- StyleGuide: '#spaces-operators'
294
- Enabled: true
295
-
296
- Layout/SpaceAfterMethodName:
297
- Description: >-
298
- Do not put a space between a method name and the opening
299
- parenthesis in a method definition.
300
- StyleGuide: '#parens-no-spaces'
301
- Enabled: true
302
-
303
- Layout/SpaceAfterNot:
304
- Description: Tracks redundant space after the ! operator.
305
- StyleGuide: '#no-space-bang'
306
- Enabled: true
307
-
308
- Layout/SpaceAfterSemicolon:
309
- Description: 'Use spaces after semicolons.'
310
- StyleGuide: '#spaces-operators'
311
- Enabled: true
312
-
313
- Layout/SpaceAroundBlockParameters:
314
- Description: 'Checks the spacing inside and after block parameters pipes.'
315
- Enabled: true
316
-
317
- Layout/SpaceAroundEqualsInParameterDefault:
318
- Description: >-
319
- Checks that the equals signs in parameter default assignments
320
- have or don't have surrounding space depending on
321
- configuration.
322
- StyleGuide: '#spaces-around-equals'
323
- Enabled: true
324
-
325
- Layout/SpaceAroundKeyword:
326
- Description: 'Use a space around keywords if appropriate.'
327
- Enabled: true
328
-
329
- Layout/SpaceAroundOperators:
330
- Description: 'Use a single space around operators.'
331
- StyleGuide: '#spaces-operators'
332
- Enabled: true
333
-
334
- Layout/SpaceBeforeBlockBraces:
335
- Description: >-
336
- Checks that the left block brace has or doesn't have space
337
- before it.
338
- Enabled: true
339
-
340
- Layout/SpaceBeforeComma:
341
- Description: 'No spaces before commas.'
342
- Enabled: true
343
-
344
- Layout/SpaceBeforeComment:
345
- Description: >-
346
- Checks for missing space between code and a comment on the
347
- same line.
348
- Enabled: true
349
-
350
- Layout/SpaceBeforeFirstArg:
351
- Description: >-
352
- Checks that exactly one space is used between a method name
353
- and the first argument for method calls without parentheses.
354
- Enabled: true
355
-
356
- Layout/SpaceBeforeSemicolon:
357
- Description: 'No spaces before semicolons.'
358
- Enabled: true
359
-
360
- Layout/SpaceInLambdaLiteral:
361
- Description: 'Checks for spaces in lambda literals.'
362
- Enabled: true
363
-
364
- Layout/SpaceInsideArrayLiteralBrackets:
365
- Description: 'Checks the spacing inside array literal brackets.'
366
- Enabled: true
367
-
368
- Layout/SpaceInsideArrayPercentLiteral:
369
- Description: 'No unnecessary additional spaces between elements in %i/%w literals.'
370
- Enabled: true
371
-
372
- Layout/SpaceInsideBlockBraces:
373
- Description: >-
374
- Checks that block braces have or don't have surrounding space.
375
- For blocks taking parameters, checks that the left brace has
376
- or doesn't have trailing space.
377
- Enabled: true
378
-
379
- Layout/SpaceInsideHashLiteralBraces:
380
- Description: "Use spaces inside hash literal braces - or don't."
381
- StyleGuide: '#spaces-operators'
382
- Enabled: true
383
-
384
- Layout/SpaceInsideParens:
385
- Description: 'No spaces after ( or before ).'
386
- StyleGuide: '#spaces-braces'
387
- Enabled: true
388
-
389
- Layout/SpaceInsidePercentLiteralDelimiters:
390
- Description: 'No unnecessary spaces inside delimiters of %i/%w/%x literals.'
391
- Enabled: true
392
-
393
- Layout/SpaceInsideRangeLiteral:
394
- Description: 'No spaces inside range literals.'
395
- StyleGuide: '#no-space-inside-range-literals'
396
- Enabled: true
397
-
398
- Layout/SpaceInsideReferenceBrackets:
399
- Description: 'Checks the spacing inside referential brackets.'
400
- Enabled: true
401
-
402
- Layout/SpaceInsideStringInterpolation:
403
- Description: 'Checks for padding/surrounding spaces inside string interpolation.'
404
- StyleGuide: '#string-interpolation'
405
- Enabled: true
406
-
407
- Layout/Tab:
408
- Description: 'No hard tabs.'
409
- StyleGuide: '#spaces-indentation'
410
- Enabled: true
411
-
412
- Layout/TrailingBlankLines:
413
- Description: 'Checks trailing blank lines and final newline.'
414
- StyleGuide: '#newline-eof'
415
- Enabled: true
416
-
417
- Layout/TrailingWhitespace:
418
- Description: 'Avoid trailing whitespace.'
419
- StyleGuide: '#no-trailing-whitespace'
420
- Enabled: true
421
-
422
- #################### Lint ##################################
423
- ### Warnings
424
-
425
- Lint/AmbiguousBlockAssociation:
426
- Description: >-
427
- Checks for ambiguous block association with method when param passed without
428
- parentheses.
429
- StyleGuide: '#syntax'
430
- Enabled: true
431
-
432
- Lint/AmbiguousOperator:
433
- Description: >-
434
- Checks for ambiguous operators in the first argument of a
435
- method invocation without parentheses.
436
- StyleGuide: '#method-invocation-parens'
437
- Enabled: true
438
-
439
- Lint/AmbiguousRegexpLiteral:
440
- Description: >-
441
- Checks for ambiguous regexp literals in the first argument of
442
- a method invocation without parentheses.
443
- Enabled: true
444
-
445
- Lint/AssignmentInCondition:
446
- Description: "Don't use assignment in conditions."
447
- StyleGuide: '#safe-assignment-in-condition'
448
- Enabled: true
449
-
450
- Lint/BigDecimalNew:
451
- Description: '`BigDecimal.new()` is deprecated. Use `BigDecimal()` instead.'
452
- Enabled: true
453
-
454
- Lint/BooleanSymbol:
455
- Description: 'Check for `:true` and `:false` symbols.'
456
- Enabled: true
457
-
458
- Lint/CircularArgumentReference:
459
- Description: "Default values in optional keyword arguments and optional ordinal arguments should not refer back to the name of the argument."
460
- Enabled: true
461
-
462
- Lint/Debugger:
463
- Description: 'Check for debugger calls.'
464
- Enabled: true
465
-
466
- Lint/DeprecatedClassMethods:
467
- Description: 'Check for deprecated class method calls.'
468
- Enabled: true
469
-
470
- Lint/DuplicateCaseCondition:
471
- Description: 'Do not repeat values in case conditionals.'
472
- Enabled: true
473
-
474
- Lint/DuplicateMethods:
475
- Description: 'Check for duplicate method definitions.'
476
- Enabled: true
477
-
478
- Lint/DuplicatedKey:
479
- Description: 'Check for duplicate keys in hash literals.'
480
- Enabled: true
481
-
482
- Lint/EachWithObjectArgument:
483
- Description: 'Check for immutable argument given to each_with_object.'
484
- Enabled: true
485
-
486
- Lint/ElseLayout:
487
- Description: 'Check for odd code arrangement in an else block.'
488
- Enabled: true
489
-
490
- Lint/EmptyEnsure:
491
- Description: 'Checks for empty ensure block.'
492
- Enabled: true
493
- AutoCorrect: false
494
-
495
- Lint/EmptyExpression:
496
- Description: 'Checks for empty expressions.'
497
- Enabled: true
498
-
499
- Lint/EmptyInterpolation:
500
- Description: 'Checks for empty string interpolation.'
501
- Enabled: true
502
-
503
- Lint/EmptyWhen:
504
- Description: 'Checks for `when` branches with empty bodies.'
505
- Enabled: true
506
-
507
- Lint/EndInMethod:
508
- Description: 'END blocks should not be placed inside method definitions.'
509
- Enabled: true
510
-
511
- Lint/EnsureReturn:
512
- Description: 'Do not use return in an ensure block.'
513
- StyleGuide: '#no-return-ensure'
514
- Enabled: true
515
-
516
- Lint/FloatOutOfRange:
517
- Description: >-
518
- Catches floating-point literals too large or small for Ruby to
519
- represent.
520
- Enabled: true
521
-
522
- Lint/FormatParameterMismatch:
523
- Description: 'The number of parameters to format/sprint must match the fields.'
524
- Enabled: true
525
-
526
- Lint/HandleExceptions:
527
- Description: "Don't suppress exception."
528
- StyleGuide: '#dont-hide-exceptions'
529
- Enabled: true
530
-
531
- Lint/ImplicitStringConcatenation:
532
- Description: >-
533
- Checks for adjacent string literals on the same line, which
534
- could better be represented as a single string literal.
535
- Enabled: true
536
-
537
- Lint/IneffectiveAccessModifier:
538
- Description: >-
539
- Checks for attempts to use `private` or `protected` to set
540
- the visibility of a class method, which does not work.
541
- Enabled: true
542
-
543
- Lint/InheritException:
544
- Description: 'Avoid inheriting from the `Exception` class.'
545
- Enabled: true
546
-
547
- Lint/InterpolationCheck:
548
- Description: 'Raise warning for interpolation in single q strs'
549
- Enabled: true
550
-
551
- Lint/LiteralAsCondition:
552
- Description: 'Checks of literals used in conditions.'
553
- Enabled: true
554
-
555
- Lint/LiteralInInterpolation:
556
- Description: 'Checks for literals used in interpolation.'
557
- Enabled: true
558
-
559
- Lint/Loop:
560
- Description: >-
561
- Use Kernel#loop with break rather than begin/end/until or
562
- begin/end/while for post-loop tests.
563
- StyleGuide: '#loop-with-break'
564
- Enabled: true
565
-
566
- Lint/MissingCopEnableDirective:
567
- Description: 'Checks for a `# rubocop:enable` after `# rubocop:disable`'
568
- Enabled: true
569
-
570
- Lint/MultipleCompare:
571
- Description: "Use `&&` operator to compare multiple value."
572
- Enabled: true
573
-
574
- Lint/NestedMethodDefinition:
575
- Description: 'Do not use nested method definitions.'
576
- StyleGuide: '#no-nested-methods'
577
- Enabled: true
578
-
579
- Lint/NestedPercentLiteral:
580
- Description: 'Checks for nested percent literals.'
581
- Enabled: true
582
-
583
- Lint/NextWithoutAccumulator:
584
- Description: >-
585
- Do not omit the accumulator when calling `next`
586
- in a `reduce`/`inject` block.
587
- Enabled: true
588
-
589
- Lint/NonLocalExitFromIterator:
590
- Description: 'Do not use return in iterator to cause non-local exit.'
591
- Enabled: true
592
-
593
- Lint/OrderedMagicComments:
594
- Description: 'Checks the proper ordering of magic comments and whether a magic comment is not placed before a shebang.'
595
- Enabled: true
596
-
597
- Lint/ParenthesesAsGroupedExpression:
598
- Description: >-
599
- Checks for method calls with a space before the opening
600
- parenthesis.
601
- StyleGuide: '#parens-no-spaces'
602
- Enabled: true
603
-
604
- Lint/PercentStringArray:
605
- Description: >-
606
- Checks for unwanted commas and quotes in %w/%W literals.
607
- Enabled: true
608
-
609
- Lint/PercentSymbolArray:
610
- Description: >-
611
- Checks for unwanted commas and colons in %i/%I literals.
612
- Enabled: true
613
-
614
- Lint/RandOne:
615
- Description: >-
616
- Checks for `rand(1)` calls. Such calls always return `0`
617
- and most likely a mistake.
618
- Enabled: true
619
-
620
- Lint/RedundantWithIndex:
621
- Description: 'Checks for redundant `with_index`.'
622
- Enabled: true
623
-
624
- Lint/RedundantWithObject:
625
- Description: 'Checks for redundant `with_object`.'
626
- Enabled: true
627
-
628
- Lint/RegexpAsCondition:
629
- Description: >-
630
- Do not use regexp literal as a condition.
631
- The regexp literal matches `$_` implicitly.
632
- Enabled: true
633
-
634
- Lint/RequireParentheses:
635
- Description: >-
636
- Use parentheses in the method call to avoid confusion
637
- about precedence.
638
- Enabled: true
639
-
640
- Lint/RescueException:
641
- Description: 'Avoid rescuing the Exception class.'
642
- StyleGuide: '#no-blind-rescues'
643
- Enabled: true
644
-
645
- Lint/RescueType:
646
- Description: 'Avoid rescuing from non constants that could result in a `TypeError`.'
647
- Enabled: true
648
-
649
- Lint/ReturnInVoidContext:
650
- Description: 'Checks for return in void context.'
651
- Enabled: true
652
-
653
- Lint/SafeNavigationChain:
654
- Description: 'Do not chain ordinary method call after safe navigation operator.'
655
- Enabled: true
656
-
657
- Lint/SafeNavigationConsistency:
658
- Description: >-
659
- Check to make sure that if safe navigation is used for a method
660
- call in an `&&` or `||` condition that safe navigation is used
661
- for all method calls on that same object.
662
- Enabled: true
663
-
664
- Lint/ScriptPermission:
665
- Description: 'Grant script file execute permission.'
666
- Enabled: true
667
-
668
- Lint/ShadowedArgument:
669
- Description: 'Avoid reassigning arguments before they were used.'
670
- Enabled: true
671
-
672
- Lint/ShadowedException:
673
- Description: >-
674
- Avoid rescuing a higher level exception
675
- before a lower level exception.
676
- Enabled: true
677
-
678
- Lint/ShadowingOuterLocalVariable:
679
- Description: >-
680
- Do not use the same name as outer local variable
681
- for block arguments or block local variables.
682
- Enabled: true
683
-
684
- Lint/StringConversionInInterpolation:
685
- Description: 'Checks for Object#to_s usage in string interpolation.'
686
- StyleGuide: '#no-to-s'
687
- Enabled: true
688
-
689
- Lint/Syntax:
690
- Description: 'Checks syntax error'
691
- Enabled: true
692
-
693
- Lint/UnderscorePrefixedVariableName:
694
- Description: 'Do not use prefix `_` for a variable that is used.'
695
- Enabled: true
696
-
697
- Lint/UnifiedInteger:
698
- Description: 'Use Integer instead of Fixnum or Bignum'
699
- Enabled: true
700
-
701
- Lint/UnneededCopDisableDirective:
702
- Description: >-
703
- Checks for rubocop:disable comments that can be removed.
704
- Note: this cop is not disabled when disabling all cops.
705
- It must be explicitly disabled.
706
- Enabled: true
707
-
708
- Lint/UnneededCopEnableDirective:
709
- Description: Checks for rubocop:enable comments that can be removed.
710
-
711
- Enabled: true
712
-
713
- Lint/UnneededRequireStatement:
714
- Description: 'Checks for unnecessary `require` statement.'
715
- Enabled: true
716
-
717
- Lint/UnneededSplatExpansion:
718
- Description: 'Checks for splat unnecessarily being called on literals'
719
- Enabled: true
720
-
721
- Lint/UnreachableCode:
722
- Description: 'Unreachable code.'
723
- Enabled: true
724
-
725
- Lint/UnusedBlockArgument:
726
- Description: 'Checks for unused block arguments.'
727
- StyleGuide: '#underscore-unused-vars'
728
- Enabled: true
729
-
730
- Lint/UnusedMethodArgument:
731
- Description: 'Checks for unused method arguments.'
732
- StyleGuide: '#underscore-unused-vars'
733
- Enabled: true
734
-
735
- Lint/UriEscapeUnescape:
736
- Description: >-
737
- `URI.escape` method is obsolete and should not be used. Instead, use
738
- `CGI.escape`, `URI.encode_www_form` or `URI.encode_www_form_component`
739
- depending on your specific use case.
740
- Also `URI.unescape` method is obsolete and should not be used. Instead, use
741
- `CGI.unescape`, `URI.decode_www_form` or `URI.decode_www_form_component`
742
- depending on your specific use case.
743
- Enabled: true
744
-
745
- Lint/UriRegexp:
746
- Description: 'Use `URI::DEFAULT_PARSER.make_regexp` instead of `URI.regexp`.'
747
- Enabled: true
748
-
749
- Lint/UselessAccessModifier:
750
- Description: 'Checks for useless access modifiers.'
751
- Enabled: true
752
- ContextCreatingMethods: []
753
- MethodCreatingMethods: []
754
-
755
- Lint/UselessAssignment:
756
- Description: 'Checks for useless assignment to a local variable.'
757
- StyleGuide: '#underscore-unused-vars'
758
- Enabled: true
759
-
760
- Lint/UselessComparison:
761
- Description: 'Checks for comparison of something with itself.'
762
- Enabled: true
763
-
764
- Lint/UselessElseWithoutRescue:
765
- Description: 'Checks for useless `else` in `begin..end` without `rescue`.'
766
- Enabled: true
767
-
768
- Lint/UselessSetterCall:
769
- Description: 'Checks for useless setter call to a local variable.'
770
- Enabled: true
771
-
772
- Lint/Void:
773
- Description: 'Possible use of operator/literal/variable in void context.'
774
- Enabled: true
775
-
776
- #################### Metrics ###############################
777
-
778
- Metrics/AbcSize:
779
- Description: >-
780
- A calculated magnitude based on number of assignments,
781
- branches, and conditions.
782
- Reference: 'http://c2.com/cgi/wiki?AbcMetric'
783
- Enabled: true
784
-
785
- Metrics/BlockLength:
786
- Description: 'Avoid long blocks with many lines.'
787
- Enabled: true
788
-
789
- Metrics/BlockNesting:
790
- Description: 'Avoid excessive block nesting'
791
- StyleGuide: '#three-is-the-number-thou-shalt-count'
792
- Enabled: true
793
-
794
- Metrics/ClassLength:
795
- Description: 'Avoid classes longer than 100 lines of code.'
796
- Enabled: true
797
-
798
- Metrics/CyclomaticComplexity:
799
- Description: >-
800
- A complexity metric that is strongly correlated to the number
801
- of test cases needed to validate a method.
802
- Enabled: true
803
-
804
- Metrics/LineLength:
805
- Description: 'Limit lines to 80 characters.'
806
- StyleGuide: '#80-character-limits'
807
- Enabled: true
808
-
809
- Metrics/MethodLength:
810
- Description: 'Avoid methods longer than 10 lines of code.'
811
- StyleGuide: '#short-methods'
812
- Enabled: true
813
-
814
- Metrics/ModuleLength:
815
- Description: 'Avoid modules longer than 100 lines of code.'
816
- Enabled: true
817
-
818
- Metrics/ParameterLists:
819
- Description: 'Avoid parameter lists longer than three or four parameters.'
820
- StyleGuide: '#too-many-params'
821
- Enabled: true
822
-
823
- Metrics/PerceivedComplexity:
824
- Description: >-
825
- A complexity metric geared towards measuring complexity for a
826
- human reader.
827
- Enabled: true
828
-
829
- #################### Naming ##############################
830
-
831
- Naming/AccessorMethodName:
832
- Description: Check the naming of accessor methods for get_/set_.
833
- StyleGuide: '#accessor_mutator_method_names'
834
- Enabled: true
835
-
836
- Naming/AsciiIdentifiers:
837
- Description: 'Use only ascii symbols in identifiers.'
838
- StyleGuide: '#english-identifiers'
839
- Enabled: true
840
-
841
- Naming/BinaryOperatorParameterName:
842
- Description: 'When defining binary operators, name the argument other.'
843
- StyleGuide: '#other-arg'
844
- Enabled: true
845
-
846
- Naming/ClassAndModuleCamelCase:
847
- Description: 'Use CamelCase for classes and modules.'
848
- StyleGuide: '#camelcase-classes'
849
- Enabled: true
850
-
851
- Naming/ConstantName:
852
- Description: 'Constants should use SCREAMING_SNAKE_CASE.'
853
- StyleGuide: '#screaming-snake-case'
854
- Enabled: true
855
-
856
- Naming/FileName:
857
- Description: 'Use snake_case for source file names.'
858
- StyleGuide: '#snake-case-files'
859
- Enabled: true
860
-
861
- Naming/HeredocDelimiterCase:
862
- Description: 'Use configured case for heredoc delimiters.'
863
- StyleGuide: '#heredoc-delimiters'
864
- Enabled: true
865
-
866
- Naming/HeredocDelimiterNaming:
867
- Description: 'Use descriptive heredoc delimiters.'
868
- StyleGuide: '#heredoc-delimiters'
869
- Enabled: true
870
-
871
- Naming/MemoizedInstanceVariableName:
872
- Description: >-
873
- Memoized method name should match memo instance variable name.
874
- Enabled: true
875
-
876
- Naming/MethodName:
877
- Description: 'Use the configured style when naming methods.'
878
- StyleGuide: '#snake-case-symbols-methods-vars'
879
- Enabled: true
880
-
881
- Naming/PredicateName:
882
- Description: 'Check the names of predicate methods.'
883
- StyleGuide: '#bool-methods-qmark'
884
- Enabled: true
885
-
886
- Naming/UncommunicativeBlockParamName:
887
- Description: >-
888
- Checks for block parameter names that contain capital letters,
889
- end in numbers, or do not meet a minimal length.
890
- Enabled: true
891
-
892
- Naming/UncommunicativeMethodParamName:
893
- Description: >-
894
- Checks for method parameter names that contain capital letters,
895
- end in numbers, or do not meet a minimal length.
896
- Enabled: true
897
-
898
- Naming/VariableName:
899
- Description: 'Use the configured style when naming variables.'
900
- StyleGuide: '#snake-case-symbols-methods-vars'
901
- Enabled: true
902
-
903
- Naming/VariableNumber:
904
- Description: 'Use the configured style when numbering variables.'
905
- Enabled: true
906
-
907
- #################### Performance ###########################
908
-
909
- Performance/Caller:
910
- Description: >-
911
- Use `caller(n..n)` instead of `caller`.
912
- Enabled: true
913
-
914
- Performance/CaseWhenSplat:
915
- Description: >-
916
- Place `when` conditions that use splat at the end
917
- of the list of `when` branches.
918
- Enabled: true
919
-
920
- Performance/Casecmp:
921
- Description: >-
922
- Use `casecmp` rather than `downcase ==`, `upcase ==`, `== downcase`, or `== upcase`..
923
- Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringcasecmp-vs-stringdowncase---code'
924
- Enabled: true
925
-
926
- Performance/CompareWithBlock:
927
- Description: 'Use `sort_by(&:foo)` instead of `sort { |a, b| a.foo <=> b.foo }`.'
928
- Enabled: true
929
-
930
- Performance/Count:
931
- Description: >-
932
- Use `count` instead of `select...size`, `reject...size`,
933
- `select...count`, `reject...count`, `select...length`,
934
- and `reject...length`.
935
- # This cop has known compatibility issues with `ActiveRecord` and other
936
- # frameworks. ActiveRecord's `count` ignores the block that is passed to it.
937
- # For more information, see the documentation in the cop itself.
938
- # If you understand the known risk, you can disable `SafeMode`.
939
- SafeMode: true
940
- Enabled: true
941
-
942
- Performance/Detect:
943
- Description: >-
944
- Use `detect` instead of `select.first`, `find_all.first`,
945
- `select.last`, and `find_all.last`.
946
- Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerabledetect-vs-enumerableselectfirst-code'
947
- # This cop has known compatibility issues with `ActiveRecord` and other
948
- # frameworks. `ActiveRecord` does not implement a `detect` method and `find`
949
- # has its own meaning. Correcting `ActiveRecord` methods with this cop
950
- # should be considered unsafe.
951
- SafeMode: true
952
- Enabled: true
953
-
954
- Performance/DoubleStartEndWith:
955
- Description: >-
956
- Use `str.{start,end}_with?(x, ..., y, ...)`
957
- instead of `str.{start,end}_with?(x, ...) || str.{start,end}_with?(y, ...)`.
958
- Enabled: true
959
-
960
- Performance/EndWith:
961
- Description: 'Use `end_with?` instead of a regex match anchored to the end of a string.'
962
- Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringmatch-vs-stringstart_withstringend_with-code-start-code-end'
963
- # This will change to a new method call which isn't guaranteed to be on the
964
- # object. Switching these methods has to be done with knowledge of the types
965
- # of the variables which rubocop doesn't have.
966
- AutoCorrect: false
967
- Enabled: true
968
-
969
- Performance/FixedSize:
970
- Description: 'Do not compute the size of statically sized objects except in constants'
971
- Enabled: true
972
-
973
- Performance/FlatMap:
974
- Description: >-
975
- Use `Enumerable#flat_map`
976
- instead of `Enumerable#map...Array#flatten(1)`
977
- or `Enumberable#collect..Array#flatten(1)`
978
- Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerablemaparrayflatten-vs-enumerableflat_map-code'
979
- Enabled: true
980
- EnabledForFlattenWithoutParams: false
981
- # If enabled, this cop will warn about usages of
982
- # `flatten` being called without any parameters.
983
- # This can be dangerous since `flat_map` will only flatten 1 level, and
984
- # `flatten` without any parameters can flatten multiple levels.
985
-
986
- Performance/LstripRstrip:
987
- Description: 'Use `strip` instead of `lstrip.rstrip`.'
988
- Enabled: true
989
-
990
- Performance/RangeInclude:
991
- Description: 'Use `Range#cover?` instead of `Range#include?`.'
992
- Reference: 'https://github.com/JuanitoFatas/fast-ruby#cover-vs-include-code'
993
- Enabled: true
994
-
995
- Performance/RedundantBlockCall:
996
- Description: 'Use `yield` instead of `block.call`.'
997
- Reference: 'https://github.com/JuanitoFatas/fast-ruby#proccall-and-block-arguments-vs-yieldcode'
998
- Enabled: true
999
-
1000
- Performance/RedundantMatch:
1001
- Description: >-
1002
- Use `=~` instead of `String#match` or `Regexp#match` in a context where the
1003
- returned `MatchData` is not needed.
1004
- Enabled: true
1005
-
1006
- Performance/RedundantMerge:
1007
- Description: 'Use Hash#[]=, rather than Hash#merge! with a single key-value pair.'
1008
- Reference: 'https://github.com/JuanitoFatas/fast-ruby#hashmerge-vs-hash-code'
1009
- Enabled: true
1010
-
1011
- Performance/RedundantSortBy:
1012
- Description: 'Use `sort` instead of `sort_by { |x| x }`.'
1013
- Enabled: true
1014
-
1015
- Performance/RegexpMatch:
1016
- Description: >-
1017
- Use `match?` instead of `Regexp#match`, `String#match`, `Symbol#match`,
1018
- `Regexp#===`, or `=~` when `MatchData` is not used.
1019
- Enabled: true
1020
-
1021
- Performance/ReverseEach:
1022
- Description: 'Use `reverse_each` instead of `reverse.each`.'
1023
- Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerablereverseeach-vs-enumerablereverse_each-code'
1024
- Enabled: true
1025
-
1026
- Performance/Sample:
1027
- Description: >-
1028
- Use `sample` instead of `shuffle.first`,
1029
- `shuffle.last`, and `shuffle[Integer]`.
1030
- Reference: 'https://github.com/JuanitoFatas/fast-ruby#arrayshufflefirst-vs-arraysample-code'
1031
- Enabled: true
1032
-
1033
- Performance/Size:
1034
- Description: >-
1035
- Use `size` instead of `count` for counting
1036
- the number of elements in `Array` and `Hash`.
1037
- Reference: 'https://github.com/JuanitoFatas/fast-ruby#arraylength-vs-arraysize-vs-arraycount-code'
1038
- Enabled: true
1039
-
1040
- Performance/StartWith:
1041
- Description: 'Use `start_with?` instead of a regex match anchored to the beginning of a string.'
1042
- Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringmatch-vs-stringstart_withstringend_with-code-start-code-end'
1043
- # This will change to a new method call which isn't guaranteed to be on the
1044
- # object. Switching these methods has to be done with knowledge of the types
1045
- # of the variables which rubocop doesn't have.
1046
- AutoCorrect: false
1047
- Enabled: true
1048
-
1049
- Performance/StringReplacement:
1050
- Description: >-
1051
- Use `tr` instead of `gsub` when you are replacing the same
1052
- number of characters. Use `delete` instead of `gsub` when
1053
- you are deleting characters.
1054
- Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringgsub-vs-stringtr-code'
1055
- Enabled: true
1056
-
1057
- Performance/TimesMap:
1058
- Description: 'Checks for .times.map calls.'
1059
- AutoCorrect: false
1060
- Enabled: true
1061
-
1062
- Performance/UnfreezeString:
1063
- Description: 'Use unary plus to get an unfrozen string literal.'
1064
- Enabled: true
1065
-
1066
- Performance/UnneededSort:
1067
- Description: >-
1068
- Use `min` instead of `sort.first`,
1069
- `max_by` instead of `sort_by...last`, etc.
1070
- Enabled: true
1071
-
1072
- Performance/UriDefaultParser:
1073
- Description: 'Use `URI::DEFAULT_PARSER` instead of `URI::Parser.new`.'
1074
- Enabled: true
1075
-
1076
- #################### Rails #################################
1077
-
1078
- Rails/ActionFilter:
1079
- Description: 'Enforces consistent use of action filter methods.'
1080
- Enabled: true
1081
-
1082
- Rails/ActiveRecordAliases:
1083
- Description: >-
1084
- Avoid Active Record aliases:
1085
- Use `update` instead of `update_attributes`.
1086
- Use `update!` instead of `update_attributes!`.
1087
- Enabled: true
1088
-
1089
- Rails/ActiveSupportAliases:
1090
- Description: >-
1091
- Avoid ActiveSupport aliases of standard ruby methods:
1092
- `String#starts_with?`, `String#ends_with?`,
1093
- `Array#append`, `Array#prepend`.
1094
- Enabled: true
1095
-
1096
- Rails/ApplicationJob:
1097
- Description: 'Check that jobs subclass ApplicationJob.'
1098
- Enabled: true
1099
-
1100
- Rails/ApplicationRecord:
1101
- Description: 'Check that models subclass ApplicationRecord.'
1102
- Enabled: true
1103
-
1104
- Rails/Blank:
1105
- Description: 'Enforce using `blank?` and `present?`.'
1106
- Enabled: true
1107
- # Convert checks for `nil` or `empty?` to `blank?`
1108
- NilOrEmpty: true
1109
- # Convert usages of not `present?` to `blank?`
1110
- NotPresent: true
1111
- # Convert usages of `unless` `present?` to `if` `blank?`
1112
- UnlessPresent: true
1113
-
1114
- Rails/CreateTableWithTimestamps:
1115
- Description: >-
1116
- Checks the migration for which timestamps are not included
1117
- when creating a new table.
1118
- Enabled: true
1119
-
1120
- Rails/Date:
1121
- Description: >-
1122
- Checks the correct usage of date aware methods,
1123
- such as Date.today, Date.current etc.
1124
- Enabled: true
1125
-
1126
- Rails/Delegate:
1127
- Description: 'Prefer delegate method for delegations.'
1128
- Enabled: true
1129
-
1130
- Rails/DelegateAllowBlank:
1131
- Description: 'Do not use allow_blank as an option to delegate.'
1132
- Enabled: true
1133
-
1134
- Rails/DynamicFindBy:
1135
- Description: 'Use `find_by` instead of dynamic `find_by_*`.'
1136
- StyleGuide: 'https://github.com/bbatsov/rails-style-guide#find_by'
1137
- Enabled: true
1138
-
1139
- Rails/EnumUniqueness:
1140
- Description: 'Avoid duplicate integers in hash-syntax `enum` declaration.'
1141
- Enabled: true
1142
-
1143
- Rails/EnvironmentComparison:
1144
- Description: "Favor `Rails.env.production?` over `Rails.env == 'production'`"
1145
- Enabled: true
1146
-
1147
- Rails/Exit:
1148
- Description: >-
1149
- Favor `fail`, `break`, `return`, etc. over `exit` in
1150
- application or library code outside of Rake files to avoid
1151
- exits during unit testing or running in production.
1152
- Enabled: true
1153
-
1154
- Rails/FilePath:
1155
- Description: 'Use `Rails.root.join` for file path joining.'
1156
- Enabled: true
1157
-
1158
- Rails/FindBy:
1159
- Description: 'Prefer find_by over where.first.'
1160
- StyleGuide: 'https://github.com/bbatsov/rails-style-guide#find_by'
1161
- Enabled: true
1162
-
1163
- Rails/FindEach:
1164
- Description: 'Prefer all.find_each over all.find.'
1165
- StyleGuide: 'https://github.com/bbatsov/rails-style-guide#find-each'
1166
- Enabled: true
1167
-
1168
- Rails/HasAndBelongsToMany:
1169
- Description: 'Prefer has_many :through to has_and_belongs_to_many.'
1170
- StyleGuide: 'https://github.com/bbatsov/rails-style-guide#has-many-through'
1171
- Enabled: true
1172
-
1173
- Rails/HasManyOrHasOneDependent:
1174
- Description: 'Define the dependent option to the has_many and has_one associations.'
1175
- StyleGuide: 'https://github.com/bbatsov/rails-style-guide#has_many-has_one-dependent-option'
1176
- Enabled: true
1177
-
1178
- Rails/HttpPositionalArguments:
1179
- Description: 'Use keyword arguments instead of positional arguments in http method calls.'
1180
- Enabled: true
1181
- Include:
1182
- - 'spec/**/*'
1183
- - 'test/**/*'
1184
-
1185
- Rails/HttpStatus:
1186
- Description: 'Enforces use of symbolic or numeric value to define HTTP status.'
1187
- Enabled: true
1188
-
1189
- Rails/InverseOf:
1190
- Description: 'Checks for associations where the inverse cannot be determined automatically.'
1191
- Enabled: true
1192
-
1193
- Rails/LexicallyScopedActionFilter:
1194
- Description: "Checks that methods specified in the filter's `only` or `except` options are explicitly defined in the controller."
1195
- StyleGuide: 'https://github.com/bbatsov/rails-style-guide#lexically-scoped-action-filter'
1196
- Enabled: true
1197
-
1198
- Rails/NotNullColumn:
1199
- Description: 'Do not add a NOT NULL column without a default value'
1200
- Enabled: true
1201
-
1202
- Rails/Output:
1203
- Description: 'Checks for calls to puts, print, etc.'
1204
- Enabled: true
1205
-
1206
- Rails/OutputSafety:
1207
- Description: 'The use of `html_safe` or `raw` may be a security risk.'
1208
- Enabled: true
1209
-
1210
- Rails/PluralizationGrammar:
1211
- Description: 'Checks for incorrect grammar when using methods like `3.day.ago`.'
1212
- Enabled: true
1213
-
1214
- Rails/Presence:
1215
- Description: 'Checks code that can be written more easily using `Object#presence` defined by Active Support.'
1216
- Enabled: true
1217
-
1218
- Rails/Present:
1219
- Description: 'Enforce using `blank?` and `present?`.'
1220
- Enabled: true
1221
- NotNilAndNotEmpty: true
1222
- # Convert checks for not `nil` and not `empty?` to `present?`
1223
- NotBlank: true
1224
- # Convert usages of not `blank?` to `present?`
1225
- UnlessBlank: true
1226
- # Convert usages of `unless` `blank?` to `if` `present?`
1227
-
1228
- Rails/ReadWriteAttribute:
1229
- Description: >-
1230
- Checks for read_attribute(:attr) and
1231
- write_attribute(:attr, val).
1232
- StyleGuide: 'https://github.com/bbatsov/rails-style-guide#read-attribute'
1233
- Enabled: true
1234
-
1235
- Rails/RedundantReceiverInWithOptions:
1236
- Description: 'Checks for redundant receiver in `with_options`.'
1237
- Enabled: true
1238
-
1239
- Rails/RelativeDateConstant:
1240
- Description: 'Do not assign relative date to constants.'
1241
- Enabled: true
1242
-
1243
- Rails/RequestReferer:
1244
- Description: 'Use consistent syntax for request.referer.'
1245
- Enabled: true
1246
-
1247
- Rails/ReversibleMigration:
1248
- Description: 'Checks whether the change method of the migration file is reversible.'
1249
- StyleGuide: 'https://github.com/bbatsov/rails-style-guide#reversible-migration'
1250
- Reference: 'http://api.rubyonrails.org/classes/ActiveRecord/Migration/CommandRecorder.html'
1251
- Enabled: true
1252
-
1253
- Rails/SafeNavigation:
1254
- Description: "Use Ruby's safe navigation operator (`&.`) instead of `try!`"
1255
- Enabled: true
1256
-
1257
- Rails/ScopeArgs:
1258
- Description: 'Checks the arguments of ActiveRecord scopes.'
1259
- Enabled: true
1260
-
1261
- Rails/SkipsModelValidations:
1262
- Description: >-
1263
- Use methods that skips model validations with caution.
1264
- See reference for more information.
1265
- Reference: 'http://guides.rubyonrails.org/active_record_validations.html#skipping-validations'
1266
- Enabled: true
1267
-
1268
- Rails/TimeZone:
1269
- Description: 'Checks the correct usage of time zone aware methods.'
1270
- StyleGuide: 'https://github.com/bbatsov/rails-style-guide#time'
1271
- Reference: 'http://danilenko.org/2012/7/6/rails_timezones'
1272
- Enabled: true
1273
-
1274
- Rails/UniqBeforePluck:
1275
- Description: 'Prefer the use of uniq or distinct before pluck.'
1276
- Enabled: true
1277
-
1278
- Rails/UnknownEnv:
1279
- Description: 'Use correct environment name.'
1280
- Enabled: true
1281
-
1282
- Rails/Validation:
1283
- Description: 'Use validates :attribute, hash of validations.'
1284
- Enabled: true
1285
-
1286
- #################### Security ##############################
1287
-
1288
- Security/Eval:
1289
- Description: 'The use of eval represents a serious security risk.'
1290
- Enabled: true
1291
-
1292
- Security/JSONLoad:
1293
- Description: >-
1294
- Prefer usage of `JSON.parse` over `JSON.load` due to potential
1295
- security issues. See reference for more information.
1296
- Reference: 'http://ruby-doc.org/stdlib-2.3.0/libdoc/json/rdoc/JSON.html#method-i-load'
1297
- Enabled: true
1298
- # Autocorrect here will change to a method that may cause crashes depending
1299
- # on the value of the argument.
1300
- AutoCorrect: false
1301
-
1302
- Security/MarshalLoad:
1303
- Description: >-
1304
- Avoid using of `Marshal.load` or `Marshal.restore` due to potential
1305
- security issues. See reference for more information.
1306
- Reference: 'http://ruby-doc.org/core-2.3.3/Marshal.html#module-Marshal-label-Security+considerations'
1307
- Enabled: true
1308
-
1309
- Security/Open:
1310
- Description: 'The use of Kernel#open represents a serious security risk.'
1311
- Enabled: true
1312
-
1313
- Security/YAMLLoad:
1314
- Description: >-
1315
- Prefer usage of `YAML.safe_load` over `YAML.load` due to potential
1316
- security issues. See reference for more information.
1317
- Reference: 'https://ruby-doc.org/stdlib-2.3.3/libdoc/yaml/rdoc/YAML.html#module-YAML-label-Security'
1318
- Enabled: true
1319
-
1320
- #################### Style ###############################
1321
-
1322
- Style/Alias:
1323
- Description: 'Use alias instead of alias_method.'
1324
- StyleGuide: '#alias-method'
1325
- Enabled: true
1326
-
1327
- Style/AndOr:
1328
- Description: 'Use &&/|| instead of and/or.'
1329
- StyleGuide: '#no-and-or-or'
1330
- Enabled: true
1331
-
1332
- Style/ArrayJoin:
1333
- Description: 'Use Array#join instead of Array#*.'
1334
- StyleGuide: '#array-join'
1335
- Enabled: true
1336
-
1337
- Style/AsciiComments:
1338
- Description: 'Use only ascii symbols in comments.'
1339
- StyleGuide: '#english-comments'
1340
- Enabled: true
1341
-
1342
- Style/Attr:
1343
- Description: 'Checks for uses of Module#attr.'
1344
- StyleGuide: '#attr'
1345
- Enabled: true
1346
-
1347
- Style/BarePercentLiterals:
1348
- Description: 'Checks if usage of %() or %Q() matches configuration.'
1349
- StyleGuide: '#percent-q-shorthand'
1350
- Enabled: true
1351
-
1352
- Style/BeginBlock:
1353
- Description: 'Avoid the use of BEGIN blocks.'
1354
- StyleGuide: '#no-BEGIN-blocks'
1355
- Enabled: true
1356
-
1357
- Style/BlockComments:
1358
- Description: 'Do not use block comments.'
1359
- StyleGuide: '#no-block-comments'
1360
- Enabled: true
1361
-
1362
- Style/BlockDelimiters:
1363
- Description: >-
1364
- Avoid using {...} for multi-line blocks (multiline chaining is
1365
- always ugly).
1366
- Prefer {...} over do...end for single-line blocks.
1367
- StyleGuide: '#single-line-blocks'
1368
- Enabled: true
1369
-
1370
- Style/BracesAroundHashParameters:
1371
- Description: 'Enforce braces style around hash parameters.'
1372
- Enabled: true
1373
-
1374
- Style/CaseEquality:
1375
- Description: 'Avoid explicit use of the case equality operator(===).'
1376
- StyleGuide: '#no-case-equality'
1377
- Enabled: true
1378
-
1379
- Style/CharacterLiteral:
1380
- Description: 'Checks for uses of character literals.'
1381
- StyleGuide: '#no-character-literals'
1382
- Enabled: true
1383
-
1384
- Style/ClassAndModuleChildren:
1385
- Description: 'Checks style of children classes and modules.'
1386
- StyleGuide: '#namespace-definition'
1387
- # Moving from compact to nested children requires knowledge of whether the
1388
- # outer parent is a module or a class. Moving from nested to compact requires
1389
- # verification that the outer parent is defined elsewhere. Rubocop does not
1390
- # have the knowledge to perform either operation safely and thus requires
1391
- # manual oversight.
1392
- AutoCorrect: false
1393
- Enabled: true
1394
-
1395
- Style/ClassCheck:
1396
- Description: 'Enforces consistent use of `Object#is_a?` or `Object#kind_of?`.'
1397
- Enabled: true
1398
-
1399
- Style/ClassMethods:
1400
- Description: 'Use self when defining module/class methods.'
1401
- StyleGuide: '#def-self-class-methods'
1402
- Enabled: true
1403
-
1404
- Style/ClassVars:
1405
- Description: 'Avoid the use of class variables.'
1406
- StyleGuide: '#no-class-vars'
1407
- Enabled: true
1408
-
1409
- Style/ColonMethodCall:
1410
- Description: 'Do not use :: for method call.'
1411
- StyleGuide: '#double-colons'
1412
- Enabled: true
1413
-
1414
- Style/ColonMethodDefinition:
1415
- Description: 'Do not use :: for defining class methods.'
1416
- StyleGuide: '#colon-method-definition'
1417
- Enabled: true
1418
-
1419
- Style/CommandLiteral:
1420
- Description: 'Use `` or %x around command literals.'
1421
- StyleGuide: '#percent-x'
1422
- Enabled: true
1423
-
1424
- Style/CommentAnnotation:
1425
- Description: >-
1426
- Checks formatting of special comments
1427
- (TODO, FIXME, OPTIMIZE, HACK, REVIEW).
1428
- StyleGuide: '#annotate-keywords'
1429
- Enabled: true
1430
-
1431
- Style/CommentedKeyword:
1432
- Description: 'Do not place comments on the same line as certain keywords.'
1433
- Enabled: true
1434
-
1435
- Style/ConditionalAssignment:
1436
- Description: >-
1437
- Use the return value of `if` and `case` statements for
1438
- assignment to a variable and variable comparison instead
1439
- of assigning that variable inside of each branch.
1440
- Enabled: true
1441
-
1442
- Style/DateTime:
1443
- Description: 'Use Date or Time over DateTime.'
1444
- StyleGuide: '#date--time'
1445
- Enabled: true
1446
-
1447
- Style/DefWithParentheses:
1448
- Description: 'Use def with parentheses when there are arguments.'
1449
- StyleGuide: '#method-parens'
1450
- Enabled: true
1451
-
1452
- Style/Dir:
1453
- Description: >-
1454
- Use the `__dir__` method to retrieve the canonicalized
1455
- absolute path to the current file.
1456
- Enabled: true
1457
-
1458
- Style/Documentation:
1459
- Description: 'Document classes and non-namespace modules.'
1460
- Enabled: true
1461
- Exclude:
1462
- - 'spec/**/*'
1463
- - 'test/**/*'
1464
-
1465
- Style/DoubleNegation:
1466
- Description: 'Checks for uses of double negation (!!).'
1467
- StyleGuide: '#no-bang-bang'
1468
- Enabled: true
1469
-
1470
- Style/EachForSimpleLoop:
1471
- Description: >-
1472
- Use `Integer#times` for a simple loop which iterates a fixed
1473
- number of times.
1474
- Enabled: true
1475
-
1476
- Style/EachWithObject:
1477
- Description: 'Prefer `each_with_object` over `inject` or `reduce`.'
1478
- Enabled: true
1479
-
1480
- Style/EmptyBlockParameter:
1481
- Description: 'Omit pipes for empty block parameters.'
1482
- Enabled: true
1483
-
1484
- Style/EmptyCaseCondition:
1485
- Description: 'Avoid empty condition in case statements.'
1486
- Enabled: true
1487
-
1488
- Style/EmptyElse:
1489
- Description: 'Avoid empty else-clauses.'
1490
- Enabled: true
1491
-
1492
- Style/EmptyLambdaParameter:
1493
- Description: 'Omit parens for empty lambda parameters.'
1494
- Enabled: true
1495
-
1496
- Style/EmptyLiteral:
1497
- Description: 'Prefer literals to Array.new/Hash.new/String.new.'
1498
- StyleGuide: '#literal-array-hash'
1499
- Enabled: true
1500
-
1501
- Style/EmptyMethod:
1502
- Description: 'Checks the formatting of empty method definitions.'
1503
- StyleGuide: '#no-single-line-methods'
1504
- Enabled: true
1505
-
1506
- Style/Encoding:
1507
- Description: 'Use UTF-8 as the source file encoding.'
1508
- StyleGuide: '#utf-8'
1509
- Enabled: true
1510
-
1511
- Style/EndBlock:
1512
- Description: 'Avoid the use of END blocks.'
1513
- StyleGuide: '#no-END-blocks'
1514
- Enabled: true
1515
-
1516
- Style/EvalWithLocation:
1517
- Description: 'Pass `__FILE__` and `__LINE__` to `eval` method, as they are used by backtraces.'
1518
- Enabled: true
1519
-
1520
- Style/EvenOdd:
1521
- Description: 'Favor the use of Integer#even? && Integer#odd?'
1522
- StyleGuide: '#predicate-methods'
1523
- Enabled: true
1524
-
1525
- Style/ExpandPathArguments:
1526
- Description: "Use `expand_path(__dir__)` instead of `expand_path('..', __FILE__)`."
1527
- Enabled: true
1528
-
1529
- Style/FlipFlop:
1530
- Description: 'Checks for flip flops'
1531
- StyleGuide: '#no-flip-flops'
1532
- Enabled: true
1533
-
1534
- Style/For:
1535
- Description: 'Checks use of for or each in multiline loops.'
1536
- StyleGuide: '#no-for-loops'
1537
- Enabled: true
1538
-
1539
- Style/FormatString:
1540
- Description: 'Enforce the use of Kernel#sprintf, Kernel#format or String#%.'
1541
- StyleGuide: '#sprintf'
1542
- Enabled: true
1543
-
1544
- Style/FormatStringToken:
1545
- Description: 'Use a consistent style for format string tokens.'
1546
- Enabled: true
1547
-
1548
- Style/FrozenStringLiteralComment:
1549
- Description: >-
1550
- Add the frozen_string_literal comment to the top of files
1551
- to help transition from Ruby 2.3.0 to Ruby 3.0.
1552
- Enabled: true
1553
-
1554
- Style/GlobalVars:
1555
- Description: 'Do not introduce global variables.'
1556
- StyleGuide: '#instance-vars'
1557
- Reference: 'http://www.zenspider.com/Languages/Ruby/QuickRef.html'
1558
- Enabled: true
1559
-
1560
- Style/GuardClause:
1561
- Description: 'Check for conditionals that can be replaced with guard clauses'
1562
- StyleGuide: '#no-nested-conditionals'
1563
- Enabled: true
1564
-
1565
- Style/HashSyntax:
1566
- Description: >-
1567
- Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax
1568
- { :a => 1, :b => 2 }.
1569
- StyleGuide: '#hash-literals'
1570
- Enabled: true
1571
-
1572
- Style/IdenticalConditionalBranches:
1573
- Description: >-
1574
- Checks that conditional statements do not have an identical
1575
- line at the end of each branch, which can validly be moved
1576
- out of the conditional.
1577
- Enabled: true
1578
-
1579
- Style/IfInsideElse:
1580
- Description: 'Finds if nodes inside else, which can be converted to elsif.'
1581
- Enabled: true
1582
-
1583
- Style/IfUnlessModifier:
1584
- Description: >-
1585
- Favor modifier if/unless usage when you have a
1586
- single-line body.
1587
- StyleGuide: '#if-as-a-modifier'
1588
- Enabled: true
1589
-
1590
- Style/IfUnlessModifierOfIfUnless:
1591
- Description: >-
1592
- Avoid modifier if/unless usage on conditionals.
1593
- Enabled: true
1594
-
1595
- Style/IfWithSemicolon:
1596
- Description: 'Do not use if x; .... Use the ternary operator instead.'
1597
- StyleGuide: '#no-semicolon-ifs'
1598
- Enabled: true
1599
-
1600
- Style/InfiniteLoop:
1601
- Description: 'Use Kernel#loop for infinite loops.'
1602
- StyleGuide: '#infinite-loop'
1603
- Enabled: true
1604
-
1605
- Style/InverseMethods:
1606
- Description: >-
1607
- Use the inverse method instead of `!.method`
1608
- if an inverse method is defined.
1609
- Enabled: true
1610
-
1611
- Style/Lambda:
1612
- Description: 'Use the new lambda literal syntax for single-line blocks.'
1613
- StyleGuide: '#lambda-multi-line'
1614
- Enabled: true
1615
-
1616
- Style/LambdaCall:
1617
- Description: 'Use lambda.call(...) instead of lambda.(...).'
1618
- StyleGuide: '#proc-call'
1619
- Enabled: true
1620
-
1621
- Style/LineEndConcatenation:
1622
- Description: >-
1623
- Use \ instead of + or << to concatenate two string literals at
1624
- line end.
1625
- Enabled: true
1626
-
1627
- Style/MethodCallWithoutArgsParentheses:
1628
- Description: 'Do not use parentheses for method calls with no arguments.'
1629
- StyleGuide: '#method-invocation-parens'
1630
- Enabled: true
1631
-
1632
- Style/MethodDefParentheses:
1633
- Description: >-
1634
- Checks if the method definitions have or don't have
1635
- parentheses.
1636
- StyleGuide: '#method-parens'
1637
- Enabled: true
1638
-
1639
- Style/MethodMissing:
1640
- Description: 'Avoid using `method_missing`.'
1641
- StyleGuide: '#no-method-missing'
1642
- Enabled: true
1643
-
1644
- Style/MinMax:
1645
- Description: >-
1646
- Use `Enumerable#minmax` instead of `Enumerable#min`
1647
- and `Enumerable#max` in conjunction.'
1648
- Enabled: true
1649
-
1650
- Style/MixinGrouping:
1651
- Description: 'Checks for grouping of mixins in `class` and `module` bodies.'
1652
- StyleGuide: '#mixin-grouping'
1653
- Enabled: true
1654
-
1655
- Style/MixinUsage:
1656
- Description: 'Checks that `include`, `extend` and `prepend` exists at the top level.'
1657
- Enabled: true
1658
-
1659
- Style/ModuleFunction:
1660
- Description: 'Checks for usage of `extend self` in modules.'
1661
- StyleGuide: '#module-function'
1662
- Enabled: true
1663
-
1664
- Style/MultilineBlockChain:
1665
- Description: 'Avoid multi-line chains of blocks.'
1666
- StyleGuide: '#single-line-blocks'
1667
- Enabled: true
1668
-
1669
- Style/MultilineIfModifier:
1670
- Description: 'Only use if/unless modifiers on single line statements.'
1671
- StyleGuide: '#no-multiline-if-modifiers'
1672
- Enabled: true
1673
-
1674
- Style/MultilineIfThen:
1675
- Description: 'Do not use then for multi-line if/unless.'
1676
- StyleGuide: '#no-then'
1677
- Enabled: true
1678
-
1679
- Style/MultilineMemoization:
1680
- Description: 'Wrap multiline memoizations in a `begin` and `end` block.'
1681
- Enabled: true
1682
-
1683
- Style/MultilineTernaryOperator:
1684
- Description: >-
1685
- Avoid multi-line ?: (the ternary operator);
1686
- use if/unless instead.
1687
- StyleGuide: '#no-multiline-ternary'
1688
- Enabled: true
1689
-
1690
- Style/MultipleComparison:
1691
- Description: >-
1692
- Avoid comparing a variable with multiple items in a conditional,
1693
- use Array#include? instead.
1694
- Enabled: true
1695
-
1696
- Style/MutableConstant:
1697
- Description: 'Do not assign mutable objects to constants.'
1698
- Enabled: true
1699
-
1700
- Style/NegatedIf:
1701
- Description: >-
1702
- Favor unless over if for negative conditions
1703
- (or control flow or).
1704
- StyleGuide: '#unless-for-negatives'
1705
- Enabled: true
1706
-
1707
- Style/NegatedWhile:
1708
- Description: 'Favor until over while for negative conditions.'
1709
- StyleGuide: '#until-for-negatives'
1710
- Enabled: true
1711
-
1712
- Style/NestedModifier:
1713
- Description: 'Avoid using nested modifiers.'
1714
- StyleGuide: '#no-nested-modifiers'
1715
- Enabled: true
1716
-
1717
- Style/NestedParenthesizedCalls:
1718
- Description: >-
1719
- Parenthesize method calls which are nested inside the
1720
- argument list of another parenthesized method call.
1721
- Enabled: true
1722
-
1723
- Style/NestedTernaryOperator:
1724
- Description: 'Use one expression per branch in a ternary operator.'
1725
- StyleGuide: '#no-nested-ternary'
1726
- Enabled: true
1727
-
1728
- Style/Next:
1729
- Description: 'Use `next` to skip iteration instead of a condition at the end.'
1730
- StyleGuide: '#no-nested-conditionals'
1731
- Enabled: true
1732
-
1733
- Style/NilComparison:
1734
- Description: 'Prefer x.nil? to x == nil.'
1735
- StyleGuide: '#predicate-methods'
1736
- Enabled: true
1737
-
1738
- Style/NonNilCheck:
1739
- Description: 'Checks for redundant nil checks.'
1740
- StyleGuide: '#no-non-nil-checks'
1741
- Enabled: true
1742
-
1743
- Style/Not:
1744
- Description: 'Use ! instead of not.'
1745
- StyleGuide: '#bang-not-not'
1746
- Enabled: true
1747
-
1748
- Style/NumericLiteralPrefix:
1749
- Description: 'Use smallcase prefixes for numeric literals.'
1750
- StyleGuide: '#numeric-literal-prefixes'
1751
- Enabled: true
1752
-
1753
- Style/NumericLiterals:
1754
- Description: >-
1755
- Add underscores to large numeric literals to improve their
1756
- readability.
1757
- StyleGuide: '#underscores-in-numerics'
1758
- Enabled: true
1759
-
1760
- Style/NumericPredicate:
1761
- Description: >-
1762
- Checks for the use of predicate- or comparison methods for
1763
- numeric comparisons.
1764
- StyleGuide: '#predicate-methods'
1765
- # This will change to a new method call which isn't guaranteed to be on the
1766
- # object. Switching these methods has to be done with knowledge of the types
1767
- # of the variables which rubocop doesn't have.
1768
- AutoCorrect: false
1769
- Enabled: true
1770
-
1771
- Style/OneLineConditional:
1772
- Description: >-
1773
- Favor the ternary operator(?:) over
1774
- if/then/else/end constructs.
1775
- StyleGuide: '#ternary-operator'
1776
- Enabled: true
1777
-
1778
- Style/OptionalArguments:
1779
- Description: >-
1780
- Checks for optional arguments that do not appear at the end
1781
- of the argument list
1782
- StyleGuide: '#optional-arguments'
1783
- Enabled: true
1784
-
1785
- Style/OrAssignment:
1786
- Description: 'Recommend usage of double pipe equals (||=) where applicable.'
1787
- StyleGuide: '#double-pipe-for-uninit'
1788
- Enabled: true
1789
-
1790
- Style/ParallelAssignment:
1791
- Description: >-
1792
- Check for simple usages of parallel assignment.
1793
- It will only warn when the number of variables
1794
- matches on both sides of the assignment.
1795
- StyleGuide: '#parallel-assignment'
1796
- Enabled: true
1797
-
1798
- Style/ParenthesesAroundCondition:
1799
- Description: >-
1800
- Don't use parentheses around the condition of an
1801
- if/unless/while.
1802
- StyleGuide: '#no-parens-around-condition'
1803
- Enabled: true
1804
-
1805
- Style/PercentLiteralDelimiters:
1806
- Description: 'Use `%`-literal delimiters consistently'
1807
- StyleGuide: '#percent-literal-braces'
1808
- Enabled: true
1809
-
1810
- Style/PercentQLiterals:
1811
- Description: 'Checks if uses of %Q/%q match the configured preference.'
1812
- Enabled: true
1813
-
1814
- Style/PerlBackrefs:
1815
- Description: 'Avoid Perl-style regex back references.'
1816
- StyleGuide: '#no-perl-regexp-last-matchers'
1817
- Enabled: true
1818
-
1819
- Style/PreferredHashMethods:
1820
- Description: 'Checks use of `has_key?` and `has_value?` Hash methods.'
1821
- StyleGuide: '#hash-key'
1822
- Enabled: true
1823
-
1824
- Style/Proc:
1825
- Description: 'Use proc instead of Proc.new.'
1826
- StyleGuide: '#proc'
1827
- Enabled: true
1828
-
1829
- Style/RaiseArgs:
1830
- Description: 'Checks the arguments passed to raise/fail.'
1831
- StyleGuide: '#exception-class-messages'
1832
- Enabled: true
1833
-
1834
- Style/RandomWithOffset:
1835
- Description: >-
1836
- Prefer to use ranges when generating random numbers instead of
1837
- integers with offsets.
1838
- StyleGuide: '#random-numbers'
1839
- Enabled: true
1840
-
1841
- Style/RedundantBegin:
1842
- Description: "Don't use begin blocks when they are not needed."
1843
- StyleGuide: '#begin-implicit'
1844
- Enabled: true
1845
-
1846
- Style/RedundantConditional:
1847
- Description: "Don't return true/false from a conditional."
1848
- Enabled: true
1849
-
1850
- Style/RedundantException:
1851
- Description: "Checks for an obsolete RuntimeException argument in raise/fail."
1852
- StyleGuide: '#no-explicit-runtimeerror'
1853
- Enabled: true
1854
-
1855
- Style/RedundantFreeze:
1856
- Description: "Checks usages of Object#freeze on immutable objects."
1857
- Enabled: true
1858
-
1859
- Style/RedundantParentheses:
1860
- Description: "Checks for parentheses that seem not to serve any purpose."
1861
- Enabled: true
1862
-
1863
- Style/RedundantReturn:
1864
- Description: "Don't use return where it's not required."
1865
- StyleGuide: '#no-explicit-return'
1866
- Enabled: true
1867
-
1868
- Style/RedundantSelf:
1869
- Description: "Don't use self where it's not needed."
1870
- StyleGuide: '#no-self-unless-required'
1871
- Enabled: true
1872
-
1873
- Style/RegexpLiteral:
1874
- Description: 'Use / or %r around regular expressions.'
1875
- StyleGuide: '#percent-r'
1876
- Enabled: true
1877
-
1878
- Style/RescueModifier:
1879
- Description: 'Avoid using rescue in its modifier form.'
1880
- StyleGuide: '#no-rescue-modifiers'
1881
- Enabled: true
1882
-
1883
- Style/RescueStandardError:
1884
- Description: 'Avoid rescuing without specifying an error class.'
1885
- Enabled: true
1886
-
1887
- Style/SafeNavigation:
1888
- Description: >-
1889
- This cop transforms usages of a method call safeguarded by
1890
- a check for the existence of the object to
1891
- safe navigation (`&.`).
1892
- Enabled: true
1893
-
1894
- Style/SelfAssignment:
1895
- Description: >-
1896
- Checks for places where self-assignment shorthand should have
1897
- been used.
1898
- StyleGuide: '#self-assignment'
1899
- Enabled: true
1900
-
1901
- Style/Semicolon:
1902
- Description: "Don't use semicolons to terminate expressions."
1903
- StyleGuide: '#no-semicolon'
1904
- Enabled: true
1905
-
1906
- Style/SignalException:
1907
- Description: 'Checks for proper usage of fail and raise.'
1908
- StyleGuide: '#prefer-raise-over-fail'
1909
- Enabled: true
1910
-
1911
- Style/SingleLineMethods:
1912
- Description: 'Avoid single-line methods.'
1913
- StyleGuide: '#no-single-line-methods'
1914
- Enabled: true
1915
-
1916
- Style/SpecialGlobalVars:
1917
- Description: 'Avoid Perl-style global variables.'
1918
- StyleGuide: '#no-cryptic-perlisms'
1919
- Enabled: true
1920
-
1921
- Style/StabbyLambdaParentheses:
1922
- Description: 'Check for the usage of parentheses around stabby lambda arguments.'
1923
- StyleGuide: '#stabby-lambda-with-args'
1924
- Enabled: true
1925
-
1926
- Style/StderrPuts:
1927
- Description: 'Use `warn` instead of `$stderr.puts`.'
1928
- StyleGuide: '#warn'
1929
- Enabled: true
1930
-
1931
- Style/StringLiterals:
1932
- Description: 'Checks if uses of quotes match the configured preference.'
1933
- StyleGuide: '#consistent-string-literals'
1934
- Enabled: true
1935
-
1936
- Style/StringLiteralsInInterpolation:
1937
- Description: >-
1938
- Checks if uses of quotes inside expressions in interpolated
1939
- strings match the configured preference.
1940
- Enabled: true
1941
-
1942
- Style/StructInheritance:
1943
- Description: 'Checks for inheritance from Struct.new.'
1944
- StyleGuide: '#no-extend-struct-new'
1945
- Enabled: true
1946
-
1947
- Style/SymbolArray:
1948
- Description: 'Use %i or %I for arrays of symbols.'
1949
- StyleGuide: '#percent-i'
1950
- Enabled: true
1951
-
1952
- Style/SymbolLiteral:
1953
- Description: 'Use plain symbols instead of string symbols when possible.'
1954
- Enabled: true
1955
-
1956
- Style/SymbolProc:
1957
- Description: 'Use symbols as procs instead of blocks when possible.'
1958
- Enabled: true
1959
-
1960
- Style/TernaryParentheses:
1961
- Description: 'Checks for use of parentheses around ternary conditions.'
1962
- Enabled: true
1963
-
1964
- Style/TrailingBodyOnClass:
1965
- Description: 'Class body goes below class statement.'
1966
- Enabled: true
1967
-
1968
- Style/TrailingBodyOnMethodDefinition:
1969
- Description: 'Method body goes below definition.'
1970
- Enabled: true
1971
-
1972
- Style/TrailingBodyOnModule:
1973
- Description: 'Module body goes below module statement.'
1974
- Enabled: true
1975
-
1976
- Style/TrailingCommaInArguments:
1977
- Description: 'Checks for trailing comma in argument lists.'
1978
- StyleGuide: '#no-trailing-params-comma'
1979
- Enabled: true
1980
-
1981
- Style/TrailingCommaInArrayLiteral:
1982
- Description: 'Checks for trailing comma in array literals.'
1983
- StyleGuide: '#no-trailing-array-commas'
1984
- Enabled: true
1985
-
1986
- Style/TrailingCommaInHashLiteral:
1987
- Description: 'Checks for trailing comma in hash literals.'
1988
- Enabled: true
1989
-
1990
- Style/TrailingMethodEndStatement:
1991
- Description: 'Checks for trailing end statement on line of method body.'
1992
- Enabled: true
1993
-
1994
- Style/TrailingUnderscoreVariable:
1995
- Description: >-
1996
- Checks for the usage of unneeded trailing underscores at the
1997
- end of parallel variable assignment.
1998
- AllowNamedUnderscoreVariables: true
1999
- Enabled: true
2000
-
2001
- Style/TrivialAccessors:
2002
- Description: 'Prefer attr_* methods to trivial readers/writers.'
2003
- StyleGuide: '#attr_family'
2004
- Enabled: true
2005
-
2006
- Style/UnlessElse:
2007
- Description: >-
2008
- Do not use unless with else. Rewrite these with the positive
2009
- case first.
2010
- StyleGuide: '#no-else-with-unless'
2011
- Enabled: true
2012
-
2013
- Style/UnneededCapitalW:
2014
- Description: 'Checks for %W when interpolation is not needed.'
2015
- Enabled: true
2016
-
2017
- Style/UnneededInterpolation:
2018
- Description: 'Checks for strings that are just an interpolated expression.'
2019
- Enabled: true
2020
-
2021
- Style/UnneededPercentQ:
2022
- Description: 'Checks for %q/%Q when single quotes or double quotes would do.'
2023
- StyleGuide: '#percent-q'
2024
- Enabled: true
2025
-
2026
- Style/UnpackFirst:
2027
- Description: >-
2028
- Checks for accessing the first element of `String#unpack`
2029
- instead of using `unpack1`
2030
- Enabled: true
2031
-
2032
- Style/VariableInterpolation:
2033
- Description: >-
2034
- Don't interpolate global, instance and class variables
2035
- directly in strings.
2036
- StyleGuide: '#curlies-interpolate'
2037
- Enabled: true
2038
-
2039
- Style/WhenThen:
2040
- Description: 'Use when x then ... for one-line cases.'
2041
- StyleGuide: '#one-line-cases'
2042
- Enabled: true
2043
-
2044
- Style/WhileUntilDo:
2045
- Description: 'Checks for redundant do after while or until.'
2046
- StyleGuide: '#no-multiline-while-do'
2047
- Enabled: true
2048
-
2049
- Style/WhileUntilModifier:
2050
- Description: >-
2051
- Favor modifier while/until usage when you have a
2052
- single-line body.
2053
- StyleGuide: '#while-as-a-modifier'
2054
- Enabled: true
2055
-
2056
- Style/WordArray:
2057
- Description: 'Use %w or %W for arrays of words.'
2058
- StyleGuide: '#percent-w'
2059
- Enabled: true
2060
-
2061
- Style/YodaCondition:
2062
- Description: 'Do not use literals as the first operand of a comparison.'
2063
- Reference: 'https://en.wikipedia.org/wiki/Yoda_conditions'
2064
- Enabled: true
2065
-
2066
- Style/ZeroLengthPredicate:
2067
- Description: 'Use #empty? when testing for objects of length 0.'
2068
- Enabled: true