rubocop-rubomatic 2.0.1 → 2.1.1

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.
data/config/lint.yml CHANGED
@@ -19,6 +19,10 @@ Lint/AmbiguousRange:
19
19
  Lint/AmbiguousRegexpLiteral:
20
20
  Enabled: true
21
21
 
22
+ Lint/ArgumentMismatch:
23
+ # Requires `AllCops/UseProjectIndex: true` and the `rubydex` gem
24
+ Enabled: true
25
+
22
26
  Lint/ArrayLiteralInRegexp:
23
27
  Enabled: true
24
28
 
@@ -61,6 +65,9 @@ Lint/ConstantResolution:
61
65
  Lint/CopDirectiveSyntax:
62
66
  Enabled: true
63
67
 
68
+ Lint/DataDefineOverride:
69
+ Enabled: true
70
+
64
71
  Lint/Debugger:
65
72
  Enabled: true
66
73
  DebuggerMethods:
@@ -141,6 +148,10 @@ Lint/DeprecatedConstants:
141
148
  Lint/DeprecatedOpenSSLConstant:
142
149
  Enabled: true
143
150
 
151
+ Lint/DeprecatedReference:
152
+ # Requires `AllCops/UseProjectIndex: true` and the `rubydex` gem
153
+ Enabled: true
154
+
144
155
  Lint/DisjunctiveAssignmentInConstructor:
145
156
  Enabled: true
146
157
 
@@ -167,6 +178,8 @@ Lint/DuplicateMatchPattern:
167
178
 
168
179
  Lint/DuplicateMethods:
169
180
  Enabled: true
181
+ DelegatingMethods:
182
+ - delegate
170
183
 
171
184
  Lint/DuplicateRegexpCharacterClassElement:
172
185
  Enabled: true
@@ -288,6 +301,9 @@ Lint/LiteralInInterpolation:
288
301
  Lint/Loop:
289
302
  Enabled: true
290
303
 
304
+ Lint/MisplacedMagicComment:
305
+ Enabled: true
306
+
291
307
  Lint/MissingCopEnableDirective:
292
308
  Enabled: true
293
309
  # Maximum number of consecutive lines the cop can be disabled for.
@@ -297,7 +313,7 @@ Lint/MissingCopEnableDirective:
297
313
  # a = 1
298
314
  # # rubocop:enable SomeCop
299
315
  # .inf for any size
300
- MaximumRangeSize: .inf
316
+ MaxRangeSize: .inf
301
317
 
302
318
  Lint/MissingSuper:
303
319
  Enabled: true
@@ -311,6 +327,13 @@ Lint/MixedRegexpCaptureTypes:
311
327
  Lint/MultipleComparison:
312
328
  Enabled: true
313
329
 
330
+ Lint/NameTypo:
331
+ # Requires `AllCops/UseProjectIndex: true` and the `rubydex` gem
332
+ Enabled: true
333
+ CheckConstants: true
334
+ CheckMethods: true
335
+ AllowedNames: [] # Project specific
336
+
314
337
  Lint/NestedMethodDefinition:
315
338
  Enabled: true
316
339
  AllowedMethods: [ ]
@@ -357,7 +380,7 @@ Lint/NumberConversion:
357
380
  - fortnights
358
381
  - in_milliseconds
359
382
  AllowedPatterns: [ ]
360
- IgnoredClasses:
383
+ AllowedClasses:
361
384
  - Time
362
385
  - DateTime
363
386
 
@@ -468,6 +491,18 @@ Lint/SafeNavigationChain:
468
491
  - try
469
492
  - try!
470
493
  - in?
494
+ # BrandsInsurance/rails-extensions NilClass support
495
+ - positive?
496
+ - negative?
497
+ - zero?
498
+ - nonzero?
499
+ - to_sym
500
+ - to_date
501
+ - to_datetime
502
+ - html_safe
503
+ - usd_to_f
504
+ - usd_to_i
505
+ - to_bool
471
506
 
