to_factory 2.1.0 → 3.0.0.pre.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/test.yml +35 -0
  3. data/.rubocop-disabled.yml +95 -0
  4. data/.rubocop-enabled.yml +1194 -0
  5. data/.rubocop.yml +938 -0
  6. data/CHANGELOG.md +11 -0
  7. data/Gemfile +6 -1
  8. data/README.md +2 -11
  9. data/Rakefile +17 -9
  10. data/lib/to_factory/collation.rb +9 -9
  11. data/lib/to_factory/file_sync.rb +10 -10
  12. data/lib/to_factory/file_writer.rb +1 -1
  13. data/lib/to_factory/finders/factory.rb +1 -1
  14. data/lib/to_factory/finders/model.rb +2 -4
  15. data/lib/to_factory/generation/attribute.rb +6 -10
  16. data/lib/to_factory/generation/factory.rb +3 -3
  17. data/lib/to_factory/klass_inference.rb +4 -6
  18. data/lib/to_factory/options_parser.rb +4 -4
  19. data/lib/to_factory/parsing/file.rb +85 -14
  20. data/lib/to_factory/representation.rb +9 -6
  21. data/lib/to_factory/version.rb +1 -1
  22. data/lib/to_factory.rb +7 -8
  23. data/spec/db/migrate/1_create_users.rb +4 -4
  24. data/spec/db/migrate/2_create_projects.rb +4 -4
  25. data/spec/db/migrate/3_create_not_namespaced.rb +4 -4
  26. data/spec/db/migrate/4_add_birthday_to_users.rb +3 -3
  27. data/spec/db/migrate/5_add_serialized_attributes_to_users.rb +3 -3
  28. data/spec/example_factories/admin.rb +6 -6
  29. data/spec/example_factories/admin_with_header.rb +7 -7
  30. data/spec/example_factories/inherited_project_with_header.rb +7 -0
  31. data/spec/example_factories/project_with_header.rb +4 -4
  32. data/spec/example_factories/user.rb +5 -5
  33. data/spec/example_factories/user_admin.rb +11 -11
  34. data/spec/example_factories/user_admin_root.rb +12 -13
  35. data/spec/example_factories/user_admin_super_admin.rb +6 -6
  36. data/spec/example_factories/user_admin_with_header.rb +12 -12
  37. data/spec/example_factories/user_with_header.rb +6 -6
  38. data/spec/integration/empty_factory_file_spec.rb +2 -2
  39. data/spec/integration/file_sync_spec.rb +16 -17
  40. data/spec/integration/file_writer_spec.rb +13 -9
  41. data/spec/integration/lint_spec.rb +4 -3
  42. data/spec/integration/multiple_to_factory_calls_spec.rb +37 -35
  43. data/spec/integration/non_active_record_classes_spec.rb +40 -0
  44. data/spec/integration/to_factory_method_spec.rb +21 -18
  45. data/spec/spec_helper.rb +8 -8
  46. data/spec/support/data_creation.rb +11 -13
  47. data/spec/support/match_sexp.rb +0 -1
  48. data/spec/support/non_active_record/inherited_project.rb +3 -0
  49. data/spec/support/non_active_record/project.rb +3 -0
  50. data/spec/support/non_active_record/some_other_service_inheriting_from_something_else.rb +4 -0
  51. data/spec/support/non_active_record/some_service.rb +2 -0
  52. data/spec/support/non_active_record/something_else.rb +2 -0
  53. data/spec/support/ruby_parser_exception_causing_string.rb +29 -29
  54. data/spec/unit/collation_spec.rb +9 -10
  55. data/spec/unit/file_writer_spec.rb +4 -8
  56. data/spec/unit/finders/factory_spec.rb +7 -9
  57. data/spec/unit/finders/model_spec.rb +6 -9
  58. data/spec/unit/generation/attribute_spec.rb +11 -12
  59. data/spec/unit/generation/factory_spec.rb +14 -16
  60. data/spec/unit/parsing/file_spec.rb +9 -9
  61. data/spec/unit/parsing/klass_inference_spec.rb +5 -7
  62. data/to_factory.gemspec +14 -10
  63. metadata +89 -31
  64. data/.travis.yml +0 -16
  65. data/lib/to_factory/parsing/syntax.rb +0 -83
