chefstyle 0.1.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,10 @@
1
1
  # These are all the cops that are disabled in the default configuration.
2
2
 
3
+ # By default, the rails cops are not run. Override in project or home
4
+ # directory .rubocop.yml files, or by giving the -R/--rails option.
5
+ Rails:
6
+ Enabled: false
7
+
3
8
  Style/AutoResourceCleanup:
4
9
  Description: 'Suggests the usage of an auto resource cleanup version of a method (if available).'
5
10
  Enabled: false
@@ -18,10 +23,6 @@ Style/Encoding:
18
23
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#utf-8'
19
24
  Enabled: false
20
25
 
21
- Style/InlineComment:
22
- Description: 'Avoid inline comments.'
23
- Enabled: false
24
-
25
26
  Style/FirstArrayElementLineBreak:
26
27
  Description: >-
27
28
  Checks for a line break before the first element in a
@@ -46,6 +47,10 @@ Style/FirstMethodParameterLineBreak:
46
47
  multi-line method parameter definition.
47
48
  Enabled: false
48
49
 
50
+ Style/InlineComment:
51
+ Description: 'Avoid inline comments.'
52
+ Enabled: false
53
+
49
54
  Style/MethodCalledOnDoEndBlock:
50
55
  Description: 'Avoid chaining a method call on a do...end block.'
51
56
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#single-line-blocks'
@@ -68,8 +73,37 @@ Style/MissingElse:
68
73
  - case
69
74
  - both
70
75
 
71
- Style/MutableConstant:
72
- Description: 'Do not assign mutable objects to constants.'
76
+ Style/MultilineArrayBraceLayout:
77
+ Description: >-
78
+ Checks that the closing brace in an array literal is
79
+ symmetrical with respect to the opening brace and the
80
+ array elements.
81
+ Enabled: false
82
+
83
+ Style/MultilineAssignmentLayout:
84
+ Description: 'Check for a newline after the assignment operator in multi-line assignments.'
85
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#indent-conditional-assignment'
86
+ Enabled: false
87
+
88
+ Style/MultilineHashBraceLayout:
89
+ Description: >-
90
+ Checks that the closing brace in a hash literal is
91
+ symmetrical with respect to the opening brace and the
92
+ hash elements.
93
+ Enabled: false
94
+
95
+ Style/MultilineMethodCallBraceLayout:
96
+ Description: >-
97
+ Checks that the closing brace in a method call is
98
+ symmetrical with respect to the opening brace and the
99
+ method arguments.
100
+ Enabled: false
101
+
102
+ Style/MultilineMethodDefinitionBraceLayout:
103
+ Description: >-
104
+ Checks that the closing brace in a method definition is
105
+ symmetrical with respect to the opening brace and the
106
+ method parameters.
73
107
  Enabled: false
74
108
 
75
109
  Style/OptionHash:
@@ -10,7 +10,7 @@ Style/AccessorMethodName:
10
10
  Enabled: true
11
11
 
12
12
  Style/Alias:
13
- Description: 'Use alias_method instead of alias.'
13
+ Description: 'Use alias instead of alias_method.'
14
14
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#alias-method'
15
15
  Enabled: true
16
16
 
@@ -153,6 +153,16 @@ Style/CommentIndentation:
153
153
  Description: 'Indentation of comments.'
154
154
  Enabled: true
155
155
 
156
+ Style/ConditionalAssignment:
157
+ Description: >-
158
+ Use the return value of `if` and `case` statements for
159
+ assignment to a variable and variable comparison instead
160
+ of assigning that variable inside of each branch.
161
+ Enabled: true
162
+ SingleLineConditionsOnly: true
163
+ # Whether the cop should register offenses for conditionals whose branches
164
+ # contain more than one statement a piece
165
+
156
166
  Style/ConstantName:
157
167
  Description: 'Constants should use SCREAMING_SNAKE_CASE.'
158
168
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#screaming-snake-case'
@@ -255,6 +265,12 @@ Style/FileName:
255
265
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#snake-case-files'
256
266
  Enabled: true