472
507
  Lint/SafeNavigationConsistency:
473
508
  Enabled: true
@@ -506,6 +541,10 @@ Lint/SharedMutableDefault:
506
541
  Lint/StructNewOverride:
507
542
  Enabled: true
508
543
 
544
+ Lint/SuperArgumentMismatch:
545
+ # Requires `AllCops/UseProjectIndex: true` and the `rubydex` gem
546
+ Enabled: true
547
+
509
548
  Lint/SuppressedException:
510
549
  Enabled: true
511
550
  AllowComments: true
@@ -576,6 +615,9 @@ Lint/UnreachableLoop:
576
615
  # eg. `exactly(2).times`
577
616
  - !ruby/regexp /(exactly|at_least|at_most)\(\d+\)\.times/
578
617
 
618
+ Lint/UnreachablePatternBranch:
619
+ Enabled: true
620
+
579
621
  Lint/UnusedBlockArgument:
580
622
  Enabled: true
581
623
  IgnoreEmptyBlocks: true
@@ -587,6 +629,12 @@ Lint/UnusedMethodArgument:
587
629
  IgnoreEmptyMethods: true
588
630
  IgnoreNotImplementedMethods: true
589
631
 
632
+ Lint/UnusedPrivateMethod:
633
+ # Requires `AllCops/UseProjectIndex: true` and the `rubydex` gem
634
+ Enabled: true
635
+ AllowedNames: [ ]
636
+ AllowedPatterns: [ ]
637
+
590
638
  Lint/UriEscapeUnescape:
591
639
  Enabled: true
592
640
 
data/config/metrics.yml CHANGED
@@ -39,9 +39,9 @@ Metrics/ClassLength:
39
39
  <% if RuboCop::Version.document_version.to_f >= 1.47 %>
40
40
  Metrics/CollectionLiteralLength:
41
41
  Enabled: true
42
- LengthThreshold: 250
42
+ Max: 250
43
43
  Exclude:
44
- - lib/tasks/seeds
44
+ - db/seeds
45
45
  <% end %>
46
46
 
47
47
  # Avoid complex methods.
data/config/rspec.yml CHANGED
@@ -96,6 +96,10 @@ RSpec/DescribedClassModuleWrapping:
96
96
  RSpec/Dialect:
97
97
  Enabled: false
98
98
 
99
+ RSpec/DiscardedMatcher:
100
+ Enabled: true
101
+ CustomMatcherMethods: [ ]
102
+
99
103
  RSpec/DuplicatedMetadata:
100
104
  Enabled: true
101
105
 
@@ -160,6 +164,7 @@ RSpec/ExpectActual:
160
164
  RSpec/ExpectChange:
161
165
  Enabled: true
162
166
  EnforcedStyle: block
167
+ NegatedMatcher: not_change
163
168
 
164
169
  RSpec/ExpectInHook:
165
170
  Enabled: true
@@ -239,12 +244,15 @@ RSpec/LetSetup:
239
244
  RSpec/MatchArray:
240
245
  Enabled: true
241
246
 
247
+ RSpec/MatchWithSimpleRegex:
248
+ Enabled: true
249
+
242
250
  RSpec/MessageChain:
243
251
  Enabled: true
244
252
 
245
253
  RSpec/MessageExpectation:
246
254
  Enabled: true
247
- EnforcedStyle: expect
255
+ EnforcedStyle: allow
248
256
 
249
257
  RSpec/MessageSpies:
250
258
  Enabled: true
@@ -295,6 +303,9 @@ RSpec/NotToNot:
295
303
  Enabled: true
296
304
  EnforcedStyle: to_not
297
305
 
306
+ RSpec/Output:
307
+ Enabled: true
308
+
298
309
  RSpec/OverwritingSetup:
299
310
  Enabled: true
300
311
 
@@ -358,6 +369,7 @@ RSpec/ScatteredSetup:
358
369
 
359
370
  RSpec/SharedContext:
360
371
  Enabled: true
