AllCops: TargetRubyVersion: 2.4 Exclude: - vendor/**/* - Guardfile ChefAttributes: Patterns: - attributes/.*\.rb ChefDefinitions: Patterns: - definitions/.*\.rb ChefLibraries: Patterns: - libraries/.*\.rb ChefMetadata: Patterns: - metadata\.rb ChefProviders: Patterns: - providers/.*\.rb ChefRecipes: Patterns: - recipes/.*\.rb ChefResources: Patterns: - resources/.*\.rb ############################### # Making cookbooks look better ############################### Chef/AttributeKeys: Description: Check which style of keys are used to access node attributes. Enabled: true EnforcedStyle: strings VersionAdded: '5.0.0' SupportedStyles: - strings - symbols Chef/CopyrightCommentFormat: Description: Properly format copyright dates in comment blocks and ensure dates are up to date Enabled: false VersionAdded: '5.0.0' Chef/CommentSentenceSpacing: Description: Use a single space after sentences in comments Enabled: false VersionAdded: '5.1.0' Chef/CommentFormat: Description: Use Chef's unique format for comment headers Enabled: true VersionAdded: '5.0.0' ############################### # Avoiding potential problems ############################### Chef/FileMode: Description: Use strings to represent file modes in Chef resources Enabled: true VersionAdded: '5.0.0' Chef/ServiceResource: Description: Use a service resource to start and stop services instead of execute resources Enabled: true VersionAdded: '5.0.0' Chef/NodeNormal: Description: Do not use the node.normal method Enabled: true VersionAdded: '5.1.0' Chef/NodeNormalUnless: Description: Do not use the node.normal_unless method Enabled: true VersionAdded: '5.1.0' Chef/TmpPath: Description: Use file_cache_path rather than hard-coding tmp paths Enabled: true VersionAdded: '5.0.0' Chef/InsecureCookbookURL: Description: Insecure http Github or Gitlab URLs for metadata source_url/issues_url fields Enabled: true VersionAdded: '5.1.0' Include: - '**/metadata.rb' Chef/NamePropertyIsRequired: Description: Resource properties marked as name properties should not also be required properties Enabled: true VersionAdded: '5.1.0' Chef/InvalidLicenseString: Description: Cookbook metadata.rb does not use a SPDX compliant license string or "all rights reserved" Enabled: true VersionAdded: '5.2.0' Include: - '**/metadata.rb' Chef/InvalidPlatformMetadata: Description: metadata.rb "supports" platform is invalid Enabled: true VersionAdded: '5.2.0' Include: - '**/metadata.rb' ############################### # Resolving Deprecations ############################### Chef/NodeSet: Description: Do not use the deprecated node.set method Enabled: true VersionAdded: '5.0.0' Chef/NodeSetUnless: Description: Do not use the deprecated node.set_unless method Enabled: true VersionAdded: '5.1.0' Chef/EpicFail: Description: Use ignore_failure method instead of the deprecated epic_fail method Enabled: true VersionAdded: '5.1.0' Chef/CookbookDependsOnPoise: Description: Cookbooks should not depend on the deprecated Poise framework Enabled: true VersionAdded: '5.1.0' Include: - '**/metadata.rb' Chef/ConflictsMetadata: Description: Don't use the deprecated 'conflicts' metadata value Enabled: true VersionAdded: '5.1.0' Include: - '**/metadata.rb' Chef/SuggestsMetadata: Description: Don't use the deprecated 'suggests' metadata value Enabled: true VersionAdded: '5.1.0' Include: - '**/metadata.rb' Chef/ProvidesMetadata: Description: Don't use the deprecated 'provides' metadata value Enabled: true VersionAdded: '5.1.0' Include: - '**/metadata.rb' Chef/ReplacesMetadata: Description: Don't use the deprecated 'replaces' metadata value Enabled: true VersionAdded: '5.1.0' Include: - '**/metadata.rb' Chef/AttributeMetadata: Description: Don't use the deprecated 'attribute' metadata value Enabled: true VersionAdded: '5.1.0' Include: - '**/metadata.rb' Chef/LongDescriptionMetadata: Description: The long_description metadata.rb method is not used and is unnecessary in cookbooks Enabled: true VersionAdded: '5.2.0' Include: - '**/metadata.rb' Chef/CookbookDependsOnCompatResource: Description: Don't depend on the deprecated compat_resource cookbook made obsolete by Chef 12.19+ Enabled: true VersionAdded: '5.1.0' Include: - '**/metadata.rb' Chef/CookbookDependsOnPartialSearch: Description: Don't depend on the deprecated partial_search cookbook made obsolete by Chef 13+ Enabled: true VersionAdded: '5.1.0' Include: - '**/metadata.rb' Chef/EasyInstallResource: Description: Don't use the deprecated easy_install resource resource removed in Chef 13 Enabled: true VersionAdded: '5.1.0' Chef/ErlCallResource: Description: Don't use the deprecated erl_call resource removed in Chef 13 Enabled: true VersionAdded: '5.1.0' Chef/RequireRecipe: Description: Use include_recipe instead of the require_recipe method Enabled: true VersionAdded: '5.2.0' ############################### # Cleaning up Legacy Code ############################### Chef/LegacyBerksfileSource: Description: Do not use legacy Berksfile community sources. Use Chef Supermarket instead. Enabled: true VersionAdded: '5.1.0' Include: - '**/Berksfile' Chef/WhyRunSupportedTrue: Description: why_run_supported? no longer needs to be set to true as it is the default in Chef 13+ Enabled: true VersionAdded: '5.1.0' Include: - '**/resources/*.rb' - '**/providers/*.rb' - '**/libraries/*.rb' Chef/PropertyWithNameAttribute: Description: Resource property sets name_attribute not name_property Enabled: true VersionAdded: '5.1.0' Include: - '**/resources/*.rb' - '**/libraries/*.rb' Chef/PropertyWithRequiredAndDefault: Description: Resource property should not be both required and have a default value Enabled: true VersionAdded: '5.1.0' Include: - '**/resources/*.rb' - '**/libraries/*.rb' Chef/UnnecessaryDependsChef14: Description: Don't depend on cookbooks made obsolete by Chef 14 Enabled: true VersionAdded: '5.1.0' Include: - '**/metadata.rb' Chef/RespondToInMetadata: Description: It is no longer necessary to use respond_to? in metadata.rb in Chef 12.15 and later Enabled: true VersionAdded: '5.2.0' Include: - '**/metadata.rb' Chef/RespondToResourceName: Description: respond_to?(:resource_name) in resources is no longer necessary in Chef Infra Client 12.5+ Enabled: true VersionAdded: '5.2.0' Include: - '**/resources/*.rb' - '**/libraries/*.rb' Chef/RespondToProvides: Description: respond_to?(:provides) in resources is no longer necessary in Chef Infra Client 12+ Enabled: true VersionAdded: '5.2.0' Include: - '**/providers/*.rb' - '**/libraries/*.rb' Chef/SetOrReturnInResources: Description: Do not use set_or_return within a method to define a property for a resource. Use the property method instead, which supports validation, reporting, and documentation functionality. Enabled: true VersionAdded: '5.2.0' Include: - '**/resources/*.rb' - '**/libraries/*.rb' Chef/CustomResourceWithAttributes: Description: Custom Resources should contain properties not attributes. Enabled: true VersionAdded: '5.2.0' Include: - '**/resources/*.rb' Chef/CustomResourceWithAllowedActions: Description: Custom Resources don't need to define the allowed actions with allowed_actions or actions methods Enabled: true VersionAdded: '5.2.0' Include: - '**/resources/*.rb' Chef/IncludingAptDefaultRecipe: Description: Do not include the Apt default recipe to update package cache. Instead use the apt_update resource, which is built into Chef Infra Client 12.7 and later. Enabled: true VersionAdded: '5.3.0' Exclude: - '**/metadata.rb' Chef/IncludingWindowsDefaultRecipe: Description: Do not include the Windows default recipe, which only installs win32 gems already included in Chef Infra Client Enabled: true VersionAdded: '5.3.0' Exclude: - '**/metadata.rb' Chef/IncludingYumDNFCompatRecipe: Description: Do not include the yum::dnf_yum_compat default recipe to install yum on dnf systems. Chef Infra Client now includes built in support for DNF. Enabled: true VersionAdded: '5.3.0' Exclude: - '**/metadata.rb' Chef/DefinesChefSpecMatchers: Description: ChefSpec matchers are now auto generated by ChefSpec 7.1+ and do not need to be defined in a cookbook Enabled: true VersionAdded: '5.3.0' Include: - '**/libraries/*.rb' Chef/ExecuteAptUpdate: Description: Use the apt_update resource instead of the execute resource to run an apt-get update package cache update Enabled: true VersionAdded: '5.3.0' Exclude: - '**/metadata.rb' ############################### # Detecting code that breaks Chef ############################### Chef/CookbooksDependsOnSelf: Description: A cookbook cannot depend on itself Enabled: true VersionAdded: '5.2.0' Include: - '**/metadata.rb' Chef/MetadataMissingName: Description: MetadataMissingName Enabled: true VersionAdded: '5.2.0' Include: - '**/metadata.rb' Chef/BlockGuardWithOnlyString: Description: A resource guard (not_if/only_if) that is a string should not be wrapped in {}. Wrapping a guard string in {} causes it be executed as Ruby code which will always returns true instead of a shell command that will actually run. Enabled: true VersionAdded: '5.2.0' ############################### # Utilize new built-in resources ############################### Chef/UseBuildEssentialResource: Description: Use the build_essential resource instead of the legacy build-essential recipe. This resource ships in the build-essential cookbook v5.0+ and is built into Chef Infra Client 14+ Enabled: true VersionAdded: '5.1.0' ############################### # Migrating to new patterns ############################### Chef/CookbookUsesSearch: Description: Cookbook uses search, which cannot be used in the Effortless Infra pattern Enabled: false VersionAdded: '5.1.0' Chef/CookbookUsesDatabags: Description: Cookbook uses data bags, which cannot be used in the Effortless Infra pattern Enabled: false VersionAdded: '5.1.0' #### The base rubocop 0.37 enabled.yml file we started with #### Layout/AccessModifierIndentation: Enabled: true Naming/AccessorMethodName: Enabled: true Layout/AlignArray: Enabled: true Layout/AlignHash: Enabled: true Style/AndOr: Enabled: true Style/ArrayJoin: Enabled: true Naming/AsciiIdentifiers: Enabled: true Style/Attr: Enabled: true Style/BeginBlock: Enabled: true Style/BarePercentLiterals: Enabled: true Style/BlockComments: Enabled: true Layout/BlockEndNewline: Enabled: true Style/BlockDelimiters: Enabled: true Style/BracesAroundHashParameters: Enabled: true Style/CaseEquality: Enabled: true Layout/CaseIndentation: Enabled: true Style/CharacterLiteral: Enabled: true Naming/ClassAndModuleCamelCase: Enabled: true Style/ClassCheck: Enabled: true Style/ClassMethods: Enabled: true Style/ClassVars: Enabled: true Layout/ClosingParenthesisIndentation: Enabled: true Style/ColonMethodCall: Enabled: true Style/CommandLiteral: Enabled: true Style/CommentAnnotation: Enabled: true Layout/CommentIndentation: Enabled: true Style/ConditionalAssignment: Enabled: true Naming/ConstantName: Enabled: true Style/DefWithParentheses: Enabled: true Style/DeprecatedHashMethods: Enabled: true Layout/DotPosition: Enabled: true Style/EachWithObject: Enabled: true Layout/ElseAlignment: Enabled: true Style/EmptyElse: Enabled: true Layout/EmptyLineBetweenDefs: Enabled: true Layout/EmptyLines: Enabled: true Layout/EmptyLinesAroundAccessModifier: Enabled: true Layout/EmptyLinesAroundBlockBody: Enabled: true Layout/EmptyLinesAroundClassBody: Enabled: true Layout/EmptyLinesAroundModuleBody: Enabled: true Layout/EmptyLinesAroundMethodBody: Enabled: true Style/EmptyLiteral: Enabled: true Style/EndBlock: Enabled: true Style/EvenOdd: Enabled: true Layout/ExtraSpacing: Enabled: true Layout/InitialIndentation: Enabled: true Layout/FirstParameterIndentation: Enabled: true Lint/FlipFlop: Enabled: true Style/For: Enabled: true Style/FormatString: Enabled: true Style/GlobalVars: Enabled: true Style/HashSyntax: Enabled: true Style/IfInsideElse: Enabled: true Style/IfWithSemicolon: Enabled: true Layout/IndentationConsistency: Enabled: true Layout/IndentationWidth: Enabled: true Style/IdenticalConditionalBranches: Enabled: true Layout/IndentArray: Enabled: true Layout/IndentAssignment: Enabled: true Layout/IndentHash: Enabled: true Style/InfiniteLoop: Enabled: true Style/Lambda: Enabled: true Style/LambdaCall: Enabled: true Layout/LeadingCommentSpace: Enabled: true Style/LineEndConcatenation: Enabled: true Style/MethodCallParentheses: Enabled: true Style/MethodDefParentheses: Enabled: true Naming/MethodName: Enabled: true Style/ModuleFunction: Enabled: true Style/MultilineBlockChain: Enabled: true Layout/MultilineBlockLayout: Enabled: true Style/MultilineIfThen: Enabled: true Layout/MultilineMethodCallIndentation: Enabled: true Layout/MultilineOperationIndentation: Enabled: true Style/MultilineTernaryOperator: Enabled: true Style/MutableConstant: Enabled: true Style/NegatedIf: Enabled: true Style/NegatedWhile: Enabled: true Style/NestedModifier: Enabled: true Style/NestedParenthesizedCalls: Enabled: true Style/NestedTernaryOperator: Enabled: true Style/Next: Enabled: true Style/NilComparison: Enabled: true Style/NonNilCheck: Enabled: true Style/Not: Enabled: true Style/OneLineConditional: Enabled: true Naming/OpMethod: Enabled: true Style/OptionalArguments: Enabled: true Style/ParallelAssignment: Enabled: true Style/ParenthesesAroundCondition: Enabled: true Style/PercentQLiterals: Enabled: true Style/PerlBackrefs: Enabled: true Naming/PredicateName: Enabled: true Style/Proc: Enabled: true Style/RaiseArgs: Enabled: true Style/RedundantBegin: Enabled: true Style/RedundantException: Enabled: true Style/RedundantFreeze: Enabled: true Style/RedundantParentheses: Enabled: true Style/RedundantReturn: Enabled: true Style/RedundantSelf: Enabled: true Style/RegexpLiteral: Enabled: true Layout/RescueEnsureAlignment: Enabled: true Style/RescueModifier: Enabled: true Style/SelfAssignment: Enabled: true Style/Semicolon: Enabled: true Style/SignalException: Enabled: true Style/SingleLineBlockParams: Enabled: true Style/SingleLineMethods: Enabled: true Layout/SpaceAfterColon: Enabled: true Layout/SpaceAfterComma: Enabled: true Layout/SpaceAfterMethodName: Enabled: true Layout/SpaceAfterNot: Enabled: true Layout/SpaceAfterSemicolon: Enabled: true Layout/SpaceBeforeBlockBraces: Enabled: true Layout/SpaceBeforeComma: Enabled: true Layout/SpaceBeforeComment: Enabled: true Layout/SpaceBeforeSemicolon: Enabled: true Layout/SpaceInsideBlockBraces: Enabled: true Layout/SpaceAroundBlockParameters: Enabled: true Layout/SpaceAroundEqualsInParameterDefault: Enabled: true Layout/SpaceAroundKeyword: Enabled: true Layout/SpaceAroundOperators: Enabled: true Layout/SpaceInsideHashLiteralBraces: Enabled: true Layout/SpaceInsideParens: Enabled: true Layout/SpaceInsideRangeLiteral: Enabled: true Layout/SpaceInsideStringInterpolation: Enabled: true Style/SpecialGlobalVars: Enabled: true Style/StabbyLambdaParentheses: Enabled: true Style/StringLiterals: Enabled: true Style/StringLiteralsInInterpolation: Enabled: true Style/StructInheritance: Enabled: true Style/SymbolLiteral: Enabled: true Layout/Tab: Enabled: true Layout/TrailingBlankLines: Enabled: true Style/TrailingCommaInArguments: Enabled: true Layout/TrailingWhitespace: Enabled: true Style/TrivialAccessors: Enabled: true Style/UnlessElse: Enabled: true Style/UnneededCapitalW: Enabled: true Style/UnneededInterpolation: Enabled: true Style/UnneededPercentQ: Enabled: true Style/TrailingUnderscoreVariable: Enabled: true Style/VariableInterpolation: Enabled: true Naming/VariableName: Enabled: true Style/WhenThen: Enabled: true Style/WhileUntilDo: Enabled: true Style/WhileUntilModifier: Enabled: true Style/WordArray: Enabled: true Style/ZeroLengthPredicate: Enabled: true Metrics/BlockNesting: Enabled: true Metrics/ParameterLists: Enabled: true Lint/AmbiguousOperator: Enabled: true Lint/AssignmentInCondition: Enabled: true Layout/BlockAlignment: Enabled: true Lint/CircularArgumentReference: Enabled: true Layout/ConditionPosition: Enabled: true Lint/Debugger: Enabled: true Layout/DefEndAlignment: Enabled: true Lint/DeprecatedClassMethods: Enabled: true Lint/DuplicateMethods: Enabled: true Lint/DuplicatedKey: Enabled: true Lint/EachWithObjectArgument: Enabled: true Lint/ElseLayout: Enabled: true Lint/EmptyEnsure: Enabled: true Lint/EmptyInterpolation: Enabled: true Layout/EndAlignment: Enabled: true Lint/EndInMethod: Enabled: true Lint/EnsureReturn: Enabled: true Security/Eval: Enabled: true Lint/FloatOutOfRange: Enabled: true Lint/FormatParameterMismatch: Enabled: true Lint/HandleExceptions: Enabled: true Lint/ImplicitStringConcatenation: Enabled: true Lint/IneffectiveAccessModifier: Enabled: true Lint/LiteralAsCondition: Enabled: true Lint/LiteralInInterpolation: Enabled: true Lint/Loop: Enabled: true Lint/NestedMethodDefinition: Enabled: true Lint/NextWithoutAccumulator: Enabled: true Lint/NonLocalExitFromIterator: Enabled: true Lint/ParenthesesAsGroupedExpression: Enabled: true Lint/RandOne: Enabled: true Lint/RequireParentheses: Enabled: true Lint/RescueException: Enabled: true Lint/ShadowingOuterLocalVariable: Enabled: true Lint/StringConversionInInterpolation: Enabled: true Lint/UnderscorePrefixedVariableName: Enabled: true Lint/UnneededCopDisableDirective: Enabled: true Lint/UnusedBlockArgument: Enabled: true Lint/UnusedMethodArgument: Enabled: true Lint/UnreachableCode: Enabled: true Lint/UselessAccessModifier: Enabled: true Lint/UselessAssignment: Enabled: true Lint/UselessComparison: Enabled: true Lint/UselessElseWithoutRescue: Enabled: true Lint/UselessSetterCall: Enabled: true Lint/Void: Enabled: true ##### Additional rules we enable/disable over the rubocop 0.37 rules ago ##### Layout/AlignParameters: Enabled: false Style/Encoding: Enabled: false Style/Alias: Enabled: false Layout/SpaceBeforeFirstArg: Enabled: false Style/ClassAndModuleChildren: Enabled: false Style/DoubleNegation: Enabled: false # file names don't matter in cookbooks Naming/FileName: Enabled: false # disable all the length cops as they're not appropriate for cookbooks Metrics/LineLength: Enabled: false Metrics/MethodLength: Enabled: false Metrics/BlockLength: Enabled: false Metrics/AbcSize: Enabled: false Metrics/ModuleLength: Enabled: false Metrics/ClassLength: Enabled: false Metrics/CyclomaticComplexity: Enabled: false Metrics/PerceivedComplexity: Enabled: false # https://github.com/chef/cookstyle/pull/5 Style/TrailingCommaInHashLiteral: Enabled: true EnforcedStyleForMultiline: comma # https://github.com/chef/cookstyle/pull/5 Style/TrailingCommaInArrayLiteral: Enabled: true EnforcedStyleForMultiline: comma # Underscores in numbers are unnecessary, especially for port numbers where they are unexpected Style/NumericLiterals: Enabled: false # This often triggers no matter what you do with inspec/serverspec matchers Lint/AmbiguousRegexpLiteral: Enabled: false # some names are not ascii and this prevents copyright comments Style/AsciiComments: Enabled: false # avoid case statements where the 2nd 'when' would never fire Lint/DuplicateCaseCondition: Enabled: true # empty expressions serve no purpose Lint/EmptyExpression: Enabled: true # when in a case statement should always do something Lint/EmptyWhen: Enabled: true # %w('something') is almost always a typo Lint/PercentStringArray: Enabled: true # %w(:something) should be a string not a symbol Lint/PercentSymbolArray: Enabled: true # if you rescue Exception, then rescue say StandardError you're gonna have a bad time Lint/ShadowedException: Enabled: true # We're on modern ruby so let's assume Integer everywhere Lint/UnifiedInteger: Enabled: true # consistent hash key/value checks Style/PreferredHashMethods: Enabled: true # when iterating a fixed number of times this is much easier to read Style/EachForSimpleLoop: Enabled: true # a case statement without a condition is just an if statement Style/EmptyCaseCondition: Enabled: true # == 0 is more performant than .zero? and .zero? also introduced several regressions Style/NumericPredicate: Enabled: true EnforcedStyle: comparison # this is bad %w(something another_thing one_more) Layout/SpaceInsideArrayPercentLiteral: Enabled: true # There's no reason to have a gem listed twice Bundler/DuplicatedGem: Enabled: true # This results in very confusing code to read with little perf benefit Performance/Casecmp: Enabled: false # This comes with changing the ruby target to 2.3+ Style/FrozenStringLiteralComment: Enabled: false # maintain the previous array behavior in previous cookstyle releases Style/PercentLiteralDelimiters: Enabled: true PreferredDelimiters: '%': () '%i': () '%I': () '%q': () '%Q': () '%r': '{}' '%s': () '%w': () '%W': () '%x': () # backwards conditions are hard to read Style/YodaCondition: Enabled: true Layout/EmptyLinesAroundExceptionHandlingKeywords: Enabled: true # enforce lf to avoid failures on Windows systems Layout/EndOfLine: Enabled: true EnforcedStyle: lf # guardclause sacrifices ease of readability for consistency at times Style/GuardClause: Enabled: false # Users really shouldn't have a gem, but if they do they should do it securely Bundler/InsecureProtocolSource: Enabled: true # It's easier to read a simple .each and they're faster Lint/RedundantWithIndex: Enabled: true # Catches when a user single quotes a string with interpolation Lint/InterpolationCheck: Enabled: true # Bad: `bar = [foo.min, foo.max]`. Good: bar = foo.minmax Style/MinMax: Enabled: true # Avoid ruby deprecation warnings Lint/UriRegexp: Enabled: true Performance/UriDefaultParser: Enabled: true # :true or :false seems like a horrible idea Lint/BooleanSymbol: Enabled: true # this avoids very verbose code for no reason Style/RedundantConditional: Enabled: true # catches people writing a regex check wrong Lint/RegexpInCondition: Enabled: true # Avoids pointless / complex code Lint/RedundantWithObject: Enabled: true # avoid requiring things that come for free Lint/UnneededRequireStatement: Enabled: true # Avoid poorly formatted methods Style/TrailingBodyOnMethodDefinition: Enabled: true # Avoid weird empty lines in an argument Layout/EmptyLinesAroundArguments: Enabled: true # don't shadow arguments Lint/ShadowedArgument: Enabled: true # find orphaned empty comments Layout/EmptyComment: Enabled: true # warn on deprecated functionality Lint/BigDecimalNew: Enabled: true # remove bogus rubocop comments. We already enabled Disable directives Lint/UnneededCopEnableDirective: Enabled: true # get people on a much simpler ruby 2.4 way of doing things Style/UnpackFirst: Enabled: true Style/SymbolProc: Enabled: true # A list of method names to be ignored by the check. # The names should be fairly unique, otherwise you'll end up ignoring lots of code. IgnoredMethods: - lazy # as much as I wish everyone would document things it's just not going to happen Style/Documentation: Enabled: false # compact code is nice, but this is actually harder to read for new users Style/IfUnlessModifier: Enabled: false # in general cookbooks shouldn't include a gemfile, but if they do they can do with it as they wish Bundler/OrderedGems: Enabled: false