257
267
 
268
+ Style/FrozenStringLiteralComment:
269
+ Description: >-
270
+ Add the frozen_string_literal comment to the top of files
271
+ to help transition from Ruby 2.3.0 to Ruby 3.0.
272
+ Enabled: true
273
+
258
274
  Style/InitialIndentation:
259
275
  Description: >-
260
276
  Checks the indentation of the first non-blank non-comment line in a file.
@@ -297,6 +313,10 @@ Style/HashSyntax:
297
313
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#hash-literals'
298
314
  Enabled: true
299
315
 
316
+ Style/IfInsideElse:
317
+ Description: 'Finds if nodes inside else, which can be converted to elsif.'
318
+ Enabled: true
319
+
300
320
  Style/IfUnlessModifier:
301
321
  Description: >-
302
322
  Favor modifier if/unless usage when you have a
@@ -318,12 +338,25 @@ Style/IndentationWidth:
318
338
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#spaces-indentation'
319
339
  Enabled: true
320
340
 
341
+ Style/IdenticalConditionalBranches:
342
+ Description: >-
343
+ Checks that conditional statements do not have an identical
344
+ line at the end of each branch, which can validly be moved
345
+ out of the conditional.
346
+ Enabled: true
347
+
321
348
  Style/IndentArray:
322
349
  Description: >-
323
350
  Checks the indentation of the first element in an array
324
351
  literal.
325
352
  Enabled: true
326
353
 
354
+ Style/IndentAssignment:
355
+ Description: >-
356
+ Checks the indentation of the first line of the
357
+ right-hand-side of a multi-line assignment.
358
+ Enabled: true
359
+
327
360
  Style/IndentHash:
328
361
  Description: 'Checks the indentation of the first key in a hash literal.'
329
362
  Enabled: true
@@ -390,6 +423,12 @@ Style/MultilineIfThen:
390
423
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-then'
391
424
  Enabled: true
392
425
 
426
+ Style/MultilineMethodCallIndentation:
427
+ Description: >-
428
+ Checks indentation of method calls with the dot operator
429
+ that span more than one line.
430
+ Enabled: true
431
+
393
432
  Style/MultilineOperationIndentation:
394
433
  Description: >-
395
434
  Checks indentation of binary operations that span more than
@@ -403,6 +442,10 @@ Style/MultilineTernaryOperator:
403
442
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-multiline-ternary'
404
443
  Enabled: true
405
444
 
445
+ Style/MutableConstant:
446
+ Description: 'Do not assign mutable objects to constants.'
447
+ Enabled: true
448
+
406
449
  Style/NegatedIf:
407
450
  Description: >-
408
451
  Favor unless over if for negative conditions
@@ -417,6 +460,13 @@ Style/NegatedWhile:
417
460
 
418
461
  Style/NestedModifier:
419
462
  Description: 'Avoid using nested modifiers.'
463
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-modifiers'
464
+ Enabled: true
465
+
466
+ Style/NestedParenthesizedCalls:
467
+ Description: >-
468
+ Parenthesize method calls which are nested inside the
469
+ argument list of another parenthesized method call.
420
470
  Enabled: true
421
471
 
422
472
  Style/NestedTernaryOperator:
@@ -528,6 +578,10 @@ Style/RedundantFreeze:
528
578
  Description: "Checks usages of Object#freeze on immutable objects."
529
579
  Enabled: true
530
580
 
581
+ Style/RedundantParentheses:
582
+ Description: "Checks for parentheses that seem not to serve any purpose."
583
+ Enabled: true
584
+
531
585
  Style/RedundantReturn:
532
586
  Description: "Don't use return where it's not required."
533
587
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-explicit-return'
@@ -566,7 +620,7 @@ Style/Semicolon:
566
620
 
567
621
  Style/SignalException:
568
622
  Description: 'Checks for proper usage of fail and raise.'