372
+ Strict: true
361
373
 
362
374
  RSpec/SharedExamples:
363
375
  Enabled: true
data/config/rubocop.yml CHANGED
@@ -20,6 +20,8 @@ inherit_mode:
20
20
 
21
21
  AllCops:
22
22
  NewCops: disable
23
+ UseProjectIndex: true
24
+ ProjectIndexIncludesGems: false
23
25
  Exclude:
24
26
  - 'vendor/**/*'
25
27
  - 'spec/fixtures/**/*'
data/config/style.yml CHANGED
@@ -299,6 +299,9 @@ Style/CollectionMethods:
299
299
  - inject
300
300
  - reduce
301
301
 
302
+ Style/CollectionQuerying:
303
+ Enabled: true
304
+
302
305
  Style/ColonMethodCall:
303
306
  Enabled: true
304
307
 
@@ -410,10 +413,15 @@ Style/Dir:
410
413
  Style/DirEmpty:
411
414
  Enabled: true
412
415
 
416
+ Style/DirectiveScope:
417
+ Enabled: true
418
+
413
419
  Style/DisableCopsWithinSourceCodeDirective:
414
420
  Severity: info # Or warning
415
421
  Enabled: true
416
- AllowedCops: # Project specific
422
+ AllowedCops: [] # Project specific
423
+ DisallowedCops: [] # Project specific
424
+ AllowWithReason: true
417
425
 
418
426
  Style/DocumentDynamicEvalDefinition:
419
427
  Enabled: true
@@ -436,9 +444,6 @@ Style/DocumentationMethod:
436
444
  - method_missing
437
445
  - respond_to_missing?
438
446
 
439
- Style/DoubleCopDisableDirective:
440
- Enabled: true
441
-
442
447
  Style/DoubleNegation:
443
448
  Enabled: true
444
449
  EnforcedStyle: allowed_in_returns
@@ -458,6 +463,14 @@ Style/EmptyBlockParameter:
458
463
  Style/EmptyCaseCondition:
459
464
  Enabled: true
460
465
 
466
+ Style/EmptyClassDefinition:
467
+ Enabled: true
468
+ EnforcedStyle: class_keyword
469
+ SupportedStyles:
470
+ - class_keyword
471
+ - class_new
472
+ AllowedParentClasses: [ ]
473
+
461
474
  Style/EmptyElse:
462
475
  Enabled: true
463
476
  EnforcedStyle: both
@@ -533,7 +546,7 @@ Style/ExponentialNotation:
533
546
  Style/FetchEnvVar:
534
547
  Enabled: true
535
548
  # Environment variables to be excluded from the inspection.
536
- AllowedVars: [ ]
549
+ AllowedVariables: [ ]
537
550
  DefaultToNil: false
538
551
 
539
552
  Style/FileEmpty:
@@ -542,6 +555,9 @@ Style/FileEmpty:
542
555
  Style/FileNull:
543
556
  Enabled: true
544
557
 
558
+ Style/FileOpen:
559
+ Enabled: true
560
+
545
561
  Style/FileRead:
546
562
  Enabled: true
547
563
 
@@ -653,6 +669,13 @@ Style/HashLikeCase:
653
669
  # to trigger this cop
654
670
  MinBranchesCount: 3
655
671
 
672
+ Style/HashLookupMethod:
673
+ Enabled: false
674
+ EnforcedStyle: fetch
675
+ SupportedStyles:
676
+ - brackets
677
+ - fetch
678
+
656
679
  Style/HashSlice:
657
680
  Enabled: true
658
681
 
@@ -840,6 +863,9 @@ Style/MapCompactWithConditionalBlock:
840
863
  Style/MapIntoArray:
841
864
  Enabled: true
842
865
 
866
+ Style/MapJoin:
867
+ Enabled: true
868
+
843
869
  Style/MapToHash:
844
870
  Enabled: true
845
871
 
@@ -849,7 +875,12 @@ Style/MapToSet:
849
875
  Style/MethodCallWithArgsParentheses:
