rspec_api_blueprint_matchers 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +33 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +26 -0
- data/.ruby-version +1 -0
- data/Rakefile +2 -1
- data/config/rubocop/.lint_rubocop.yml +749 -0
- data/config/rubocop/.metrics_rubocop.yml +94 -0
- data/config/rubocop/.performance_rubocop.yml +323 -0
- data/config/rubocop/.rails_rubocop.yml +256 -0
- data/config/rubocop/.style_rubocop.yml +2299 -0
- data/docker-compose.yml +17 -0
- data/lib/rspec_api_blueprint_matchers.rb +1 -0
- data/lib/rspec_apib/config.rb +1 -0
- data/lib/rspec_apib/elements/annotation.rb +1 -0
- data/lib/rspec_apib/elements/array.rb +1 -0
- data/lib/rspec_apib/elements/asset.rb +1 -0
- data/lib/rspec_apib/elements/base.rb +11 -10
- data/lib/rspec_apib/elements/category.rb +2 -1
- data/lib/rspec_apib/elements/copy.rb +2 -1
- data/lib/rspec_apib/elements/data_structure.rb +2 -0
- data/lib/rspec_apib/elements/href_variables.rb +3 -2
- data/lib/rspec_apib/elements/http_headers.rb +5 -4
- data/lib/rspec_apib/elements/http_message_payload.rb +3 -2
- data/lib/rspec_apib/elements/http_request.rb +16 -10
- data/lib/rspec_apib/elements/http_response.rb +3 -1
- data/lib/rspec_apib/elements/http_transaction.rb +4 -3
- data/lib/rspec_apib/elements/member.rb +3 -2
- data/lib/rspec_apib/elements/object.rb +2 -1
- data/lib/rspec_apib/elements/parse_result.rb +1 -0
- data/lib/rspec_apib/elements/resource.rb +1 -0
- data/lib/rspec_apib/elements/source_map.rb +1 -0
- data/lib/rspec_apib/elements/string.rb +1 -0
- data/lib/rspec_apib/elements/templated_href.rb +1 -0
- data/lib/rspec_apib/elements/transition.rb +1 -0
- data/lib/rspec_apib/elements.rb +1 -0
- data/lib/rspec_apib/extractors/http_transaction.rb +1 -0
- data/lib/rspec_apib/extractors/resource.rb +1 -0
- data/lib/rspec_apib/extractors.rb +1 -0
- data/lib/rspec_apib/parser.rb +2 -1
- data/lib/rspec_apib/request.rb +7 -10
- data/lib/rspec_apib/response.rb +2 -2
- data/lib/rspec_apib/rspec.rb +4 -3
- data/lib/rspec_apib/transaction_coverage_report.rb +4 -3
- data/lib/rspec_apib/transaction_coverage_validator.rb +4 -3
- data/lib/rspec_apib/transaction_validator.rb +1 -0
- data/lib/rspec_apib/transcluder.rb +2 -2
- data/lib/rspec_apib/version.rb +2 -1
- data/lib/rspec_apib.rb +2 -1
- data/lib/transcluder.rb +1 -0
- data/rspec_api_blueprint_matchers.gemspec +6 -4
- metadata +25 -2
@@ -0,0 +1,2299 @@
|
|
1
|
+
# "Style::AccessModifierIndentation"
|
2
|
+
#
|
3
|
+
# Modifiers should be indented as deep as method definitions,
|
4
|
+
# or as deep as the class/module keyword, depending on configuration.
|
5
|
+
|
6
|
+
Style/AccessModifierIndentation:
|
7
|
+
Enabled: false
|
8
|
+
|
9
|
+
# Style::AccessorMethodName
|
10
|
+
#
|
11
|
+
# Makes sure that accessor methods are named properly
|
12
|
+
#
|
13
|
+
# bad:
|
14
|
+
#
|
15
|
+
# def set_attribute(value)..
|
16
|
+
# def get_attribute
|
17
|
+
#
|
18
|
+
# good:
|
19
|
+
#
|
20
|
+
# def attribute=(value)..
|
21
|
+
# def attribute...
|
22
|
+
#
|
23
|
+
Style/AccessorMethodName:
|
24
|
+
Enabled: true
|
25
|
+
|
26
|
+
# Style::Alias
|
27
|
+
#
|
28
|
+
# Finds uses of `alias` where `alias_method` would be more appropriate, and vice versa.
|
29
|
+
|
30
|
+
Style/Alias:
|
31
|
+
Enabled: false
|
32
|
+
|
33
|
+
# Style::AlignArray
|
34
|
+
#
|
35
|
+
# Check if elements of a multi-line array literal are aligned.
|
36
|
+
|
37
|
+
Style/AlignArray:
|
38
|
+
Enabled: false
|
39
|
+
|
40
|
+
# Style::AlignHash
|
41
|
+
#
|
42
|
+
# Check if the keys, separators, and values of a multi-line hash literal are aligned.
|
43
|
+
|
44
|
+
Style/AlignHash:
|
45
|
+
Enabled: false
|
46
|
+
|
47
|
+
# Style::AlignParameters
|
48
|
+
#
|
49
|
+
# Check if parameters on a multi-line method call or definition are aligned.
|
50
|
+
|
51
|
+
Style/AlignParameters:
|
52
|
+
Enabled: false
|
53
|
+
|
54
|
+
# Style::AndOr
|
55
|
+
#
|
56
|
+
# Checks for uses of 'and' and 'or'
|
57
|
+
# ( use &&, || )
|
58
|
+
|
59
|
+
Style/AndOr:
|
60
|
+
Enabled: true
|
61
|
+
|
62
|
+
# Style::AnnotationComment
|
63
|
+
#
|
64
|
+
# Common functionality related to annotation comments
|
65
|
+
|
66
|
+
Style/AnnotationComment:
|
67
|
+
Enabled: false
|
68
|
+
|
69
|
+
# Style::ArrayJoin
|
70
|
+
#
|
71
|
+
# Checks for users of "*" as a substitute for join.
|
72
|
+
|
73
|
+
Style/ArrayJoin:
|
74
|
+
Enabled: false
|
75
|
+
|
76
|
+
# Style::AsciiComments
|
77
|
+
#
|
78
|
+
# Checks for non-ascii (non-English) characters in comments.
|
79
|
+
|
80
|
+
Style/AsciiComments:
|
81
|
+
Enabled: true
|
82
|
+
|
83
|
+
# Style::AsciiComments
|
84
|
+
#
|
85
|
+
# Checks for non-ascii characters in identifier names.
|
86
|
+
|
87
|
+
Style/AsciiIdentifiers:
|
88
|
+
Enabled: false
|
89
|
+
|
90
|
+
# Style::Attr
|
91
|
+
#
|
92
|
+
# Checks for uses of Module#attr.
|
93
|
+
|
94
|
+
Style/Attr:
|
95
|
+
Enabled: false
|
96
|
+
|
97
|
+
# Style::AutoResourceCleanup
|
98
|
+
#
|
99
|
+
# Checks for cases when you could use a block accepting version of a method that does automatic resource cleanup.
|
100
|
+
#
|
101
|
+
# bad:
|
102
|
+
#
|
103
|
+
# f = File.open('file')
|
104
|
+
#
|
105
|
+
# good:
|
106
|
+
#
|
107
|
+
# f = File.open('file') do
|
108
|
+
# ....
|
109
|
+
# end
|
110
|
+
|
111
|
+
Style/AutoResourceCleanup:
|
112
|
+
Enabled: true
|
113
|
+
|
114
|
+
# Style::BarePercentLiterals
|
115
|
+
#
|
116
|
+
# Checks if usage of %() or %Q() matches configuration
|
117
|
+
|
118
|
+
Style/BarePercentLiterals:
|
119
|
+
Enabled: false
|
120
|
+
|
121
|
+
# Style::BeginBlock
|
122
|
+
#
|
123
|
+
# Checks for BEGIN blocks
|
124
|
+
|
125
|
+
Style/BeginBlock:
|
126
|
+
Enabled: false
|
127
|
+
|
128
|
+
|
129
|
+
# Style::BlockComments
|
130
|
+
#
|
131
|
+
# Looks for uses of block comments
|
132
|
+
|
133
|
+
Style/BlockComments:
|
134
|
+
Enabled: true
|
135
|
+
|
136
|
+
# Style::BlockDelimiters
|
137
|
+
#
|
138
|
+
# Checks for uses of braces or do/end around single line or multi-line blocks.
|
139
|
+
|
140
|
+
Style/BlockDelimiters:
|
141
|
+
Enabled: true
|
142
|
+
|
143
|
+
|
144
|
+
# Style::BlockEndNewLine
|
145
|
+
#
|
146
|
+
# Checks whether the end statement of a do..end block is on its own line.
|
147
|
+
#
|
148
|
+
# bad:
|
149
|
+
#
|
150
|
+
# apple do |piece|
|
151
|
+
# eat(piece) end
|
152
|
+
#
|
153
|
+
# good:
|
154
|
+
#
|
155
|
+
# apple do |piece|
|
156
|
+
# eat(piece)
|
157
|
+
# end
|
158
|
+
|
159
|
+
Style/BlockEndNewLine:
|
160
|
+
Enabled: true
|
161
|
+
|
162
|
+
# Style::BracesAroundHashParameters
|
163
|
+
#
|
164
|
+
# Checks for braces around the last parameter in a method call,
|
165
|
+
# if last parameter is a hash.
|
166
|
+
|
167
|
+
Style/BracesAroundHashParameters:
|
168
|
+
Enabled: true
|
169
|
+
|
170
|
+
# Style::CaseCorrector
|
171
|
+
#
|
172
|
+
# Corrector to correct conditional alignment in `case` statements.
|
173
|
+
|
174
|
+
Style/CaseCorrector:
|
175
|
+
Enabled: false
|
176
|
+
|
177
|
+
# Style::CaseEquality
|
178
|
+
#
|
179
|
+
# Checks for uses of the case equality operator(===)
|
180
|
+
|
181
|
+
Style/CaseEquality:
|
182
|
+
Enabled: true
|
183
|
+
|
184
|
+
# Style::CaseIndentation
|
185
|
+
#
|
186
|
+
# Checks how the 'when's of a case expression are indented in relation to its
|
187
|
+
# 'case' or 'end' keyword
|
188
|
+
|
189
|
+
Style/CaseIndentation:
|
190
|
+
Enabled: false
|
191
|
+
|
192
|
+
# Style::CharacterLiteral
|
193
|
+
#
|
194
|
+
# Checks for uses of the character literal ?x.
|
195
|
+
|
196
|
+
Style/CharacterLiteral:
|
197
|
+
Enabled: true
|
198
|
+
|
199
|
+
# Style::ClassAndModuleCamelCase
|
200
|
+
#
|
201
|
+
# Checks for class and module names with an underscore in them
|
202
|
+
|
203
|
+
Style/ClassAndModuleCamelCase:
|
204
|
+
Enabled: true
|
205
|
+
|
206
|
+
# Style::ClassAndModuleChildren
|
207
|
+
#
|
208
|
+
# Checks the style of children definitions at classes and modules.
|
209
|
+
#
|
210
|
+
# Not preferred:
|
211
|
+
# class Foo
|
212
|
+
# class Bar
|
213
|
+
# end
|
214
|
+
# end
|
215
|
+
#
|
216
|
+
# Preferred:
|
217
|
+
#
|
218
|
+
# class Foo::Bar
|
219
|
+
# end
|
220
|
+
#
|
221
|
+
Style/ClassAndModuleChildren:
|
222
|
+
Enabled: false
|
223
|
+
|
224
|
+
# Style::ClassCheck
|
225
|
+
#
|
226
|
+
# Enforces consistent use of 'Object#is_a?' or 'Object#kind_of?'.
|
227
|
+
|
228
|
+
Style/ClassCheck:
|
229
|
+
Enabled: false
|
230
|
+
|
231
|
+
# Style::ClassMethods
|
232
|
+
#
|
233
|
+
# Checks for uses of the class/module name instead of self,
|
234
|
+
# when defining class/module methods.
|
235
|
+
#
|
236
|
+
# bad:
|
237
|
+
#
|
238
|
+
# class SomeClass
|
239
|
+
# def SomeClass.class_method
|
240
|
+
# end
|
241
|
+
# end
|
242
|
+
#
|
243
|
+
# good:
|
244
|
+
#
|
245
|
+
# class SomeClass
|
246
|
+
# def self.class_method
|
247
|
+
# end
|
248
|
+
# end
|
249
|
+
|
250
|
+
Style/ClassMethods:
|
251
|
+
Enabled: true
|
252
|
+
|
253
|
+
# Style::ClassVars
|
254
|
+
#
|
255
|
+
# Checks for uses of class variables. Offenses are signaled only on assignment to class variables to
|
256
|
+
# reduce the number of offenses that would be reported.
|
257
|
+
# (Try replacing the class variable with class instance variable)
|
258
|
+
|
259
|
+
Style/ClassVars:
|
260
|
+
Enabled: true
|
261
|
+
|
262
|
+
# Style::ClosingParenthesesIndentation
|
263
|
+
#
|
264
|
+
# Checks the indentation of hanging closing parenthesese in method calls, method definitions and
|
265
|
+
# grouped expressions. A hanging closing parentheses means ')' preceded by a line break
|
266
|
+
#
|
267
|
+
# bad:
|
268
|
+
#
|
269
|
+
# def func(
|
270
|
+
# x,
|
271
|
+
# y
|
272
|
+
# )
|
273
|
+
#
|
274
|
+
# good:
|
275
|
+
#
|
276
|
+
# a = b * (x +
|
277
|
+
# y
|
278
|
+
# )
|
279
|
+
|
280
|
+
Style/ClosingParenthesisIndentation:
|
281
|
+
Enabled: true
|
282
|
+
|
283
|
+
# Style::CollectionMethods
|
284
|
+
#
|
285
|
+
# Enforces the use of consistent method names from the Enumerable module.
|
286
|
+
|
287
|
+
Style/CollectionMethods:
|
288
|
+
Enabled: true
|
289
|
+
PreferredMethods:
|
290
|
+
length: "size"
|
291
|
+
|
292
|
+
# Style::ColonMethodCall
|
293
|
+
#
|
294
|
+
# Checks for methods invoked via the '::' operator instead of '.' operator.
|
295
|
+
#
|
296
|
+
# bad: FileUtils::rmdir
|
297
|
+
#
|
298
|
+
# good: FileUtils.rmdir
|
299
|
+
|
300
|
+
Style/ColonMethodCall:
|
301
|
+
Enabled: false
|
302
|
+
|
303
|
+
|
304
|
+
# Style::CommandLiteral
|
305
|
+
#
|
306
|
+
# Enforces using `` or %x around command literals.
|
307
|
+
|
308
|
+
Style/CommandLiteral:
|
309
|
+
Enabled: false
|
310
|
+
|
311
|
+
# Style::CommentAnnotation
|
312
|
+
#
|
313
|
+
# Checks that comment annotation keywords are written according to guidelines
|
314
|
+
|
315
|
+
Style/CommentAnnotation:
|
316
|
+
Enabled: false
|
317
|
+
|
318
|
+
# Style::CommentIndentation
|
319
|
+
#
|
320
|
+
# Checks the indentation of comments.
|
321
|
+
|
322
|
+
Style/CommentIndentation:
|
323
|
+
Enabled: false
|
324
|
+
|
325
|
+
|
326
|
+
# Style::ConditionalAssignment
|
327
|
+
#
|
328
|
+
# Check for `if` and `case` statements where each branch is used for assignment to the same variable
|
329
|
+
# when using the return of the condition can be used instead
|
330
|
+
#
|
331
|
+
# bad:
|
332
|
+
#
|
333
|
+
# bar = if foo
|
334
|
+
# 1
|
335
|
+
# else
|
336
|
+
# 2
|
337
|
+
# end
|
338
|
+
#
|
339
|
+
# good:
|
340
|
+
#
|
341
|
+
# if foo
|
342
|
+
# bar = 1
|
343
|
+
# else
|
344
|
+
# bar = 2
|
345
|
+
# end
|
346
|
+
|
347
|
+
Style/ConditionalAssignment:
|
348
|
+
Enabled: false
|
349
|
+
|
350
|
+
# Style::ConditionalAssignmentHelper
|
351
|
+
#
|
352
|
+
# Helper module to provide common methods to classes needed for the ConditionalAssignment Cop
|
353
|
+
|
354
|
+
Style/ConditionalAssignmentHelper:
|
355
|
+
Enabled: true
|
356
|
+
|
357
|
+
# Style::ConditionalCorrectorHelper
|
358
|
+
#
|
359
|
+
# Helper module to provide common methodsw to ConditionalAssignment correctors
|
360
|
+
|
361
|
+
Style/ConditionalCorrectorHelper:
|
362
|
+
Enabled: true
|
363
|
+
|
364
|
+
# Style::ConstantName
|
365
|
+
#
|
366
|
+
# Checks for 'snake_case' is used or not for naming Constants
|
367
|
+
|
368
|
+
Style/ConstantName:
|
369
|
+
Enabled: true
|
370
|
+
|
371
|
+
# Style::Copyright
|
372
|
+
#
|
373
|
+
# Check that a copyright notice was given in each source file
|
374
|
+
|
375
|
+
Style/Copyright:
|
376
|
+
Enabled: false
|
377
|
+
|
378
|
+
# Style::DefWithParentheses
|
379
|
+
#
|
380
|
+
# Checks for parentheses in the definition of a method, that doesnt take any arguments.
|
381
|
+
# Both instance and class/singleton methods are checked.
|
382
|
+
|
383
|
+
Style/DefWithParentheses:
|
384
|
+
Enabled: true
|
385
|
+
|
386
|
+
# Style::Documentation
|
387
|
+
#
|
388
|
+
# Checks for mising top-level documentation of classes and modules
|
389
|
+
|
390
|
+
Style/Documentation:
|
391
|
+
Enabled: false
|
392
|
+
|
393
|
+
# Style::DocumentationMethod
|
394
|
+
#
|
395
|
+
# Checks for missing documentation comment for public methods.
|
396
|
+
|
397
|
+
Style/DocumentationMethod:
|
398
|
+
Enabled: false
|
399
|
+
|
400
|
+
# Style::DotPosition
|
401
|
+
#
|
402
|
+
# Checks the '.' position in multi-line method calls
|
403
|
+
|
404
|
+
Style/DotPosition:
|
405
|
+
EnforcedStyle: trailing
|
406
|
+
|
407
|
+
# Style::DoubleNegation
|
408
|
+
#
|
409
|
+
# Checks for uses of a double negation (!!) to convert something into a boolean value.
|
410
|
+
#
|
411
|
+
# bad: !!something
|
412
|
+
#
|
413
|
+
# good: !something.nil?
|
414
|
+
# (when something is a 'boolean' the above are not the same thing)
|
415
|
+
#
|
416
|
+
Style/DoubleNegation:
|
417
|
+
Enabled: true
|
418
|
+
|
419
|
+
# Style::EachForSimpleLoop
|
420
|
+
#
|
421
|
+
# Checks for loops which iterate a constant number of times, using a Range literal and "#each"
|
422
|
+
# This can be achieved by using 'times'
|
423
|
+
#
|
424
|
+
# bad: (1..5).each { }
|
425
|
+
#
|
426
|
+
# good: 5.times { }
|
427
|
+
#
|
428
|
+
|
429
|
+
Style/EachForSimpleLoop:
|
430
|
+
Enabled: true
|
431
|
+
|
432
|
+
# Style::EachWithObject
|
433
|
+
#
|
434
|
+
# Checks for induce/reject calls where the passed in object is returned at the end.
|
435
|
+
# This can be replaced with 'each_with_object' , so that there is no need to return the object.
|
436
|
+
#
|
437
|
+
# bad:
|
438
|
+
# [1,2].inject({}) { |a,e| a[e]= e; a }
|
439
|
+
# good:
|
440
|
+
# [1,2].each_with_object({}) { |a,e| a[e] = e }
|
441
|
+
|
442
|
+
Style/EachWithObject:
|
443
|
+
Enabled: true
|
444
|
+
|
445
|
+
# Style::ElseAlignment
|
446
|
+
#
|
447
|
+
# Checks for alignment of `else` keywords
|
448
|
+
|
449
|
+
Style/ElseAlignment:
|
450
|
+
Enabled: true
|
451
|
+
|
452
|
+
# Style::EmptyCaseCondition
|
453
|
+
#
|
454
|
+
# Checks for case statements with an empty condition
|
455
|
+
#
|
456
|
+
# bad:
|
457
|
+
#
|
458
|
+
# case
|
459
|
+
# when x == 0
|
460
|
+
# puts 'x is 0'
|
461
|
+
# when y == 0
|
462
|
+
# puts 'y is 0'
|
463
|
+
# else
|
464
|
+
# puts 'nothing is 0'
|
465
|
+
# end
|
466
|
+
#
|
467
|
+
# good:
|
468
|
+
#
|
469
|
+
# if x == 0
|
470
|
+
# puts 'x is 0'
|
471
|
+
# elsif y == 0
|
472
|
+
# puts 'y is 0'
|
473
|
+
# else
|
474
|
+
# puts 'nothing is 0'
|
475
|
+
# end
|
476
|
+
|
477
|
+
Style/EmptyCaseCondition:
|
478
|
+
Enabled: true
|
479
|
+
|
480
|
+
# Style::EmptyElse
|
481
|
+
#
|
482
|
+
# Checks for empty else-clauses, possibly including comments and/or an explicit 'nil'
|
483
|
+
# depending on Enforced Style
|
484
|
+
|
485
|
+
Style/EmptyElse:
|
486
|
+
EnforcedStyle: both
|
487
|
+
|
488
|
+
# Style::EmptyLineBetweenDefs
|
489
|
+
#
|
490
|
+
# Checks whether method definitions are separated by empty lines
|
491
|
+
|
492
|
+
Style/EmptyLineBetweenDefs:
|
493
|
+
Enabled: true
|
494
|
+
|
495
|
+
# Style::EmptyLines
|
496
|
+
#
|
497
|
+
# Checks for two or more consecutive blank lines
|
498
|
+
|
499
|
+
Style/EmptyLines:
|
500
|
+
Enabled: true
|
501
|
+
|
502
|
+
# Style::EmptyLinesAroundAccessModifier
|
503
|
+
#
|
504
|
+
# Access modifiers should be surrounded by blank spaces.
|
505
|
+
|
506
|
+
Style/EmptyLinesAroundAccessModifier:
|
507
|
+
Enabled: false
|
508
|
+
|
509
|
+
# Style::EmptyLinesAroundBlockBody
|
510
|
+
#
|
511
|
+
# Checks if empty lines around the bodies of blocks match the configuration.
|
512
|
+
#
|
513
|
+
# bad:
|
514
|
+
#
|
515
|
+
# foo do |bar|
|
516
|
+
# ...
|
517
|
+
# end
|
518
|
+
#
|
519
|
+
# good:
|
520
|
+
#
|
521
|
+
# foo do |bar|
|
522
|
+
#
|
523
|
+
# ....
|
524
|
+
#
|
525
|
+
# end
|
526
|
+
#
|
527
|
+
# ( This helps in readability of code )
|
528
|
+
|
529
|
+
Style/EmptyLinesAroundBlockBody:
|
530
|
+
Enabled: false
|
531
|
+
|
532
|
+
# Styles::EmptyLinesAroundBody
|
533
|
+
#
|
534
|
+
# Checks the presence/absence of empty lines around some kind of body matches the configuration
|
535
|
+
|
536
|
+
Style/EmptyLinesAroundBody:
|
537
|
+
Enabled: false
|
538
|
+
|
539
|
+
# Style::EmptyLinesAroundClassBody
|
540
|
+
#
|
541
|
+
# Checks if empty lines around the bodies of classes match the configuration
|
542
|
+
|
543
|
+
Style/EmptyLinesAroundClassBody:
|
544
|
+
Enabled: false
|
545
|
+
|
546
|
+
# Style::EmptyLinesAroundMethodBody
|
547
|
+
#
|
548
|
+
# Checks if empty lines exist around the bodies of methods.
|
549
|
+
|
550
|
+
Style/EmptyLinesAroundMethodBody:
|
551
|
+
Enabled: false
|
552
|
+
|
553
|
+
# Style::EmptyLinesAroundModuleBody
|
554
|
+
#
|
555
|
+
# Checks if empty lines around the bodies of modules match the configuration
|
556
|
+
|
557
|
+
Style/EmptyLinesAroundModuleBody:
|
558
|
+
Enabled: false
|
559
|
+
|
560
|
+
# Style::EmptyLiteral
|
561
|
+
#
|
562
|
+
# Checks for the use of a method, the result of which would be a literal, like an empty array, hash or string
|
563
|
+
|
564
|
+
Style/EmptyLiteral:
|
565
|
+
Enabled: false
|
566
|
+
|
567
|
+
# Style::EmptyMethod
|
568
|
+
#
|
569
|
+
# Checks for the formatting of empty method definitions.
|
570
|
+
#
|
571
|
+
# bad:
|
572
|
+
#
|
573
|
+
# def foo(bar)
|
574
|
+
# end
|
575
|
+
#
|
576
|
+
# good:
|
577
|
+
#
|
578
|
+
# def foo(bar); end
|
579
|
+
|
580
|
+
Style/EmptyMethod:
|
581
|
+
Enabled: true
|
582
|
+
|
583
|
+
# Style::Encoding
|
584
|
+
#
|
585
|
+
# Checks whether the source file has a utf-8 encoding comment or not
|
586
|
+
# This is required if code should be supported by Ruby 1.9, since in 2.0+ utf-8 is default
|
587
|
+
|
588
|
+
Style/Encoding:
|
589
|
+
Enabled: false
|
590
|
+
|
591
|
+
# Style::EndBlock
|
592
|
+
#
|
593
|
+
# Checks for END blocks. Use `kernel#at_exit` instead
|
594
|
+
|
595
|
+
Style/Encoding:
|
596
|
+
Enabled: false
|
597
|
+
|
598
|
+
# Style::EndOfLine
|
599
|
+
#
|
600
|
+
# Checks for Windows-style line endings in source code.
|
601
|
+
|
602
|
+
Style/EndOfLine:
|
603
|
+
Enabled: false
|
604
|
+
|
605
|
+
# Style::EvenOdd
|
606
|
+
#
|
607
|
+
# Checks for places where Integer#even? or Integer#odd? should have been used.
|
608
|
+
#
|
609
|
+
# bad: if x % 2 == 0
|
610
|
+
#
|
611
|
+
# good: if x.even?
|
612
|
+
#
|
613
|
+
Style/EvenOdd:
|
614
|
+
Enabled: true
|
615
|
+
|
616
|
+
# Style::ExtraSpacing
|
617
|
+
#
|
618
|
+
# Checks for extra/unnecessary whitespace
|
619
|
+
|
620
|
+
Style/ExtraSpacing:
|
621
|
+
# When true, allows most uses of extra spacing if the intent is to align
|
622
|
+
# things with the previous or next line, not counting empty lines or comment
|
623
|
+
# lines.
|
624
|
+
AllowForAlignment: true
|
625
|
+
# When true, forces the alignment of `=` in assignments on consecutive lines.
|
626
|
+
ForceEqualSignAlignment: false
|
627
|
+
|
628
|
+
# Style::FileName
|
629
|
+
#
|
630
|
+
# Makes sure that Ruby source files have snake_case names.
|
631
|
+
|
632
|
+
Style/FileName:
|
633
|
+
Enabled: true
|
634
|
+
|
635
|
+
# Style::FirstArrayElementLineBreak
|
636
|
+
#
|
637
|
+
# Checks for a line break before the first element in a multi-line array.
|
638
|
+
#
|
639
|
+
# bad:
|
640
|
+
#
|
641
|
+
# [ :a,
|
642
|
+
# :b]
|
643
|
+
#
|
644
|
+
# good:
|
645
|
+
#
|
646
|
+
# [
|
647
|
+
# :a,
|
648
|
+
# :b]
|
649
|
+
|
650
|
+
Style/FirstArrayElementLineBreak:
|
651
|
+
Enabled: false
|
652
|
+
|
653
|
+
# Style::FirstHashElementLineBreak
|
654
|
+
#
|
655
|
+
# Checks for a line break before the first element in a multi-line hash.
|
656
|
+
#
|
657
|
+
# bad:
|
658
|
+
#
|
659
|
+
# { a: 1,
|
660
|
+
# b: 2}
|
661
|
+
#
|
662
|
+
# good:
|
663
|
+
#
|
664
|
+
# {
|
665
|
+
# a: 1,
|
666
|
+
# b: 2 }
|
667
|
+
|
668
|
+
Style/FirstHashElementLineBreak:
|
669
|
+
Enabled: false
|
670
|
+
|
671
|
+
# Style::FirstMethodArgumentLineBreak
|
672
|
+
#
|
673
|
+
# Checks for a line break before the first argument in a multi-line method call.
|
674
|
+
#
|
675
|
+
# bad:
|
676
|
+
#
|
677
|
+
# method(foo, bar,
|
678
|
+
# baz)
|
679
|
+
#
|
680
|
+
# good:
|
681
|
+
#
|
682
|
+
# method(
|
683
|
+
# foo, bar,
|
684
|
+
# baz)
|
685
|
+
#
|
686
|
+
# ignored:
|
687
|
+
#
|
688
|
+
# method foo, bar,
|
689
|
+
# baz
|
690
|
+
|
691
|
+
Style/FirstMethodArgumentLineBreak:
|
692
|
+
Enabled: true
|
693
|
+
|
694
|
+
# Style::FirstMethodParameterLineBreak
|
695
|
+
#
|
696
|
+
# Checks for a line break before the first parameter in a multi-line method parameter definition
|
697
|
+
#
|
698
|
+
# bad:
|
699
|
+
#
|
700
|
+
# def method(foo, bar,
|
701
|
+
# baz)
|
702
|
+
# do_something
|
703
|
+
# end
|
704
|
+
#
|
705
|
+
# good:
|
706
|
+
#
|
707
|
+
# def method(
|
708
|
+
# foo, bar,
|
709
|
+
# baz)
|
710
|
+
# do_something
|
711
|
+
# end
|
712
|
+
#
|
713
|
+
# ignored:
|
714
|
+
#
|
715
|
+
# def method foo,
|
716
|
+
# bar
|
717
|
+
# do_something
|
718
|
+
# end
|
719
|
+
|
720
|
+
Style/FirstMethodParameterLineBreak:
|
721
|
+
Enabled: true
|
722
|
+
|
723
|
+
# Style::FirstParameterIndentation
|
724
|
+
#
|
725
|
+
# Checks the indentation of the first parameter in a method call.
|
726
|
+
# ( This cop checks only for first parameter indentation )
|
727
|
+
# bad:
|
728
|
+
#
|
729
|
+
# some_method(
|
730
|
+
# first_param,
|
731
|
+
# second_param)
|
732
|
+
#
|
733
|
+
# good:
|
734
|
+
#
|
735
|
+
# some_method(
|
736
|
+
# first_param,
|
737
|
+
# second_param)
|
738
|
+
|
739
|
+
Style/FirstParameterIndentation:
|
740
|
+
EnforcedStyle: special_for_inner_method_call_in_parentheses
|
741
|
+
|
742
|
+
# Style::FlipFlop
|
743
|
+
#
|
744
|
+
# Looks for uses of flip flop operator.
|
745
|
+
# ( Avoid the use of flip flop operators)
|
746
|
+
|
747
|
+
Style/FlipFlop:
|
748
|
+
Enabled: true
|
749
|
+
|
750
|
+
# Style::For
|
751
|
+
#
|
752
|
+
# Looks for used of the `for` keyword, or `each` method in multi-line loops.
|
753
|
+
|
754
|
+
Style/For:
|
755
|
+
EnforcedStyle: each
|
756
|
+
|
757
|
+
# Style::FormatString
|
758
|
+
#
|
759
|
+
# Enforce the method used for string formatting.
|
760
|
+
|
761
|
+
Style/FormatString:
|
762
|
+
EnforcedStyle: format
|
763
|
+
|
764
|
+
# Style::FrozenStringLiteralComment
|
765
|
+
#
|
766
|
+
# This cop is designed to help upgrade to Ruby 3.0
|
767
|
+
# It will add the comment '#frozen_string_literal:true' to top of files to enable frozen string literals.
|
768
|
+
|
769
|
+
Style/FrozenStringLiteralComment:
|
770
|
+
Enabled: true
|
771
|
+
EnforcedStyle: when_needed
|
772
|
+
|
773
|
+
# Style::GlobalVars
|
774
|
+
#
|
775
|
+
# Looks for uses of global variables. Report offenses for any global variables found
|
776
|
+
# Build-in global variables are allowed by default
|
777
|
+
Style/GlobalVars:
|
778
|
+
Enabled: false
|
779
|
+
|
780
|
+
# Style::GuardClause
|
781
|
+
#
|
782
|
+
# Use a guard clause instead of wrapping the code inside a conditional expression
|
783
|
+
#
|
784
|
+
# bad:
|
785
|
+
#
|
786
|
+
# def test
|
787
|
+
# if something
|
788
|
+
# work
|
789
|
+
# end
|
790
|
+
# end
|
791
|
+
#
|
792
|
+
# good:
|
793
|
+
#
|
794
|
+
# def test
|
795
|
+
# return unless something
|
796
|
+
# work
|
797
|
+
# end
|
798
|
+
#
|
799
|
+
# 'MinBodyLength' defines the number of lines of the body of an `if` or `unless`
|
800
|
+
# needs to have to trigger this cop
|
801
|
+
|
802
|
+
Style/GuardClause:
|
803
|
+
MinBodyLength: 2
|
804
|
+
|
805
|
+
# Style::HashSyntax
|
806
|
+
#
|
807
|
+
# Checks hash literal syntax
|
808
|
+
# 'ruby19_no_mixed_keys' checks for hash syntax for all hashes
|
809
|
+
#
|
810
|
+
# bad:
|
811
|
+
#
|
812
|
+
# {:a => 1, :b => 2}
|
813
|
+
# {c: 2, 'd' => 3} # should just use hash rockets
|
814
|
+
#
|
815
|
+
# good:
|
816
|
+
#
|
817
|
+
# {a: 1, b: 2}
|
818
|
+
# {:c => 3, :d => 4}
|
819
|
+
|
820
|
+
Style/HashSyntax:
|
821
|
+
EnforcedStyle: ruby19_no_mixed_keys
|
822
|
+
# Force hashes that have a symbol value to use hash rockets
|
823
|
+
UseHashRocketsWithSymbolValues: false
|
824
|
+
# Do not suggest { a?: 1 } over { :a? => 1 } in ruby19 style
|
825
|
+
PreferHashRocketsForNonAlnumEndingSymbols: false
|
826
|
+
|
827
|
+
# Style::IdenticalConditionalBranches
|
828
|
+
#
|
829
|
+
# Checks for identical lines at the end of each branch of a conditional statement
|
830
|
+
#
|
831
|
+
# bad:
|
832
|
+
#
|
833
|
+
# if condition
|
834
|
+
# do_x
|
835
|
+
# do_z
|
836
|
+
# else
|
837
|
+
# do_y
|
838
|
+
# do_z
|
839
|
+
# end
|
840
|
+
#
|
841
|
+
# good:
|
842
|
+
#
|
843
|
+
# if condition
|
844
|
+
# do_x
|
845
|
+
# else
|
846
|
+
# do_y
|
847
|
+
# end
|
848
|
+
# do_z
|
849
|
+
|
850
|
+
Style/IdenticalConditionalBranches:
|
851
|
+
Enabled: true
|
852
|
+
|
853
|
+
# Style::IfCorrector
|
854
|
+
#
|
855
|
+
# Corrector to correct conditional assignment in `if` statements.
|
856
|
+
|
857
|
+
Style/IfCorrector:
|
858
|
+
Enabled: true
|
859
|
+
|
860
|
+
# Style::IfInsideElse
|
861
|
+
#
|
862
|
+
# if the `else` branch of a condition consists solely of an `if` node, it can be combined with
|
863
|
+
# the `else` to become an `elsif`. This helps to keep the nesting level from getting too deep.
|
864
|
+
#
|
865
|
+
# bad:
|
866
|
+
#
|
867
|
+
# if condition_a
|
868
|
+
# action_a
|
869
|
+
# else
|
870
|
+
# if condition_b
|
871
|
+
# action_b
|
872
|
+
# else
|
873
|
+
# action_c
|
874
|
+
# end
|
875
|
+
# end
|
876
|
+
#
|
877
|
+
# good:
|
878
|
+
#
|
879
|
+
# if condition_a
|
880
|
+
# action_a
|
881
|
+
# elsif condition_b
|
882
|
+
# action_b
|
883
|
+
# else
|
884
|
+
# action_c
|
885
|
+
# end
|
886
|
+
|
887
|
+
Style/IfInsideElse:
|
888
|
+
Enabled: true
|
889
|
+
|
890
|
+
# Style::IfUnlessModifier
|
891
|
+
#
|
892
|
+
# Checks for if and unless statements that would fit on one line if written as a modifier if/unless.
|
893
|
+
|
894
|
+
Style/IfUnlessModifier:
|
895
|
+
MaxLineLength: 80
|
896
|
+
|
897
|
+
# Style::IfUnlessModifierOfIfUnless
|
898
|
+
#
|
899
|
+
# Checks for if and unless statements used as modifiers of other if or unless statements
|
900
|
+
#
|
901
|
+
# bad:
|
902
|
+
#
|
903
|
+
# if tired?
|
904
|
+
# "please stop"
|
905
|
+
# else
|
906
|
+
# "keep going"
|
907
|
+
# end if running?
|
908
|
+
#
|
909
|
+
# good:
|
910
|
+
#
|
911
|
+
# if running?
|
912
|
+
# tired? ? 'stop' : 'go faster'
|
913
|
+
# end
|
914
|
+
|
915
|
+
Style/IfUnlessModifierOfIfUnless:
|
916
|
+
Enabled: true
|
917
|
+
|
918
|
+
# Style::IfWithSemicolon
|
919
|
+
#
|
920
|
+
# Checks for uses of semicolon in if statements
|
921
|
+
|
922
|
+
Style/IfWithSemicolon:
|
923
|
+
Enabled: true
|
924
|
+
|
925
|
+
# Style::ImplicitRuntimeError
|
926
|
+
#
|
927
|
+
# Checks for `raise` or `fail` statements which do not specify an explicit exception class.
|
928
|
+
#
|
929
|
+
# bad: raise 'Error message here'
|
930
|
+
#
|
931
|
+
# good: raise ArgumentError, 'Error message here'
|
932
|
+
|
933
|
+
Style/ImplicitRunTimeError:
|
934
|
+
Enabled: true
|
935
|
+
|
936
|
+
# Style::IndentArray
|
937
|
+
#
|
938
|
+
# Checks for indentation of the first element in the array literal where
|
939
|
+
# the opening bracket and the first elements are on separate lines.
|
940
|
+
# ( Array literals shall have their first element indented one step (2 spaces)
|
941
|
+
# more than the start of the line where the opening bracket is )
|
942
|
+
|
943
|
+
Style/IndentArray:
|
944
|
+
Enabled: false
|
945
|
+
|
946
|
+
# Style::IndentHash
|
947
|
+
#
|
948
|
+
# Same as the Indent Array but in case of hash
|
949
|
+
|
950
|
+
Style/IndentHash:
|
951
|
+
Enabled: false
|
952
|
+
|
953
|
+
# Style::IndentAssignment
|
954
|
+
#
|
955
|
+
# Checks the indentation of the first line of the right-hand-side of a multi-line assignment.
|
956
|
+
#
|
957
|
+
# bad:
|
958
|
+
#
|
959
|
+
# value =
|
960
|
+
# if foo
|
961
|
+
# 'bar'
|
962
|
+
# end
|
963
|
+
#
|
964
|
+
# good:
|
965
|
+
#
|
966
|
+
# value =
|
967
|
+
# if foo
|
968
|
+
# 'bar'
|
969
|
+
# end
|
970
|
+
|
971
|
+
Style/IndentAssignment:
|
972
|
+
Enabled: false
|
973
|
+
|
974
|
+
# Style::IndentationConsistency
|
975
|
+
#
|
976
|
+
# Checks for inconsistent indentation
|
977
|
+
#
|
978
|
+
# bad:
|
979
|
+
#
|
980
|
+
# def test
|
981
|
+
# puts "world"
|
982
|
+
# puts "here"
|
983
|
+
# end
|
984
|
+
|
985
|
+
Style/IndentationConsistency:
|
986
|
+
EnforcedStyle: normal
|
987
|
+
|
988
|
+
# Style::IndentationWidth
|
989
|
+
#
|
990
|
+
# Checks for indentation that does't use two spaces
|
991
|
+
#
|
992
|
+
# bad:
|
993
|
+
#
|
994
|
+
# def test
|
995
|
+
# puts "world"
|
996
|
+
# end
|
997
|
+
|
998
|
+
Style/IndentationWidth:
|
999
|
+
Width: 2
|
1000
|
+
IgnoredPatterns: []
|
1001
|
+
|
1002
|
+
# Style::InfiniteLoop
|
1003
|
+
#
|
1004
|
+
# Use `Kernel#loop` for infinite loops
|
1005
|
+
#
|
1006
|
+
# bad:
|
1007
|
+
#
|
1008
|
+
# while true
|
1009
|
+
# work
|
1010
|
+
# end
|
1011
|
+
#
|
1012
|
+
# good:
|
1013
|
+
#
|
1014
|
+
# loop do
|
1015
|
+
# work
|
1016
|
+
# end
|
1017
|
+
|
1018
|
+
Style/InfiniteLoop:
|
1019
|
+
Enabled: true
|
1020
|
+
|
1021
|
+
# Style::InitialIndentation:
|
1022
|
+
#
|
1023
|
+
# Checks for indentation of the first non-blank non-comment line in a file.
|
1024
|
+
|
1025
|
+
Style/InitialIndentation:
|
1026
|
+
Enabled: true
|
1027
|
+
|
1028
|
+
# Style::InlineComment
|
1029
|
+
#
|
1030
|
+
# Checks for trailing inline comments
|
1031
|
+
#
|
1032
|
+
# bad:
|
1033
|
+
#
|
1034
|
+
# foo.each do |f|
|
1035
|
+
# f.bar # Trailing inline comment
|
1036
|
+
# end
|
1037
|
+
#
|
1038
|
+
# good:
|
1039
|
+
#
|
1040
|
+
# foo.each do |f|
|
1041
|
+
# # Standalone comment
|
1042
|
+
# f.bar
|
1043
|
+
# end
|
1044
|
+
|
1045
|
+
Style/InlineComment:
|
1046
|
+
Enabled: true
|
1047
|
+
|
1048
|
+
# Style::Lamba
|
1049
|
+
#
|
1050
|
+
# Checks for uses of the pre 1.9 lambda syntax for one-line anonymous functions
|
1051
|
+
# and uses of the 1.9 lambda syntax for multi-line anonymous functions.
|
1052
|
+
# In simple terms, for single line `->(params) {...}` is expected to use and
|
1053
|
+
# for multiline 'lambda' method is expected.
|
1054
|
+
|
1055
|
+
Style/Lambda:
|
1056
|
+
EnforcedStyle: line_count_dependent
|
1057
|
+
|
1058
|
+
# Style::LambdaCall
|
1059
|
+
#
|
1060
|
+
# Checks for use of the lambda.(args) syntax.
|
1061
|
+
#
|
1062
|
+
# bad: lambda.(x,y)
|
1063
|
+
#
|
1064
|
+
# good: lambda.call(x,y)
|
1065
|
+
|
1066
|
+
Style/LambdaCall:
|
1067
|
+
EnforcedStyle: call
|
1068
|
+
|
1069
|
+
# Style::LeadingCommentSpace
|
1070
|
+
#
|
1071
|
+
# Checks whether comments have a leading space after the '#'
|
1072
|
+
# Note: Leading space is not required for RDoc special syntax, like #++, #-, #:nodoc, etc.
|
1073
|
+
|
1074
|
+
Style/LeadingCommentSpace:
|
1075
|
+
Enabled: true
|
1076
|
+
|
1077
|
+
# Style::LineEndConcatenation
|
1078
|
+
#
|
1079
|
+
# Checks for string literal concatenatio at the end of the line.
|
1080
|
+
#
|
1081
|
+
# bad:
|
1082
|
+
#
|
1083
|
+
# some_str = 'pras' +
|
1084
|
+
# 'anna'
|
1085
|
+
# some_Str = 'pras' <<
|
1086
|
+
# 'anna'
|
1087
|
+
#
|
1088
|
+
# good:
|
1089
|
+
#
|
1090
|
+
# some_str = 'pras' \
|
1091
|
+
# 'anna'
|
1092
|
+
|
1093
|
+
Style/LineEndConcatenation:
|
1094
|
+
Enabled: false
|
1095
|
+
|
1096
|
+
# Style::MethodCallWithoutArgsParentheses
|
1097
|
+
#
|
1098
|
+
# Checks for unwanted parenthesis in parameterless method calls
|
1099
|
+
|
1100
|
+
Style/MethodCallWithoutArgsParentheses:
|
1101
|
+
Enabled: true
|
1102
|
+
|
1103
|
+
# Style::MethodCalledOnDoEndBlock
|
1104
|
+
#
|
1105
|
+
# Checks for methods called on a do..end block.
|
1106
|
+
# The point of this check is that its easy to miss the call tacked
|
1107
|
+
# on to the block when reading code.
|
1108
|
+
|
1109
|
+
Style/MethodCalledOnDoEndBlock:
|
1110
|
+
Enabled: true
|
1111
|
+
|
1112
|
+
# Style::MethodDefParentheses
|
1113
|
+
#
|
1114
|
+
# Checks for parenthesis around the arguments in method definitions.
|
1115
|
+
# Both instance and class/singleton methods are checked.
|
1116
|
+
|
1117
|
+
Style/MethodDefParentheses:
|
1118
|
+
EnforcedStyle: require_parentheses
|
1119
|
+
|
1120
|
+
# Style::MethodMissing
|
1121
|
+
#
|
1122
|
+
# Checks for the presence of `method_missing` without also defining `respond_to_missing?` and
|
1123
|
+
# falling back on `super`
|
1124
|
+
#
|
1125
|
+
# bad:
|
1126
|
+
#
|
1127
|
+
# def method_missing(...)
|
1128
|
+
# ...
|
1129
|
+
# end
|
1130
|
+
#
|
1131
|
+
# good:
|
1132
|
+
#
|
1133
|
+
# def respond_to_missing?(...)
|
1134
|
+
# ...
|
1135
|
+
# end
|
1136
|
+
#
|
1137
|
+
# def method_missing(...)
|
1138
|
+
# ...
|
1139
|
+
# super
|
1140
|
+
# end
|
1141
|
+
|
1142
|
+
Style/MethodMissing:
|
1143
|
+
Enabled: true
|
1144
|
+
|
1145
|
+
# Style::MethodName
|
1146
|
+
#
|
1147
|
+
# Makes sure that all methods use the 'snake_case' for their name.
|
1148
|
+
|
1149
|
+
Style/MethodName:
|
1150
|
+
EnforcedStyle: snake_case
|
1151
|
+
|
1152
|
+
# Style::MissingElse
|
1153
|
+
#
|
1154
|
+
# Checks for `if` expressions that do not have an `else` branch.
|
1155
|
+
#
|
1156
|
+
# bad:
|
1157
|
+
#
|
1158
|
+
# if condition
|
1159
|
+
# statement
|
1160
|
+
# end
|
1161
|
+
#
|
1162
|
+
# bad:
|
1163
|
+
#
|
1164
|
+
# case var
|
1165
|
+
# when condition
|
1166
|
+
# statement
|
1167
|
+
# end
|
1168
|
+
#
|
1169
|
+
# good:
|
1170
|
+
#
|
1171
|
+
# if condition
|
1172
|
+
# statement
|
1173
|
+
# else
|
1174
|
+
# # the content of the else branch will be determined by Style/EmptyElse
|
1175
|
+
# end
|
1176
|
+
|
1177
|
+
Style/MissingElse:
|
1178
|
+
Enabled: false
|
1179
|
+
|
1180
|
+
# Style::ModuleFunction
|
1181
|
+
#
|
1182
|
+
# Checks for use of `extend self` in a module
|
1183
|
+
#
|
1184
|
+
# bad:
|
1185
|
+
#
|
1186
|
+
# module Test
|
1187
|
+
# extend self
|
1188
|
+
# ....
|
1189
|
+
# end
|
1190
|
+
# end
|
1191
|
+
#
|
1192
|
+
# Use 'module_function' instead of 'extend self'
|
1193
|
+
|
1194
|
+
Style/ModuleFunction:
|
1195
|
+
Enabled: false
|
1196
|
+
|
1197
|
+
# Style::MultilineArrayBraceLayout
|
1198
|
+
#
|
1199
|
+
# Checks that the closing brace in an array literal is either on the
|
1200
|
+
# same line as the last array element, or a new line.
|
1201
|
+
#
|
1202
|
+
# symmetrical: closing brace is positioned in same way as opening brace
|
1203
|
+
|
1204
|
+
Style/MultilineArrayBraceLayout:
|
1205
|
+
EnforcedStyle: symmetrical
|
1206
|
+
|
1207
|
+
# Style::MultilineAssignmentLayout
|
1208
|
+
#
|
1209
|
+
# Checks whether the multiline assignments have a new line after
|
1210
|
+
# the assignment operator
|
1211
|
+
#
|
1212
|
+
# bad: (with EnforcedStyle set to new_line)
|
1213
|
+
#
|
1214
|
+
# foo = if expression
|
1215
|
+
# 'bar'
|
1216
|
+
# end
|
1217
|
+
#
|
1218
|
+
# good: (with EnforcedStyle set to same_line)
|
1219
|
+
#
|
1220
|
+
# foo = if expression
|
1221
|
+
# 'bar'
|
1222
|
+
# end
|
1223
|
+
|
1224
|
+
Style/MultilineAssignmentLayout:
|
1225
|
+
EnforcedStyle: same_line
|
1226
|
+
|
1227
|
+
|
1228
|
+
# Style::MultilineBlockChain
|
1229
|
+
#
|
1230
|
+
# Checks for chaining of a block another block that spans multiple lines
|
1231
|
+
#
|
1232
|
+
# bad:
|
1233
|
+
#
|
1234
|
+
# do_something.do |t|
|
1235
|
+
# ....
|
1236
|
+
# end.map do |t|
|
1237
|
+
# ....
|
1238
|
+
# end
|
1239
|
+
|
1240
|
+
Style/MultilineBlockChain:
|
1241
|
+
Enabled: true
|
1242
|
+
|
1243
|
+
# Style::MultilineBlockLayout
|
1244
|
+
#
|
1245
|
+
# Checks whether the multiline do end blocks have a newline after the start of the block.
|
1246
|
+
# Additionally, it checks whether the block arguments, if any, are on the same line as the start of the block.
|
1247
|
+
#
|
1248
|
+
# bad:
|
1249
|
+
#
|
1250
|
+
# blah do
|
1251
|
+
# |i| foo(i)
|
1252
|
+
# bar(i)
|
1253
|
+
# end
|
1254
|
+
#
|
1255
|
+
# good:
|
1256
|
+
#
|
1257
|
+
# blah do |i|
|
1258
|
+
# foo(i)
|
1259
|
+
# bar(i)
|
1260
|
+
# end
|
1261
|
+
|
1262
|
+
Style/MultilineBlockLayout:
|
1263
|
+
Enabled: true
|
1264
|
+
|
1265
|
+
# Style::MultilineHashBraceLayout
|
1266
|
+
#
|
1267
|
+
# Checks that the closing brace in a hash literal is either on the
|
1268
|
+
# same line as the last hash element, or a new line
|
1269
|
+
#
|
1270
|
+
# Symmetrical:
|
1271
|
+
# { a: 1,
|
1272
|
+
# b: 2 }
|
1273
|
+
#
|
1274
|
+
# {
|
1275
|
+
# a: 1,
|
1276
|
+
# b: 2
|
1277
|
+
# }
|
1278
|
+
|
1279
|
+
Style/MultilineHashBraceLayout:
|
1280
|
+
EnforcedStyle: symmetrical
|
1281
|
+
|
1282
|
+
# Style::MultilineIfModifier
|
1283
|
+
#
|
1284
|
+
# Checks for uses of if/unless modifiers with multiline-lines bodies.
|
1285
|
+
#
|
1286
|
+
# bad:
|
1287
|
+
#
|
1288
|
+
# {
|
1289
|
+
# result: 'this should not happen'
|
1290
|
+
# } unless cond
|
1291
|
+
#
|
1292
|
+
# good:
|
1293
|
+
#
|
1294
|
+
# { result: 'ok' } if cond
|
1295
|
+
|
1296
|
+
Style/MultilineIfModifier:
|
1297
|
+
Enabled: true
|
1298
|
+
|
1299
|
+
# Style::MultilineIfThen
|
1300
|
+
#
|
1301
|
+
# Checks for uses of 'then' keyword in multiline statements
|
1302
|
+
#
|
1303
|
+
# bad:
|
1304
|
+
#
|
1305
|
+
# if cond then
|
1306
|
+
# do_something
|
1307
|
+
# end
|
1308
|
+
#
|
1309
|
+
# good:
|
1310
|
+
#
|
1311
|
+
# if cond1 then do_a
|
1312
|
+
# elsif cond2 then do_b
|
1313
|
+
# end
|
1314
|
+
|
1315
|
+
Style/MultilineIfThen:
|
1316
|
+
Enabled: true
|
1317
|
+
|
1318
|
+
# Style::MultilineMemoization
|
1319
|
+
#
|
1320
|
+
# Checks that multiline memoizations are wrapped in a `begin` and `end` block.
|
1321
|
+
#
|
1322
|
+
# bad:
|
1323
|
+
#
|
1324
|
+
# foo ||= (
|
1325
|
+
# bar
|
1326
|
+
# baz
|
1327
|
+
# )
|
1328
|
+
#
|
1329
|
+
# good:
|
1330
|
+
#
|
1331
|
+
# foo ||= begin
|
1332
|
+
# bar
|
1333
|
+
# baz
|
1334
|
+
# end
|
1335
|
+
|
1336
|
+
Style/MultilineMemoization:
|
1337
|
+
Enabled: false
|
1338
|
+
|
1339
|
+
# Style::MultilineMethodCallBraceLayout
|
1340
|
+
#
|
1341
|
+
# Checks that the closing brace in a method call is either on the
|
1342
|
+
# same line as the last method argument, or a new line
|
1343
|
+
|
1344
|
+
Style/MultilineMethodCallBraceLayout:
|
1345
|
+
EnforcedStyle: symmetrical
|
1346
|
+
|
1347
|
+
# Style::MultilineMethodCallIndentation
|
1348
|
+
#
|
1349
|
+
# Checks the indentation of the method name part in method calls
|
1350
|
+
# that span more than one line.
|
1351
|
+
#
|
1352
|
+
# bad
|
1353
|
+
# while a
|
1354
|
+
# .b
|
1355
|
+
# something
|
1356
|
+
# end
|
1357
|
+
#
|
1358
|
+
# good:
|
1359
|
+
#
|
1360
|
+
# while a
|
1361
|
+
# .b
|
1362
|
+
# something
|
1363
|
+
# end
|
1364
|
+
|
1365
|
+
Style/MultilineMethodCallIndentation:
|
1366
|
+
EnforcedStyle: aligned
|
1367
|
+
|
1368
|
+
# Style::MultilineMethodDefinitionBraceLayout
|
1369
|
+
#
|
1370
|
+
# Checks that the closing brace in a method definition is either on the
|
1371
|
+
# same line as the last method parameter, or a new line
|
1372
|
+
|
1373
|
+
Style/MultilineMethodDefinitionBraceLayout:
|
1374
|
+
EnforcedStyle: symmetrical
|
1375
|
+
|
1376
|
+
# Style::MultilineOperationIndentation
|
1377
|
+
#
|
1378
|
+
# Checks the indentation of the right hand side operand in the binary operations that span
|
1379
|
+
# more than one line.
|
1380
|
+
#
|
1381
|
+
# bad:
|
1382
|
+
#
|
1383
|
+
# if a +
|
1384
|
+
# b
|
1385
|
+
# something
|
1386
|
+
# end
|
1387
|
+
|
1388
|
+
Style/MultilineOperationIndentation:
|
1389
|
+
EnforcedStyle: aligned
|
1390
|
+
|
1391
|
+
# Style::MultilineTernaryOperator
|
1392
|
+
#
|
1393
|
+
# Checks for uses of ternary operator in multiline statements
|
1394
|
+
# ( Avoid multi-line ?: (the ternary operator) )
|
1395
|
+
|
1396
|
+
Style/MultilineTernaryOperator:
|
1397
|
+
Enabled: true
|
1398
|
+
|
1399
|
+
# Style::MutedConstant
|
1400
|
+
#
|
1401
|
+
# Checks whether some constant value isn`t a mutable literal (e.g. array or hash)
|
1402
|
+
#
|
1403
|
+
# bad:
|
1404
|
+
#
|
1405
|
+
# CONST = [1, 2, 3]
|
1406
|
+
#
|
1407
|
+
# good:
|
1408
|
+
#
|
1409
|
+
# CONST = [1, 2, 3].freeze
|
1410
|
+
|
1411
|
+
Style/MutedConstant:
|
1412
|
+
Enabled: true
|
1413
|
+
|
1414
|
+
# Style::NegatedIf
|
1415
|
+
#
|
1416
|
+
# Checks for uses of negated ifs. Only ifs without else are considered
|
1417
|
+
|
1418
|
+
Style/NegatedIf:
|
1419
|
+
Enabled: true
|
1420
|
+
|
1421
|
+
# Style::NegatedWhile
|
1422
|
+
#
|
1423
|
+
# Checks for uses of while with negated conditions
|
1424
|
+
|
1425
|
+
Style/NegatedWhile:
|
1426
|
+
Enabled: true
|
1427
|
+
|
1428
|
+
# Style::NegatedModifier
|
1429
|
+
#
|
1430
|
+
# bad:
|
1431
|
+
#
|
1432
|
+
# something if a if b
|
1433
|
+
#
|
1434
|
+
# good:
|
1435
|
+
#
|
1436
|
+
# something if b && a
|
1437
|
+
|
1438
|
+
Style/NegatedModifier:
|
1439
|
+
Enabled: true
|
1440
|
+
|
1441
|
+
# Style::NestedParenthesizedCalls
|
1442
|
+
#
|
1443
|
+
# Checks for unparenthesized method calls in the argument list of a parenthesized method call.
|
1444
|
+
#
|
1445
|
+
# bad: method1(method2 arg, method3, arg)
|
1446
|
+
#
|
1447
|
+
# good: method1(method2(arg), method3(arg))
|
1448
|
+
|
1449
|
+
Style/NestedParenthesizedCalls:
|
1450
|
+
Enabled: true
|
1451
|
+
|
1452
|
+
# Style::NestedTernaryOperator
|
1453
|
+
#
|
1454
|
+
# Checks for nested ternary op expressions
|
1455
|
+
# ( Ternary operators must not be nested. Prefer `if` or `else` constructors instead )
|
1456
|
+
|
1457
|
+
Style/NestedTernaryOperator:
|
1458
|
+
Enabled: true
|
1459
|
+
|
1460
|
+
# Style::Next
|
1461
|
+
#
|
1462
|
+
# Use `next` to skip iteration instead of a condition at the end.
|
1463
|
+
#
|
1464
|
+
# bad:
|
1465
|
+
#
|
1466
|
+
# [1, 2].each do |a|
|
1467
|
+
# if a == 1 do
|
1468
|
+
# puts a
|
1469
|
+
# end
|
1470
|
+
# end
|
1471
|
+
#
|
1472
|
+
# good:
|
1473
|
+
#
|
1474
|
+
# [1, 2].each do |a|
|
1475
|
+
# next unless a == 1
|
1476
|
+
# puts a
|
1477
|
+
# end
|
1478
|
+
|
1479
|
+
Style/Next:
|
1480
|
+
Enabled: true
|
1481
|
+
|
1482
|
+
# Style::NilComparison
|
1483
|
+
#
|
1484
|
+
# Checks for something comparison with == nil
|
1485
|
+
#
|
1486
|
+
# bad: x == nil
|
1487
|
+
#
|
1488
|
+
# good: x.nil?
|
1489
|
+
|
1490
|
+
Style/NilComparison:
|
1491
|
+
Enabled: true
|
1492
|
+
|
1493
|
+
# Style::NonNilCheck
|
1494
|
+
#
|
1495
|
+
# Checks for non-nil checks, which are usually redundant.
|
1496
|
+
# ( Non-nil checks are allowed if they are the final nodes of predicate. )
|
1497
|
+
#
|
1498
|
+
# bad:
|
1499
|
+
#
|
1500
|
+
# if !x.nil?
|
1501
|
+
# if x != nil
|
1502
|
+
#
|
1503
|
+
# good:
|
1504
|
+
#
|
1505
|
+
# if x
|
1506
|
+
#
|
1507
|
+
|
1508
|
+
Style/NonNilCheck:
|
1509
|
+
Enabled: true
|
1510
|
+
|
1511
|
+
# Style::Not
|
1512
|
+
#
|
1513
|
+
# Checks for uses if the keyword not instead of !.
|
1514
|
+
|
1515
|
+
Style/Not:
|
1516
|
+
Enabled: true
|
1517
|
+
|
1518
|
+
# Style::NumericLiteralPrefix
|
1519
|
+
#
|
1520
|
+
# Checks for octal, hext, binary and decimal literals using uppercase prefixes and corrects
|
1521
|
+
# them to lowercase prefix or no prefix (in case of decimals).
|
1522
|
+
# e.g. For octal use '0o' instad of '0' or '0O'
|
1523
|
+
|
1524
|
+
Style/NumericLiteralPrefix:
|
1525
|
+
EnforcedOctalStyle: zero_with_o
|
1526
|
+
|
1527
|
+
# Style::NumericLiterals
|
1528
|
+
#
|
1529
|
+
# Checks for big numeric literals without _ between groups of digits in them
|
1530
|
+
Style/NumericLiterals:
|
1531
|
+
MinDigits: 5
|
1532
|
+
|
1533
|
+
# Style::NumericPredicate
|
1534
|
+
#
|
1535
|
+
# Checks for usage of comparison operators (`==`, `>`, `<`) to test numbers as zero,
|
1536
|
+
# positive, or negative. These can be replaced by their respective perdicate methods.
|
1537
|
+
#
|
1538
|
+
# Note: This cop regards `nonzero?` as its value is truthy or falsey, but not `true`
|
1539
|
+
# and `false`, and thus not always interchangeable with `!=0`
|
1540
|
+
#
|
1541
|
+
# bad
|
1542
|
+
#
|
1543
|
+
# foo == 0
|
1544
|
+
# 0 > foo
|
1545
|
+
# bar.baz > 0
|
1546
|
+
#
|
1547
|
+
# good
|
1548
|
+
#
|
1549
|
+
# foo.zero?
|
1550
|
+
# foo.negative?
|
1551
|
+
# bar.baz.positive?
|
1552
|
+
|
1553
|
+
Style/NumericPredicate:
|
1554
|
+
EnforcedStyle: predicate
|
1555
|
+
|
1556
|
+
# Style::OneLineConditional
|
1557
|
+
#
|
1558
|
+
# Checks for uses of if/then/else/end on a single line.
|
1559
|
+
Style/OneLineConditional:
|
1560
|
+
Enabled: false
|
1561
|
+
|
1562
|
+
# Style::OpMethod
|
1563
|
+
#
|
1564
|
+
# Makes sure that certain operator method have their sole parameter named `other`
|
1565
|
+
Style/OpMethod:
|
1566
|
+
Enabled: false
|
1567
|
+
|
1568
|
+
# Style::OptionHash
|
1569
|
+
#
|
1570
|
+
# Checks for options hashes and discourages them if the current Ruby version
|
1571
|
+
# supports keyword arguments
|
1572
|
+
#
|
1573
|
+
# Example:
|
1574
|
+
#
|
1575
|
+
# Instead of:
|
1576
|
+
#
|
1577
|
+
# def fry(options = {})
|
1578
|
+
# temperature = options.fetch(:temperature, 300)
|
1579
|
+
# ...
|
1580
|
+
# end
|
1581
|
+
#
|
1582
|
+
# Prefer:
|
1583
|
+
#
|
1584
|
+
# def fry(temperature: 300)
|
1585
|
+
# ...
|
1586
|
+
# end
|
1587
|
+
|
1588
|
+
Style/OptionHash:
|
1589
|
+
Enabled: false
|
1590
|
+
|
1591
|
+
# Style::OptionalArguments
|
1592
|
+
#
|
1593
|
+
# Checks for optional arguments to methods that do not come at the end of the argument list
|
1594
|
+
#
|
1595
|
+
# bad:
|
1596
|
+
#
|
1597
|
+
# def foo(a = 1, b, c)
|
1598
|
+
# end
|
1599
|
+
#
|
1600
|
+
# good:
|
1601
|
+
#
|
1602
|
+
# def baz(a, b, c = 1)
|
1603
|
+
# end
|
1604
|
+
#
|
1605
|
+
# def foobar(a = 1, b = 2, c = 3)
|
1606
|
+
# end
|
1607
|
+
|
1608
|
+
Style/OptionalArguments:
|
1609
|
+
Enabled: true
|
1610
|
+
|
1611
|
+
# Style::ParallelAssignment
|
1612
|
+
#
|
1613
|
+
# Checks for simple usages of parallel assignments. This will complain only when the number of
|
1614
|
+
# variables being assigned matched the number of assigning variables
|
1615
|
+
#
|
1616
|
+
# bad:
|
1617
|
+
#
|
1618
|
+
# a, b, c = 1, 2, 3
|
1619
|
+
# a, b, c = [1, 2, 3]
|
1620
|
+
#
|
1621
|
+
# good:
|
1622
|
+
#
|
1623
|
+
# one, two = *foo
|
1624
|
+
# a, b = foo()
|
1625
|
+
# a, b = b, a
|
1626
|
+
#
|
1627
|
+
# a = 1
|
1628
|
+
# b = 2
|
1629
|
+
# c = 3
|
1630
|
+
|
1631
|
+
Style/ParallelAssignment:
|
1632
|
+
Enabled: true
|
1633
|
+
|
1634
|
+
# Style::ParenthesesAroundCondition
|
1635
|
+
#
|
1636
|
+
# Checks for the presence of superfluous parentheses around the condition of if/while/unless/until.
|
1637
|
+
Style/ParenthesesAroundCondition:
|
1638
|
+
AllowSafeAssignment: true
|
1639
|
+
|
1640
|
+
# Style::PercentLiteralDelimiters
|
1641
|
+
#
|
1642
|
+
# Enforces the consistent usage of '%'- literal delimiters.
|
1643
|
+
Style/PercentLiteralDelimiters:
|
1644
|
+
Enabled: false
|
1645
|
+
|
1646
|
+
# Style::PercentQLiterals
|
1647
|
+
#
|
1648
|
+
# Checks for usage of the %Q() syntax when %q() would do
|
1649
|
+
|
1650
|
+
Style/PercentQLiteral:
|
1651
|
+
Enabled: true
|
1652
|
+
|
1653
|
+
# Style::PerlBackrefs
|
1654
|
+
#
|
1655
|
+
# Loks for uses of Perl-style regexp match backreferences like $1, $2 etc.
|
1656
|
+
Style/PerlBackrefs:
|
1657
|
+
Enabled: false
|
1658
|
+
|
1659
|
+
# Style::PredicateName
|
1660
|
+
#
|
1661
|
+
# Makes sure that predicates are named properly.
|
1662
|
+
#
|
1663
|
+
# bad: def is_even?(value)
|
1664
|
+
#
|
1665
|
+
# good: def even?(value)
|
1666
|
+
Style/PredicateName:
|
1667
|
+
Enabled: true
|
1668
|
+
|
1669
|
+
# Style::PreferredHashMethods
|
1670
|
+
#
|
1671
|
+
# Checks for uses of methods `Hash#has_key?` and `Hash#has_value?` where it enforces `Hash#key?` and `Hash#value?`
|
1672
|
+
# It is configurable to enforce the inverse
|
1673
|
+
# EnforcedStyle: short
|
1674
|
+
#
|
1675
|
+
# good:
|
1676
|
+
#
|
1677
|
+
# Hash#key?
|
1678
|
+
# Hash#value?
|
1679
|
+
#
|
1680
|
+
# bad:
|
1681
|
+
#
|
1682
|
+
# Hash#has_key?
|
1683
|
+
# Hash#has_value?
|
1684
|
+
|
1685
|
+
Style/PreferredHashMethods:
|
1686
|
+
EnforcedStyle: short
|
1687
|
+
|
1688
|
+
# Style::Proc
|
1689
|
+
#
|
1690
|
+
# Checks for uses of Proc.new where Kernel#proc would be more appropriate
|
1691
|
+
Style/Proc:
|
1692
|
+
Enabled: false
|
1693
|
+
|
1694
|
+
# Style::RaiseArgs
|
1695
|
+
#
|
1696
|
+
# Checks the args passed to 'fail' and 'raise'
|
1697
|
+
Style/RaiseArgs:
|
1698
|
+
Enabled: true
|
1699
|
+
|
1700
|
+
# Style::RedundantBegin
|
1701
|
+
#
|
1702
|
+
# Checks for redundant 'begin' blocks
|
1703
|
+
#
|
1704
|
+
# Currently checks for code like this:
|
1705
|
+
#
|
1706
|
+
# def test
|
1707
|
+
# begin
|
1708
|
+
# ..do something..
|
1709
|
+
# rescue StandardError => e
|
1710
|
+
# ..do something else..
|
1711
|
+
# end
|
1712
|
+
# end
|
1713
|
+
Style/RedundantBegin:
|
1714
|
+
Enabled: true
|
1715
|
+
|
1716
|
+
# Style::RedundantException
|
1717
|
+
#
|
1718
|
+
# Checks for RuntimeError as the argument of raise/fail.
|
1719
|
+
#
|
1720
|
+
# Currently checks for code like this:
|
1721
|
+
#
|
1722
|
+
# raise RuntimeError, 'message'
|
1723
|
+
Style/RedundantException:
|
1724
|
+
Enabled: true
|
1725
|
+
|
1726
|
+
# Style::RedundantFreeze
|
1727
|
+
#
|
1728
|
+
# Checks for uses of Object#Freeze on immutable objects.
|
1729
|
+
#
|
1730
|
+
# bad: CONST = 1.freeze
|
1731
|
+
#
|
1732
|
+
# good: CONST = 1
|
1733
|
+
|
1734
|
+
Style/RedundantFreeze:
|
1735
|
+
Enabled: false
|
1736
|
+
|
1737
|
+
# Style::RedundantParentheses
|
1738
|
+
#
|
1739
|
+
# Check for redundant parentheses
|
1740
|
+
#
|
1741
|
+
# bad: (x) if ((y.z).nil?)
|
1742
|
+
#
|
1743
|
+
# good: x if y.z.nil?
|
1744
|
+
|
1745
|
+
Style/RedundantParentheses:
|
1746
|
+
Enabled: true
|
1747
|
+
|
1748
|
+
# Style::RedundantReturn
|
1749
|
+
#
|
1750
|
+
# Checks for redundant 'return' expressions
|
1751
|
+
#
|
1752
|
+
# bad:
|
1753
|
+
#
|
1754
|
+
# def test
|
1755
|
+
# return something
|
1756
|
+
# end
|
1757
|
+
#
|
1758
|
+
# good:
|
1759
|
+
#
|
1760
|
+
# def test
|
1761
|
+
# something
|
1762
|
+
# end
|
1763
|
+
Style/RedundantReturn:
|
1764
|
+
Enabled: true
|
1765
|
+
|
1766
|
+
# Style::RedundantSelf
|
1767
|
+
#
|
1768
|
+
# Checks for redundant uses of self.
|
1769
|
+
# For more info: http://www.rubydoc.info/github/bbatsov/rubocop/Rubocop/Cop/Style/RedundantSelf
|
1770
|
+
#
|
1771
|
+
Style/RedundantSelf:
|
1772
|
+
Enabled: true
|
1773
|
+
|
1774
|
+
# Style::RegexpLiteral
|
1775
|
+
#
|
1776
|
+
# Checks for regexp literal and reports offenses based on how many escaped slashes
|
1777
|
+
# there are in the regexp and on the value of the configuration parameter MaxSlashes.
|
1778
|
+
Style/RegexpLiteral:
|
1779
|
+
Enabled: false
|
1780
|
+
|
1781
|
+
# Style::RescueModifierAlignment
|
1782
|
+
#
|
1783
|
+
# Checks whether the rescue and ensure keywords are aligned properly
|
1784
|
+
#
|
1785
|
+
# bad:
|
1786
|
+
# begin
|
1787
|
+
# something
|
1788
|
+
# rescue
|
1789
|
+
# puts 'error'
|
1790
|
+
# end
|
1791
|
+
#
|
1792
|
+
# good:
|
1793
|
+
#
|
1794
|
+
# begin
|
1795
|
+
# something
|
1796
|
+
# rescue
|
1797
|
+
# puts 'error'
|
1798
|
+
# end
|
1799
|
+
|
1800
|
+
Style/RescueModifierAlignment:
|
1801
|
+
Enabled: true
|
1802
|
+
|
1803
|
+
# Style::RescueModifier
|
1804
|
+
#
|
1805
|
+
# Checks for uses of rescue in its modifier form.
|
1806
|
+
Style/RescueModifier:
|
1807
|
+
Enabled: true
|
1808
|
+
|
1809
|
+
# Style::SafeNavigation
|
1810
|
+
#
|
1811
|
+
# Transforms usages of a method call safeguarded by a non `nil` check for the variable
|
1812
|
+
# whose method is being called to safe navigation (`&`).
|
1813
|
+
|
1814
|
+
Style/SafeNavigation:
|
1815
|
+
# Safe navigation may cause a statement to start returning `nil` in addition
|
1816
|
+
# to whatever it used to return.
|
1817
|
+
ConvertCodeThatCanStartToReturnNil: false
|
1818
|
+
|
1819
|
+
# Style::SelfAssignment
|
1820
|
+
#
|
1821
|
+
# Enforces the use of shorthand for self assignment.
|
1822
|
+
#
|
1823
|
+
# bad: x = x + 1
|
1824
|
+
#
|
1825
|
+
# good: x += 1
|
1826
|
+
Style/SelfAssignment:
|
1827
|
+
Enabled: true
|
1828
|
+
|
1829
|
+
# Style::Semicolon
|
1830
|
+
#
|
1831
|
+
# Checks for multiple expressions placed on the same line.
|
1832
|
+
# It also checks for lines terminated with a semicolon.
|
1833
|
+
# ( Do not include semicolons to terminate expressions )
|
1834
|
+
Style/Semicolon:
|
1835
|
+
Enabled: true
|
1836
|
+
|
1837
|
+
# Style::Send
|
1838
|
+
#
|
1839
|
+
# Checks for the usage of the send method.
|
1840
|
+
# ( Prefer object.public_send to send )
|
1841
|
+
Style/Send:
|
1842
|
+
Enabled: true
|
1843
|
+
|
1844
|
+
# Style::SignalException
|
1845
|
+
#
|
1846
|
+
# Checks for the uses of 'fail' and 'exception'.
|
1847
|
+
# ( Use 'fail' instead of 'raise' to signal exceptions. )
|
1848
|
+
# ( Use 'raise' instead of 'fail' to rethrow exceptions. )
|
1849
|
+
Style/SignalException:
|
1850
|
+
Enabled: true
|
1851
|
+
|
1852
|
+
# Style/SingleLineBlockParams
|
1853
|
+
#
|
1854
|
+
# Checks whether the block parameters of a single-line method accepting a block
|
1855
|
+
# match the names specified via configuration.
|
1856
|
+
Style/SingleLineBlockParams:
|
1857
|
+
Enabled: false
|
1858
|
+
|
1859
|
+
# Style/SingleLineMethods
|
1860
|
+
#
|
1861
|
+
# Checks for single-line method definitions.
|
1862
|
+
Style/SingleLineMethods:
|
1863
|
+
Enabled: true
|
1864
|
+
|
1865
|
+
# Style/SpaceAfterColon
|
1866
|
+
#
|
1867
|
+
# Checks for colon(:) not followed by some kind of space.
|
1868
|
+
Style/SpaceAfterColon:
|
1869
|
+
Enabled: true
|
1870
|
+
|
1871
|
+
# Style/SpaceAfterComma
|
1872
|
+
#
|
1873
|
+
# Checks for comma(,) not followed by some kind of space.
|
1874
|
+
Style/SpaceAfterComma:
|
1875
|
+
Enabled: true
|
1876
|
+
|
1877
|
+
# Style::SpaceAfterMethodName
|
1878
|
+
#
|
1879
|
+
# Checks for space between a method name and a left parenthesis in defs
|
1880
|
+
#
|
1881
|
+
# bad:
|
1882
|
+
#
|
1883
|
+
# def func (x) .. end
|
1884
|
+
#
|
1885
|
+
# good:
|
1886
|
+
#
|
1887
|
+
# def func(x) ... end
|
1888
|
+
#
|
1889
|
+
Style/SpaceAfterMethodName:
|
1890
|
+
Enabled: true
|
1891
|
+
|
1892
|
+
# Style::SpaceAfterNot
|
1893
|
+
#
|
1894
|
+
# Checks for space after '!'
|
1895
|
+
#
|
1896
|
+
# bad: ! something
|
1897
|
+
#
|
1898
|
+
# good: !something
|
1899
|
+
#
|
1900
|
+
Style/SpaceAfterNot:
|
1901
|
+
Enabled: true
|
1902
|
+
|
1903
|
+
# Style::SpaceAfterSemicolon
|
1904
|
+
#
|
1905
|
+
# Checks for semicolon not followed by somekind of space
|
1906
|
+
Style/SpaceAfterSemicolon:
|
1907
|
+
Enabled: true
|
1908
|
+
|
1909
|
+
# Style::SpaceAroundBlockParameters
|
1910
|
+
#
|
1911
|
+
# Checks that spacing inside and after block parameters pipes
|
1912
|
+
#
|
1913
|
+
# bad: {}.each { | x, y | puts x }
|
1914
|
+
#
|
1915
|
+
# good: {}.each { |x,y| puts x }
|
1916
|
+
|
1917
|
+
Style/SpaceAroundBlockParameters:
|
1918
|
+
Enabled: true
|
1919
|
+
|
1920
|
+
# Style::SpaceAroundEqualsInParameterDefault
|
1921
|
+
#
|
1922
|
+
# Checks that the equals signs in parameter default assignments have surrounding space
|
1923
|
+
|
1924
|
+
Style/SpaceAroundEqualsInParameterDefault:
|
1925
|
+
EnforcedStyle: space
|
1926
|
+
|
1927
|
+
# Style::SpaceAroundKeyword
|
1928
|
+
#
|
1929
|
+
# Checks the spacing around the keywords.
|
1930
|
+
#
|
1931
|
+
# bad:
|
1932
|
+
#
|
1933
|
+
# while(something)
|
1934
|
+
# end
|
1935
|
+
#
|
1936
|
+
# good:
|
1937
|
+
#
|
1938
|
+
# while (something)
|
1939
|
+
# end
|
1940
|
+
|
1941
|
+
Style/SpaceAroundKeyword:
|
1942
|
+
Enabled: true
|
1943
|
+
|
1944
|
+
# Style::SpaceAroundOperators
|
1945
|
+
#
|
1946
|
+
# Checks that operators have space around them,
|
1947
|
+
# except for ** which should not have surrounding space.
|
1948
|
+
#
|
1949
|
+
# bad: x+y
|
1950
|
+
#
|
1951
|
+
# good: x + y
|
1952
|
+
#
|
1953
|
+
Style/SpaceAroundOperators:
|
1954
|
+
Enabled: true
|
1955
|
+
|
1956
|
+
# Style::SpaceBeforeBlockBraces
|
1957
|
+
#
|
1958
|
+
# Checks that block braces have/dont have space before the opening brace depending on configuration
|
1959
|
+
Style/SpaceBeforeBlockBraces:
|
1960
|
+
Enabled: false
|
1961
|
+
|
1962
|
+
# Style::SpaceBeforeComma
|
1963
|
+
#
|
1964
|
+
# Checks for comma (,) preceded by space
|
1965
|
+
|
1966
|
+
Style/SpaceBeforeComma:
|
1967
|
+
Enabled: true
|
1968
|
+
|
1969
|
+
# Style::SpaceBeforeComment
|
1970
|
+
#
|
1971
|
+
# Checks for missing space between a token and comment on the same line.
|
1972
|
+
|
1973
|
+
Style/SpaceBeforeComment:
|
1974
|
+
Enabled: false
|
1975
|
+
|
1976
|
+
# Style::SpaceBeforeFirstArg
|
1977
|
+
#
|
1978
|
+
# Checks that exactly one space is used between a method name and
|
1979
|
+
# the first argument for method calls without parentheses
|
1980
|
+
#
|
1981
|
+
# bad:
|
1982
|
+
#
|
1983
|
+
# something x
|
1984
|
+
# something x, y
|
1985
|
+
|
1986
|
+
Style/SpaceBeforeFirstArg:
|
1987
|
+
AllowForAlignment: true
|
1988
|
+
|
1989
|
+
# Style::SpaceBeforeSemicolon
|
1990
|
+
#
|
1991
|
+
# Checks for semicolon (;) preceded by space.
|
1992
|
+
|
1993
|
+
Style/SpaceBeforeSemiColon:
|
1994
|
+
Enabled: true
|
1995
|
+
|
1996
|
+
# Style::SpaceInLambdaLiteral
|
1997
|
+
#
|
1998
|
+
# Checks for spaces between -> and opening parameter brace in lambda literals
|
1999
|
+
#
|
2000
|
+
# bad: a = ->(x,y) { x + y }
|
2001
|
+
#
|
2002
|
+
# good: a = -> (x,y) { x + y }
|
2003
|
+
|
2004
|
+
Style/SpaceInLambdaLiteral:
|
2005
|
+
EnforcedStyle: require_space
|
2006
|
+
|
2007
|
+
# Style::SpaceInsideArrayPercentLiteral
|
2008
|
+
#
|
2009
|
+
# Checks for unnecessary additional spaces inside array percent literals (i.e. %i/%w).
|
2010
|
+
#
|
2011
|
+
# bad: %w(foo bar baz)
|
2012
|
+
#
|
2013
|
+
# good: %w(foo bar baz)
|
2014
|
+
|
2015
|
+
Style/SpaceInsideArrayPercentLiteral:
|
2016
|
+
Enabled: true
|
2017
|
+
|
2018
|
+
# Style::SpaceInsideBlockBraces
|
2019
|
+
#
|
2020
|
+
# Checks that block braces have or don't have surrounding space inside them on configuration
|
2021
|
+
Style/SpaceInsideBlockBraces:
|
2022
|
+
Enabled: false
|
2023
|
+
|
2024
|
+
# Style::SpaceInsideBrackets
|
2025
|
+
#
|
2026
|
+
# Checks for spaces inside square brackets.
|
2027
|
+
Style/SpaceInsideBrackets:
|
2028
|
+
Enabled: false
|
2029
|
+
|
2030
|
+
# Style::SpaceInsideHashLiteralBraces
|
2031
|
+
#
|
2032
|
+
# Checks that braces used for hash literals have or
|
2033
|
+
# don't have surrounding space depending on configuration.
|
2034
|
+
Style/SpaceInsideHashLiteralBraces:
|
2035
|
+
Enabled: false
|
2036
|
+
|
2037
|
+
# Style::SpacsInsideParens
|
2038
|
+
#
|
2039
|
+
# Checks for spaces inside ordinary round parenthesis
|
2040
|
+
Style/SpaceInsideParens:
|
2041
|
+
Enabled: false
|
2042
|
+
|
2043
|
+
# Style::SpaceInsidePercentLiteralDelimeters
|
2044
|
+
#
|
2045
|
+
# Checks for unnecessary additional spaces inside the delimiters of %i,%w, %X literals.
|
2046
|
+
#
|
2047
|
+
# bad: %x( ls -l )
|
2048
|
+
|
2049
|
+
Style/SpaceInsidePercentLiteralDelimiters:
|
2050
|
+
Enabled: true
|
2051
|
+
|
2052
|
+
# Style::SpaceInsideRangeLiteral
|
2053
|
+
#
|
2054
|
+
# Checks for spaces inside range literals
|
2055
|
+
#
|
2056
|
+
# bad: 1 .. 3
|
2057
|
+
#
|
2058
|
+
# good: 1..3
|
2059
|
+
|
2060
|
+
Style/SpaceInsideRangeLiteral:
|
2061
|
+
Enabled: true
|
2062
|
+
|
2063
|
+
# Style::SpaceInsideStringInterpolation
|
2064
|
+
#
|
2065
|
+
# Checks for whitespace withing string interpolations.
|
2066
|
+
#
|
2067
|
+
# bad: "#{no_space}"
|
2068
|
+
#
|
2069
|
+
# good: "#{ space }"
|
2070
|
+
|
2071
|
+
Style/SpaceInsideStringInterpolation:
|
2072
|
+
EnforcedStyle: no_space
|
2073
|
+
|
2074
|
+
# Style::SpecialGlobalVars
|
2075
|
+
#
|
2076
|
+
# Looks for uses of Perl-style global variables.
|
2077
|
+
Style/SpecialGlobalVars:
|
2078
|
+
Enabled: false
|
2079
|
+
|
2080
|
+
# Style::StabbyLambdaParentheses
|
2081
|
+
#
|
2082
|
+
# Checks for parentheses around stabby lambda arguments.
|
2083
|
+
|
2084
|
+
Style/StabbyLambdaParentheses:
|
2085
|
+
Enabled: true
|
2086
|
+
|
2087
|
+
# Style::StringLiterals
|
2088
|
+
#
|
2089
|
+
# Checks if uses of quotes match the configured preference.
|
2090
|
+
Style/StringLiterals:
|
2091
|
+
EnforcedStyle: double_quotes
|
2092
|
+
|
2093
|
+
# Style::StringLiteralsInterpolation
|
2094
|
+
#
|
2095
|
+
# Checks if uses of quotes match the configured preference
|
2096
|
+
|
2097
|
+
Style/StringLiteralsInterpolation:
|
2098
|
+
Enabled: true
|
2099
|
+
|
2100
|
+
# Style::StructInheritance
|
2101
|
+
#
|
2102
|
+
# Checks for inheritance from Struct.new
|
2103
|
+
#
|
2104
|
+
# bad:
|
2105
|
+
# class Person < Struct.new(:first_name, :last_name)
|
2106
|
+
# end
|
2107
|
+
#
|
2108
|
+
# good:
|
2109
|
+
#
|
2110
|
+
# Person = Struct.new(:first_name, :last_name)
|
2111
|
+
Style/StructInheritance:
|
2112
|
+
Enabled: true
|
2113
|
+
|
2114
|
+
# Style::StringMethods
|
2115
|
+
#
|
2116
|
+
# Enforces the use of consistent method names from the string class
|
2117
|
+
Style/StringMethods:
|
2118
|
+
Enabled: true
|
2119
|
+
|
2120
|
+
# Style::SymbolArray
|
2121
|
+
#
|
2122
|
+
# Checks for array literals made up of symbols that are not using the %i() syntax
|
2123
|
+
# ( Use %i or %I for array of symbols )
|
2124
|
+
Style/SymbolArray:
|
2125
|
+
Enabled: true
|
2126
|
+
EnforcedStyle: brackets
|
2127
|
+
|
2128
|
+
# Style::SymbolLiteral
|
2129
|
+
#
|
2130
|
+
# Checks symbol literal syntax
|
2131
|
+
Style/SymbolLiteral:
|
2132
|
+
Enabled: true
|
2133
|
+
|
2134
|
+
# Style::SymbolProc
|
2135
|
+
#
|
2136
|
+
# Use Symbols as procs when possible
|
2137
|
+
#
|
2138
|
+
# bad: something.map { |s| s.upcase }
|
2139
|
+
#
|
2140
|
+
# good: something.map(&:upcase)
|
2141
|
+
Style/SymbolProc:
|
2142
|
+
Enabled: true
|
2143
|
+
|
2144
|
+
# Style::Tab
|
2145
|
+
#
|
2146
|
+
# Checks for tabs inside the source code
|
2147
|
+
Style/Tab:
|
2148
|
+
Enabled: false
|
2149
|
+
|
2150
|
+
# Style::TernaryCorrector
|
2151
|
+
#
|
2152
|
+
# Corrector to correct conditional assignment in ternanry conditions
|
2153
|
+
Style/TernaryCorrector:
|
2154
|
+
Enabled: false
|
2155
|
+
|
2156
|
+
# Style::TernaryParentheses
|
2157
|
+
#
|
2158
|
+
# Checks the presence if parentheses around ternary conditions.
|
2159
|
+
Style/TernaryParentheses:
|
2160
|
+
Enabled: false
|
2161
|
+
|
2162
|
+
# Style::TrailingBlankLines
|
2163
|
+
#
|
2164
|
+
# Checks for trailing blank lines
|
2165
|
+
Style/TrailingBlankLines:
|
2166
|
+
Enabled: true
|
2167
|
+
|
2168
|
+
# Style::TrailingCommaInArguments
|
2169
|
+
#
|
2170
|
+
# Checks for trailing commas in the argument.
|
2171
|
+
#
|
2172
|
+
# bad: method(1,2,)
|
2173
|
+
# good: method(1,2)
|
2174
|
+
#
|
2175
|
+
Style/TrailingCommaInArguments:
|
2176
|
+
Enabled: true
|
2177
|
+
|
2178
|
+
# Style::TrailingCommaInLiteral
|
2179
|
+
#
|
2180
|
+
# Checks for trailing commas in array and hash literals.
|
2181
|
+
#
|
2182
|
+
# bad: a = [1,2,]
|
2183
|
+
#
|
2184
|
+
# good: a = [1,2]
|
2185
|
+
#
|
2186
|
+
Style/TrailingCommaInLiteral:
|
2187
|
+
Enabled: true
|
2188
|
+
|
2189
|
+
# Style::TrailingWhitespace
|
2190
|
+
#
|
2191
|
+
# Checks for trailing whitespace in the source code
|
2192
|
+
Style/TrailingWhitespace:
|
2193
|
+
Enabled: false
|
2194
|
+
|
2195
|
+
# Style::TrailingUnderscoreVariable
|
2196
|
+
#
|
2197
|
+
# Checks for extra underscores in variable assignment
|
2198
|
+
Style/TrailingUnderscoreVariable:
|
2199
|
+
Enabled: true
|
2200
|
+
|
2201
|
+
# Style::TrivialAccessors
|
2202
|
+
#
|
2203
|
+
# Looks for trivial writer/reader methods,
|
2204
|
+
# that could have been created with attr_* family of functions automatically
|
2205
|
+
|
2206
|
+
Style/TrivialAccessors:
|
2207
|
+
Enabled: true
|
2208
|
+
|
2209
|
+
# Style::UnlessCorrector
|
2210
|
+
#
|
2211
|
+
# Corrector to correct conditional assignment in 'unless' statements
|
2212
|
+
Style/UnlessCorrector:
|
2213
|
+
Enabled: false
|
2214
|
+
|
2215
|
+
# Style::UnlessElse
|
2216
|
+
#
|
2217
|
+
# Looks for 'unless' expressions with 'else' clauses
|
2218
|
+
Style/UnlessElse:
|
2219
|
+
Enabled: true
|
2220
|
+
|
2221
|
+
# Style::UnneededCapitalW
|
2222
|
+
#
|
2223
|
+
# Checks for usage of the %W() syntax when %w() would do
|
2224
|
+
Style/UnneededCapitalW:
|
2225
|
+
Enabled: true
|
2226
|
+
|
2227
|
+
# Style::UnneededInterpolation
|
2228
|
+
#
|
2229
|
+
# Checks for strings that are just an interpolated expression.
|
2230
|
+
#
|
2231
|
+
# bad: "#{@var}"
|
2232
|
+
#
|
2233
|
+
# good: @var.to_s ( if @var is not a string )
|
2234
|
+
# @var ( if @var is string )
|
2235
|
+
Style/UnneededInterpolation:
|
2236
|
+
Enabled: true
|
2237
|
+
|
2238
|
+
# Style::UnneededPercentQ
|
2239
|
+
#
|
2240
|
+
# Checks for usage of the %q / %Q when '' or "" would do
|
2241
|
+
Style/UnneededPercentQ:
|
2242
|
+
Enabled: true
|
2243
|
+
|
2244
|
+
# Style::VariableInterpolation
|
2245
|
+
#
|
2246
|
+
# Checks for variable interpolation ( like "#@ivar" )
|
2247
|
+
# ( Replace the variable '%s' with "#{%s}" )
|
2248
|
+
Style/VariableInterpolation:
|
2249
|
+
Enabled: true
|
2250
|
+
|
2251
|
+
# Style::VariableName
|
2252
|
+
#
|
2253
|
+
# Makes sure that all the variables use the configured style : snake_case
|
2254
|
+
Style/VariableName:
|
2255
|
+
EnforcedStyle: snake_case
|
2256
|
+
|
2257
|
+
# Style::VariableNumber
|
2258
|
+
#
|
2259
|
+
# Makes sure that all numbered variables use the snake_case style, for their numbering
|
2260
|
+
Style/VariableNumber:
|
2261
|
+
EnforcedStyle: snake_case
|
2262
|
+
|
2263
|
+
# Style::WhenThen
|
2264
|
+
#
|
2265
|
+
# Checks for 'when;' uses in case expressions.
|
2266
|
+
# ( use `when x then` instead of `when x;` )
|
2267
|
+
Style/WhenThen:
|
2268
|
+
Enabled: true
|
2269
|
+
|
2270
|
+
# Style::WhileUntilDo
|
2271
|
+
#
|
2272
|
+
# Checks for uses of `do` with multi-line `while/until` statements
|
2273
|
+
Style/WhileUntilDo:
|
2274
|
+
Enabled: true
|
2275
|
+
|
2276
|
+
# Style::WhileUntilModifier
|
2277
|
+
#
|
2278
|
+
# Checks for while and until statements that would fit on one line if
|
2279
|
+
# written as a modifier while/until.
|
2280
|
+
Style/WhileUntilModifier:
|
2281
|
+
Enabled: true
|
2282
|
+
|
2283
|
+
# Style::WordArray
|
2284
|
+
#
|
2285
|
+
# Check for array literals made up of word-like strings,
|
2286
|
+
# that are not using the %w() syntax
|
2287
|
+
Style/WordArray:
|
2288
|
+
Enabled: true
|
2289
|
+
EnforcedStyle: brackets
|
2290
|
+
|
2291
|
+
# Style::ZeroLengthPredicate
|
2292
|
+
#
|
2293
|
+
# Checks for numeric comparison that can be replaced by a predicate method
|
2294
|
+
#
|
2295
|
+
# bad: x.length != 0 , x.size == 0 , x.length > 0
|
2296
|
+
#
|
2297
|
+
# good: x.empty? , !x.empty?
|
2298
|
+
Style/ZeroLengthPredicate:
|
2299
|
+
Enabled: true
|