activerecord-spatial 1.0.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1670 -0
  3. data/Gemfile +12 -13
  4. data/Guardfile +7 -10
  5. data/MIT-LICENSE +1 -1
  6. data/README.rdoc +8 -19
  7. data/Rakefile +2 -1
  8. data/activerecord-spatial.gemspec +12 -13
  9. data/lib/activerecord-spatial/active_record/connection_adapters/postgresql/adapter_extensions/active_record.rb +46 -0
  10. data/lib/activerecord-spatial/active_record/connection_adapters/postgresql/adapter_extensions.rb +7 -38
  11. data/lib/activerecord-spatial/active_record/connection_adapters/postgresql/postgis.rb +6 -7
  12. data/lib/activerecord-spatial/active_record/connection_adapters/postgresql/unknown_srid.rb +4 -5
  13. data/lib/activerecord-spatial/active_record/models/geography_column.rb +1 -2
  14. data/lib/activerecord-spatial/active_record/models/geometry_column.rb +1 -2
  15. data/lib/activerecord-spatial/active_record/models/spatial_column.rb +1 -2
  16. data/lib/activerecord-spatial/active_record/models/spatial_ref_sys.rb +5 -6
  17. data/lib/activerecord-spatial/active_record.rb +0 -1
  18. data/lib/activerecord-spatial/associations/active_record.rb +62 -120
  19. data/lib/activerecord-spatial/associations/base.rb +26 -75
  20. data/lib/activerecord-spatial/associations/preloader/spatial_association.rb +57 -0
  21. data/lib/activerecord-spatial/associations/reflection/spatial_reflection.rb +41 -0
  22. data/lib/activerecord-spatial/associations.rb +26 -4
  23. data/lib/activerecord-spatial/spatial_columns.rb +85 -94
  24. data/lib/activerecord-spatial/spatial_function.rb +62 -51
  25. data/lib/activerecord-spatial/spatial_scope_constants/postgis_2_0.rb +48 -0
  26. data/lib/activerecord-spatial/spatial_scope_constants/postgis_2_2.rb +46 -0
  27. data/lib/activerecord-spatial/spatial_scope_constants/postgis_legacy.rb +30 -0
  28. data/lib/activerecord-spatial/spatial_scope_constants.rb +10 -61
  29. data/lib/activerecord-spatial/spatial_scopes.rb +47 -49
  30. data/lib/activerecord-spatial/version.rb +1 -2
  31. data/lib/activerecord-spatial.rb +2 -6
  32. data/lib/tasks/test.rake +21 -19
  33. data/test/.rubocop.yml +35 -0
  34. data/test/accessors_geographies_tests.rb +19 -19
  35. data/test/accessors_geometries_tests.rb +19 -19
  36. data/test/adapter_tests.rb +1 -2
  37. data/test/associations_tests.rb +181 -203
  38. data/test/geography_column_tests.rb +2 -3
  39. data/test/geometry_column_tests.rb +1 -2
  40. data/test/models/bar.rb +2 -3
  41. data/test/models/blort.rb +1 -2
  42. data/test/models/foo.rb +2 -3
  43. data/test/models/foo3d.rb +2 -3
  44. data/test/models/foo_geography.rb +2 -3
  45. data/test/models/zortable.rb +2 -3
  46. data/test/spatial_function_tests.rb +12 -17
  47. data/test/spatial_scopes_geographies_tests.rb +17 -20
  48. data/test/spatial_scopes_tests.rb +84 -75
  49. data/test/test_helper.rb +66 -79
  50. metadata +16 -14
  51. data/lib/activerecord-spatial/associations/active_record_3.rb +0 -123