850
876
  Enabled: true
851
877
  IgnoreMacros: true
852
- AllowedMethods: [ ]
878
+ AllowedMethods:
879
+ - has_many
880
+ - has_one
881
+ - belongs_to
882
+ - delegate
883
+ - accepts_nested_attributes_for
853
884
  AllowedPatterns: [ ]
854
885
  IncludedMacros: [ ]
855
886
  IncludedMacroPatterns: [ ]
@@ -958,7 +989,7 @@ Style/MultilineWhenThen:
958
989
  Style/MultipleComparison:
959
990
  Enabled: true
960
991
  AllowMethodComparison: true
961
- ComparisonsThreshold: 2
992
+ ComparisonsThreshold: 3
962
993
 
963
994
  Style/MutableConstant:
964
995
  Enabled: true
@@ -1001,6 +1032,9 @@ Style/NegatedUnless:
1001
1032
  Style/NegatedWhile:
1002
1033
  Enabled: true
1003
1034
 
1035
+ Style/NegativeArrayIndex:
1036
+ Enabled: true
1037
+
1004
1038
  Style/NestedFileDirname:
1005
1039
  Enabled: true
1006
1040
 
@@ -1126,6 +1160,10 @@ Style/ObjectThen:
1126
1160
  - then
1127
1161
  - yield_self
1128
1162
 
1163
+ Style/OneClassPerFile:
1164
+ Enabled: true
1165
+ AllowedClasses: [ ]
1166
+
1129
1167
  Style/OneLineConditional:
1130
1168
  Enabled: true
1131
1169
  AlwaysCorrectToMultiline: false
@@ -1166,6 +1204,9 @@ Style/ParenthesesAroundCondition:
1166
1204
  AllowSafeAssignment: true
1167
1205
  AllowInMultilineConditions: false
1168
1206
 
1207
+ Style/PartitionInsteadOfDoubleSelect:
1208
+ Enabled: true
1209
+
1169
1210
  Style/PercentLiteralDelimiters:
1170
1211
  Enabled: true
1171
1212
  # Specify the default preferred delimiter for all types with the 'default' key
@@ -1184,6 +1225,9 @@ Style/PercentQLiterals:
1184
1225
  Style/PerlBackrefs:
1185
1226
  Enabled: true
1186
1227
 
1228
+ Style/PredicateWithKind:
1229
+ Enabled: true
1230
+
1187
1231
  Style/PreferredHashMethods:
1188
1232
  Enabled: false
1189
1233
  EnforcedStyle: short
@@ -1213,6 +1257,9 @@ Style/RaiseArgs:
1213
1257
  Style/RandomWithOffset:
1214
1258
  Enabled: true
1215
1259
 
1260
+ Style/ReduceToHash:
1261
+ Enabled: true
1262
+
1216
1263
  Style/RedundantArgument:
1217
1264
  Enabled: true
1218
1265
  Methods:
@@ -1294,6 +1341,9 @@ Style/RedundantInterpolationUnfreeze:
1294
1341
  Style/RedundantLineContinuation:
1295
1342
  Enabled: true
1296
1343
 
1344
+ Style/RedundantMinMaxBy:
1345
+ Enabled: true
1346
+
1297
1347
  Style/RedundantParentheses:
1298
1348
  Enabled: true
1299
1349
 
@@ -1335,6 +1385,9 @@ Style/RedundantSortBy:
1335
1385
  Style/RedundantStringEscape:
1336
1386
  Enabled: true
1337
1387
 
1388
+ Style/RedundantStructKeywordInit:
1389
+ Enabled: true
1390
+
1338
1391
  Style/RegexpLiteral:
1339
1392
  Enabled: true
1340
1393
  EnforcedStyle: slashes
@@ -1365,7 +1418,7 @@ Style/RescueStandardError:
1365
1418
  - explicit
1366
1419
 
1367
1420
  Style/ReturnNil:
