forked from discourse/onebox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.rubocop.yml
476 lines (365 loc) · 9.66 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
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
AllCops:
# Include gemspec and Rakefile
Includes:
- '**/*.gemspec'
- '**/Rakefile'
Excludes: []
# Use UTF-8 as the source file encoding.
Encoding:
Enabled: true
# Limit lines to 79 characters.
LineLength:
Enabled: true
Max: 180
# Avoid methods longer than 10 lines of code
MethodLength:
Enabled: true
CountComments: false # count full line comments?
Max: 10
# No hard tabs.
Tab:
Enabled: true
# Avoid trailing whitespace.
TrailingWhitespace:
Enabled: true
# Indent when as deep as case.
CaseIndentation:
Enabled: true
# Use empty lines between defs.
EmptyLineBetweenDefs:
Enabled: true
# Don't use several empty lines in a row.
EmptyLines:
Enabled: true
# Use spaces around operators.
SpaceAroundOperators:
Enabled: true
# Use spaces around { and before }.
SpaceAroundBraces:
Enabled: true
# No spaces after ( or before ).
SpaceInsideParens:
Enabled: true
# No spaces after [ or before ].
SpaceInsideBrackets:
Enabled: true
# Use spaces after commas.
SpaceAfterComma:
Enabled: true
# Use spaces after semicolons.
SpaceAfterSemicolon:
Enabled: true
# Use spaces after colons.
SpaceAfterColon:
Enabled: true
# Use spaces after if/elsif/unless/while/until/case/when.
SpaceAfterControlKeyword:
Enabled: true
# Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax
# { :a => 1, :b => 2 }.
HashSyntax:
Enabled: true
# Use Unix-style line endings.
EndOfLine:
Enabled: true
# Add underscores to large numeric literals to improve their readability.
NumericLiterals:
Enabled: true
# Align the parameters of a method call if they span more than one line.
AlignParameters:
Enabled: true
# Use def with parentheses when there are arguments.
DefWithParentheses:
Enabled: true
# Omit the parentheses when the method doesn't accept any arguments.
DefWithoutParentheses:
Enabled: true
# Never use if x; .... Use the ternary operator instead.
IfWithSemicolon:
Enabled: true
# Never use then for multi-line if/unless.
MultilineIfThen:
Enabled: true
# Favor the ternary operator(?:) over if/then/else/end constructs.
OneLineConditional:
Enabled: true
# Avoid using {...} for multi-line blocks (multiline chaining is always ugly).
# Prefer {...} over do...end for single-line blocks.
Blocks:
Enabled: true
# Avoid parameter lists longer than three or four parameters.
ParameterLists:
Enabled: true
Max: 5
CountKeywordArgs: true
# Prefer ' strings when you don't need string interpolation or special symbols.
StringLiterals:
Enabled: false
# Avoid multi-line ?: (the ternary operator); use if/unless instead.
MultilineTernaryOperator:
Enabled: true
# Use one expression per branch in a ternary operator.
NestedTernaryOperator:
Enabled: true
# Never use unless with else. Rewrite these with the positive case first.
UnlessElse:
Enabled: true
# Use &&/|| instead of and/or.
AndOr:
Enabled: true
# Use when x then ... for one-line cases.
WhenThen:
Enabled: true
# Favor modifier if/unless usage when you have a single-line body.
IfUnlessModifier:
Enabled: true
# Favor modifier while/until usage when you have a single-line body.
WhileUntilModifier:
Enabled: true
# Favor unless over if for negative conditions (or control flow or).
FavorUnlessOverNegatedIf:
Enabled: true
# Favor until over while for negative conditions.
FavorUntilOverNegatedWhile:
Enabled: true
# Use spaces around the = operator when assigning default values in def params.
SpaceAroundEqualsInParameterDefault:
Enabled: false
# Use the new lambda literal syntax for single-line blocks.
Lambda:
Enabled: true
# Use proc instead of Proc.new.
Proc:
Enabled: true
# Don't use parentheses around the condition of an if/unless/while.
ParenthesesAroundCondition:
Enabled: true
AllowSafeAssignment: true
# Use snake_case for symbols, methods and variables.
MethodAndVariableSnakeCase:
Enabled: true
# Use CamelCase for classes and modules.
ClassAndModuleCamelCase:
Enabled: true
# Preferred collection methods.
CollectionMethods:
Enabled: true
PreferredMethods:
collect: 'map'
inject: 'reduce'
detect: 'find'
find_all: 'select'
# Prefer each over for.
AvoidFor:
Enabled: true
# Avoid Perl-style global variables.
AvoidPerlisms:
Enabled: true
# Avoid Perl-style regex back references.
AvoidPerlBackrefs:
Enabled: true
# Avoid the use of class variables.
AvoidClassVars:
Enabled: true
# Don't interpolate global, instance and class variables directly in strings.
VariableInterpolation:
Enabled: true
# Don't use semicolons to terminate expressions.
Semicolon:
Enabled: true
# For example; def area(height, width); height * width end
AllowAfterParameterListInOneLineMethods: false
# For example; def area(height, width) height * width; end
AllowBeforeEndInOneLineMethods: true
# Use sprintf instead of String#%.
FavorSprintf:
Enabled: true
# Use Array#join instead of Array#*.
FavorJoin:
Enabled: true
# Use alias_method instead of alias.
Alias:
Enabled: true
# Use ! instead of not.
Not:
Enabled: true
# Avoid using rescue in its modifier form.
RescueModifier:
Enabled: true
# Never use return in an ensure block.
EnsureReturn:
Enabled: true
# Don't suppress exception.
HandleExceptions:
Enabled: true
# Use only ascii symbols in identifiers.
AsciiIdentifiers:
Enabled: true
# Use only ascii symbols in comments.
AsciiComments:
Enabled: true
# Do not use block comments.
BlockComments:
Enabled: true
# Avoid rescuing the Exception class.
RescueException:
Enabled: true
# Prefer literals to Array.new/Hash.new/String.new.
EmptyLiteral:
Enabled: true
# When defining binary operators, name the argument other.
OpMethod:
Enabled: true
# Name reduce arguments |a, e| (accumulator, element)
ReduceArguments:
Enabled: true
# Use %r for regular expressions matching more than `MaxSlashes` '/'
# characters.
# Use %r only for regular expressions matching more than `MaxSlashes` '/'
# character.
RegexpLiteral:
Enabled: true
MaxSlashes: 1
# Use self when defining module/class methods.
ClassMethods:
Enabled: true
# Avoid single-line methods.
SingleLineMethods:
Enabled: true
AllowIfMethodIsEmpty: true
# Use %w or %W for arrays of words.
WordArray:
Enabled: true
# Use spaces inside hash literal braces - or don't.
SpaceInsideHashLiteralBraces:
Enabled: true
EnforcedStyleIsWithSpaces: true
# Avoid the use of line continuation (/).
LineContinuation:
Enabled: true
# Prefer attr_* methods to trivial readers/writers.
# TrivialAccessors doesn't require exact name matches and doesn't allow
# predicated methods by default.
TrivialAccessors:
Enabled: true
ExactNameMatch: true # this is not the best way, but currently rubocop does not support something better https://github.com/bbatsov/rubocop/issues/421
AllowPredicates: false
# Comments should start with a space.
LeadingCommentSpace:
Enabled: true
# Do not use :: for method call.
ColonMethodCall:
Enabled: true
# Do not introduce global variables.
AvoidGlobalVars:
Enabled: true
# The use of eval represents a serious security risk.
Eval:
Enabled: true
# Symbol literals should use snake_case.
SymbolName:
Enabled: true
AllowCamelCase: false
# Constants should use SCREAMING_SNAKE_CASE.
ConstantName:
Enabled: true
# Indent private/protected as deep as defs and keep blank lines around them.
AccessControl:
Enabled: true
# Use Kernel#loop with break rather than begin/end/until or begin/end/while for
# post-loop tests.
Loop:
Enabled: true
# Avoid excessive block nesting
BlockNesting:
Enabled: true
Max: 3
# Avoid explicit use of the case equality operator(===).
CaseEquality:
Enabled: true
# Document classes and non-namespace modules.
Documentation:
Enabled: false
# Do not use parentheses for method calls with no arguments.
MethodCallParentheses:
Enabled: true
# Checks for redundant do after while or until.
WhileUntilDo:
Enabled: true
# Checks for uses of character literals.
CharacterLiteral:
Enabled: true
# Avoid the use of BEGIN blocks.
BeginBlock:
Enabled: true
# Avoid the use of END blocks.
EndBlock:
Enabled: true
# Don't use return where it's not required.
RedundantReturn:
Enabled: true
# Don't use begin blocks when they are not needed.
RedundantBegin:
Enabled: true
# Don't use self where it's not needed.
RedundantSelf:
Enabled: true
# Checks the position of the dot in multi-line method calls.
DotPosition:
Enabled: true
Style: 'leading'
# Checks for uses of Module#attr.
Attr:
Enabled: true
#################### Lint ################################
# Don't use assignment in conditions.
AssignmentInCondition:
Enabled: true
AllowSafeAssignment: true
# Align ends correctly.
EndAlignment:
Enabled: true
# Align block ends correctly.
BlockAlignment:
Enabled: true
# Possible use of operator/literal/variable in void context.
Void:
Enabled: true
# Unreachable code.
UnreachableCode:
Enabled: true
# Unused local variable.
UnusedLocalVariable:
Enabled: true
# Do not use the same name as outer local variable
# for block arguments or block local variables.
ShadowingOuterLocalVariable:
Enabled: true
# END blocks should not be placed inside method definitions.
EndInMethod:
Enabled: true
# Checks of literals used in conditions.
LiteralInCondition:
Enabled: true
# Checks for empty ensure block.
EmptyEnsure:
Enabled: true
# Checks formatting of special comments (TODO, FIXME, OPTIMIZE, HACK, REVIEW).
CommentAnnotation:
Enabled: true
Keywords:
- TODO
- FIXME
- OPTIMIZE
- HACK
- REVIEW
# Checks for useless assignment to a local variable.
UselessAssignment:
Enabled: true
# Checks for comparison of something with itself.
UselessComparison:
Enabled: true
##################### Rails ##################################
# Use sexy validations.
Validation:
Enabled: true