data/.rubocop.yml ADDED
@@ -0,0 +1,1670 @@
1
+ # These are all the cops that are enabled in the default configuration.
2
+
3
+ AllCops:
4
+ TargetRubyVersion: 2.1
5
+
6
+ Exclude:
7
+ - 'node_modules/**/*'
8
+ - 'bower_components/**/*'
9
+
10
+ Style/AccessModifierIndentation:
11
+ Description: Check indentation of private/protected visibility modifiers.
12
+ StyleGuide: '#indent-public-private-protected'
13
+ Enabled: true
14
+
15
+ Style/AccessorMethodName:
16
+ Description: Check the naming of accessor methods for get_/set_.
17
+ StyleGuide: '#accessor_mutator_method_names'
18
+ Enabled: true
19
+
20
+ Style/Alias:
21
+ Description: 'Use alias instead of alias_method.'
22
+ StyleGuide: '#alias-method'
23
+ Enabled: true
24
+
25
+ Style/AlignArray:
26
+ Description: >-
27
+ Align the elements of an array literal if they span more than
28
+ one line.
29
+ StyleGuide: '#align-multiline-arrays'
30
+ Enabled: true
31
+
32
+ Style/AlignHash:
33
+ Description: >-
34
+ Align the elements of a hash literal if they span more than
35
+ one line.
36
+ Enabled: true
37
+
38
+ Style/AlignParameters:
39
+ Description: >-
40
+ Align the parameters of a method call if they span more
41
+ than one line.
42
+ StyleGuide: '#no-double-indent'
43
+ EnforcedStyle: with_fixed_indentation
44
+ Enabled: true
45
+
46
+ Style/AndOr:
47
+ Description: 'Use &&/|| instead of and/or.'
48
+ StyleGuide: '#no-and-or-or'
49
+ Enabled: true
50
+
51
+ Style/ArrayJoin:
52
+ Description: 'Use Array#join instead of Array#*.'
53
+ StyleGuide: '#array-join'
54
+ Enabled: true
55
+
56
+ Style/AsciiComments:
57
+ Description: 'Use only ascii symbols in comments.'
58
+ StyleGuide: '#english-comments'
59
+ Enabled: true
60
+
61
+ Style/AsciiIdentifiers:
62
+ Description: 'Use only ascii symbols in identifiers.'
63
+ StyleGuide: '#english-identifiers'
64
+ Enabled: true
65
+
66
+ Style/Attr:
67
+ Description: 'Checks for uses of Module#attr.'
68
+ StyleGuide: '#attr'
69
+ Enabled: true
70
+
71
+ Style/BeginBlock:
72
+ Description: 'Avoid the use of BEGIN blocks.'
73
+ StyleGuide: '#no-BEGIN-blocks'
74
+ Enabled: true
75
+
76
+ Style/BarePercentLiterals:
77
+ Description: 'Checks if usage of %() or %Q() matches configuration.'
78
+ StyleGuide: '#percent-q-shorthand'
79
+ Enabled: true
80
+
81
+ Style/BlockComments:
82
+ Description: 'Do not use block comments.'
83
+ StyleGuide: '#no-block-comments'
84
+ Enabled: true
85
+
86
+ Style/BlockEndNewline:
87
+ Description: 'Put end statement of multiline block on its own line.'
88
+ Enabled: true
89
+
90
+ Style/BlockDelimiters:
91
+ Description: >-
92
+ Avoid using {...} for multi-line blocks (multiline chaining is
93
+ always ugly).
94
+ Prefer {...} over do...end for single-line blocks.
95
+ StyleGuide: '#single-line-blocks'
96
+ Enabled: true
97
+ EnforcedStyle: braces_for_chaining
98
+
99
+ Style/BracesAroundHashParameters:
100
+ Description: 'Enforce braces style around hash parameters.'
101
+ Enabled: true
102
+
103
+ Style/CaseEquality:
104
+ Description: 'Avoid explicit use of the case equality operator(===).'
105
+ StyleGuide: '#no-case-equality'
106
+ Enabled: true
107
+
108
+ Style/CaseIndentation:
109
+ Description: 'Indentation of when in a case/when/[else/]end.'
110
+ StyleGuide: '#indent-when-to-case'
111
+ Enabled: true
112
+ EnforcedStyle: end
113
+ IndentOneStep: true
114
+
115
+ Style/CharacterLiteral:
116
+ Description: 'Checks for uses of character literals.'
117
+ StyleGuide: '#no-character-literals'
118
+ Enabled: true
119
+
120
+ Style/ClassAndModuleCamelCase:
121
+ Description: 'Use CamelCase for classes and modules.'
122
+ StyleGuide: '#camelcase-classes'
123
+ Enabled: true
124
+
125
+ Style/ClassAndModuleChildren:
126
+ Description: 'Checks style of children classes and modules.'
127
+ Enabled: false
128
+
129
+ Style/ClassCheck:
130
+ Description: 'Enforces consistent use of `Object#is_a?` or `Object#kind_of?`.'
131
+ Enabled: true
132
+
133
+ Style/ClassMethods:
134
+ Description: 'Use self when defining module/class methods.'
135
+ StyleGuide: '#def-self-class-methods'
136
+ Enabled: true
137
+
138
+ Style/ClassVars:
139
+ Description: 'Avoid the use of class variables.'
140
+ StyleGuide: '#no-class-vars'
141
+ Enabled: true
142
+
143
+ Style/ClosingParenthesisIndentation:
144
+ Description: 'Checks the indentation of hanging closing parentheses.'
145
+ Enabled: true
146
+
147
+ Style/ColonMethodCall:
148
+ Description: 'Do not use :: for method call.'
149
+ StyleGuide: '#double-colons'
150
+ Enabled: true
151
+
152
+ Style/CommandLiteral:
153
+ Description: 'Use `` or %x around command literals.'
154
+ StyleGuide: '#percent-x'
155
+ Enabled: true
156
+
157
+ Style/CommentAnnotation:
158
+ Description: >-
159
+ Checks formatting of special comments
160
+ (TODO, FIXME, OPTIMIZE, HACK, REVIEW).
161
+ StyleGuide: '#annotate-keywords'
162
+ Enabled: false
163
+
164
+ Style/CommentIndentation:
165
+ Description: 'Indentation of comments.'
166
+ Enabled: true
167
+
168
+ Style/ConditionalAssignment:
169
+ Description: >-
170
+ Use the return value of `if` and `case` statements for
171
+ assignment to a variable and variable comparison instead
172
+ of assigning that variable inside of each branch.
173
+ Enabled: true
174
+
175
+ Style/ConstantName:
176
+ Description: 'Constants should use SCREAMING_SNAKE_CASE.'
177
+ StyleGuide: '#screaming-snake-case'
178
+ Enabled: true
179
+
180
+ Style/DefWithParentheses:
181
+ Description: 'Use def with parentheses when there are arguments.'
182
+ StyleGuide: '#method-parens'
183
+ Enabled: true
184
+
185
+ Style/Documentation:
186
+ Description: 'Document classes and non-namespace modules.'
187
+ Enabled: false
188
+ Exclude:
189
+ - 'spec/**/*'
190
+ - 'test/**/*'
191
+
192
+ Style/DotPosition:
193
+ Description: 'Checks the position of the dot in multi-line method calls.'
194
+ StyleGuide: '#consistent-multi-line-chains'
195
+ Enabled: false
196
+
197
+ Style/DoubleNegation:
198
+ Description: 'Checks for uses of double negation (!!).'
199
+ StyleGuide: '#no-bang-bang'
200
+ Enabled: false
201
+
202
+ Style/EachForSimpleLoop:
203
+ Description: >-
204
+ Use `Integer#times` for a simple loop which iterates a fixed
205
+ number of times.
206
+ Enabled: true
207
+
208
+ Style/EachWithObject:
209
+ Description: 'Prefer `each_with_object` over `inject` or `reduce`.'
210
+ Enabled: true
211
+
212
+ Style/ElseAlignment:
213
+ Description: 'Align elses and elsifs correctly.'
214
+ Enabled: true
215
+
216
+ Style/EmptyElse:
217
+ Description: 'Avoid empty else-clauses.'
218
+ Enabled: true
219
+
220
+ Style/EmptyCaseCondition:
221
+ Description: 'Avoid empty condition in case statements.'
222
+ Enabled: true
223
+
224
+ Style/EmptyLineBetweenDefs:
225
+ Description: 'Use empty lines between defs.'
226
+ StyleGuide: '#empty-lines-between-methods'
227
+ Enabled: true
228
+
229
+ Style/EmptyLines:
230
+ Description: "Don't use several empty lines in a row."
231
+ Enabled: true
232
+
233
+ Style/EmptyLinesAroundAccessModifier:
234
+ Description: "Keep blank lines around access modifiers."
235
+ Enabled: true
236
+
237
+ Style/EmptyLinesAroundBlockBody:
238
+ Description: "Keeps track of empty lines around block bodies."
239
+ Enabled: true
240
+
241
+ Style/EmptyLinesAroundClassBody:
242
+ Description: "Keeps track of empty lines around class bodies."
243
+ Enabled: true
244
+
245
+ Style/EmptyLinesAroundModuleBody:
246
+ Description: "Keeps track of empty lines around module bodies."
247
+ Enabled: true
248
+
249
+ Style/EmptyLinesAroundMethodBody:
250
+ Description: "Keeps track of empty lines around method bodies."
251
+ Enabled: true
252
+
253
+ Style/EmptyLiteral:
254
+ Description: 'Prefer literals to Array.new/Hash.new/String.new.'
255
+ StyleGuide: '#literal-array-hash'
256
+ Enabled: true
257
+
258
+ Style/EmptyMethod:
259
+ Description: 'Checks the formatting of empty method definitions.'
260
+ StyleGuide: '#no-single-line-methods'
261
+ Enabled: true
262
+
263
+ Style/EndBlock:
264
+ Description: 'Avoid the use of END blocks.'
265
+ StyleGuide: '#no-END-blocks'
266
+ Enabled: true
267
+
268
+ Style/EndOfLine:
269
+ Description: 'Use Unix-style line endings.'
270
+ StyleGuide: '#crlf'
271
+ Enabled: true
272
+
273
+ Style/EvenOdd:
274
+ Description: 'Favor the use of Integer#even? && Integer#odd?'
275
+ StyleGuide: '#predicate-methods'
276
+ Enabled: true
277
+
278
+ Style/ExtraSpacing:
279
+ Description: 'Do not use unnecessary spacing.'
280
+ Enabled: true
281
+
282
+ Style/FileName:
283
+ Description: 'Use snake_case for source file names.'
284
+ StyleGuide: '#snake-case-files'
285
+ Enabled: true
286
+
287
+ Style/FrozenStringLiteralComment:
288
+ Description: >-
289
+ Add the frozen_string_literal comment to the top of files
290
+ to help transition from Ruby 2.3.0 to Ruby 3.0.
291
+ Enabled: false
292
+
293
+ Style/InitialIndentation:
294
+ Description: >-
295
+ Checks the indentation of the first non-blank non-comment line in a file.
296
+ Enabled: true
297
+
298
+ Style/FirstParameterIndentation:
299
+ Description: 'Checks the indentation of the first parameter in a method call.'
300
+ Enabled: true
301
+
302
+ Style/FlipFlop:
303
+ Description: 'Checks for flip flops'
304
+ StyleGuide: '#no-flip-flops'
305
+ Enabled: true
306
+
307
+ Style/For:
308
+ Description: 'Checks use of for or each in multiline loops.'
309
+ StyleGuide: '#no-for-loops'
310
+ Enabled: true
311
+
312
+ Style/FormatString:
313
+ Description: 'Enforce the use of Kernel#sprintf, Kernel#format or String#%.'
314
+ StyleGuide: '#sprintf'
315
+ Enabled: true
316
+
317
+ Style/GlobalVars:
318
+ Description: 'Do not introduce global variables.'
319
+ StyleGuide: '#instance-vars'
320
+ Reference: 'http://www.zenspider.com/Languages/Ruby/QuickRef.html'
321
+ Enabled: true
322
+ AllowedVariables:
323
+ - $SITE_SETTINGS
324
+ - $REV_MANIFEST
325
+
326
+ Style/GuardClause:
327
+ Description: 'Check for conditionals that can be replaced with guard clauses'
328
+ StyleGuide: '#no-nested-conditionals'
329
+ Enabled: true
330
+
331
+ Style/HashSyntax:
332
+ Description: >-
333
+ Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax
334
+ { :a => 1, :b => 2 }.
335
+ StyleGuide: '#hash-literals'
336
+ # EnforcedStyle: hash_rockets
337
+ EnforcedStyle: ruby19
338
+ Enabled: true
339
+
340
+ Style/IfInsideElse:
341
+ Description: 'Finds if nodes inside else, which can be converted to elsif.'
342
+ Enabled: true
343
+
344
+ Style/IfUnlessModifier:
345
+ Description: >-
346
+ Favor modifier if/unless usage when you have a
347
+ single-line body.
348
+ StyleGuide: '#if-as-a-modifier'
349
+ Enabled: true
350
+
351
+ Style/IfUnlessModifierOfIfUnless:
352
+ Description: >-
353
+ Avoid modifier if/unless usage on conditionals.
354
+ Enabled: true
355
+
356
+ Style/IfWithSemicolon:
357
+ Description: 'Do not use if x; .... Use the ternary operator instead.'
358
+ StyleGuide: '#no-semicolon-ifs'
359
+ Enabled: true
360
+
361
+ Style/IndentationConsistency:
362
+ Description: 'Keep indentation straight.'
363
+ Enabled: true
364
+ EnforcedStyle: rails
365
+
366
+ Style/IndentationWidth:
367
+ Description: 'Use 2 spaces for indentation.'
368
+ StyleGuide: '#spaces-indentation'
369
+ Enabled: true
370
+
371
+ Style/IdenticalConditionalBranches:
372
+ Description: >-
373
+ Checks that conditional statements do not have an identical
374
+ line at the end of each branch, which can validly be moved
375
+ out of the conditional.
376
+ Enabled: true
377
+
378
+ Style/IndentArray:
379
+ Description: >-
380
+ Checks the indentation of the first element in an array
381
+ literal.
382
+ EnforcedStyle: consistent
383
+ Enabled: true
384
+
385
+ Style/IndentAssignment:
386
+ Description: >-
387
+ Checks the indentation of the first line of the
388
+ right-hand-side of a multi-line assignment.
389
+ Enabled: true
390
+
391
+ Style/IndentHash:
392
+ Description: 'Checks the indentation of the first key in a hash literal.'
393
+ EnforcedStyle: 'consistent'
394
+ Enabled: true
395
+
396
+ Style/InfiniteLoop:
397
+ Description: 'Use Kernel#loop for infinite loops.'
398
+ StyleGuide: '#infinite-loop'
399
+ Enabled: true
400
+
401
+ Style/Lambda:
402
+ Description: 'Use the new lambda literal syntax for single-line blocks.'
403
+ StyleGuide: '#lambda-multi-line'
404
+ Enabled: false
405
+
406
+ Style/SpaceInLambdaLiteral:
407
+ Description: 'Checks for spaces in lambda literals.'
408
+ Enabled: true
409
+
410
+ Style/LambdaCall:
411
+ Description: 'Use lambda.call(...) instead of lambda.(...).'
412
+ StyleGuide: '#proc-call'
413
+ Enabled: true
414
+
415
+ Style/LeadingCommentSpace:
416
+ Description: 'Comments should start with a space.'
417
+ StyleGuide: '#hash-space'
418
+ Enabled: true
419
+
420
+ Style/LineEndConcatenation:
421
+ Description: >-
422
+ Use \ instead of + or << to concatenate two string literals at
423
+ line end.
424
+ Enabled: true
425
+
426
+ Style/MethodCallWithoutArgsParentheses:
427
+ Description: 'Do not use parentheses for method calls with no arguments.'
428
+ StyleGuide: '#method-invocation-parens'
429
+ Enabled: true
430
+
431
+ Style/MethodDefParentheses:
432
+ Description: >-
433
+ Checks if the method definitions have or don't have
434
+ parentheses.
435
+ StyleGuide: '#method-parens'
436
+ Enabled: true
437
+
438
+ Style/MethodName:
439
+ Description: 'Use the configured style when naming methods.'
440
+ StyleGuide: '#snake-case-symbols-methods-vars'
441
+ Enabled: true
442
+
443
+ Style/MethodMissing:
444
+ Description: 'Avoid using `method_missing`.'
445
+ StyleGuide: '#no-method-missing'
446
+ Enabled: true
447
+
448
+ Style/ModuleFunction:
449
+ Description: 'Checks for usage of `extend self` in modules.'
450
+ StyleGuide: '#module-function'
451
+ Enabled: true
452
+
453
+ Style/MultilineArrayBraceLayout:
454
+ Description: >-
455
+ Checks that the closing brace in an array literal is
456
+ either on the same line as the last array element, or
457
+ a new line.
458
+ Enabled: true
459
+
460
+ Style/MultilineBlockChain:
461
+ Description: 'Avoid multi-line chains of blocks.'
462
+ StyleGuide: '#single-line-blocks'
463
+ Enabled: true
464
+
465
+ Style/MultilineBlockLayout:
466
+ Description: 'Ensures newlines after multiline block do statements.'
467
+ Enabled: true
468
+
469
+ Style/MultilineHashBraceLayout:
470
+ Description: >-
471
+ Checks that the closing brace in a hash literal is
472
+ either on the same line as the last hash element, or
473
+ a new line.
474
+ Enabled: true
475
+
476
+ Style/MultilineIfThen:
477
+ Description: 'Do not use then for multi-line if/unless.'
478
+ StyleGuide: '#no-then'
479
+ Enabled: true
480
+
481
+ Style/MultilineIfModifier:
482
+ Description: 'Only use if/unless modifiers on single line statements.'
483
+ StyleGuide: '#no-multiline-if-modifiers'
484
+ Enabled: true
485
+
486
+ Style/MultilineMemoization:
487
+ Description: 'Wrap multiline memoizations in a `begin` and `end` block.'
488
+ Enabled: true
489
+
490
+ Style/MultilineMethodCallBraceLayout:
491
+ Description: >-
492
+ Checks that the closing brace in a method call is
493
+ either on the same line as the last method argument, or
494
+ a new line.
495
+ Enabled: true
496
+
497
+ Style/MultilineMethodCallIndentation:
498
+ Description: >-
499
+ Checks indentation of method calls with the dot operator
500
+ that span more than one line.
501
+ EnforcedStyle: indented
502
+ Enabled: true
503
+
504
+ Style/MultilineMethodDefinitionBraceLayout:
505
+ Description: >-
506
+ Checks that the closing brace in a method definition is
507
+ either on the same line as the last method parameter, or
508
+ a new line.
509
+ Enabled: true
510
+
511
+ Style/MultilineOperationIndentation:
512
+ Description: >-
513
+ Checks indentation of binary operations that span more than
514
+ one line.
515
+ Enabled: true
516
+ EnforcedStyle: indented
517
+
518
+ Style/MultilineTernaryOperator:
519
+ Description: >-
520
+ Avoid multi-line ?: (the ternary operator);
521
+ use if/unless instead.
522
+ StyleGuide: '#no-multiline-ternary'
523
+ Enabled: true
524
+
525
+ Style/MutableConstant:
526
+ Description: 'Do not assign mutable objects to constants.'
527
+ Enabled: true
528
+
529
+ Style/NegatedIf:
530
+ Description: >-
531
+ Favor unless over if for negative conditions
532
+ (or control flow or).
533
+ StyleGuide: '#unless-for-negatives'
534
+ Enabled: true
535
+
536
+ Style/NegatedWhile:
537
+ Description: 'Favor until over while for negative conditions.'
538
+ StyleGuide: '#until-for-negatives'
539
+ Enabled: true
540
+
541
+ Style/NestedModifier:
542
+ Description: 'Avoid using nested modifiers.'
543
+ StyleGuide: '#no-nested-modifiers'
544
+ Enabled: true
545
+
546
+ Style/NestedParenthesizedCalls:
547
+ Description: >-
548
+ Parenthesize method calls which are nested inside the
549
+ argument list of another parenthesized method call.
550
+ Enabled: true
551
+
552
+ Style/NestedTernaryOperator:
553
+ Description: 'Use one expression per branch in a ternary operator.'
554
+ StyleGuide: '#no-nested-ternary'
555
+ Enabled: true
556
+
557
+ Style/Next:
558
+ Description: 'Use `next` to skip iteration instead of a condition at the end.'
559
+ StyleGuide: '#no-nested-conditionals'
560
+ Enabled: true
561
+
562
+ Style/NilComparison:
563
+ Description: 'Prefer x.nil? to x == nil.'
564
+ StyleGuide: '#predicate-methods'
565
+ Enabled: true
566
+
567
+ Style/NonNilCheck:
568
+ Description: 'Checks for redundant nil checks.'
569
+ StyleGuide: '#no-non-nil-checks'
570
+ Enabled: true
571
+
572
+ Style/Not:
573
+ Description: 'Use ! instead of not.'
574
+ StyleGuide: '#bang-not-not'
575
+ Enabled: true
576
+
577
+ Style/NumericLiterals:
578
+ Description: >-
579
+ Add underscores to large numeric literals to improve their
580
+ readability.
581
+ StyleGuide: '#underscores-in-numerics'
582
+ Enabled: false
583
+
584
+ Style/NumericLiteralPrefix:
585
+ Description: 'Use smallcase prefixes for numeric literals.'
586
+ StyleGuide: '#numeric-literal-prefixes'
587
+ Enabled: true
588
+
589
+ Style/NumericPredicate:
590
+ Description: >-
591
+ Checks for the use of predicate- or comparison methods for
592
+ numeric comparisons.
593
+ StyleGuide: '#predicate-methods'
594
+ # This will change to a new method call which isn't guaranteed to be on the
595
+ # object. Switching these methods has to be done with knowledge of the types
596
+ # of the variables which rubocop doesn't have.
597
+ AutoCorrect: false
598
+ Enabled: true
599
+
600
+ Style/OneLineConditional:
601
+ Description: >-
602
+ Favor the ternary operator(?:) over
603
+ if/then/else/end constructs.
604
+ StyleGuide: '#ternary-operator'
605
+ Enabled: true
606
+
607
+ Style/OpMethod:
608
+ Description: 'When defining binary operators, name the argument other.'
609
+ StyleGuide: '#other-arg'
610
+ Enabled: true
611
+
612
+ Style/OptionalArguments:
613
+ Description: >-
614
+ Checks for optional arguments that do not appear at the end
615
+ of the argument list
616
+ StyleGuide: '#optional-arguments'
617
+ Enabled: true
618
+
619
+ Style/ParallelAssignment:
620
+ Description: >-
621
+ Check for simple usages of parallel assignment.
622
+ It will only warn when the number of variables
623
+ matches on both sides of the assignment.
624
+ StyleGuide: '#parallel-assignment'
625
+ Enabled: true
626
+
627
+ Style/ParenthesesAroundCondition:
628
+ Description: >-
629
+ Don't use parentheses around the condition of an
630
+ if/unless/while.
631
+ StyleGuide: '#no-parens-around-condition'
632
+ Enabled: true
633
+
634
+ Style/PercentLiteralDelimiters:
635
+ Description: 'Use `%`-literal delimiters consistently'
636
+ StyleGuide: '#percent-literal-braces'
637
+ Enabled: true
638
+ PreferredDelimiters:
639
+ '%': '{}'
640
+ '%i': '{}'
641
+ '%q': '{}'
642
+ '%Q': '{}'
643
+ '%r': '{}'
644
+ '%s': '{}'
645
+ '%w': '{}'
646
+ '%W': '{}'
647
+ '%x': '{}'
648
+
649
+ Style/PercentQLiterals:
650
+ Description: 'Checks if uses of %Q/%q match the configured preference.'
651
+ Enabled: true
652
+
653
+ Style/PerlBackrefs:
654
+ Description: 'Avoid Perl-style regex back references.'
655
+ StyleGuide: '#no-perl-regexp-last-matchers'
656
+ Enabled: true
657
+
658
+ Style/PredicateName:
659
+ Description: 'Check the names of predicate methods.'
660
+ StyleGuide: '#bool-methods-qmark'
661
+ Enabled: true
662
+
663
+ Style/PreferredHashMethods:
664
+ Description: 'Checks use of `has_key?` and `has_value?` Hash methods.'
665
+ StyleGuide: '#hash-key'
666
+ Enabled: true
667
+
668
+ Style/Proc:
669
+ Description: 'Use proc instead of Proc.new.'
670
+ StyleGuide: '#proc'
671
+ Enabled: true
672
+
673
+ Style/RaiseArgs:
674
+ Description: 'Checks the arguments passed to raise/fail.'
675
+ StyleGuide: '#exception-class-messages'
676
+ Enabled: true
677
+
678
+ Style/RedundantBegin:
679
+ Description: "Don't use begin blocks when they are not needed."
680
+ StyleGuide: '#begin-implicit'
681
+ Enabled: true
682
+
683
+ Style/RedundantException:
684
+ Description: "Checks for an obsolete RuntimeException argument in raise/fail."
685
+ StyleGuide: '#no-explicit-runtimeerror'
686
+ Enabled: true
687
+
688
+ Style/RedundantFreeze:
689
+ Description: "Checks usages of Object#freeze on immutable objects."
690
+ Enabled: true
691
+
692
+ Style/RedundantParentheses:
693
+ Description: "Checks for parentheses that seem not to serve any purpose."
694
+ Enabled: true
695
+
696
+ Style/RedundantReturn:
697
+ Description: "Don't use return where it's not required."
698
+ StyleGuide: '#no-explicit-return'
699
+ Enabled: true
700
+
701
+ Style/RedundantSelf:
702
+ Description: "Don't use self where it's not needed."
703
+ StyleGuide: '#no-self-unless-required'
704
+ Enabled: true
705
+
706
+ Style/RegexpLiteral:
707
+ Description: 'Use / or %r around regular expressions.'
708
+ StyleGuide: '#percent-r'
709
+ Enabled: true
710
+
711
+ Style/RescueEnsureAlignment:
712
+ Description: 'Align rescues and ensures correctly.'
713
+ Enabled: true
714
+
715
+ Style/RescueModifier:
716
+ Description: 'Avoid using rescue in its modifier form.'
717
+ StyleGuide: '#no-rescue-modifiers'
718
+ Enabled: true
719
+
720
+ Style/SafeNavigation:
721
+ Description: >-
722
+ This cop transforms usages of a method call safeguarded by
723
+ a check for the existance of the object to
724
+ safe navigation (`&.`).
725
+ Enabled: true
726
+
727
+ Style/SelfAssignment:
728
+ Description: >-
729
+ Checks for places where self-assignment shorthand should have
730
+ been used.
731
+ StyleGuide: '#self-assignment'
732
+ Enabled: true
733
+
734
+ Style/Semicolon:
735
+ Description: "Don't use semicolons to terminate expressions."
736
+ StyleGuide: '#no-semicolon'
737
+ Enabled: true
738
+
739
+ Style/SignalException:
740
+ Description: 'Checks for proper usage of fail and raise.'
741
+ StyleGuide: '#prefer-raise-over-fail'
742
+ Enabled: true
743
+
744
+ Style/SingleLineMethods:
745
+ Description: 'Avoid single-line methods.'
746
+ StyleGuide: '#no-single-line-methods'
747
+ Enabled: true
748
+
749
+ Style/SpaceBeforeFirstArg:
750
+ Description: >-
751
+ Checks that exactly one space is used between a method name
752
+ and the first argument for method calls without parentheses.
753
+ Enabled: true
754
+
755
+ Style/SpaceAfterColon:
756
+ Description: 'Use spaces after colons.'
757
+ StyleGuide: '#spaces-operators'
758
+ Enabled: true
759
+
760
+ Style/SpaceAfterComma:
761
+ Description: 'Use spaces after commas.'
762
+ StyleGuide: '#spaces-operators'
763
+ Enabled: true
764
+
765
+ Style/SpaceAfterMethodName:
766
+ Description: >-
767
+ Do not put a space between a method name and the opening
768
+ parenthesis in a method definition.
769
+ StyleGuide: '#parens-no-spaces'
770
+ Enabled: true
771
+
772
+ Style/SpaceAfterNot:
773
+ Description: Tracks redundant space after the ! operator.
774
+ StyleGuide: '#no-space-bang'
775
+ Enabled: true
776
+
777
+ Style/SpaceAfterSemicolon:
778
+ Description: 'Use spaces after semicolons.'
779
+ StyleGuide: '#spaces-operators'
780
+ Enabled: true
781
+
782
+ Style/SpaceBeforeBlockBraces:
783
+ Description: >-
784
+ Checks that the left block brace has or doesn't have space
785
+ before it.
786
+ Enabled: true
787
+
788
+ Style/SpaceBeforeComma:
789
+ Description: 'No spaces before commas.'
790
+ Enabled: true
791
+
792
+ Style/SpaceBeforeComment:
793
+ Description: >-
794
+ Checks for missing space between code and a comment on the
795
+ same line.
796
+ Enabled: true
797
+
798
+ Style/SpaceBeforeSemicolon:
799
+ Description: 'No spaces before semicolons.'
800
+ Enabled: true
801
+
802
+ Style/SpaceInsideBlockBraces:
803
+ Description: >-
804
+ Checks that block braces have or don't have surrounding space.
805
+ For blocks taking parameters, checks that the left brace has
806
+ or doesn't have trailing space.
807
+ Enabled: true
808
+
809
+ Style/SpaceAroundBlockParameters:
810
+ Description: 'Checks the spacing inside and after block parameters pipes.'
811
+ Enabled: true
812
+
813
+ Style/SpaceAroundEqualsInParameterDefault:
814
+ Description: >-
815
+ Checks that the equals signs in parameter default assignments
816
+ have or don't have surrounding space depending on
817
+ configuration.
818
+ StyleGuide: '#spaces-around-equals'
819
+ Enabled: true
820
+
821
+ Style/SpaceAroundKeyword:
822
+ Description: 'Use a space around keywords if appropriate.'
823
+ Enabled: true
824
+
825
+ Style/SpaceAroundOperators:
826
+ Description: 'Use a single space around operators.'
827
+ StyleGuide: '#spaces-operators'
828
+ Enabled: true
829
+
830
+ Style/SpaceInsideArrayPercentLiteral:
831
+ Description: 'No unnecessary additional spaces between elements in %i/%w literals.'
832
+ Enabled: true
833
+
834
+ Style/SpaceInsidePercentLiteralDelimiters:
835
+ Description: 'No unnecessary spaces inside delimiters of %i/%w/%x literals.'
836
+ Enabled: false
837
+
838
+ Style/SpaceInsideBrackets:
839
+ Description: 'No spaces after [ or before ].'
840
+ StyleGuide: '#no-spaces-braces'
841
+ Enabled: true
842
+
843
+ Style/SpaceInsideHashLiteralBraces:
844
+ Description: "Use spaces inside hash literal braces - or don't."
845
+ StyleGuide: '#spaces-operators'
846
+ Enabled: true
847
+
848
+ Style/SpaceInsideParens:
849
+ Description: 'No spaces after ( or before ).'
850
+ StyleGuide: '#no-spaces-braces'
851
+ Enabled: true
852
+
853
+ Style/SpaceInsideRangeLiteral:
854
+ Description: 'No spaces inside range literals.'
855
+ StyleGuide: '#no-space-inside-range-literals'
856
+ Enabled: true
857
+
858
+ Style/SpaceInsideStringInterpolation:
859
+ Description: 'Checks for padding/surrounding spaces inside string interpolation.'
860
+ StyleGuide: '#string-interpolation'
861
+ Enabled: true
862
+
863
+ Style/SpecialGlobalVars:
864
+ Description: 'Avoid Perl-style global variables.'
865
+ StyleGuide: '#no-cryptic-perlisms'
866
+ Enabled: true
867
+
868
+ Style/StabbyLambdaParentheses:
869
+ Description: 'Check for the usage of parentheses around stabby lambda arguments.'
870
+ StyleGuide: '#stabby-lambda-with-args'
871
+ Enabled: true
872
+
873
+ Style/StringLiterals:
874
+ Description: 'Checks if uses of quotes match the configured preference.'
875
+ StyleGuide: '#consistent-string-literals'
876
+ Enabled: true
877
+
878
+ Style/StringLiteralsInInterpolation:
879
+ Description: >-
880
+ Checks if uses of quotes inside expressions in interpolated
881
+ strings match the configured preference.
882
+ Enabled: true
883
+
884
+ Style/StructInheritance:
885
+ Description: 'Checks for inheritance from Struct.new.'
886
+ StyleGuide: '#no-extend-struct-new'
887
+ Enabled: true
888
+
889
+ Style/SymbolLiteral:
890
+ Description: 'Use plain symbols instead of string symbols when possible.'
891
+ Enabled: true
892
+
893
+ Style/SymbolProc:
894
+ Description: 'Use symbols as procs instead of blocks when possible.'
895
+ Enabled: true
896
+
897
+ Style/Tab:
898
+ Description: 'No hard tabs.'
899
+ StyleGuide: '#spaces-indentation'
900
+ Enabled: true
901
+
902
+ Style/TernaryParentheses:
903
+ Description: 'Checks for use of parentheses around ternary conditions.'
904
+ Enabled: true
905
+
906
+ Style/TrailingBlankLines:
907
+ Description: 'Checks trailing blank lines and final newline.'
908
+ StyleGuide: '#newline-eof'
909
+ Enabled: true
910
+
911
+ Style/TrailingCommaInArguments:
912
+ Description: 'Checks for trailing comma in argument lists.'
913
+ StyleGuide: '#no-trailing-params-comma'
914
+ Enabled: true
915
+
916
+ Style/TrailingCommaInLiteral:
917
+ Description: 'Checks for trailing comma in array and hash literals.'
918
+ StyleGuide: '#no-trailing-array-commas'
919
+ Enabled: true
920
+
921
+ Style/TrailingWhitespace:
922
+ Description: 'Avoid trailing whitespace.'
923
+ StyleGuide: '#no-trailing-whitespace'
924
+ Enabled: true
925
+
926
+ Style/TrivialAccessors:
927
+ Description: 'Prefer attr_* methods to trivial readers/writers.'
928
+ StyleGuide: '#attr_family'
929
+ Enabled: true
930
+
931
+ Style/UnlessElse:
932
+ Description: >-
933
+ Do not use unless with else. Rewrite these with the positive
934
+ case first.
935
+ StyleGuide: '#no-else-with-unless'
936
+ Enabled: true
937
+
938
+ Style/UnneededCapitalW:
939
+ Description: 'Checks for %W when interpolation is not needed.'
940
+ Enabled: true
941
+
942
+ Style/UnneededInterpolation:
943
+ Description: 'Checks for strings that are just an interpolated expression.'
944
+ Enabled: true
945
+
946
+ Style/UnneededPercentQ:
947
+ Description: 'Checks for %q/%Q when single quotes or double quotes would do.'
948
+ StyleGuide: '#percent-q'
949
+ Enabled: true
950
+
951
+ Style/TrailingUnderscoreVariable:
952
+ Description: >-
953
+ Checks for the usage of unneeded trailing underscores at the
954
+ end of parallel variable assignment.
955
+ AllowNamedUnderscoreVariables: true
956
+ Enabled: true
957
+
958
+ Style/VariableInterpolation:
959
+ Description: >-
960
+ Don't interpolate global, instance and class variables
961
+ directly in strings.
962
+ StyleGuide: '#curlies-interpolate'
963
+ Enabled: true
964
+
965
+ Style/VariableName:
966
+ Description: 'Use the configured style when naming variables.'
967
+ StyleGuide: '#snake-case-symbols-methods-vars'
968
+ Enabled: true
969
+
970
+ Style/VariableNumber:
971
+ Description: 'Use the configured style when numbering variables.'
972
+ Enabled: true
973
+ EnforcedStyle: snake_case
974
+
975
+ Style/WhenThen:
976
+ Description: 'Use when x then ... for one-line cases.'
977
+ StyleGuide: '#one-line-cases'
978
+ Enabled: true
979
+
980
+ Style/WhileUntilDo:
981
+ Description: 'Checks for redundant do after while or until.'
982
+ StyleGuide: '#no-multiline-while-do'
983
+ Enabled: true
984
+
985
+ Style/WhileUntilModifier:
986
+ Description: >-
987
+ Favor modifier while/until usage when you have a
988
+ single-line body.
989
+ StyleGuide: '#while-as-a-modifier'
990
+ Enabled: true
991
+
992
+ Style/WordArray:
993
+ Description: 'Use %w or %W for arrays of words.'
994
+ StyleGuide: '#percent-w'
995
+ Enabled: true
996
+
997
+ Style/ZeroLengthPredicate:
998
+ Description: 'Use #empty? when testing for objects of length 0.'
999
+ Enabled: true
1000
+
1001
+ #################### Metrics ################################
1002
+
1003
+ Metrics/AbcSize:
1004
+ Description: >-
1005
+ A calculated magnitude based on number of assignments,
1006
+ branches, and conditions.
1007
+ Reference: 'http://c2.com/cgi/wiki?AbcMetric'
1008
+ Enabled: true
1009
+ Max: 30
1010
+
1011
+ Metrics/BlockNesting:
1012
+ Description: 'Avoid excessive block nesting'
1013
+ StyleGuide: '#three-is-the-number-thou-shalt-count'
1014
+ Enabled: true
1015
+
1016
+ Metrics/ClassLength:
1017
+ Description: 'Avoid classes longer than 300 lines of code.'
1018
+ Enabled: true
1019
+ Max: 300
1020
+
1021
+ Metrics/ModuleLength:
1022
+ Description: 'Avoid modules longer than 300 lines of code.'
1023
+ Enabled: true
1024
+ Max: 300
1025
+
1026
+ Metrics/CyclomaticComplexity:
1027
+ Description: >-
1028
+ A complexity metric that is strongly correlated to the number
1029
+ of test cases needed to validate a method.
1030
+ Enabled: true
1031
+ Max: 10
1032
+
1033
+ Metrics/LineLength:
1034
+ Max: 2000
1035
+ Description: 'Limit lines to 200 characters.'
1036
+ StyleGuide: '#80-character-limits'
1037
+ Enabled: true
1038
+
1039
+ Metrics/MethodLength:
1040
+ Description: 'Avoid methods longer than 10 lines of code.'
1041
+ StyleGuide: '#short-methods'
1042
+ Enabled: true
1043
+ Max: 50
1044
+
1045
+ Metrics/BlockLength:
1046
+ Description: 'Avoid long blocks with many lines.'
1047
+ Enabled: true
1048
+
1049
+ Metrics/ParameterLists:
1050
+ Description: 'Avoid parameter lists longer than three or four parameters.'
1051
+ StyleGuide: '#too-many-params'
1052
+ Enabled: true
1053
+
1054
+ Metrics/PerceivedComplexity:
1055
+ Description: >-
1056
+ A complexity metric geared towards measuring complexity for a
1057
+ human reader.
1058
+ Enabled: true
1059
+
1060
+ #################### Lint ################################
1061
+ ### Warnings
1062
+
1063
+ Lint/AmbiguousOperator:
1064
+ Description: >-
1065
+ Checks for ambiguous operators in the first argument of a
1066
+ method invocation without parentheses.
1067
+ StyleGuide: '#method-invocation-parens'
1068
+ Enabled: true
1069
+
1070
+ Lint/AmbiguousRegexpLiteral:
1071
+ Description: >-
1072
+ Checks for ambiguous regexp literals in the first argument of
1073
+ a method invocation without parentheses.
1074
+ Enabled: true
1075
+
1076
+ Lint/AssignmentInCondition:
1077
+ Description: "Don't use assignment in conditions."
1078
+ StyleGuide: '#safe-assignment-in-condition'
1079
+ Enabled: true
1080
+
1081
+ Lint/BlockAlignment:
1082
+ Description: 'Align block ends correctly.'
1083
+ Enabled: true
1084
+
1085
+ Lint/CircularArgumentReference:
1086
+ Description: "Default values in optional keyword arguments and optional ordinal arguments should not refer back to the name of the argument."
1087
+ Enabled: true
1088
+
1089
+ Lint/ConditionPosition:
1090
+ Description: >-
1091
+ Checks for condition placed in a confusing position relative to
1092
+ the keyword.
1093
+ StyleGuide: '#same-line-condition'
1094
+ Enabled: true
1095
+
1096
+ Lint/Debugger:
1097
+ Description: 'Check for debugger calls.'
1098
+ Enabled: true
1099
+
1100
+ Lint/DefEndAlignment:
1101
+ Description: 'Align ends corresponding to defs correctly.'
1102
+ Enabled: true
1103
+
1104
+ Lint/DeprecatedClassMethods:
1105
+ Description: 'Check for deprecated class method calls.'
1106
+ Enabled: true
1107
+
1108
+ Lint/DuplicateCaseCondition:
1109
+ Description: 'Do not repeat values in case conditionals.'
1110
+ Enabled: true
1111
+
1112
+ Lint/DuplicateMethods:
1113
+ Description: 'Check for duplicate method definitions.'
1114
+ Enabled: true
1115
+
1116
+ Lint/DuplicatedKey:
1117
+ Description: 'Check for duplicate keys in hash literals.'
1118
+ Enabled: true
1119
+
1120
+ Lint/EachWithObjectArgument:
1121
+ Description: 'Check for immutable argument given to each_with_object.'
1122
+ Enabled: true
1123
+
1124
+ Lint/ElseLayout:
1125
+ Description: 'Check for odd code arrangement in an else block.'
1126
+ Enabled: true
1127
+
1128
+ Lint/EmptyEnsure:
1129
+ Description: 'Checks for empty ensure block.'
1130
+ Enabled: true
1131
+
1132
+ Lint/EmptyExpression:
1133
+ Description: 'Checks for empty expressions.'
1134
+ Enabled: true
1135
+
1136
+ Lint/EmptyInterpolation:
1137
+ Description: 'Checks for empty string interpolation.'
1138
+ Enabled: true
1139
+
1140
+ Lint/EmptyWhen:
1141
+ Description: 'Checks for `when` branches with empty bodies.'
1142
+ Enabled: true
1143
+
1144
+ Lint/EndAlignment:
1145
+ Description: 'Align ends correctly.'
1146
+ Enabled: true
1147
+ EnforcedStyleAlignWith: variable
1148
+
1149
+ Lint/EndInMethod:
1150
+ Description: 'END blocks should not be placed inside method definitions.'
1151
+ Enabled: true
1152
+
1153
+ Lint/EnsureReturn:
1154
+ Description: 'Do not use return in an ensure block.'
1155
+ StyleGuide: '#no-return-ensure'
1156
+ Enabled: true
1157
+
1158
+ Lint/FloatOutOfRange:
1159
+ Description: >-
1160
+ Catches floating-point literals too large or small for Ruby to
1161
+ represent.
1162
+ Enabled: true
1163
+
1164
+ Lint/FormatParameterMismatch:
1165
+ Description: 'The number of parameters to format/sprint must match the fields.'
1166
+ Enabled: true
1167
+
1168
+ Lint/HandleExceptions:
1169
+ Description: "Don't suppress exception."
1170
+ StyleGuide: '#dont-hide-exceptions'
1171
+ Enabled: true
1172
+
1173
+ Lint/ImplicitStringConcatenation:
1174
+ Description: >-
1175
+ Checks for adjacent string literals on the same line, which
1176
+ could better be represented as a single string literal.
1177
+ Enabled: true
1178
+
1179
+ Lint/IneffectiveAccessModifier:
1180
+ Description: >-
1181
+ Checks for attempts to use `private` or `protected` to set
1182
+ the visibility of a class method, which does not work.
1183
+ Enabled: true
1184
+
1185
+ Lint/InheritException:
1186
+ Description: 'Avoid inheriting from the `Exception` class.'
1187
+ Enabled: true
1188
+
1189
+ Lint/InvalidCharacterLiteral:
1190
+ Description: >-
1191
+ Checks for invalid character literals with a non-escaped
1192
+ whitespace character.
1193
+ Enabled: true
1194
+
1195
+ Lint/LiteralInCondition:
1196
+ Description: 'Checks of literals used in conditions.'
1197
+ Enabled: true
1198
+
1199
+ Lint/LiteralInInterpolation:
1200
+ Description: 'Checks for literals used in interpolation.'
1201
+ Enabled: true
1202
+
1203
+ Lint/Loop:
1204
+ Description: >-
1205
+ Use Kernel#loop with break rather than begin/end/until or
1206
+ begin/end/while for post-loop tests.
1207
+ StyleGuide: '#loop-with-break'
1208
+ Enabled: true
1209
+
1210
+ Lint/MultipleCompare:
1211
+ Description: "Use `&&` operator to compare multiple value."
1212
+ Enabled: true
1213
+
1214
+ Lint/NestedMethodDefinition:
1215
+ Description: 'Do not use nested method definitions.'
1216
+ StyleGuide: '#no-nested-methods'
1217
+ Enabled: true
1218
+
1219
+ Lint/NextWithoutAccumulator:
1220
+ Description: >-
1221
+ Do not omit the accumulator when calling `next`
1222
+ in a `reduce`/`inject` block.
1223
+ Enabled: true
1224
+
1225
+ Lint/NonLocalExitFromIterator:
1226
+ Description: 'Do not use return in iterator to cause non-local exit.'
1227
+ Enabled: true
1228
+
1229
+ Lint/ParenthesesAsGroupedExpression:
1230
+ Description: >-
1231
+ Checks for method calls with a space before the opening
1232
+ parenthesis.
1233
+ StyleGuide: '#parens-no-spaces'
1234
+ Enabled: true
1235
+
1236
+ Lint/PercentStringArray:
1237
+ Description: >-
1238
+ Checks for unwanted commas and quotes in %w/%W literals.
1239
+ Enabled: true
1240
+
1241
+ Lint/PercentSymbolArray:
1242
+ Description: >-
1243
+ Checks for unwanted commas and colons in %i/%I literals.
1244
+ Enabled: true
1245
+
1246
+ Lint/RandOne:
1247
+ Description: >-
1248
+ Checks for `rand(1)` calls. Such calls always return `0`
1249
+ and most likely a mistake.
1250
+ Enabled: true
1251
+
1252
+ Lint/RequireParentheses:
1253
+ Description: >-
1254
+ Use parentheses in the method call to avoid confusion
1255
+ about precedence.
1256
+ Enabled: true
1257
+
1258
+ Lint/RescueException:
1259
+ Description: 'Avoid rescuing the Exception class.'
1260
+ StyleGuide: '#no-blind-rescues'
1261
+ Enabled: true
1262
+
1263
+ Lint/SafeNavigationChain:
1264
+ Description: 'Do not chain ordinary method call after safe navigation operator.'
1265
+ Enabled: true
1266
+
1267
+ Lint/ShadowedException:
1268
+ Description: >-
1269
+ Avoid rescuing a higher level exception
1270
+ before a lower level exception.
1271
+ Enabled: true
1272
+
1273
+ Lint/ShadowingOuterLocalVariable:
1274
+ Description: >-
1275
+ Do not use the same name as outer local variable
1276
+ for block arguments or block local variables.
1277
+ Enabled: true
1278
+
1279
+ Lint/StringConversionInInterpolation:
1280
+ Description: 'Checks for Object#to_s usage in string interpolation.'
1281
+ StyleGuide: '#no-to-s'
1282
+ Enabled: true
1283
+
1284
+ Lint/UnderscorePrefixedVariableName:
1285
+ Description: 'Do not use prefix `_` for a variable that is used.'
1286
+ Enabled: true
1287
+
1288
+ Lint/UnifiedInteger:
1289
+ Description: 'Use Integer instead of Fixnum or Bignum'
1290
+ Enabled: true
1291
+
1292
+ Lint/UnneededDisable:
1293
+ Description: >-
1294
+ Checks for rubocop:disable comments that can be removed.
1295
+ Note: this cop is not disabled when disabling all cops.
1296
+ It must be explicitly disabled.
1297
+ Enabled: true
1298
+
1299
+ Lint/UnneededSplatExpansion:
1300
+ Description: 'Checks for splat unnecessarily being called on literals'
1301
+ Enabled: true
1302
+
1303
+ Lint/UnusedBlockArgument:
1304
+ Description: 'Checks for unused block arguments.'
1305
+ StyleGuide: '#underscore-unused-vars'
1306
+ Enabled: true
1307
+
1308
+ Lint/UnusedMethodArgument:
1309
+ Description: 'Checks for unused method arguments.'
1310
+ StyleGuide: '#underscore-unused-vars'
1311
+ Enabled: true
1312
+
1313
+ Lint/UnreachableCode:
1314
+ Description: 'Unreachable code.'
1315
+ Enabled: true
1316
+
1317
+ Lint/UselessAccessModifier:
1318
+ Description: 'Checks for useless access modifiers.'
1319
+ Enabled: true
1320
+ ContextCreatingMethods: []
1321
+ MethodCreatingMethods: []
1322
+
1323
+ Lint/UselessAssignment:
1324
+ Description: 'Checks for useless assignment to a local variable.'
1325
+ StyleGuide: '#underscore-unused-vars'
1326
+ Enabled: true
1327
+
1328
+ Lint/UselessComparison:
1329
+ Description: 'Checks for comparison of something with itself.'
1330
+ Enabled: true
1331
+
1332
+ Lint/UselessElseWithoutRescue:
1333
+ Description: 'Checks for useless `else` in `begin..end` without `rescue`.'
1334
+ Enabled: true
1335
+
1336
+ Lint/UselessSetterCall:
1337
+ Description: 'Checks for useless setter call to a local variable.'
1338
+ Enabled: true
1339
+
1340
+ Lint/Void:
1341
+ Description: 'Possible use of operator/literal/variable in void context.'
1342
+ Enabled: true
1343
+
1344
+ ##################### Performance #############################
1345
+
1346
+ Performance/Casecmp:
1347
+ Description: >-
1348
+ Use `casecmp` rather than `downcase ==`, `upcase ==`, `== downcase`, or `== upcase`..
1349
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringcasecmp-vs-stringdowncase---code'
1350
+ Enabled: true
1351
+
1352
+ Performance/CaseWhenSplat:
1353
+ Description: >-
1354
+ Place `when` conditions that use splat at the end
1355
+ of the list of `when` branches.
1356
+ Enabled: true
1357
+
1358
+ Performance/Count:
1359
+ Description: >-
1360
+ Use `count` instead of `select...size`, `reject...size`,
1361
+ `select...count`, `reject...count`, `select...length`,
1362
+ and `reject...length`.
1363
+ # This cop has known compatibility issues with `ActiveRecord` and other
1364
+ # frameworks. ActiveRecord's `count` ignores the block that is passed to it.
1365
+ # For more information, see the documentation in the cop itself.
1366
+ # If you understand the known risk, you can disable `SafeMode`.
1367
+ SafeMode: true
1368
+ Enabled: true
1369
+
1370
+ Performance/Detect:
1371
+ Description: >-
1372
+ Use `detect` instead of `select.first`, `find_all.first`,
1373
+ `select.last`, and `find_all.last`.
1374
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerabledetect-vs-enumerableselectfirst-code'
1375
+ # This cop has known compatibility issues with `ActiveRecord` and other
1376
+ # frameworks. `ActiveRecord` does not implement a `detect` method and `find`
1377
+ # has its own meaning. Correcting `ActiveRecord` methods with this cop
1378
+ # should be considered unsafe.
1379
+ SafeMode: true
1380
+ Enabled: true
1381
+
1382
+ Performance/DoubleStartEndWith:
1383
+ Description: >-
1384
+ Use `str.{start,end}_with?(x, ..., y, ...)`
1385
+ instead of `str.{start,end}_with?(x, ...) || str.{start,end}_with?(y, ...)`.
1386
+ Enabled: true
1387
+
1388
+ Performance/EndWith:
1389
+ Description: 'Use `end_with?` instead of a regex match anchored to the end of a string.'
1390
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringmatch-vs-stringstart_withstringend_with-code-start-code-end'
1391
+ # This will change to a new method call which isn't guaranteed to be on the
1392
+ # object. Switching these methods has to be done with knowledge of the types
1393
+ # of the variables which rubocop doesn't have.
1394
+ AutoCorrect: false
1395
+ Enabled: true
1396
+
1397
+ Performance/FixedSize:
1398
+ Description: 'Do not compute the size of statically sized objects except in constants'
1399
+ Enabled: true
1400
+
1401
+ Performance/FlatMap:
1402
+ Description: >-
1403
+ Use `Enumerable#flat_map`
1404
+ instead of `Enumerable#map...Array#flatten(1)`
1405
+ or `Enumberable#collect..Array#flatten(1)`
1406
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerablemaparrayflatten-vs-enumerableflat_map-code'
1407
+ Enabled: true
1408
+ EnabledForFlattenWithoutParams: false
1409
+ # If enabled, this cop will warn about usages of
1410
+ # `flatten` being called without any parameters.
1411
+ # This can be dangerous since `flat_map` will only flatten 1 level, and
1412
+ # `flatten` without any parameters can flatten multiple levels.
1413
+
1414
+ Performance/HashEachMethods:
1415
+ Description: >-
1416
+ Use `Hash#each_key` and `Hash#each_value` instead of
1417
+ `Hash#keys.each` and `Hash#values.each`.
1418
+ StyleGuide: '#hash-each'
1419
+ Enabled: true
1420
+ AutoCorrect: false
1421
+
1422
+ Performance/LstripRstrip:
1423
+ Description: 'Use `strip` instead of `lstrip.rstrip`.'
1424
+ Enabled: true
1425
+
1426
+ Performance/RangeInclude:
1427
+ Description: 'Use `Range#cover?` instead of `Range#include?`.'
1428
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#cover-vs-include-code'
1429
+ Enabled: true
1430
+
1431
+ Performance/RedundantBlockCall:
1432
+ Description: 'Use `yield` instead of `block.call`.'
1433
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#proccall-vs-yield-code'
1434
+ Enabled: true
1435
+
1436
+ Performance/RedundantMatch:
1437
+ Description: >-
1438
+ Use `=~` instead of `String#match` or `Regexp#match` in a context where the
1439
+ returned `MatchData` is not needed.
1440
+ Enabled: true
1441
+
1442
+ Performance/RedundantMerge:
1443
+ Description: 'Use Hash#[]=, rather than Hash#merge! with a single key-value pair.'
1444
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#hashmerge-vs-hash-code'
1445
+ Enabled: true
1446
+
1447
+ Performance/RedundantSortBy:
1448
+ Description: 'Use `sort` instead of `sort_by { |x| x }`.'
1449
+ Enabled: true
1450
+
1451
+ Performance/RegexpMatch:
1452
+ Description: 'Use `match?` instead of `Regexp#match`, `String#match`, `Symbol#match`, `Regexp#===` or `=~` when `MatchData` is not used.'
1453
+ Enabled: true
1454
+
1455
+ Performance/ReverseEach:
1456
+ Description: 'Use `reverse_each` instead of `reverse.each`.'
1457
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerablereverseeach-vs-enumerablereverse_each-code'
1458
+ Enabled: true
1459
+
1460
+ Performance/Sample:
1461
+ Description: >-
1462
+ Use `sample` instead of `shuffle.first`,
1463
+ `shuffle.last`, and `shuffle[Integer]`.
1464
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#arrayshufflefirst-vs-arraysample-code'
1465
+ Enabled: true
1466
+
1467
+ Performance/Size:
1468
+ Description: >-
1469
+ Use `size` instead of `count` for counting
1470
+ the number of elements in `Array` and `Hash`.
1471
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#arraycount-vs-arraysize-code'
1472
+ Enabled: true
1473
+
1474
+ Performance/CompareWithBlock:
1475
+ Description: 'Use `sort_by(&:foo)` instead of `sort_by { |a, b| a.foo <=> b.foo }`.'
1476
+ Enabled: true
1477
+
1478
+ Performance/StartWith:
1479
+ Description: 'Use `start_with?` instead of a regex match anchored to the beginning of a string.'
1480
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringmatch-vs-stringstart_withstringend_with-code-start-code-end'
1481
+ # This will change to a new method call which isn't guaranteed to be on the
1482
+ # object. Switching these methods has to be done with knowledge of the types
1483
+ # of the variables which rubocop doesn't have.
1484
+ AutoCorrect: false
1485
+ Enabled: true
1486
+
1487
+ Performance/StringReplacement:
1488
+ Description: >-
1489
+ Use `tr` instead of `gsub` when you are replacing the same
1490
+ number of characters. Use `delete` instead of `gsub` when
1491
+ you are deleting characters.
1492
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringgsub-vs-stringtr-code'
1493
+ Enabled: true
1494
+
1495
+ Performance/TimesMap:
1496
+ Description: 'Checks for .times.map calls.'
1497
+ Enabled: true
1498
+
1499
+ ##################### Rails ##################################
1500
+
1501
+ Rails:
1502
+ Enabled: false
1503
+
1504
+ Rails/ActionFilter:
1505
+ Description: 'Enforces consistent use of action filter methods.'
1506
+ Enabled: true
1507
+
1508
+ Rails/Date:
1509
+ Description: >-
1510
+ Checks the correct usage of date aware methods,
1511
+ such as Date.today, Date.current etc.
1512
+ Enabled: true
1513
+
1514
+ Rails/Delegate:
1515
+ Description: 'Prefer delegate method for delegations.'
1516
+ Enabled: true
1517
+
1518
+ Rails/DelegateAllowBlank:
1519
+ Description: 'Do not use allow_blank as an option to delegate.'
1520
+ Enabled: true
1521
+
1522
+ Rails/DynamicFindBy:
1523
+ Description: 'Use `find_by` instead of dynamic `find_by_*`.'
1524
+ StyleGuide: 'https://github.com/bbatsov/rails-style-guide#find_by'
1525
+ Enabled: true
1526
+
1527
+ Rails/EnumUniqueness:
1528
+ Description: 'Avoid duplicate integers in hash-syntax `enum` declaration.'
1529
+ Enabled: true
1530
+
1531
+ Rails/Exit:
1532
+ Description: >-
1533
+ Favor `fail`, `break`, `return`, etc. over `exit` in
1534
+ application or library code outside of Rake files to avoid
1535
+ exits during unit testing or running in production.
1536
+ Enabled: true
1537
+
1538
+ Rails/FilePath:
1539
+ Description: 'Use `Rails.root.join` for file path joining.'
1540
+ Enabled: false
1541
+
1542
+ Rails/FindBy:
1543
+ Description: 'Prefer find_by over where.first.'
1544
+ StyleGuide: 'https://github.com/bbatsov/rails-style-guide#find_by'
1545
+ Enabled: true
1546
+
1547
+ Rails/FindEach:
1548
+ Description: 'Prefer all.find_each over all.find.'
1549
+ StyleGuide: 'https://github.com/bbatsov/rails-style-guide#find-each'
1550
+ Enabled: true
1551
+
1552
+ Rails/HasAndBelongsToMany:
1553
+ Description: 'Prefer has_many :through to has_and_belongs_to_many.'
1554
+ StyleGuide: 'https://github.com/bbatsov/rails-style-guide#has-many-through'
1555
+ Enabled: true
1556
+
1557
+ Rails/HttpPositionalArguments:
1558
+ Description: 'Use keyword arguments instead of positional arguments in http method calls.'
1559
+ Enabled: true
1560
+ Include:
1561
+ - 'spec/**/*'
1562
+ - 'test/**/*'
1563
+
1564
+ Rails/NotNullColumn:
1565
+ Description: 'Do not add a NOT NULL column without a default value'
1566
+ Enabled: true
1567
+
1568
+ Rails/Output:
1569
+ Description: 'Checks for calls to puts, print, etc.'
1570
+ Enabled: true
1571
+
1572
+ Rails/OutputSafety:
1573
+ Description: 'The use of `html_safe` or `raw` may be a security risk.'
1574
+ Enabled: true
1575
+
1576
+ Rails/PluralizationGrammar:
1577
+ Description: 'Checks for incorrect grammar when using methods like `3.day.ago`.'
1578
+ Enabled: true
1579
+
1580
+ Rails/ReadWriteAttribute:
1581
+ Description: >-
1582
+ Checks for read_attribute(:attr) and
1583
+ write_attribute(:attr, val).
1584
+ StyleGuide: 'https://github.com/bbatsov/rails-style-guide#read-attribute'
1585
+ Enabled: true
1586
+
1587
+ Rails/RequestReferer:
1588
+ Description: 'Use consistent syntax for request.referer.'
1589
+ Enabled: true
1590
+
1591
+ Rails/ReversibleMigration:
1592
+ Description: 'Checks whether the change method of the migration file is reversible.'
1593
+ StyleGuide: 'https://github.com/bbatsov/rails-style-guide#reversible-migration'
1594
+ Reference: 'http://api.rubyonrails.org/classes/ActiveRecord/Migration/CommandRecorder.html'
1595
+ Enabled: true
1596
+
1597
+ Rails/SafeNavigation:
1598
+ Description: "Use Ruby's safe navigation operator (`&.`) instead of `try!`"
1599
+ Enabled: true
1600
+
1601
+ Rails/ScopeArgs:
1602
+ Description: 'Checks the arguments of ActiveRecord scopes.'
1603
+ Enabled: true
1604
+
1605
+ Rails/TimeZone:
1606
+ Description: 'Checks the correct usage of time zone aware methods.'
1607
+ StyleGuide: 'https://github.com/bbatsov/rails-style-guide#time'
1608
+ Reference: 'http://danilenko.org/2012/7/6/rails_timezones'
1609
+ Enabled: true
1610
+
1611
+ Rails/UniqBeforePluck:
1612
+ Description: 'Prefer the use of uniq or distinct before pluck.'
1613
+ Enabled: true
1614
+
1615
+ Rails/SkipsModelValidations:
1616
+ Description: >-
1617
+ Use methods that skips model validations with caution.
1618
+ See reference for more information.
1619
+ Reference: 'http://guides.rubyonrails.org/active_record_validations.html#skipping-validations'
1620
+ Enabled: true
1621
+
1622
+ Rails/Validation:
1623
+ Description: 'Use validates :attribute, hash of validations.'
1624
+ Enabled: true
1625
+
1626
+ Security/Eval:
1627
+ Description: 'The use of eval represents a serious security risk.'
1628
+ Enabled: true
1629
+
1630
+ Security/JSONLoad:
1631
+ Description: >-
1632
+ Prefer usage of `JSON.parse` over `JSON.load` due to potential
1633
+ security issues. See reference for more information.
1634
+ Reference: 'http://ruby-doc.org/stdlib-2.3.0/libdoc/json/rdoc/JSON.html#method-i-load'
1635
+ Enabled: true
1636
+ # Autocorrect here will change to a method that may cause crashes depending
1637
+ # on the value of the argument.
1638
+ AutoCorrect: false
1639
+
1640
+ Security/MarshalLoad:
1641
+ Description: >-
1642
+ Avoid using of `Marshal.load` or `Marshal.restore` due to potential
1643
+ security issues. See reference for more information.
1644
+ Reference: 'http://ruby-doc.org/core-2.3.3/Marshal.html#module-Marshal-label-Security+considerations'
1645
+ Enabled: true
1646
+
1647
+ Security/YAMLLoad:
1648
+ Description: >-
1649
+ Prefer usage of `YAML.safe_load` over `YAML.load` due to potential
1650
+ security issues. See reference for more information.
1651
+ Reference: 'https://ruby-doc.org/stdlib-2.3.3/libdoc/yaml/rdoc/YAML.html#module-YAML-label-Security'
1652
+ Enabled: true
1653
+
1654
+ ##################### Bundler #############################
1655
+
1656
+ Bundler/DuplicatedGem:
1657
+ Description: 'Checks for duplicate gem entries in Gemfile.'
1658
+ Enabled: true
1659
+ Include:
1660
+ - '**/Gemfile'
1661
+ - '**/gems.rb'
1662
+
1663
+ Bundler/OrderedGems:
1664
+ Description: >-
1665
+ Sort alphabetically gems appearing within a contiguous set
1666
+ of lines in the Gemfile
1667
+ Enabled: true
1668
+ Include:
1669
+ - '**/Gemfile'
1670
+ - '**/gems.rb'