1368
- Enabled: false
1421
+ Enabled: true
1369
1422
  EnforcedStyle: return
1370
1423
  SupportedStyles:
1371
1424
  - return
@@ -1376,6 +1429,10 @@ Style/ReturnNilInPredicateMethodDefinition:
1376
1429
  AllowedMethods: [ ]
1377
1430
  AllowedPatterns: [ ]
1378
1431
 
1432
+ Style/ReverseFind:
1433
+ # `Array#rfind` was added in ruby 4.0
1434
+ Enabled: <%= ENV['RUBY_VERSION'].to_f >= 4.0 %>
1435
+
1379
1436
  Style/SafeNavigation:
1380
1437
  Enabled: true
1381
1438
  # Safe navigation may cause a statement to start returning `nil` in addition
@@ -1396,6 +1453,12 @@ Style/SafeNavigationChainLength:
1396
1453
  Style/Sample:
1397
1454
  Enabled: true
1398
1455
 
1456
+ Style/SelectByKind:
1457
+ Enabled: false
1458
+
1459
+ Style/SelectByRange:
1460
+ Enabled: false
1461
+
1399
1462
  Style/SelectByRegexp:
1400
1463
  Enabled: true
1401
1464
 
@@ -1545,6 +1608,9 @@ Style/SymbolProc:
1545
1608
  AllowedPatterns: [ ]
1546
1609
  AllowComments: false
1547
1610
 
1611
+ Style/TallyMethod:
1612
+ Enabled: true
1613
+
1548
1614
  Style/TernaryParentheses:
1549
1615
  Enabled: true
1550
1616
  EnforcedStyle: require_parentheses_when_complex
@@ -1554,6 +1620,9 @@ Style/TernaryParentheses:
1554
1620
  - require_parentheses_when_complex
1555
1621
  AllowSafeAssignment: false
1556
1622
 
1623
+ Style/TimeNow:
1624
+ Enabled: true
1625
+
1557
1626
  Style/TopLevelMethodDefinition:
1558
1627
  Enabled: false
1559
1628
 
@@ -0,0 +1,7 @@
1
+ # Layout
2
+
3
+ Layout cops check for stylistic whitespace in your code
4
+
5
+ ## Cops
6
+
7
+ * [`Layout/MultilineArrayLineBreaks`](./multiline_array_line_breaks/README.md)
@@ -0,0 +1,36 @@
1
+ # `Layout/MultilineArrayLineBreaks`
2
+
3
+ ## Description
4
+
5
+ Extends the built-in [`Layout/MultilineArrayLineBreaks`][upstream] and adds the `AllowPercentArray` option
6
+
7
+ [upstream]: https://docs.rubocop.org/rubocop/1.49/cops_layout.html#layoutmultilinearraylinebreaks
8
+
9
+ ## Examples
10
+
11
+ ```ruby
12
+ # bad
13
+ %w[
14
+ 1
15
+ 2
16
+ 3
17
+ 4
18
+ ]
19
+
20
+ # good
21
+ %w[
22
+ 1 2
23
+ 3 4
24
+ ]
25
+ ```
26
+
27
+ ## Configurable Attributes
28
+
29
+ | Name | Default value | Configurable values |
30
+ | -------------------------- | ------------- | ------------------- |
31
+ | AllowMultilineFinalElement | false | Boolean |
32
+ | AllowPercentArray | false | Boolean |
33
+
34
+ ## References
35
+
36
+ * https://github.com/BrandsInsurance/expert-chainsaw/issues/1032
@@ -0,0 +1,7 @@
1
+ # Style
2
+
3
+ Style cops check for stylistic consistency of your code
4
+
5
+ ## Cops
6
+
7
+ * [`Style/DisallowedMethods`](./disallowed_methods/README.md)
@@ -1,13 +1,12 @@
1
- = ``Style/DisallowedMethods``
1
+ # `Style/DisallowedMethods`
2
2
 
3
- == Description
3
+ ## Description
4
4
 
