-
Notifications
You must be signed in to change notification settings - Fork 7
/
chefstyle.yml
733 lines (668 loc) · 17.6 KB
/
chefstyle.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
AllCops:
TargetRubyVersion: 2.5
NewCops: disable
DisabledByDefault: true
SuggestExtensions: false
#
# Bundler
#
Bundler/DuplicatedGem:
Enabled: false
Bundler/InsecureProtocolSource:
Enabled: true
AllowHttpProtocol: false
#
# Lint
#
Lint/AmbiguousOperator:
Enabled: true
Lint/AmbiguousBlockAssociation:
Enabled: true
Lint/AmbiguousRegexpLiteral:
Enabled: true
Lint/AssignmentInCondition:
Enabled: true
Layout/BlockAlignment:
EnforcedStyleAlignWith: start_of_block
Enabled: true
Lint/CircularArgumentReference:
Enabled: true
Layout/ConditionPosition:
Enabled: true
Lint/Debugger:
Enabled: true
Layout/DefEndAlignment:
Enabled: true
AutoCorrect: true
Lint/DeprecatedClassMethods:
Enabled: true
Lint/DuplicateCaseCondition:
Enabled: true
Lint/DuplicateMethods:
Enabled: true
# Lint/DuplicatedKey: TODO broken with rubocop 1.25.1 move
# Enabled: true
Lint/EachWithObjectArgument:
Enabled: true
Lint/ElseLayout:
Enabled: true
Lint/EmptyEnsure:
Enabled: true
Lint/EmptyExpression:
Enabled: true
Lint/EmptyInterpolation:
Enabled: true
Lint/EmptyWhen:
Enabled: true
Layout/EndAlignment:
Enabled: true
AutoCorrect: true
# Lint/EndInMethod: TODO broken with rubocop 1.25.1 move
# Enabled: true
Lint/EnsureReturn:
Enabled: true
Lint/FloatOutOfRange:
Enabled: true
Lint/FormatParameterMismatch:
Enabled: true
Lint/ImplicitStringConcatenation:
Enabled: true
Lint/InheritException:
Enabled: true
Lint/IneffectiveAccessModifier:
Enabled: true
Lint/LiteralAsCondition:
Enabled: true
Lint/LiteralInInterpolation:
Enabled: true
Lint/Loop:
Enabled: true
# Lint/MultipleCompare: TODO broken with rubocop 1.25.1 move
# Enabled: true
Lint/NestedMethodDefinition:
Enabled: true
Lint/NextWithoutAccumulator:
Enabled: true
Lint/NonLocalExitFromIterator:
Enabled: true
Lint/ParenthesesAsGroupedExpression:
Enabled: true
Lint/PercentStringArray:
Enabled: true
Lint/PercentSymbolArray:
Enabled: true
Lint/RandOne:
Enabled: true
Lint/RequireParentheses:
Enabled: true
Lint/SafeNavigationChain:
Enabled: true
Lint/ShadowedException:
Enabled: true
Lint/ShadowingOuterLocalVariable:
Enabled: true
# Lint/StringConversionInInterpolation: TODO broken with rubocop 1.25.1 move
# Enabled: true
Lint/UnderscorePrefixedVariableName:
Enabled: true
Lint/UnifiedInteger:
Enabled: true
# Lint/UnneededSplatExpansion: TODO broken with rubocop 1.25.1 move
# Enabled: true
Lint/UnreachableCode:
Enabled: true
Lint/UriEscapeUnescape:
Enabled: true
Lint/UselessAccessModifier:
Enabled: true
Lint/UselessAssignment:
Enabled: true
# Lint/UselessComparison: TODO broken with rubocop 1.25.1 move
# Enabled: true
Lint/UselessElseWithoutRescue:
Enabled: true
Lint/UselessSetterCall:
Enabled: true
Lint/Void:
Enabled: true
Layout/CommentIndentation:
Enabled: true
#
# Disabled Lint
#
# These are disabled per https://github.com/chef/chef/pull/3038
Lint/UnusedBlockArgument:
Enabled: false
Lint/UnusedMethodArgument:
Enabled: false
# We ignore Exceptions a lot
Lint/SuppressedException:
Enabled: false
# We also decorate Exceptions a lot
Lint/RescueException:
Enabled: false
# disabling this will make it easier to stage chefstyle rollouts
Lint/RedundantCopDisableDirective:
Enabled: false
#
# Security
#
Security/Eval:
Enabled: true
#
# Metrics
#
# Metrics cops are all disabled, there would be too much refactoring
# work to do and we have much higher priorities.
Metrics/AbcSize:
Enabled: false
Metrics/BlockNesting:
Enabled: false
Metrics/BlockLength:
Enabled: false
Metrics/ClassLength:
Enabled: false
Metrics/CyclomaticComplexity:
Enabled: false
Layout/LineLength:
Enabled: false
Metrics/MethodLength:
Enabled: false
Metrics/ModuleLength:
Enabled: false
Metrics/ParameterLists:
Enabled: false
Metrics/PerceivedComplexity:
Enabled: false
#
# Style/Naming/Layout
#
Layout/AccessModifierIndentation:
Enabled: true
# Layout/AlignArguments: TODO broken with rubocop 1.25.1 move
# Enabled: true
# EnforcedStyle: with_fixed_indentation
# Layout/AlignParameters: TODO broken with rubocop 1.25.1 move
# Enabled: true
# EnforcedStyle: with_fixed_indentation
# the "ignore_implict" is here for keyword args in method calls which are
# "implicit" hashes, and those should not be treated like normal hashes
# Layout/AlignHash: TODO broken with rubocop 1.25.1 move
# Enabled: true
# EnforcedLastArgumentHashStyle: ignore_implicit
Style/AndOr:
Enabled: true
Style/ArrayJoin:
Enabled: true
Naming/AsciiIdentifiers:
Enabled: true
Style/Attr:
Enabled: true
Style/BeginBlock:
Enabled: true
# there's debate over one-liner vs semantic blockstyle, chef projects should just pick one style
# and stick with it.
Style/BlockDelimiters:
Enabled: false
Layout/BlockEndNewline:
Enabled: true
Style/CharacterLiteral:
Enabled: true
Style/ClassCheck:
Enabled: true
Style/ClassMethods:
Enabled: true
Layout/ClosingHeredocIndentation:
Enabled: true
Layout/ClosingParenthesisIndentation:
Enabled: true
Style/ColonMethodCall:
Enabled: true
Style/CommandLiteral:
Enabled: true
Naming/ConstantName:
Enabled: true
Style/DefWithParentheses:
Enabled: true
Layout/DotPosition:
Enabled: True
Style/EachForSimpleLoop:
Enabled: true
Layout/ElseAlignment:
Enabled: true
Layout/EmptyLineAfterGuardClause:
Enabled: true
Layout/EmptyLineBetweenDefs:
Enabled: true
AllowAdjacentOneLineDefs: true
Layout/EmptyLines:
Enabled: true
Layout/EmptyLinesAroundAccessModifier:
Enabled: true
Layout/EmptyLinesAroundMethodBody:
Enabled: true
Style/EmptyLiteral:
Enabled: true
Style/EmptyMethod:
Enabled: true
Style/EndBlock:
Enabled: true
Layout/EndOfLine:
Enabled: true
EnforcedStyle: lf
Style/EvenOdd:
Enabled: true
Layout/ExtraSpacing:
Enabled: true
Lint/FlipFlop:
Enabled: true
Style/For:
Enabled: true
Style/HashSyntax:
Enabled: true
Naming/HeredocDelimiterCase:
Enabled: true
Style/IfUnlessModifierOfIfUnless:
Enabled: true
Style/IfWithSemicolon:
Enabled: true
# Layout/IndentAssignment: TODO broken with rubocop 1.25.1 move
# Enabled: true
# Layout/IndentFirstArgument: TODO broken with rubocop 1.25.1 move
# EnforcedStyle: consistent
# Enabled: true
# Layout/IndentHeredoc: TODO broken with rubocop 1.25.1 move
# Enabled: true
Layout/IndentationConsistency:
Enabled: true
Layout/IndentationWidth:
Enabled: true
Style/InfiniteLoop:
Enabled: true
Layout/InitialIndentation:
Enabled: true
Style/LambdaCall:
Enabled: true
Layout/LeadingCommentSpace:
Enabled: true
Style/MethodDefParentheses:
Enabled: true
Style/MethodCallWithoutArgsParentheses:
Enabled: true
Layout/MultilineBlockLayout:
Enabled: true
Style/MultilineIfModifier:
Enabled: true
Style/MultilineIfThen:
Enabled: true
Style/MultilineMemoization:
Enabled: true
Layout/MultilineMethodCallBraceLayout:
Enabled: true
Layout/MultilineMethodCallIndentation:
Enabled: true
EnforcedStyle: indented
Layout/MultilineMethodDefinitionBraceLayout:
Enabled: true
Layout/MultilineOperationIndentation:
Enabled: true
EnforcedStyle: indented
Style/MultilineTernaryOperator:
Enabled: true
Style/MutableConstant:
Enabled: true
Style/NegatedIf:
Enabled: true
Style/NegatedWhile:
Enabled: true
Style/NegatedUnless:
Enabled: true
Style/NestedModifier:
Enabled: true
Style/NestedTernaryOperator:
Enabled: true
Style/NilComparison:
Enabled: true
Style/NonNilCheck:
Enabled: true
# `foo.zero?` is slower and substantially more annoying to read than `foo == 0`
Style/NumericPredicate:
Enabled: true
EnforcedStyle: comparison
Style/OneLineConditional:
Enabled: true
Naming/BinaryOperatorParameterName:
Enabled: true
Style/OptionalArguments:
Enabled: true
Style/ParenthesesAroundCondition:
Enabled: true
# - The chef source code predominantly uses {} for %,%i,%q,%Q,%r,%w,%W
# - The old 1.9 pickaxe book predominantly uses {} for %,%q,%Q,%r,%w,%W,%x
# - The chef source code does not use %x enough to determine a preference
# - The old 1.9 pickaxe book does not use %i
# - %s is not used in chef code or the pickaxe book, and is %s{} for consistency
Style/PercentLiteralDelimiters:
Enabled: true
PreferredDelimiters:
'%': '{}'
'%i': '{}'
'%I': '{}'
'%q': '{}'
'%Q': '{}'
'%r': '{}'
'%s': '{}'
'%w': '{}'
'%W': '{}'
'%x': '{}'
Style/PercentQLiterals:
Enabled: true
Style/PreferredHashMethods:
Enabled: true
Style/RedundantBegin:
Enabled: true
Style/RedundantException:
Enabled: true
Style/RedundantFreeze:
Enabled: true
Style/RedundantReturn:
Enabled: true
Style/RedundantSelf:
Enabled: true
Layout/RescueEnsureAlignment:
Enabled: true
Style/RegexpLiteral:
Enabled: true
# temporarily disabled, but we should do this
Style/SafeNavigation:
Enabled: false
Style/SelfAssignment:
Enabled: true
Style/Semicolon:
AllowAsExpressionSeparator: true
Enabled: true
# we only 'raise' and do not 'fail'
Style/SignalException:
EnforcedStyle: only_raise
Enabled: true
Layout/SpaceAfterColon:
Enabled: true
Layout/SpaceAfterComma:
Enabled: true
Layout/SpaceAfterMethodName:
Enabled: true
Layout/SpaceAfterSemicolon:
Enabled: true
Layout/SpaceAroundBlockParameters:
Enabled: true
Layout/SpaceAroundEqualsInParameterDefault:
Enabled: true
Layout/SpaceAroundOperators:
Enabled: true
Layout/SpaceBeforeBlockBraces:
Enabled: true
Layout/SpaceBeforeComment:
Enabled: true
Layout/SpaceBeforeSemicolon:
Enabled: true
Layout/SpaceAroundKeyword:
Enabled: true
Layout/SpaceInLambdaLiteral:
Enabled: true
Layout/SpaceInsideArrayPercentLiteral:
Enabled: true
Layout/SpaceInsideBlockBraces:
Enabled: true
Layout/SpaceInsideHashLiteralBraces:
Enabled: true
Layout/SpaceInsideRangeLiteral:
Enabled: true
Layout/SpaceInsideStringInterpolation:
Enabled: true
Style/StabbyLambdaParentheses:
Enabled: true
# core chef community prefers double quotes over single quotes
Style/StringLiterals:
EnforcedStyle: double_quotes
Enabled: true
Style/StringLiteralsInInterpolation:
EnforcedStyle: double_quotes
Enabled: true
Style/StructInheritance:
Enabled: true
Style/SymbolLiteral:
Enabled: true
Style/StringMethods:
Enabled: true
Style/SymbolArray:
Enabled: true
Style/SymbolProc:
Enabled: true
Layout/IndentationStyle:
Enabled: true
# Layout/TrailingBlankLines: TODO broken with rubocop 1.25.1 move
# Enabled: true
Style/TrailingCommaInArguments:
Enabled: true
# rubocop's default gets this completely backwards
Style/TrailingCommaInArrayLiteral:
Enabled: true
EnforcedStyleForMultiline: comma
Style/TrailingCommaInHashLiteral:
Enabled: true
EnforcedStyleForMultiline: comma
Style/TrailingUnderscoreVariable:
Enabled: true
Layout/TrailingWhitespace:
Enabled: true
# Style/UnneededCapitalW: TODO broken with rubocop 1.25.1 move
# Enabled: true
Style/RedundantInterpolation:
Enabled: false # buggy: https://github.com/rubocop-hq/rubocop/issues/6099
#Style/UnneededPercentQ: # would like to enable this one but its buggy as of 0.35.1
# Enabled: true
Naming/VariableName:
Enabled: true
Style/VariableInterpolation:
Enabled: true
Style/WhenThen:
Enabled: true
Style/WhileUntilDo:
Enabled: true
Style/WhileUntilModifier:
Enabled: true
Style/WordArray:
Enabled: true
# we are ruby > 2.0 only so we can remove encoding comments for utf-8
Style/Encoding:
Enabled: true
#
# Disabled Style
#
# reduces memory usage, but isn't a simple autocorrect so we need to do this one project at a time
Style/FrozenStringLiteralComment:
Enabled: false
# As of this commit we have 686 modules and classes without docs.
# This is a cop that we /should/ have enabled, but tactically we can't really enable.
Style/Documentation:
Enabled: false
Style/DocumentationMethod:
Enabled: false
# this makes whitespace formatting of DSL code impossible
Layout/SpaceBeforeFirstArg:
Enabled: false
# whitespace in expressions is useful to enhance readability
Layout/SpaceInsideArrayLiteralBrackets:
Enabled: false
Layout/SpaceInsideReferenceBrackets:
Enabled: false
Layout/SpaceInsideParens:
Enabled: false
Layout/SpaceInsidePercentLiteralDelimiters:
Enabled: false
# more whitespace cops that we allow since they can enhance readability
Layout/EmptyLinesAroundBlockBody:
Enabled: false
Layout/EmptyLinesAroundClassBody:
Enabled: false
Layout/EmptyLinesAroundModuleBody:
Enabled: false
# double negation is perfectly idiomatic ruby
Style/DoubleNegation:
Enabled: false
# format strings are also perfectly idiomatic ruby
Style/FormatString:
Enabled: false
# single line if/unless blocks may read more naturally than modifiers
Style/IfUnlessModifier:
Enabled: false
# Dan is -1 on this one: https://github.com/chef/chef/pull/4526#issuecomment-179950045
Layout/FirstHashElementIndentation:
Enabled: false
# This is overly aggressive and autofix broke stuff, would need to exclude classes
# - https://github.com/chef/chef/pull/4541
Style/TrivialAccessors:
Enabled: false
# Not a lot of offenses and this seems to catch code that looks otherwise fine to my eye
Style/MultilineBlockChain:
Enabled: false
# We see nothing at all wrong with a trailing `rescue nil`
Style/RescueModifier:
Enabled: false
# Resulted in a bit of a bikeshed over names with unicode chars vs silently hidden unicode chars in comments
Style/AsciiComments:
Enabled: false
# Parens around ternaries often make them more readable and reduces cognitive load over operator precedence
Style/TernaryParentheses:
Enabled: false
# Underscores in numbers are super ugly for port numbers, freebsd versions, etc.
# If we could mandate that this gets turned on only for numbers >= 1e9 which require three _'s then maybe.
Style/NumericLiterals:
Enabled: false
# I tend to find this more readable than long elsif chains
Style/EmptyCaseCondition:
Enabled: false
# This didn't quite do what we need
Layout/MultilineArrayBraceLayout:
Enabled: false
# This rule isn't smart enough to figure out accessors vs. things that set stuff on the system (e.g. set_member method in group providers)
Naming/AccessorMethodName:
Enabled: false
# Perl backrefs are just fine and the alternative is a lot of typing.
Style/PerlBackrefs:
Enabled: false
# This has an annoying auto-fix which fails to `require "english"` and then fails silently
Style/SpecialGlobalVars:
Enabled: false
# This cop is horrible and I hate the code it produces (even though I tend to like GuardClauses in lots of cases)
Style/GuardClause:
Enabled: false
Style/RedundantSortBy:
Enabled: true
Style/Sample:
Enabled: true
# Let authors order gems however makes sense
Bundler/OrderedGems:
Enabled: false
# Naming cops produce fairly pointless makework (e.g. EOF on HEREDOC's is
# perfectly fine and understandable, using 'ip' as a parameter to a function
# is also perfectly descriptive even though its only 2 characters...).
Naming/HeredocDelimiterNaming:
Enabled: false
Naming/PredicateName:
Enabled: false
Naming/MethodParameterName:
Enabled: false
Naming/MemoizedInstanceVariableName:
Enabled: false
Naming/VariableNumber:
Enabled: false
# We almost never use format strings but this cop triggers on any string with "%{whatever}" in it and is 99% false positives
Style/FormatStringToken:
Enabled: false
# This cop is annoying. The rubocop default of course goes against the most popular community guidelines due to contrariness
# and then the autocorrect mangles specs in chef/chef. Burned more time than it was worth looking at this one so its off.
Style/Alias:
Enabled: false
# No autofix for this one, and I don't care to fix 138 instances of it in the chef/chef codebase. Don't think its worth wasting
# anyone else's time either.
Style/CommentedKeyword:
Enabled: false
# make sure we catch this Ruby 3.0 breaking change now
Lint/DeprecatedOpenSSLConstant:
Enabled: true
# alert on invalid ruby synatx
Lint/Syntax:
Enabled: true
# remove extra requires like 'thread'
Lint/RedundantRequireStatement:
Enabled: true
# simplify stripping strings
Style/Strip:
Enabled: true
# simplify getting min/max
Style/RedundantSort:
Enabled: true
# no need for .rb in requires
Style/RedundantFileExtensionInRequire:
Enabled: true
# more code you don't need
Style/RedundantCondition:
Enabled: true
# Use __dir__ to simplify things
Style/Dir:
Enabled: true
# Use __FILE__ or __dir__ to simplify expand_paths
Style/ExpandPathArguments:
Enabled: true
# more code you don't need
Lint/RedundantSafeNavigation:
Enabled: true
# Eases readability
Lint/RedundantStringCoercion:
Enabled: true
# unnecessary complexity
Lint/RedundantWithObject:
Enabled: true
# unnecessary complexity
Lint/RedundantWithIndex:
Enabled: true
# avoid requiring twice
Lint/DuplicateRequire:
Enabled: true
# detect assignment typos
Lint/AmbiguousAssignment:
Enabled: true
Chef/Ruby/Ruby27KeywordArgumentWarnings:
Description: Pass options to shell_out helpers without the brackets to avoid Ruby 2.7 deprecation warnings.
Enabled: true
VersionAdded: '1.3.0'
Chef/Ruby/UnlessDefinedRequire:
Description: Workaround RubyGems' slow requires by only running require if the constant isn't already defined
Enabled: true
VersionAdded: '1.3.0'
Include:
- 'lib/**/*'
Chef/Ruby/GemspecRequireRubygems:
Description: Rubygems does not need to be required in a Gemspec
Enabled: true
VersionAdded: '1.3.0'
Include:
- '**/*.gemspec'
Chef/Ruby/GemspecLicense:
Description: 'All gemspec files should define their license.'
Enabled: true
VersionAdded: '1.7.0'
Include:
- '**/*.gemspec'
Exclude:
- '/**/spec/**/*'
- '/**/test/**/*'
Chef/Ruby/RequireNetHttps:
Description: net/https is deprecated and just includes net/http and openssl. We should include those directly instead
Enabled: true
VersionAdded: '1.3.0'
Chef/Ruby/LegacyPowershellOutMethods:
Description: Use powershell_exec!/powershell_exec instead of the slower legacy powershell_out!/powershell_out methods.
Enabled: true
VersionAdded: '1.6.0'