569
- StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#fail-method'
623
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#prefer-raise-over-fail'
570
624
  Enabled: true
571
625
 
572
626
  Style/SingleLineBlockParams:
@@ -579,7 +633,7 @@ Style/SingleLineMethods:
579
633
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-single-line-methods'
580
634
  Enabled: true
581
635
 
582
- Style/SingleSpaceBeforeFirstArg:
636
+ Style/SpaceBeforeFirstArg:
583
637
  Description: >-
584
638
  Checks that exactly one space is used between a method name
585
639
  and the first argument for method calls without parentheses.
@@ -595,10 +649,6 @@ Style/SpaceAfterComma:
595
649
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#spaces-operators'
596
650
  Enabled: true
597
651
 
598
- Style/SpaceAfterControlKeyword:
599
- Description: 'Use spaces after if/elsif/unless/while/until/case/when.'
600
- Enabled: true
601
-
602
652
  Style/SpaceAfterMethodName:
603
653
  Description: >-
604
654
  Do not put a space between a method name and the opening
@@ -655,15 +705,15 @@ Style/SpaceAroundEqualsInParameterDefault:
655
705
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#spaces-around-equals'
656
706
  Enabled: true
657
707
 
708
+ Style/SpaceAroundKeyword:
709
+ Description: 'Use a space around keywords if appropriate.'
710
+ Enabled: true
711
+
658
712
  Style/SpaceAroundOperators:
659
713
  Description: 'Use a single space around operators.'
660
714
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#spaces-operators'
661
715
  Enabled: true
662
716
 
663
- Style/SpaceBeforeModifierKeyword:
664
- Description: 'Put a space before the modifier keyword.'
665
- Enabled: true
666
-
667
717
  Style/SpaceInsideBrackets:
668
718
  Description: 'No spaces after [ or before ].'
669
719
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-spaces-braces'
@@ -733,8 +783,13 @@ Style/TrailingBlankLines:
733
783
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#newline-eof'
734
784
  Enabled: true
735
785
 
736
- Style/TrailingComma:
737
- Description: 'Checks for trailing comma in parameter lists and literals.'
786
+ Style/TrailingCommaInArguments:
787
+ Description: 'Checks for trailing comma in argument lists.'
788
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
789
+ Enabled: true
790
+
791
+ Style/TrailingCommaInLiteral:
792
+ Description: 'Checks for trailing comma in array and hash literals.'
738
793
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
739
794
  Enabled: true
740
795
 
@@ -759,6 +814,10 @@ Style/UnneededCapitalW:
759
814
  Description: 'Checks for %W when interpolation is not needed.'
760
815
  Enabled: true
761
816
 
817
+ Style/UnneededInterpolation:
818
+ Description: 'Checks for strings that are just an interpolated expression.'
819
+ Enabled: true
820
+
762
821
  Style/UnneededPercentQ:
763
822
  Description: 'Checks for %q/%Q when single quotes or double quotes would do.'
764
823
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-q'
@@ -805,6 +864,10 @@ Style/WordArray:
805
864
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-w'
806
865
  Enabled: true
807
866
 
867
+ Style/ZeroLengthPredicate:
868
+ Description: 'Use #empty? when testing for objects of length 0.'
869
+ Enabled: true
870
+
808
871
  #################### Metrics ################################
809
872
 
810
873
  Metrics/AbcSize:
@@ -903,7 +966,7 @@ Lint/DeprecatedClassMethods:
903
966
  Enabled: true
904
967
 
905
968
  Lint/DuplicateMethods:
906
- Description: 'Check for duplicate methods calls.'
969
+ Description: 'Check for duplicate method definitions.'
907
970
  Enabled: true
908
971
 
909
972
  Lint/DuplicatedKey:
@@ -943,6 +1006,12 @@ Lint/Eval:
943
1006
  Description: 'The use of eval represents a serious security risk.'
944
1007
  Enabled: true
945
1008
 
