-
Notifications
You must be signed in to change notification settings - Fork 185
/
.rubocop.yml
438 lines (360 loc) · 12.1 KB
/
.rubocop.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
require:
- ./tool/rubocop-truffleruby/cop/replace_with_primitive_nil.rb
- ./tool/rubocop-truffleruby/cop/replace_with_primitive_class.rb
- ./tool/rubocop-truffleruby/cop/replace_with_primitive_equal.rb
- ./tool/rubocop-truffleruby/cop/replace_with_primitive_is_a.rb
- ./tool/rubocop-truffleruby/cop/replace_with_primitive_true_and_false_predicates.rb
AllCops:
TargetRubyVersion: 3.2
DisabledByDefault: true
DisplayCopNames: true
ExtraDetails: true
Exclude:
- 'lib/truffle/date/format.rb' # crashes Rubocop in VariableForce
- 'lib/truffle/date/delta/parser.rb' # generated code
- 'lib/truffle/pathname.rb' # from upstream and should be upstreamed
- 'lib/truffle/socket/mri.rb' # taken from MRI
- 'lib/truffle/ffi/**/*.rb' # taken from FFI gem
- 'src/main/ruby/truffleruby/core/truffle/ffi/pointer_extra.rb' # taken from FFI gem
- 'src/test-internal/ruby/types.rb' # deliberately strange code for debugging purposes
- 'src/tck/ruby/lexical-context.rb' # deliberately strange code for debugging purposes
# Type 'Layout' (166):
# Supports --auto-correct
Layout/TrailingEmptyLines:
Description: Checks trailing blank lines and final newline.
StyleGuide: "#newline-eof"
Enabled: true
EnforcedStyle: final_newline
SupportedStyles:
- final_newline
- final_blank_line
# Supports --auto-correct
Layout/TrailingWhitespace:
Description: Avoid trailing whitespace.
StyleGuide: "#no-trailing-whitespace"
Enabled: true
# Supports --auto-correct
Style/Lambda:
Description: Enforce -> {} style lambdas instead of Kernel#lamba.
EnforcedStyle: literal
# Department 'Lint' (58):
Lint/AmbiguousOperator:
Description: Checks for ambiguous operators in the first argument of a method invocation
without parentheses.
StyleGuide: "#method-invocation-parens"
Enabled: true
Lint/AmbiguousRegexpLiteral:
Description: Checks for ambiguous regexp literals in the first argument of a method
invocation without parentheses.
Enabled: true
# Supports --auto-correct
Layout/BlockAlignment:
Description: Align block ends correctly.
Enabled: true
EnforcedStyleAlignWith: either
SupportedStylesAlignWith:
- either
- start_of_block
- start_of_line
Lint/CircularArgumentReference:
Description: Default values in optional keyword arguments and optional ordinal arguments
should not refer back to the name of the argument.
Enabled: true
Layout/ConditionPosition:
Description: Checks for condition placed in a confusing position relative to the keyword.
StyleGuide: "#same-line-condition"
Enabled: true
# Supports --auto-correct
Lint/Debugger:
Description: Check for debugger calls.
Enabled: true
# Supports --auto-correct
Layout/DefEndAlignment:
Description: Align ends corresponding to defs correctly.
Enabled: true
EnforcedStyleAlignWith: start_of_line
SupportedStylesAlignWith:
- start_of_line
- def
AutoCorrect: false
# Supports --auto-correct
Lint/DeprecatedClassMethods:
Description: Check for deprecated class method calls.
Enabled: true
Lint/DuplicateCaseCondition:
Description: Do not repeat values in case conditionals.
Enabled: true
Lint/DuplicateMethods:
Description: Check for duplicate method definitions.
Enabled: true
Lint/DuplicateHashKey:
Description: Check for duplicate keys in hash literals.
Enabled: true
Lint/EachWithObjectArgument:
Description: Check for immutable argument given to each_with_object.
Enabled: true
Lint/ElseLayout:
Description: Check for odd code arrangement in an else block.
Enabled: true
Lint/EmptyEnsure:
Description: Checks for empty ensure block.
Enabled: true
Lint/EmptyExpression:
Description: Checks for empty expressions.
Enabled: true
# Supports --auto-correct
Lint/EmptyInterpolation:
Description: Checks for empty string interpolation.
Enabled: true
Lint/EmptyWhen:
Description: Checks for `when` branches with empty bodies.
# disabled, used quite often
Enabled: false
# Supports --auto-correct
Layout/EndAlignment:
Description: Align ends correctly.
Enabled: true
EnforcedStyleAlignWith: keyword
SupportedStylesAlignWith:
- keyword
- variable
- start_of_line
AutoCorrect: false
Style/EndBlock:
Description: END blocks should not be placed inside method definitions.
Enabled: true
Lint/EnsureReturn:
Description: Do not use return in an ensure block.
StyleGuide: "#no-return-ensure"
Enabled: true
Lint/FloatOutOfRange:
Description: Catches floating-point literals too large or small for Ruby to represent.
Enabled: true
Lint/FormatParameterMismatch:
Description: The number of parameters to format/sprint must match the fields.
Enabled: true
Lint/SuppressedException:
Description: Don't suppress exception.
StyleGuide: "#dont-hide-exceptions"
Enabled: true
Lint/ImplicitStringConcatenation:
Description: Checks for adjacent string literals on the same line, which could better
be represented as a single string literal.
Enabled: true
Lint/IneffectiveAccessModifier:
Description: Checks for attempts to use `private` or `protected` to set the visibility
of a class method, which does not work.
Enabled: true
# Supports --auto-correct
Lint/InheritException:
Description: Avoid inheriting from the `Exception` class.
Enabled: true
EnforcedStyle: runtime_error
SupportedStyles:
- runtime_error
- standard_error
Exclude:
- src/main/ruby/truffleruby/core/exception.rb
Lint/LiteralAsCondition:
Description: Checks of literals used in conditions.
# disabled, it prevents `while true`, which is useful
Enabled: false
# Supports --auto-correct
Lint/LiteralInInterpolation:
Description: Checks for literals used in interpolation.
Enabled: true
Lint/Loop:
Description: Use Kernel#loop with break rather than begin/end/until or begin/end/while
for post-loop tests.
StyleGuide: "#loop-with-break"
# disabled, begin/end/until or begin/end/while seems better alternative to loop and a break
Enabled: false
# Supports --auto-correct
Lint/MultipleComparison:
Description: Use `&&` operator to compare multiple value.
Enabled: true
Lint/NestedMethodDefinition:
Description: Do not use nested method definitions.
StyleGuide: "#no-nested-methods"
Enabled: true
Lint/NextWithoutAccumulator:
Description: Do not omit the accumulator when calling `next` in a `reduce`/`inject`
block.
Enabled: true
Lint/NonLocalExitFromIterator:
Description: Do not use return in iterator to cause non-local exit.
Enabled: true
Lint/ParenthesesAsGroupedExpression:
Description: Checks for method calls with a space before the opening parenthesis.
StyleGuide: "#parens-no-spaces"
Enabled: true
# Supports --auto-correct
Lint/PercentStringArray:
Description: Checks for unwanted commas and quotes in %w/%W literals.
Enabled: true
# Supports --auto-correct
Lint/PercentSymbolArray:
Description: Checks for unwanted commas and colons in %i/%I literals.
Enabled: true
Lint/RandOne:
Description: Checks for `rand(1)` calls. Such calls always return `0` and most likely
a mistake.
Enabled: true
Lint/RequireParentheses:
Description: Use parentheses in the method call to avoid confusion about precedence.
Enabled: true
Lint/RescueException:
Description: Avoid rescuing the Exception class.
StyleGuide: "#no-blind-rescues"
Enabled: true
# Supports --auto-correct
Lint/SafeNavigationChain:
Description: Do not chain ordinary method call after safe navigation operator.
Enabled: true
Lint/ShadowedException:
Description: Avoid rescuing a higher level exception before a lower level exception.
Enabled: true
Lint/ShadowingOuterLocalVariable:
Description: Do not use the same name as outer local variable for block arguments
or block local variables.
Enabled: true
# Supports --auto-correct
Lint/RedundantStringCoercion:
Description: Checks for Object#to_s usage in string interpolation.
StyleGuide: "#no-to-s"
Enabled: true
Lint/UnderscorePrefixedVariableName:
Description: Do not use prefix `_` for a variable that is used.
Enabled: true
# Supports --auto-correct
Lint/UnifiedInteger:
Description: Use Integer instead of Fixnum or Bignum
# disabled, not a 2.4 yet
Enabled: false
# Supports --auto-correct
Lint/RedundantCopDisableDirective:
Description: 'Checks for rubocop:disable comments that can be removed. Note: this
cop is not disabled when disabling all cops. It must be explicitly disabled.'
Enabled: true
# Supports --auto-correct
Lint/RedundantSplatExpansion:
Description: Checks for splat unnecessarily being called on literals
Enabled: true
Lint/UnreachableCode:
Description: Unreachable code.
Enabled: true
# Supports --auto-correct
Lint/UnusedBlockArgument:
Description: Checks for unused block arguments.
StyleGuide: "#underscore-unused-vars"
Enabled: true
IgnoreEmptyBlocks: true
AllowUnusedKeywordArguments: false
# Supports --auto-correct
Lint/UnusedMethodArgument:
Description: Checks for unused method arguments.
StyleGuide: "#underscore-unused-vars"
# disabled, used often in primitives
Enabled: false
AllowUnusedKeywordArguments: false
IgnoreEmptyMethods: true
Lint/UselessAccessModifier:
Description: Checks for useless access modifiers.
Enabled: true
ContextCreatingMethods: []
MethodCreatingMethods: []
Lint/UselessAssignment:
Description: Checks for useless assignment to a local variable.
StyleGuide: "#underscore-unused-vars"
Enabled: true
Lint/BinaryOperatorWithIdenticalOperands:
Description: Checks for comparison of something with itself.
Enabled: true
Lint/UselessElseWithoutRescue:
Description: Checks for useless `else` in `begin..end` without `rescue`.
Enabled: true
Lint/UselessSetterCall:
Description: Checks for useless setter call to a local variable.
Enabled: true
Lint/Void:
Description: Possible use of operator/literal/variable in void context.
Enabled: false # Triggers for any return value for #initialize and #[]=
#################### Layout ###########################
# Supports --auto-correct
Style/BlockDelimiters:
Enabled: true
Layout/CaseIndentation:
Enabled: true
EnforcedStyle: 'end'
Layout/IndentationConsistency:
Enabled: true
Layout/IndentationWidth:
Enabled: true
# Supports --auto-correct
Style/RaiseArgs:
Description: 'Checks the arguments passed to raise/fail.'
StyleGuide: '#exception-class-messages'
Enabled: true
Style/RedundantReturn:
Enabled: true
# Supports --auto-correct
Style/StringLiterals:
Description: Checks if uses of quotes match the configured preference.
StyleGuide: "#consistent-string-literals"
Details: Use `rubocop --only Style/StringLiterals -a` to fix.
Enabled: true
EnforcedStyle: single_quotes
SupportedStyles:
- single_quotes
- double_quotes
ConsistentQuotesInMultiline: false
# Supports --auto-correct
Style/UnlessElse:
Description: Checks for unless expressions with else clauses.
Enabled: true
# Supports --auto-correct
Layout/SpaceBeforeBlockBraces:
Enabled: true
EnforcedStyle: space
EnforcedStyleForEmptyBraces: space
# Supports --auto-correct
Layout/SpaceInsideBlockBraces:
Enabled: true
EnforcedStyle: space
EnforcedStyleForEmptyBraces: space
# Supports --auto-correct
Layout/SpaceAroundEqualsInParameterDefault:
Description: Checks that the equals signs in parameter default assignments have or don't have surrounding space depending on configuration.
Enabled: true
Style/FrozenStringLiteralComment:
Enabled: true
# Supports --auto-correct
TruffleRuby/ReplaceWithPrimitiveNil:
Enabled: true
Include: # inspect *only* these files
- lib/truffle/**/*.rb
- src/main/ruby/**/*.rb
# Supports --auto-correct
TruffleRuby/ReplaceWithPrimitiveClass:
Enabled: true
Include: # inspect *only* these files
- lib/truffle/**/*.rb
- src/main/ruby/**/*.rb
# Supports --auto-correct
TruffleRuby/ReplaceWithPrimitiveEqual:
Enabled: true
Include: # inspect *only* these files
- lib/truffle/**/*.rb
- src/main/ruby/**/*.rb
# Supports --auto-correct
TruffleRuby/ReplaceWithPrimitiveIsA:
Enabled: true
Include: # inspect *only* these files
- lib/truffle/**/*.rb
- src/main/ruby/**/*.rb
# Supports --auto-correct
TruffleRuby/ReplaceWithPrimitiveTrueAndFalsePredicates:
Enabled: true
Include: # inspect *only* these files
- lib/truffle/**/*.rb
- src/main/ruby/**/*.rb