data/.rubocop.yml ADDED
@@ -0,0 +1,938 @@
1
+ # This is the default configuration file. Enabling and disabling is configured
2
+ # in separate files. This file adds all other parameters apart from Enabled.
3
+
4
+ inherit_from:
5
+ - .rubocop-enabled.yml
6
+ - .rubocop-disabled.yml
7
+
8
+ # Common configuration.
9
+ AllCops:
10
+ # Include common Ruby source files.
11
+ Include:
12
+ - '**/*.gemspec'
13
+ - '**/*.podspec'
14
+ - '**/*.jbuilder'
15
+ - '**/*.rake'
16
+ - '**/*.opal'
17
+ - '**/config.ru'
18
+ - '**/Gemfile'
19
+ - '**/Rakefile'
20
+ - '**/Capfile'
21
+ - '**/Guardfile'
22
+ - '**/Podfile'
23
+ - '**/Thorfile'
24
+ - '**/Vagrantfile'
25
+ - '**/Berksfile'
26
+ - '**/Cheffile'
27
+ - '**/Vagabondfile'
28
+ Exclude:
29
+ - 'vendor/**/*'
30
+ # By default, the rails cops are not run. Override in project or home
31
+ # directory .rubocop.yml files, or by giving the -R/--rails option.
32
+ RunRailsCops: false
33
+ # Cop names are not displayed in offense messages by default. Change behavior
34
+ # by overriding DisplayCopNames, or by giving the -D/--display-cop-names
35
+ # option.
36
+ DisplayCopNames: false
37
+ # Style guide URLs are not displayed in offense messages by default. Change
38
+ # behavior by overriding DisplayStyleGuide, or by giving the
39
+ # -S/--display-style-guide option.
40
+ DisplayStyleGuide: false
41
+ # Extra details are not displayed in offense messages by default. Change
42
+ # behaviour by overriding ExtraDetails, or by giving the
43
+ # -E/--extra-details option.
44
+ ExtraDetails: false
45
+ # Additional cops that do not reference a style guide rule may be enabled by
46
+ # default. Change behavior by overriding StyleGuideCopsOnly, or by giving
47
+ # the --only-guide-cops option.
48
+ StyleGuideCopsOnly: false
49
+ # All cops except the ones in disabled.yml are enabled by default. Change
50
+ # this behavior by overriding DisabledByDefault. When DisabledByDefault is
51
+ # true, all cops in the default configuration are disabled, and and only cops
52
+ # in user configuration are enabled. This makes cops opt-in instead of
53
+ # opt-out. Note that when DisabledByDefault is true, cops in user
54
+ # configuration will be enabled even if they don't set the Enabled parameter.
55
+ DisabledByDefault: false
56
+ # Enables the result cache if true. Can be overridden by the --cache command
57
+ # line option.
58
+ UseCache: true
59
+ # Threshold for how many files can be stored in the result cache before some
60
+ # of the files are automatically removed.
61
+ MaxFilesInCache: 20000
62
+ # The cache will be stored in "rubocop_cache" under this directory. The name
63
+ # "/tmp" is special and will be converted to the system temporary directory,
64
+ # which is "/tmp" on Unix-like systems, but could be something else on other
65
+ # systems.
66
+ CacheRootDirectory: /tmp
67
+
68
+ # Indent private/protected/public as deep as method definitions
69
+ Style/AccessModifierIndentation:
70
+ EnforcedStyle: indent
71
+ SupportedStyles:
72
+ - outdent
73
+ - indent
74
+
75
+ # Align the elements of a hash literal if they span more than one line.
76
+ Style/AlignHash:
77
+ # Alignment of entries using hash rocket as separator. Valid values are:
78
+ #
79
+ # key - left alignment of keys
80
+ # 'a' => 2
81
+ # 'bb' => 3
82
+ # separator - alignment of hash rockets, keys are right aligned
83
+ # 'a' => 2
84
+ # 'bb' => 3
85
+ # table - left alignment of keys, hash rockets, and values
86
+ # 'a' => 2
87
+ # 'bb' => 3
88
+ EnforcedHashRocketStyle: key
89
+ # Alignment of entries using colon as separator. Valid values are:
90
+ #
91
+ # key - left alignment of keys
92
+ # a: 0
93
+ # bb: 1
94
+ # separator - alignment of colons, keys are right aligned
95
+ # a: 0
96
+ # bb: 1
97
+ # table - left alignment of keys and values
98
+ # a: 0
99
+ # bb: 1
100
+ EnforcedColonStyle: key
101
+ # Select whether hashes that are the last argument in a method call should be
102
+ # inspected? Valid values are:
103
+ #
104
+ # always_inspect - Inspect both implicit and explicit hashes.
105
+ # Registers an offense for:
106
+ # function(a: 1,
107
+ # b: 2)
108
+ # Registers an offense for:
109
+ # function({a: 1,
110
+ # b: 2})
111
+ # always_ignore - Ignore both implicit and explicit hashes.
112
+ # Accepts:
113
+ # function(a: 1,
114
+ # b: 2)
115
+ # Accepts:
116
+ # function({a: 1,
117
+ # b: 2})
118
+ # ignore_implicit - Ignore only implicit hashes.
119
+ # Accepts:
120
+ # function(a: 1,
121
+ # b: 2)
122
+ # Registers an offense for:
123
+ # function({a: 1,
124
+ # b: 2})
125
+ # ignore_explicit - Ignore only explicit hashes.
126
+ # Accepts:
127
+ # function({a: 1,
128
+ # b: 2})
129
+ # Registers an offense for:
130
+ # function(a: 1,
131
+ # b: 2)
132
+ EnforcedLastArgumentHashStyle: always_inspect
133
+ SupportedLastArgumentHashStyles:
134
+ - always_inspect
135
+ - always_ignore
136
+ - ignore_implicit
137
+ - ignore_explicit
138
+
139
+ Style/AlignParameters:
140
+ # Alignment of parameters in multi-line method calls.
141
+ #
142
+ # The `with_first_parameter` style aligns the following lines along the same
143
+ # column as the first parameter.
144
+ #
145
+ # method_call(a,
146
+ # b)
147
+ #
148
+ # The `with_fixed_indentation` style aligns the following lines with one
149
+ # level of indentation relative to the start of the line with the method call.
150
+ #
151
+ # method_call(a,
152
+ # b)
153
+ EnforcedStyle: with_first_parameter
154
+ SupportedStyles:
155
+ - with_first_parameter
156
+ - with_fixed_indentation
157
+
158
+ Style/AndOr:
159
+ # Whether `and` and `or` are banned only in conditionals (conditionals)
160
+ # or completely (always).
161
+ EnforcedStyle: always
162
+ SupportedStyles:
163
+ - always
164
+ - conditionals
165
+
166
+
167
+ # Checks if usage of %() or %Q() matches configuration.
168
+ Style/BarePercentLiterals:
169
+ EnforcedStyle: bare_percent
170
+ SupportedStyles:
171
+ - percent_q
172
+ - bare_percent
173
+
174
+ Style/BlockDelimiters:
175
+ EnforcedStyle: line_count_based
176
+ SupportedStyles:
177
+ # The `line_count_based` style enforces braces around single line blocks and
178
+ # do..end around multi-line blocks.
179
+ - line_count_based
180
+ # The `semantic` style enforces braces around functional blocks, where the
181
+ # primary purpose of the block is to return a value and do..end for
182
+ # procedural blocks, where the primary purpose of the block is its
183
+ # side-effects.
184
+ #
185
+ # This looks at the usage of a block's method to determine its type (e.g. is
186
+ # the result of a `map` assigned to a variable or passed to another
187
+ # method) but exceptions are permitted in the `ProceduralMethods`,
188
+ # `FunctionalMethods` and `IgnoredMethods` sections below.
189
+ - semantic
190
+ # The `braces_for_chaining` style enforces braces around single line blocks
191
+ # and do..end around multi-line blocks, except for multi-line blocks whose
192
+ # return value is being chained with another method (in which case braces
193
+ # are enforced).
194
+ - braces_for_chaining
195
+ ProceduralMethods:
196
+ # Methods that are known to be procedural in nature but look functional from
197
+ # their usage, e.g.
198
+ #
199
+ # time = Benchmark.realtime do
200
+ # foo.bar
201
+ # end
202
+ #
203
+ # Here, the return value of the block is discarded but the return value of
204
+ # `Benchmark.realtime` is used.
205
+ - benchmark
206
+ - bm
207
+ - bmbm
208
+ - create
209
+ - each_with_object
210
+ - measure
211
+ - new
212
+ - realtime
213
+ - tap
214
+ - with_object
215
+ FunctionalMethods:
216
+ # Methods that are known to be functional in nature but look procedural from
217
+ # their usage, e.g.
218
+ #
219
+ # let(:foo) { Foo.new }
220
+ #
221
+ # Here, the return value of `Foo.new` is used to define a `foo` helper but
222
+ # doesn't appear to be used from the return value of `let`.
223
+ - let
224
+ - let!
225
+ - subject
226
+ - watch
227
+ IgnoredMethods:
228
+ # Methods that can be either procedural or functional and cannot be
229
+ # categorised from their usage alone, e.g.
230
+ #
231
+ # foo = lambda do |x|
232
+ # puts "Hello, #{x}"
233
+ # end
234
+ #
235
+ # foo = lambda do |x|
236
+ # x * 100
237
+ # end
238
+ #
239
+ # Here, it is impossible to tell from the return value of `lambda` whether
240
+ # the inner block's return value is significant.
241
+ - lambda
242
+ - proc
243
+ - it
244
+
245
+ Style/BracesAroundHashParameters:
246
+ EnforcedStyle: no_braces
247
+ SupportedStyles:
248
+ # The `braces` style enforces braces around all method parameters that are
249
+ # hashes.
250
+ - braces
251
+ # The `no_braces` style checks that the last parameter doesn't have braces
252
+ # around it.
253
+ - no_braces
254
+ # The `context_dependent` style checks that the last parameter doesn't have
255
+ # braces around it, but requires braces if the second to last parameter is
256
+ # also a hash literal.
257
+ - context_dependent
258
+
259
+ # Indentation of `when`.
260
+ Style/CaseIndentation:
261
+ IndentWhenRelativeTo: case
262
+ SupportedStyles:
263
+ - case
264
+ - end
265
+ IndentOneStep: false
266
+
267
+ Style/ClassAndModuleChildren:
268
+ # Checks the style of children definitions at classes and modules.
269
+ #
270
+ # Basically there are two different styles:
271
+ #
272
+ # `nested` - have each child on a separate line
273
+ # class Foo
274
+ # class Bar
275
+ # end
276
+ # end
277
+ #
278
+ # `compact` - combine definitions as much as possible
279
+ # class Foo::Bar
280
+ # end
281
+ #
282
+ # The compact style is only forced, for classes / modules with one child.
283
+ EnforcedStyle: nested
284
+ SupportedStyles:
285
+ - nested
286
+ - compact
287
+
288
+ Style/ClassCheck:
289
+ EnforcedStyle: is_a?
290
+ SupportedStyles:
291
+ - is_a?
292
+ - kind_of?
293
+
294
+ # Align with the style guide.
295
+ Style/CollectionMethods:
296
+ # Mapping from undesired method to desired_method
297
+ # e.g. to use `detect` over `find`:
298
+ #
299
+ # CollectionMethods:
300
+ # PreferredMethods:
301
+ # find: detect
302
+ PreferredMethods:
303
+ collect: 'map'
304
+ collect!: 'map!'
305
+ inject: 'reduce'
306
+ detect: 'find'
307
+ find_all: 'select'
308
+
309
+ # Use ` or %x around command literals.
310
+ Style/CommandLiteral:
311
+ EnforcedStyle: backticks
312
+ # backticks: Always use backticks.
313
+ # percent_x: Always use %x.
314
+ # mixed: Use backticks on single-line commands, and %x on multi-line commands.
315
+ SupportedStyles:
316
+ - backticks
317
+ - percent_x
318
+ - mixed
319
+ # If false, the cop will always recommend using %x if one or more backticks
320
+ # are found in the command string.
321
+ AllowInnerBackticks: false
322
+
323
+ # Checks formatting of special comments
324
+ Style/CommentAnnotation:
325
+ Keywords:
326
+ - TODO
327
+ - FIXME
328
+ - OPTIMIZE
329
+ - HACK
330
+ - REVIEW
331
+
332
+ # Checks that you have put a copyright in a comment before any code.
333
+ #
334
+ # You can override the default Notice in your .rubocop.yml file.
335
+ #
336
+ # In order to use autocorrect, you must supply a value for the
337
+ # AutocorrectNotice key that matches the regexp Notice. A blank
338
+ # AutocorrectNotice will cause an error during autocorrect.
339
+ #
340
+ # Autocorrect will add a copyright notice in a comment at the top
341
+ # of the file immediately after any shebang or encoding comments.
342
+ #
343
+ # Example rubocop.yml:
344
+ #
345
+ # Style/Copyright:
346
+ # Enabled: true
347
+ # Notice: 'Copyright (\(c\) )?2015 Yahoo! Inc'
348
+ # AutocorrectNotice: '# Copyright (c) 2015 Yahoo! Inc.'
349
+ #
350
+ Style/Copyright:
351
+ Notice: '^Copyright (\(c\) )?2[0-9]{3} .+'
352
+ AutocorrectNotice: ''
353
+
354
+ # Multi-line method chaining should be done with leading dots.
355
+ Style/DotPosition:
356
+ EnforcedStyle: leading
357
+ SupportedStyles:
358
+ - leading
359
+ - trailing
360
+
361
+ # Warn on empty else statements
362
+ # empty - warn only on empty else
363
+ # nil - warn on else with nil in it
364
+ # both - warn on empty else and else with nil in it
365
+ Style/EmptyElse:
366
+ EnforcedStyle: both
367
+ SupportedStyles:
368
+ - empty
369
+ - nil
370
+ - both
371
+
372
+ # Use empty lines between defs.
373
+ Style/EmptyLineBetweenDefs:
374
+ # If true, this parameter means that single line method definitions don't
375
+ # need an empty line between them.
376
+ AllowAdjacentOneLineDefs: false
377
+
378
+ Style/EmptyLinesAroundBlockBody:
379
+ EnforcedStyle: no_empty_lines
380
+ SupportedStyles:
381
+ - empty_lines
382
+ - no_empty_lines
383
+
384
+ Style/EmptyLinesAroundClassBody:
385
+ EnforcedStyle: no_empty_lines
386
+ SupportedStyles:
387
+ - empty_lines
388
+ - no_empty_lines
389
+
390
+ Style/EmptyLinesAroundModuleBody:
391
+ EnforcedStyle: no_empty_lines
392
+ SupportedStyles:
393
+ - empty_lines
394
+ - no_empty_lines
395
+
396
+ # Checks whether the source file has a utf-8 encoding comment or not
397
+ # AutoCorrectEncodingComment must match the regex
398
+ # /#.*coding\s?[:=]\s?(?:UTF|utf)-8/
399
+ Style/Encoding:
400
+ EnforcedStyle: always
401
+ SupportedStyles:
402
+ - when_needed
403
+ - always
404
+ AutoCorrectEncodingComment: '# encoding: utf-8'
405
+
406
+ Style/ExtraSpacing:
407
+ # When true, allows most uses of extra spacing if the intent is to align
408
+ # things with the previous or next line, not counting empty lines or comment
409
+ # lines.
410
+ AllowForAlignment: true
411
+
412
+ Style/FileName:
413
+ # File names listed in AllCops:Include are excluded by default. Add extra
414
+ # excludes here.
415
+ Exclude: []
416
+
417
+ Style/FirstParameterIndentation:
418
+ EnforcedStyle: special_for_inner_method_call_in_parentheses
419
+ SupportedStyles:
420
+ # The first parameter should always be indented one step more than the
421
+ # preceding line.
422
+ - consistent
423
+ # The first parameter should normally be indented one step more than the
424
+ # preceding line, but if it's a parameter for a method call that is itself
425
+ # a parameter in a method call, then the inner parameter should be indented
426
+ # relative to the inner method.
427
+ - special_for_inner_method_call
428
+ # Same as special_for_inner_method_call except that the special rule only
429
+ # applies if the outer method call encloses its arguments in parentheses.
430
+ - special_for_inner_method_call_in_parentheses
431
+
432
+ # Checks use of for or each in multiline loops.
433
+ Style/For:
434
+ EnforcedStyle: each
435
+ SupportedStyles:
436
+ - for
437
+ - each
438
+
439
+ # Enforce the method used for string formatting.
440
+ Style/FormatString:
441
+ EnforcedStyle: format
442
+ SupportedStyles:
443
+ - format
444
+ - sprintf
445
+ - percent
446
+
447
+ # Built-in global variables are allowed by default.
448
+ Style/GlobalVars:
449
+ AllowedVariables: []
450
+
451
+ # `MinBodyLength` defines the number of lines of the a body of an if / unless
452
+ # needs to have to trigger this cop
453
+ Style/GuardClause:
454
+ MinBodyLength: 1
455
+
456
+ Style/HashSyntax:
457
+ EnforcedStyle: ruby19
458
+ SupportedStyles:
459
+ - ruby19
460
+ - ruby19_no_mixed_keys
461
+ - hash_rockets
462
+ # Force hashes that have a symbol value to use hash rockets
463
+ UseHashRocketsWithSymbolValues: false
464
+
465
+ Style/IfUnlessModifier:
466
+ MaxLineLength: 80
467
+
468
+ Style/IndentationConsistency:
469
+ # The difference between `rails` and `normal` is that the `rails` style
470
+ # prescribes that in classes and modules the `protected` and `private`
471
+ # modifier keywords shall be indented the same as public methods and that
472
+ # protected and private members shall be indented one step more than the
473
+ # modifiers. Other than that, both styles mean that entities on the same
474
+ # logical depth shall have the same indentation.
475
+ EnforcedStyle: normal
476
+ SupportedStyles:
477
+ - normal
478
+ - rails
479
+
480
+ Style/IndentationWidth:
481
+ # Number of spaces for each indentation level.
482
+ Width: 2
483
+
484
+ # Checks the indentation of the first key in a hash literal.
485
+ Style/IndentHash:
486
+ # The value `special_inside_parentheses` means that hash literals with braces
487
+ # that have their opening brace on the same line as a surrounding opening
488
+ # round parenthesis, shall have their first key indented relative to the
489
+ # first position inside the parenthesis.
490
+ # The value `consistent` means that the indentation of the first key shall
491
+ # always be relative to the first position of the line where the opening
492
+ # brace is.
493
+ EnforcedStyle: special_inside_parentheses
494
+ SupportedStyles:
495
+ - special_inside_parentheses
496
+ - consistent
497
+ - align_braces
498
+
499
+ Style/LambdaCall:
500
+ EnforcedStyle: call
501
+ SupportedStyles:
502
+ - call
503
+ - braces
504
+
505
+ Style/Next:
506
+ # With `always` all conditions at the end of an iteration needs to be
507
+ # replaced by next - with `skip_modifier_ifs` the modifier if like this one
508
+ # are ignored: [1, 2].each { |a| return 'yes' if a == 1 }
509
+ EnforcedStyle: skip_modifier_ifs
510
+ # `MinBodyLength` defines the number of lines of the a body of an if / unless
511
+ # needs to have to trigger this cop
512
+ MinBodyLength: 3
513
+ SupportedStyles:
514
+ - skip_modifier_ifs
515
+ - always
516
+
517
+ Style/NonNilCheck:
518
+ # With `IncludeSemanticChanges` set to `true`, this cop reports offenses for
519
+ # `!x.nil?` and autocorrects that and `x != nil` to solely `x`, which is
520
+ # **usually** OK, but might change behavior.
521
+ #
522
+ # With `IncludeSemanticChanges` set to `false`, this cop does not report
523
+ # offenses for `!x.nil?` and does no changes that might change behavior.
524
+ IncludeSemanticChanges: false
525
+
526
+ Style/MethodDefParentheses:
527
+ EnforcedStyle: require_parentheses
528
+ SupportedStyles:
529
+ - require_parentheses
530
+ - require_no_parentheses
531
+ - require_no_parentheses_except_multiline
532
+
533
+ Style/MethodName:
534
+ EnforcedStyle: snake_case
535
+ SupportedStyles:
536
+ - snake_case
537
+ - camelCase
538
+
539
+ Style/MultilineOperationIndentation:
540
+ EnforcedStyle: aligned
541
+ SupportedStyles:
542
+ - aligned
543
+ - indented
544
+
545
+ Style/NumericLiterals:
546
+ MinDigits: 5
547
+
548
+ Style/OptionHash:
549
+ # A list of parameter names that will be flagged by this cop.
550
+ SuspiciousParamNames:
551
+ - options
552
+ - opts
553
+ - args
554
+ - params
555
+ - parameters
556
+
557
+ # Allow safe assignment in conditions.
558
+ Style/ParenthesesAroundCondition:
559
+ AllowSafeAssignment: true
560
+
561
+ Style/PercentLiteralDelimiters:
562
+ PreferredDelimiters:
563
+ '%': ()
564
+ '%i': ()
565
+ '%q': ()
566
+ '%Q': ()
567
+ '%r': '{}'
568
+ '%s': ()
569
+ '%w': ()
570
+ '%W': ()
571
+ '%x': ()
572
+
573
+ Style/PercentQLiterals:
574
+ EnforcedStyle: lower_case_q
575
+ SupportedStyles:
576
+ - lower_case_q # Use %q when possible, %Q when necessary
577
+ - upper_case_q # Always use %Q
578
+
579
+ Style/PredicateName:
580
+ # Predicate name prefixes.
581
+ NamePrefix:
582
+ - is_
583
+ - has_
584
+ - have_
585
+ # Predicate name prefixes that should be removed.
586
+ NamePrefixBlacklist:
587
+ - is_
588
+ - has_
589
+ - have_
590
+ # Predicate names which, despite having a blacklisted prefix, or no ?,
591
+ # should still be accepted
592
+ NameWhitelist:
593
+ - is_a?
594
+
595
+ Style/RaiseArgs:
596
+ EnforcedStyle: exploded
597
+ SupportedStyles:
598
+ - compact # raise Exception.new(msg)
599
+ - exploded # raise Exception, msg
600
+
601
+ Style/RedundantReturn:
602
+ # When true allows code like `return x, y`.
603
+ AllowMultipleReturnValues: false
604
+
605
+ # Use / or %r around regular expressions.
606
+ Style/RegexpLiteral:
607
+ EnforcedStyle: slashes
608
+ # slashes: Always use slashes.
609
+ # percent_r: Always use %r.
610
+ # mixed: Use slashes on single-line regexes, and %r on multi-line regexes.
611
+ SupportedStyles:
612
+ - slashes
613
+ - percent_r
614
+ - mixed
615
+ # If false, the cop will always recommend using %r if one or more slashes
616
+ # are found in the regexp string.
617
+ AllowInnerSlashes: false
618
+
619
+ Style/Semicolon:
620
+ # Allow ; to separate several expressions on the same line.
621
+ AllowAsExpressionSeparator: false
622
+
623
+ Style/SignalException:
624
+ EnforcedStyle: semantic
625
+ SupportedStyles:
626
+ - only_raise
627
+ - only_fail
628
+ - semantic
629
+
630
+ Style/SingleLineBlockParams:
631
+ Methods:
632
+ - reduce:
633
+ - a
634
+ - e
635
+ - inject:
636
+ - a
637
+ - e
638
+
639
+ Style/SingleLineMethods:
640
+ AllowIfMethodIsEmpty: true
641
+
642
+ Style/StabbyLambdaParentheses:
643
+ EnforcedStyle: require_parentheses
644
+ SupportedStyles:
645
+ - require_parentheses
646
+ - require_no_parentheses
647
+
648
+ Style/StringLiterals:
649
+ EnforcedStyle: double_quotes
650
+ SupportedStyles:
651
+ - single_quotes
652
+ - double_quotes
653
+
654
+ Style/StringLiteralsInInterpolation:
655
+ EnforcedStyle: single_quotes
656
+ SupportedStyles:
657
+ - single_quotes
658
+ - double_quotes
659
+
660
+ Style/StringMethods:
661
+ # Mapping from undesired method to desired_method
662
+ # e.g. to use `to_sym` over `intern`:
663
+ #
664
+ # StringMethods:
665
+ # PreferredMethods:
666
+ # intern: to_sym
667
+ PreferredMethods:
668
+ intern: to_sym
669
+
670
+ Style/SpaceAroundBlockParameters:
671
+ EnforcedStyleInsidePipes: no_space
672
+ SupportedStyles:
673
+ - space
674
+ - no_space
675
+
676
+ Style/SpaceAroundEqualsInParameterDefault:
677
+ EnforcedStyle: space
678
+ SupportedStyles:
679
+ - space
680
+ - no_space
681
+
682
+ Style/SpaceAroundOperators:
683
+ MultiSpaceAllowedForOperators:
684
+ - '='
685
+ - '=>'
686
+
687
+ Style/SpaceBeforeBlockBraces:
688
+ EnforcedStyle: space
689
+ SupportedStyles:
690
+ - space
691
+ - no_space
692
+
693
+ Style/SpaceInsideBlockBraces:
694
+ EnforcedStyle: space
695
+ SupportedStyles:
696
+ - space
697
+ - no_space
698
+ # Valid values are: space, no_space
699
+ EnforcedStyleForEmptyBraces: no_space
700
+ # Space between { and |. Overrides EnforcedStyle if there is a conflict.
701
+ SpaceBeforeBlockParameters: true
702
+
703
+ Style/SpaceInsideHashLiteralBraces:
704
+ EnforcedStyle: space
705
+ EnforcedStyleForEmptyBraces: no_space
706
+ SupportedStyles:
707
+ - space
708
+ - no_space
709
+
710
+ Style/SpaceInsideStringInterpolation:
711
+ EnforcedStyle: no_space
712
+ SupportedStyles:
713
+ - space
714
+ - no_space
715
+
716
+ Style/SymbolProc:
717
+ # A list of method names to be ignored by the check.
718
+ # The names should be fairly unique, otherwise you'll end up ignoring lots of code.
719
+ IgnoredMethods:
720
+ - respond_to
721
+
722
+ Style/TrailingBlankLines:
723
+ EnforcedStyle: final_newline
724
+ SupportedStyles:
725
+ - final_newline
726
+ - final_blank_line
727
+
728
+ Style/TrailingComma:
729
+ # If EnforcedStyleForMultiline is comma, the cop requires a comma after the
730
+ # last item of a list, but only for lists where each item is on its own line.
731
+ # If EnforcedStyleForMultiline is consistent_comma, the cop requires a comma
732
+ # after the last item of a list, for all lists.
733
+ EnforcedStyleForMultiline: no_comma
734
+ SupportedStyles:
735
+ - comma
736
+ - consistent_comma
737
+ - no_comma
738
+
739
+ # TrivialAccessors requires exact name matches and doesn't allow
740
+ # predicated methods by default.
741
+ Style/TrivialAccessors:
742
+ # When set to false the cop will suggest the use of accessor methods
743
+ # in situations like:
744
+ #
745
+ # def name
746
+ # @other_name
747
+ # end
748
+ #
749
+ # This way you can uncover "hidden" attributes in your code.
750
+ ExactNameMatch: true
751
+ AllowPredicates: false
752
+ # Allows trivial writers that don't end in an equal sign. e.g.
753
+ #
754
+ # def on_exception(action)
755
+ # @on_exception=action
756
+ # end
757
+ # on_exception :restart
758
+ #
759
+ # Commonly used in DSLs
760
+ AllowDSLWriters: false
761
+ IgnoreClassMethods: false
762
+ Whitelist:
763
+ - to_ary
764
+ - to_a
765
+ - to_c
766
+ - to_enum
767
+ - to_h
768
+ - to_hash
769
+ - to_i
770
+ - to_int
771
+ - to_io
772
+ - to_open
773
+ - to_path
774
+ - to_proc
775
+ - to_r
776
+ - to_regexp
777
+ - to_str
778
+ - to_s
779
+ - to_sym
780
+
781
+ Style/VariableName:
782
+ EnforcedStyle: snake_case
783
+ SupportedStyles:
784
+ - snake_case
785
+ - camelCase
786
+
787
+ Style/WhileUntilModifier:
788
+ MaxLineLength: 80
789
+
790
+ Style/WordArray:
791
+ MinSize: 0
792
+ # The regular expression WordRegex decides what is considered a word.
793
+ WordRegex: !ruby/regexp '/\A[\p{Word}]+\z/'
794
+
795
+ ##################### Metrics ##################################
796
+
797
+ Metrics/AbcSize:
798
+ # The ABC size is a calculated magnitude, so this number can be a Fixnum or
799
+ # a Float.
800
+ Max: 15
801
+
802
+ Metrics/BlockNesting:
803
+ Max: 3
804
+
805
+ Metrics/ClassLength:
806
+ CountComments: false # count full line comments?
807
+ Max: 100
808
+
809
+ Metrics/ModuleLength:
810
+ CountComments: false # count full line comments?
811
+ Max: 100
812
+
813
+ # Avoid complex methods.
814
+ Metrics/CyclomaticComplexity:
815
+ Max: 6
816
+
817
+ Metrics/LineLength:
818
+ Max: 80
819
+ # To make it possible to copy or click on URIs in the code, we allow lines
820
+ # contaning a URI to be longer than Max.
821
+ AllowURI: true
822
+ URISchemes:
823
+ - http
824
+ - https
825
+
826
+ Metrics/MethodLength:
827
+ CountComments: false # count full line comments?
828
+ Max: 10
829
+
830
+ Metrics/ParameterLists:
831
+ Max: 5
832
+ CountKeywordArgs: true
833
+
834
+ Metrics/PerceivedComplexity:
835
+ Max: 7
836
+
837
+ ##################### Lint ##################################
838
+
839
+ # Allow safe assignment in conditions.
840
+ Lint/AssignmentInCondition:
841
+ AllowSafeAssignment: true
842
+
843
+ # Align ends correctly.
844
+ Lint/EndAlignment:
845
+ # The value `keyword` means that `end` should be aligned with the matching
846
+ # keyword (if, while, etc.).
847
+ # The value `variable` means that in assignments, `end` should be aligned
848
+ # with the start of the variable on the left hand side of `=`. In all other
849
+ # situations, `end` should still be aligned with the keyword.
850
+ AlignWith: keyword
851
+ SupportedStyles:
852
+ - keyword
853
+ - variable
854
+ AutoCorrect: false
855
+
856
+ Lint/DefEndAlignment:
857
+ # The value `def` means that `end` should be aligned with the def keyword.
858
+ # The value `start_of_line` means that `end` should be aligned with method
859
+ # calls like `private`, `public`, etc, if present in front of the `def`
860
+ # keyword on the same line.
861
+ AlignWith: start_of_line
862
+ SupportedStyles:
863
+ - start_of_line
864
+ - def
865
+ AutoCorrect: false
866
+
867
+ # Checks for unused block arguments
868
+ Lint/UnusedBlockArgument:
869
+ IgnoreEmptyBlocks: true
870
+
871
+ # Checks for unused method arguments.
872
+ Lint/UnusedMethodArgument:
873
+ AllowUnusedKeywordArguments: false
874
+ IgnoreEmptyMethods: true
875
+
876
+ ##################### Rails ##################################
877
+
878
+ Rails/ActionFilter:
879
+ EnforcedStyle: action
880
+ SupportedStyles:
881
+ - action
882
+ - filter
883
+ Include:
884
+ - app/controllers/**/*.rb
885
+
886
+ Rails/Date:
887
+ # The value `strict` disallows usage of `Date.today`, `Date.current`,
888
+ # `Date#to_time` etc.
889
+ # The value `flexible` allows usage of `Date.current`, `Date.yesterday`, etc
890
+ # (but not `Date.today`) which are overriden by ActiveSupport to handle current
891
+ # time zone.
892
+ EnforcedStyle: flexible
893
+ SupportedStyles:
894
+ - strict
895
+ - flexible
896
+
897
+ Rails/DefaultScope:
898
+ Include:
899
+ - app/models/**/*.rb
900
+
901
+ Rails/FindBy:
902
+ Include:
903
+ - app/models/**/*.rb
904
+
905
+ Rails/FindEach:
906
+ Include:
907
+ - app/models/**/*.rb
908
+
909
+ Rails/HasAndBelongsToMany:
910
+ Include:
911
+ - app/models/**/*.rb
912
+
913
+ Rails/Output:
914
+ Include:
915
+ - app/**/*.rb
916
+ - config/**/*.rb
917
+ - db/**/*.rb
918
+ - lib/**/*.rb
919
+
920
+ Rails/ReadWriteAttribute:
921
+ Include:
922
+ - app/models/**/*.rb
923
+
924
+ Rails/ScopeArgs:
925
+ Include:
926
+ - app/models/**/*.rb
927
+
928
+ Rails/TimeZone:
929
+ # The value `strict` means that `Time` should be used with `zone`.
930
+ # The value `flexible` allows usage of `in_time_zone` instead of `zone`.
931
+ EnforcedStyle: flexible
932
+ SupportedStyles:
933
+ - strict
934
+ - flexible
935
+
936
+ Rails/Validation:
937
+ Include:
938
+ - app/models/**/*.rb