5
5
  Certain methods should not be used
6
6
 
7
- == Examples
7
+ ## Examples
8
8
 
9
- [source,ruby]
10
- ----
9
+ ```ruby
11
10
  # Bad (Don't use `tap`)
12
11
  tap do
13
12
  end
@@ -17,12 +16,12 @@ abort
17
16
 
18
17
  # Good (Use `raise` instead of `abort`)
19
18
  raise
20
- ----
19
+ ```
21
20
 
22
- == Configurable Attributes
21
+ ## Configurable Attributes
23
22
 
24
23
  There are no configurable attributes
25
24
 
26
- == References
25
+ ## References
27
26
 
28
27
  * https://github.com/BrandsInsurance/expert-chainsaw/issues/434
@@ -6,7 +6,7 @@ module RuboCop
6
6
  class Generator
7
7
  class CopReadmeInjector < DeptReadmeInjector
8
8
  TEMPLATE =
9
- '* xref:./%{cop_folder}/README.adoc[``%{department}/%{cop}``]'
9
+ '* [`%{department}/%{cop}`](./%{cop_folder}/README.md)'
10
10
 
11
11
  # :nodoc:
12
12
  def initialize(badge:, **kwargs)
@@ -26,7 +26,7 @@ module RuboCop
26
26
  department_folder: snake_case(department),
27
27
  cop_folder: snake_case(cop),
28
28
  department: department,
29
- cop: cop
29
+ cop: cop,
30
30
  })
31
31
  end
32
32
 
@@ -42,7 +42,7 @@ module RuboCop
42
42
 
43
43
  # @see super
44
44
  def target_regex
45
- %r{\* xref:\./docs/cops/[a-z_]+/[a-z_]+/README\.adoc\[``(?<department>[a-zA-Z_]+)/(?<cop>[a-zA-Z_]+)``\]}
45
+ %r{\* \[`(?<department>[a-zA-Z_]+)/(?<cop>[a-zA-Z_]+)`\]\(\./[a-z_]+/README\.md\)}
46
46
  end
47
47
  end
48
48
  end
@@ -5,7 +5,7 @@ module RuboCop
5
5
  module Rubomatic
6
6
  class Generator
7
7
  class DeptReadmeInjector
8
- TEMPLATE = '* xref:./docs/cops/%{department_folder}/README.adoc[``%{department}``]'
8
+ TEMPLATE = '* [`%{department}`](./docs/cops/%{department_folder}/README.md)'
9
9
 
10
10
  # :nodoc:
11
11
  def initialize(readme_file_path:, badge:, department:)
@@ -46,7 +46,7 @@ module RuboCop
46
46
  # @return [*] Default $stdout
47
47
  attr_reader :output
48
48
 
49
- # Lines in <department>/README.adoc
49
+ # Lines in <department>/README.md
50
50
  #
51
51
  # @return [Array<String>]
52
52
  #
@@ -61,7 +61,7 @@ module RuboCop
61
61
  def new_readme_entry
62
62
  format(TEMPLATE, {
63
63
  department_folder: snake_case(department),
64
- department: department
64
+ department: department,
65
65
  })
66
66
  end
67
67
 
@@ -74,7 +74,7 @@ module RuboCop
74
74
  return index if line_is_good?(line)
75
75
  end
76
76
 
77
- return nil
77
+ return
78
78
  end
79
79
 
80
80
  # Determines if the given line is the same type we're trying to add and if it's alphabetically before
@@ -93,7 +93,7 @@ module RuboCop
93
93
  # @return [Regexp]
94
94
  #
95
95
  def target_regex
96
- %r{\* xref:\./docs/cops/[a-z_]+/README\.adoc\[``(?<department>[a-zA-Z_]+)``\]}
96
+ %r{\* \[`(?<department>[a-zA-Z_]+)`\]\(\./docs/cops/[a-z_]+/README\.md\)}
97
97
  end
98
98
 
99
99
  # Copied from Rubocop::Cop::Generator