1009
+ Lint/FloatOutOfRange:
1010
+ Description: >-
1011
+ Catches floating-point literals too large or small for Ruby to
1012
+ represent.
1013
+ Enabled: true
1014
+
946
1015
  Lint/FormatParameterMismatch:
947
1016
  Description: 'The number of parameters to format/sprint must match the fields.'
948
1017
  Enabled: true
@@ -952,6 +1021,18 @@ Lint/HandleExceptions:
952
1021
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions'
953
1022
  Enabled: true
954
1023
 
1024
+ Lint/ImplicitStringConcatenation:
1025
+ Description: >-
1026
+ Checks for adjacent string literals on the same line, which
1027
+ could better be represented as a single string literal.
1028
+ Enabled: true
1029
+
1030
+ Lint/IneffectiveAccessModifier:
1031
+ Description: >-
1032
+ Checks for attempts to use `private` or `protected` to set
1033
+ the visibility of a class method, which does not work.
1034
+ Enabled: true
1035
+
955
1036
  Lint/InvalidCharacterLiteral:
956
1037
  Description: >-
957
1038
  Checks for invalid character literals with a non-escaped
@@ -978,6 +1059,12 @@ Lint/NestedMethodDefinition:
978
1059
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-methods'
979
1060
  Enabled: true
980
1061
 
1062
+ Lint/NextWithoutAccumulator:
1063
+ Description: >-
1064
+ Do not omit the accumulator when calling `next`
1065
+ in a `reduce`/`inject` block.
1066
+ Enabled: true
1067
+
981
1068
  Lint/NonLocalExitFromIterator:
982
1069
  Description: 'Do not use return in iterator to cause non-local exit.'
983
1070
  Enabled: true
@@ -989,6 +1076,12 @@ Lint/ParenthesesAsGroupedExpression:
989
1076
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#parens-no-spaces'
990
1077
  Enabled: true
991
1078
 
1079
+ Lint/RandOne:
1080
+ Description: >-
1081
+ Checks for `rand(1)` calls. Such calls always return `0`
1082
+ and most likely a mistake.
1083
+ Enabled: true
1084
+
992
1085
  Lint/RequireParentheses:
993
1086
  Description: >-
994
1087
  Use parentheses in the method call to avoid confusion
@@ -1006,12 +1099,6 @@ Lint/ShadowingOuterLocalVariable:
1006
1099
  for block arguments or block local variables.
1007
1100
  Enabled: true
1008
1101
 
1009
- Lint/SpaceBeforeFirstArg:
1010
- Description: >-
1011
- Put a space between a method name and the first argument
1012
- in a method call without parentheses.
1013
- Enabled: true
1014
-
1015
1102
  Lint/StringConversionInInterpolation:
1016
1103
  Description: 'Checks for Object#to_s usage in string interpolation.'
1017
1104
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-to-s'
@@ -1069,6 +1156,12 @@ Lint/Void:
1069
1156
 
1070
1157
  ##################### Performance #############################
1071
1158
 
1159
+ Performance/Casecmp:
1160
+ Description: >-
1161
+ Use `casecmp` rather than `downcase ==`, `upcase ==`, `== downcase`, or `== upcase`..
1162
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringcasecmp-vs-stringdowncase---code'
1163
+ Enabled: true
1164
+
1072
1165
  Performance/CaseWhenSplat:
1073
1166
  Description: >-
1074
1167
  Place `when` conditions that use splat at the end
@@ -1089,6 +1182,17 @@ Performance/Detect:
1089
1182
  Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerabledetect-vs-enumerableselectfirst-code'
1090
1183
  Enabled: true
1091
1184
 
1185
+ Performance/DoubleStartEndWith:
1186
+ Description: >-
1187
+ Use `str.{start,end}_with?(x, ..., y, ...)`
1188
+ instead of `str.{start,end}_with?(x, ...) || str.{start,end}_with?(y, ...)`.
1189
+ Enabled: true
1190
+
1191
+ Performance/EndWith:
1192
+ Description: 'Use `end_with?` instead of a regex match anchored to the end of a string.'
1193
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringmatch-vs-stringstart_withstringend_with-code-start-code-end'
1194
+ Enabled: true
1195
+
1092
1196
  Performance/FixedSize:
1093
1197
  Description: 'Do not compute the size of statically sized objects except in constants'
1094
1198
  Enabled: true
@@ -1106,6 +1210,43 @@ Performance/FlatMap:
1106
1210
  # This can be dangerous since `flat_map` will only flatten 1 level, and
1107
1211
  # `flatten` without any parameters can flatten multiple levels.
1108
1212
 
1213
+ Performance/HashEachMethods:
1214
+ Description: >-
1215
+ Use `Hash#each_key` and `Hash#each_value` instead of
1216
+ `Hash#keys.each` and `Hash#values.each`.
1217
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#hash-each'
1218
+ Enabled: true
1219
+ AutoCorrect: false
1220
+
1221
+ Performance/LstripRstrip:
1222
+ Description: 'Use `strip` instead of `lstrip.rstrip`.'
1223
+ Enabled: true
1224
+
1225
+ Performance/RangeInclude:
1226
+ Description: 'Use `Range#cover?` instead of `Range#include?`.'
1227
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#cover-vs-include-code'
1228
+ Enabled: true
1229
+
1230
+ Performance/RedundantBlockCall:
1231
+ Description: 'Use `yield` instead of `block.call`.'
1232
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#proccall-vs-yield-code'
1233
+ Enabled: true
1234
+
1235
+ Performance/RedundantMatch:
1236
+ Description: >-
1237
+ Use `=~` instead of `String#match` or `Regexp#match` in a context where the
1238
+ returned `MatchData` is not needed.
1239
+ Enabled: true
1240
+
1241
+ Performance/RedundantMerge:
1242
+ Description: 'Use Hash#[]=, rather than Hash#merge! with a single key-value pair.'
1243
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#hashmerge-vs-hash-code'
1244
+ Enabled: true
1245
+
1246
+ Performance/RedundantSortBy:
1247
+ Description: 'Use `sort` instead of `sort_by { |x| x }`.'
1248
+ Enabled: true
1249
+
1109
1250
  Performance/ReverseEach:
1110
1251
  Description: 'Use `reverse_each` instead of `reverse.each`.'
1111
1252
  Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerablereverseeach-vs-enumerablereverse_each-code'
@@ -1125,6 +1266,11 @@ Performance/Size:
1125
1266
  Reference: 'https://github.com/JuanitoFatas/fast-ruby#arraycount-vs-arraysize-code'
1126
1267
  Enabled: true
1127
1268
 
1269
+ Performance/StartWith:
1270
+ Description: 'Use `start_with?` instead of a regex match anchored to the beginning of a string.'
1271
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringmatch-vs-stringstart_withstringend_with-code-start-code-end'
1272
+ Enabled: true
1273
+
1128
1274
  Performance/StringReplacement:
1129
1275
  Description: >-
1130
1276
  Use `tr` instead of `gsub` when you are replacing the same
@@ -1133,6 +1279,10 @@ Performance/StringReplacement:
1133
1279
  Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringgsub-vs-stringtr-code'
1134
1280
  Enabled: true
1135
1281
 
1282
+ Performance/TimesMap:
1283
+ Description: 'Checks for .times.map calls.'
1284
+ Enabled: true
1285
+
1136
1286
  ##################### Rails ##################################
1137
1287
 
1138
1288
  Rails/ActionFilter:
@@ -1145,10 +1295,6 @@ Rails/Date:
1145
1295
  such as Date.today, Date.current etc.
1146
1296
  Enabled: true
1147
1297
 
1148
- Rails/DefaultScope:
1149
- Description: 'Checks if the argument passed to default_scope is a block.'
1150
- Enabled: true
1151
-
1152
1298
  Rails/Delegate:
1153
1299
  Description: 'Prefer delegate method for delegations.'
1154
1300
  Enabled: true