AllCops: SuggestExtensions: false TargetRubyVersion: 2.5 TargetChefVersion: ~ Exclude: - '**/files/**/*' - '**/vendor/**/*' - Guardfile ############################### # Chef/Style: Making cookbooks look better ############################### Chef/Style: StyleGuideBaseURL: https://docs.chef.io/workstation/cookstyle/ Chef/Style/AttributeKeys: Description: Check which style of keys are used to access node attributes. StyleGuide: 'chef_style_attributekeys' Enabled: true EnforcedStyle: strings VersionAdded: '5.0.0' SupportedStyles: - strings - symbols Exclude: - '**/metadata.rb' Chef/Style/CopyrightCommentFormat: Description: Properly format copyright dates in comment blocks and ensure dates are up to date StyleGuide: 'chef_style_copyrightcommentformat' Enabled: false VersionAdded: '5.0.0' Chef/Style/CommentSentenceSpacing: Description: Use a single space after sentences in comments StyleGuide: 'chef_style_commentsentencespacing' Enabled: false VersionAdded: '5.1.0' Chef/Style/CommentFormat: Description: Use Chef's unique format for comment headers StyleGuide: 'chef_style_commentformat' Enabled: true VersionAdded: '5.0.0' Exclude: - '**/Berksfile' Chef/Style/FileMode: Description: Use strings to represent file modes to avoid confusion between octal and base 10 integer formats. StyleGuide: 'chef_style_filemode' Enabled: true VersionAdded: '5.0.0' Exclude: - '**/attributes/*' - '**/metadata.rb' - '**/Berksfile' Chef/Style/UsePlatformHelpers: Description: Use platform? and platform_family? helpers to check node platform in resources and recipes StyleGuide: 'chef_style_useplatformhelpers' Enabled: true VersionAdded: '5.6.0' Exclude: - '**/metadata.rb' - '**/libraries/*' - '**/Berksfile' Chef/Style/SimplifyPlatformMajorVersionCheck: Description: Use node['platform_version'].to_i instead of node['platform_version'].split('.').first or node['platform_version'].split('.')[0] StyleGuide: 'chef_style_simplifyplatformmajorversioncheck' Enabled: true VersionAdded: '5.8.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Style/DefaultCopyrightComments: Description: Cookbook copyright comment headers should be updated for a real person or organization. StyleGuide: 'chef_style_defaultcopyrightcomments' Enabled: true VersionAdded: '5.12.0' Chef/Style/UnnecessaryPlatformCaseStatement: Description: Use the platform?() and platform_family?() helpers instead of a case statement that only includes a single when statement. StyleGuide: 'chef_style_unnecessaryplatformcasestatement' Enabled: true VersionAdded: '5.16.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Style/ImmediateNotificationTiming: Description: Use :immediately instead of :immediate for resource notification timing. StyleGuide: 'chef_style_immediatenotificationtiming' Enabled: true VersionAdded: '5.16.0' Exclude: - '**/attributes/*.rb' - '**/metadata.rb' - '**/Berksfile' Chef/Style/TrueClassFalseClassResourceProperties: Description: When setting the allowed types for a resource to accept either true or false values it's much simpler to use true and false instead of TrueClass and FalseClass. StyleGuide: 'chef_style_trueclassfalseclassresourceproperties' Enabled: true VersionAdded: '5.16.0' Include: - '**/libraries/*.rb' - '**/resources/*.rb' Chef/Style/OverlyComplexSupportsDependsMetadata: Description: Don't loop over an array to set cookbook dependencies or supported platforms if you have fewer than three values to set. StyleGuide: 'chef_style_overcomplexsupportsdependsmetadata' Enabled: true VersionAdded: '5.19.0' Include: - '**/metadata.rb' Chef/Style/ChefWhaaat: Description: Do you mean Chef (the company) or a Chef product (e.g. Chef Infra, Chef InSpec, etc)? StyleGuide: 'chef_style_chefwhaaat' Enabled: false VersionAdded: '5.20.0' Chef/Style/UnnecessaryOSCheck: Description: Use the platform_family?() helpers instead of node['os] == 'foo' for platform_families that match 1:1 with OS values. These helpers are easier to read and can accept multiple platform arguments, which greatly simplifies complex platform logic. StyleGuide: 'chef_style_unnecessaryoscheck' Enabled: true VersionAdded: '5.21.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Style/NegatingOnlyIf: Description: Use not_if instead of only_if that negates the Ruby statement with a ! StyleGuide: 'chef_style_negatingonlyif' VersionAdded: '6.2.0' Enabled: true Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Style/IncludeRecipeWithParentheses: Description: There is no need to wrap the recipe in parentheses when using the include_recipe helper StyleGuide: '#includerecipewithparentheses' VersionAdded: '6.11.0' Enabled: true Exclude: - '**/attributes/*.rb' - '**/metadata.rb' - '**/Berksfile' ############################### # Chef/Correctness: Avoiding potential problems ############################### Chef/Correctness: StyleGuideBaseURL: https://docs.chef.io/workstation/cookstyle/ Chef/Correctness/ServiceResource: Description: Use a service resource to start and stop services instead of execute resources StyleGuide: 'chef_correctness_serviceresource' Enabled: true VersionAdded: '5.0.0' Exclude: - '**/attributes/*.rb' - '**/metadata.rb' - '**/Berksfile' Chef/Correctness/NodeNormal: Description: Do not use the node.normal method StyleGuide: 'chef_correctness_nodenormal' Enabled: true VersionAdded: '5.1.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Correctness/NodeNormalUnless: Description: Do not use the node.normal_unless method StyleGuide: 'chef_correctness_chernodenormalunless' Enabled: true VersionAdded: '5.1.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Correctness/TmpPath: Description: Use file_cache_path rather than hard-coding tmp paths StyleGuide: 'chef_correctness_nodenormalunless' Enabled: true VersionAdded: '5.0.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Correctness/InvalidPlatformMetadata: Description: metadata.rb "supports" platform is invalid StyleGuide: 'chef_correctness_invalidplatformmetadata' Enabled: true VersionAdded: '5.2.0' Include: - '**/metadata.rb' Chef/Correctness/CookbookUsesNodeSave: Description: Don't use node.save to save partial node data to the Chef Infra Server mid-run unless it's absolutely necessary. Node.save can result in failed Chef Infra runs appearing in search and increases load on the Chef Infra Server. StyleGuide: 'chef_correctness_cookbookusesnodesave' Enabled: true VersionAdded: '5.5.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Correctness/MetadataMissingName: Description: The metadata.rb file is missing the name field which is required by Chef Infra Client 12 and later StyleGuide: 'chef_correctness_metadatamissingname' Enabled: true VersionAdded: '5.2.0' Include: - '**/metadata.rb' Chef/Correctness/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 to be executed as Ruby code which will always return true instead of a shell command that will actually run. StyleGuide: 'chef_correctness_blockguardwithonlystring' Enabled: true VersionAdded: '5.2.0' Exclude: - '**/attributes/*.rb' - '**/metadata.rb' - '**/Berksfile' Chef/Correctness/ResourceSetsInternalProperties: Description: Do not set properties used internally by Chef Infra Client to track the system state. StyleGuide: 'chef_correctness_resourcesetsinternalproperties' Enabled: true VersionAdded: '5.5.0' Exclude: - '**/attributes/*.rb' - '**/metadata.rb' - '**/Berksfile' Chef/Correctness/ResourceSetsNameProperty: Description: Resource sets the name property in the resource instead of using a name_property. StyleGuide: 'chef_correctness_resourcesetsnameproperty' Enabled: true VersionAdded: '5.5.0' Exclude: - '**/attributes/*.rb' - '**/metadata.rb' - '**/Berksfile' Chef/Correctness/ResourceWithNoneAction: Description: Resource uses the nonexistent :none action instead of the :nothing action StyleGuide: 'chef_correctness_resourcewithnoneaction' Enabled: true VersionAdded: '5.5.0' Exclude: - '**/attributes/*.rb' - '**/metadata.rb' - '**/Berksfile' Chef/Correctness/InvalidVersionMetadata: Description: Cookbook metadata.rb version field should follow X.Y.Z version format. StyleGuide: 'chef_correctness_invalidversionmetadata' Enabled: true VersionAdded: '5.8.0' Include: - '**/metadata.rb' Chef/Correctness/NotifiesActionNotSymbol: Description: When notifying or subscribing an action within a resource the action should always be a symbol. In Chef Infra Client releases before 14.0 this may result in double notification. StyleGuide: 'chef_correctness_notifiesactionnotsymbol' Enabled: true VersionAdded: '5.10.0' Exclude: - '**/attributes/*.rb' - '**/metadata.rb' - '**/Berksfile' Chef/Correctness/IncorrectLibraryInjection: Description: Libraries should be injected into the Chef::DSL::Recipe or Chef::DSL::Resource classes and not Recipe/Resource/Provider classes directly. StyleGuide: 'chef_correctness_incorrectlibraryinjection' Enabled: true VersionAdded: '5.10.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Correctness/InvalidPlatformHelper: Description: Pass valid platforms to the platform? helper. StyleGuide: 'chef_correctness_invalidplatformhelper' Enabled: true VersionAdded: '5.15.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Correctness/InvalidPlatformFamilyHelper: Description: Pass valid platform families to the platform_family? helper. StyleGuide: 'chef_correctness_invalidplatformfamilyhelper' Enabled: true VersionAdded: '5.15.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Correctness/ScopedFileExist: Description: Scope file exist to access the correct File class by using ::File.exist? not File.exist?. StyleGuide: 'chef_correctness_scopedfileexist' Enabled: true VersionAdded: '5.15.0' Exclude: - '**/attributes/*.rb' - '**/metadata.rb' - '**/Berksfile' Chef/Correctness/InvalidPlatformValueForPlatformFamilyHelper: Description: Pass valid platforms families to the value_for_platform_family helper. StyleGuide: 'chef_correctness_invalidplatformvalueforplatformfamilyhelper' Enabled: true VersionAdded: '5.15.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Correctness/InvalidPlatformValueForPlatformHelper: Description: Pass valid platforms to the value_for_platform helper. StyleGuide: 'chef_correctness_invalidplatformvalueforplatformhelper' Enabled: true VersionAdded: '5.15.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Correctness/InvalidNotificationTiming: Description: Valid notification timings are :immediately, :immediate (alias for :immediately), :delayed, and :before. StyleGuide: 'chef_correctness_invalidnotificationtiming' Enabled: true VersionAdded: '5.16.0' Exclude: - '**/attributes/*.rb' - '**/metadata.rb' - '**/Berksfile' Chef/Correctness/MalformedPlatformValueForPlatformHelper: Description: When using the value_for_platform helper you must include a hash of possible platforms where each platform contains a hash of versions and potential values. If you don't wish to match on a particular version you can instead use the key 'default'. StyleGuide: 'chef_correctness_malformedplatformvalueforplatformhelper' Enabled: true VersionAdded: '5.16.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Correctness/DnfPackageAllowDowngrades: Description: dnf_package does not support the allow_downgrades property StyleGuide: 'chef_correctness_dnfpackageallowdowngrades' Enabled: true VersionAdded: '5.16.0' Exclude: - '**/attributes/*.rb' - '**/metadata.rb' - '**/Berksfile' Chef/Correctness/ChefApplicationFatal: Description: Use raise to force Chef Infra Client to fail instead of using Chef::Application.fatal StyleGuide: 'chef_correctness_chefapplicationfatal' Enabled: true VersionAdded: '6.0.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Correctness/PowershellScriptDeleteFile: Description: Use the `file` or `directory` resources built into Chef Infra Client with the :delete action to remove files/directories instead of using Remove-Item in a powershell_script resource StyleGuide: 'chef_correctness_powershellscriptdeletefiles' Enabled: true VersionAdded: '6.0.0' Exclude: - '**/attributes/*.rb' - '**/metadata.rb' - '**/Berksfile' Chef/Correctness/ConditionalRubyShellout: Description: Don't use Ruby to shellout in an only_if / not_if conditional when you can shellout directly by wrapping the command in quotes. StyleGuide: 'chef_correctness_conditionalrubyshellout' Enabled: true VersionAdded: '6.1.0' Exclude: - '**/attributes/*.rb' - '**/metadata.rb' - '**/Berksfile' Chef/Correctness/LazyEvalNodeAttributeDefaults: Description: When setting a node attribute as a default value for a custom resource property, make sure to wrap the node attribute in `lazy {}` so that the node attribute is available when the resource executes. StyleGuide: 'chef_correctness_lazyevalnodeattributedefaults' Enabled: true VersionAdded: '6.6.0' Include: - '**/libraries/*.rb' - '**/resources/*.rb' Chef/Correctness/OpenSSLPasswordHelpers: Description: The secure_password helper from the openssl cookbooks Opscode::OpenSSL::Password class should not be used to generate passwords. StyleGuide: 'chef_correctness_opensslpasswordhelpers' Enabled: true VersionAdded: '6.6.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Correctness/InvalidPlatformFamilyInCase: Description: Use valid platform family values in case statements. StyleGuide: 'chef_correctness_invalidplatformfamilyincase' Enabled: true VersionAdded: '6.6.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Correctness/InvalidPlatformInCase: Description: Use valid platform values in case statements. StyleGuide: 'chef_correctness_invalidplatformincase' Enabled: true VersionAdded: '6.6.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Correctness/InvalidDefaultAction: Description: Default actions in resources should be a symbol or an array of symbols. StyleGuide: 'chef_correctness_invaliddefaultaction' Enabled: true VersionAdded: '6.13.0' Include: - '**/libraries/*.rb' - '**/resources/*.rb' Chef/Correctness/SupportsMustBeFloat: Description: Versions used in metadata.rb supports calls should be floats not integers. StyleGuide: 'chef_correctness_supportsmustbefloat' Enabled: true VersionAdded: '6.13.0' Include: - '**/metadata.rb' Chef/Correctness/MacosUserdefaultsInvalidType: Description: The macos_userdefaults resource prior to Chef Infra Client 16.3 would silently continue if invalid types were passed resulting in unexpected behavior. Valid values are 'array', 'bool', 'dict', 'float', 'int', and 'string'. StyleGuide: 'chef_correctness_macosuserdefaultsinvalidtype' Enabled: true VersionAdded: '6.14.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Correctness/LazyInResourceGuard: Description: Using `lazy {}` within a resource guard (not_if/only_if) will cause failures and is unnecessary as resource guards are always lazily evaluated. StyleGuide: 'chef_correctness_lazyinresourceguard' Enabled: true VersionAdded: '6.18.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Correctness/PropertyWithoutType: Description: Custom resource properties or attributes should always define a type to help users understand the correct allowed values. StyleGuide: 'chef_correctness_propertywithouttype' Enabled: true VersionAdded: '6.18.0' Include: - '**/libraries/*.rb' - '**/resources/*.rb' Chef/Correctness/OctalModeAsString: Description: Don't represent file modes as strings containing octal values. Use standard base 10 file modes instead. StyleGuide: 'chef_correctness_octalmodeasstring' Enabled: true VersionAdded: '6.21.0' Exclude: - '**/attributes/*.rb' - '**/metadata.rb' - '**/Berksfile' ############################### # Chef/Sharing: Issues that prevent sharing code with other teams or with the Chef community in general ############################### Chef/Sharing: StyleGuideBaseURL: https://docs.chef.io/workstation/cookstyle/ Chef/Sharing/InsecureCookbookURL: Description: Insecure http Github or Gitlab URLs for metadata source_url/issues_url fields StyleGuide: 'chef_sharing_insecurecookbookurl' Enabled: true VersionAdded: '5.1.0' VersionChanged: '5.15.0' Include: - '**/metadata.rb' Chef/Sharing/InvalidLicenseString: Description: Cookbook metadata.rb does not use a SPDX compliant license string or "all rights reserved" StyleGuide: 'chef_sharing_invalidlicensestring' Enabled: true VersionAdded: '5.2.0' VersionChanged: '5.15.0' Include: - '**/metadata.rb' Chef/Sharing/DefaultMetadataMaintainer: Description: Metadata contains default maintainer information from the cookbook generator. Add actual cookbook maintainer information to the metadata.rb. StyleGuide: 'chef_sharing_defaultmetadatamaintainer' Enabled: true VersionAdded: '5.4.0' VersionChanged: '5.15.0' Include: - '**/metadata.rb' Chef/Sharing/EmptyMetadataField: Description: metadata.rb should not include fields with an empty string. Either don't include the field or add a value. StyleGuide: 'chef_sharing_emptymetadatafield' Enabled: true VersionAdded: '5.8.0' VersionChanged: '5.15.0' Include: - '**/metadata.rb' Chef/Sharing/IncludePropertyDescriptions: Description: Properties should include description fields to allow automated documentation. Requires Chef Infra Client 13.9 or later. StyleGuide: 'chef_sharing_includepropetydescriptions' Enabled: false VersionAdded: '6.1.0' Include: - '**/libraries/*.rb' - '**/resources/*.rb' Chef/Sharing/IncludeResourceDescriptions: Description: Resources should include description fields to allow automated documentation. Requires Chef Infra Client 13.9 or later. StyleGuide: 'chef_sharing_includeresourcedescriptions' Enabled: false VersionAdded: '6.1.0' Include: - '**/resources/*.rb' Chef/Sharing/IncludeResourceExamples: Description: Resources should include examples field to allow automated documentation. Requires Chef Infra Client 13.9 or later. StyleGuide: 'chef_sharing_includeresourceexamples' Enabled: false VersionAdded: '6.10.0' Include: - '**/resources/*.rb' ############################### # Chef/Deprecations: Resolving Deprecations that block upgrading Chef Infra Client ############################### Chef/Deprecations: StyleGuideBaseURL: https://docs.chef.io/workstation/cookstyle/ Chef/Deprecations/NodeDeepFetch: Description: Do not use the deprecated chef-sugar node.deep_fetch methods StyleGuide: 'chef_deprecations_nodedeepfetch' Enabled: true VersionAdded: '5.12.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Deprecations/NodeSet: Description: Do not use the deprecated node.set method StyleGuide: 'chef_deprecations_nodeset' Enabled: true VersionAdded: '5.0.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Deprecations/NodeSetUnless: Description: Do not use the deprecated node.set_unless method StyleGuide: 'chef_deprecations_nodesetunless' Enabled: true VersionAdded: '5.1.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Deprecations/EpicFail: Description: Use `ignore_failure` in resources to continue when failures occur instead of the deprecated `epic_fail` property StyleGuide: 'chef_deprecations_epicfail' Enabled: true VersionAdded: '5.1.0' Exclude: - '**/attributes/*.rb' - '**/metadata.rb' - '**/Berksfile' Chef/Deprecations/CookbookDependsOnPoise: Description: Cookbooks should not depend on the deprecated Poise framework StyleGuide: 'chef_deprecations_cookbookdependsonpoise' Enabled: true VersionAdded: '5.1.0' Include: - '**/metadata.rb' Chef/Deprecations/CookbookDependsOnCompatResource: Description: Don't depend on the deprecated compat_resource cookbook made obsolete by Chef Infra Client 12.19+ StyleGuide: 'chef_deprecations_cookbookdependsoncompatresource' Enabled: true VersionAdded: '5.1.0' Include: - '**/metadata.rb' Chef/Deprecations/CookbookDependsOnPartialSearch: Description: Don't depend on the deprecated partial_search cookbook made obsolete by Chef Infra Client 13+ StyleGuide: 'chef_deprecations_cookbookdependsonpartialsearch' Enabled: true VersionAdded: '5.1.0' Include: - '**/metadata.rb' Chef/Deprecations/EasyInstallResource: Description: Don't use the deprecated easy_install resource resource removed in Chef Infra Client 13 StyleGuide: 'chef_deprecations_easyinstallresource' Enabled: true VersionAdded: '5.1.0' Exclude: - '**/attributes/*.rb' - '**/metadata.rb' - '**/Berksfile' Chef/Deprecations/ErlCallResource: Description: Don't use the deprecated erl_call resource removed in Chef Infra Client 13 StyleGuide: 'chef_deprecations_erlcallresource' Enabled: true VersionAdded: '5.1.0' Exclude: - '**/attributes/*.rb' - '**/metadata.rb' - '**/Berksfile' Chef/Deprecations/RequireRecipe: Description: Use include_recipe instead of the require_recipe method StyleGuide: 'chef_deprecations_requirerecipe' Enabled: true VersionAdded: '5.2.0' Exclude: - '**/attributes/*.rb' - '**/metadata.rb' - '**/Berksfile' Chef/Deprecations/NodeMethodsInsteadofAttributes: Description: Use node attributes to access Ohai data instead of node methods, which were deprecated in Chef Infra Client 13. StyleGuide: 'chef_deprecations_nodemethodsinsteadofattributes' Enabled: true VersionAdded: '5.4.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Deprecations/UsesDeprecatedMixins: Description: Don't use deprecated Mixins no longer included in Chef Infra Client 14 and later. StyleGuide: 'chef_deprecations_usesdeprecatedmixins' Enabled: true VersionAdded: '5.4.0' Include: - '**/libraries/*.rb' - '**/providers/*.rb' - '**/resources/*.rb' Chef/Deprecations/IncludingXMLRubyRecipe: Description: The xml::ruby recipe installs nokogiri which is included in Chef Infra Client 12 and later. StyleGuide: 'chef_deprecations_includingxmlrubyrecipe' Enabled: true VersionAdded: '5.4.0' Exclude: - '**/attributes/*.rb' - '**/metadata.rb' - '**/Berksfile' Chef/Deprecations/LegacyYumCookbookRecipes: Description: The elrepo, epel, ius, remi, and repoforge recipes were split into their own cookbooks and the yum recipe was renamed to be default with the release of yum cookbook 3.0 (Dec 2013). StyleGuide: 'chef_deprecations_legacyyumcookbookrecipes' Enabled: true VersionAdded: '5.4.0' Exclude: - '**/metadata.rb' Chef/Deprecations/UsesChefRESTHelpers: Description: Don't use the helpers in Chef::REST which were removed in Chef Infra Client 13 StyleGuide: 'chef_deprecations_useschefresthelpers' Enabled: true VersionAdded: '5.5.0' Exclude: - '**/metadata.rb' Chef/Deprecations/ChocolateyPackageUninstallAction: Description: Use the :remove action in the chocolatey_package resource instead of :uninstall which was removed in Chef Infra Client 14+ StyleGuide: 'chef_deprecations_chocolateypackageuninstallaction' Enabled: true VersionAdded: '5.5.0' Exclude: - '**/metadata.rb' Chef/Deprecations/LaunchdDeprecatedHashProperty: Description: The launchd resource's hash property was renamed to plist_hash in Chef Infra Client 13+ to avoid conflicts with Ruby's hash class. StyleGuide: 'chef_deprecations_launchddeprecatedhashproperty' Enabled: true VersionAdded: '5.5.0' Exclude: - '**/metadata.rb' Chef/Deprecations/LocaleDeprecatedLcAllProperty: Description: The local resource's lc_all property has been deprecated and will be removed in Chef Infra Client 16 StyleGuide: 'chef_deprecations_localedeprecatedlcallproperty' Enabled: true VersionAdded: '5.5.0' Exclude: - '**/metadata.rb' Chef/Deprecations/UserDeprecatedSupportsProperty: Description: The supports property was removed in Chef Infra Client 13 in favor of individual 'manage_home' and 'non_unique' properties. StyleGuide: 'chef_deprecations_userdeprecatedsupportsproperty' Enabled: true VersionAdded: '5.5.0' Exclude: - '**/metadata.rb' Chef/Deprecations/UseInlineResourcesDefined: Description: use_inline_resources is now the default for resources in Chef Infra Client 13+ and does not need to be specified. StyleGuide: 'chef_deprecations_useinlineresourcesdefined' Enabled: true VersionAdded: '5.4.0' Include: - '**/libraries/*.rb' - '**/providers/*.rb' - '**/resources/*.rb' Chef/Deprecations/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. StyleGuide: 'chef_deprecations_includingyumdnfcompatrecipe' Enabled: true VersionAdded: '5.3.0' Exclude: - '**/metadata.rb' Chef/Deprecations/WindowsTaskChangeAction: Description: The :change action in the windows_task resource was removed when windows_task was added to Chef Infra Client 13+. The default action of :create should can now be used to create an update tasks. StyleGuide: 'chef_deprecations_windowstaskchangeaction' Enabled: true VersionAdded: '5.6.0' Exclude: - '**/metadata.rb' Chef/Deprecations/ResourceOverridesProvidesMethod: Description: Don't override the provides? method in a resource provider. Use provides :SOME_PROVIDER_NAME instead. This will cause failures in Chef Infra Client 13 and later. StyleGuide: 'chef_deprecations_resourceoverridesprovidesmethod' Enabled: true VersionAdded: '5.7.0' Include: - '**/libraries/*.rb' - '**/providers/*.rb' - '**/resources/*.rb' Chef/Deprecations/ResourceUsesDslNameMethod: Description: Use resource_name instead of the dsl_name method in resources. This will cause failures in Chef Infra Client 13 and later. StyleGuide: 'chef_deprecations_resourceusesdslnamemethod' Enabled: true VersionAdded: '5.7.0' Include: - '**/libraries/*.rb' - '**/providers/*.rb' - '**/resources/*.rb' Chef/Deprecations/ResourceUsesUpdatedMethod: Description: Don't use updated = true/false to update resource state. This will cause failures in Chef Infra Client 13 and later. StyleGuide: 'chef_deprecations_resourceusesupdatedmethod' Enabled: false # has a high potential for false positives VersionAdded: '5.7.0' Include: - '**/libraries/*.rb' - '**/providers/*.rb' - '**/resources/*.rb' Chef/Deprecations/NamePropertyWithDefaultValue: Description: A resource property can't be marked as a name_property and also have a default value. This will fail in Chef Infra Client 13 or later. StyleGuide: 'chef_deprecations_namepropertywithdefaultvalue' Enabled: true VersionAdded: '5.7.0' Include: - '**/libraries/*.rb' - '**/resources/*.rb' Chef/Deprecations/ResourceUsesProviderBaseMethod: Description: Don't use the deprecated provider_base method in a resource to specify the provider module to use. Instead, the provider should call provides to register itself, or the resource should call provider to specify the provider to use. This will cause failures in Chef Infra Client 13 and later. StyleGuide: 'chef_deprecations_resourceusesproviderbasemethod' Enabled: true VersionAdded: '5.7.0' Include: - '**/libraries/*.rb' - '**/resources/*.rb' Chef/Deprecations/ChefSpecCoverageReport: Description: Don't use the deprecated ChefSpec coverage report functionality in your specs. StyleGuide: 'chef_deprecations_chefspeccoveragereport' Enabled: true VersionAdded: '5.8.0' Include: - '**/spec/*.rb' Chef/Deprecations/ChefSpecLegacyRunner: Description: Use ChefSpec::SoloRunner or ChefSpec::ServerRunner instead of the deprecated ChefSpec::Runner. StyleGuide: 'chef_deprecations_chefspeclegacyrunner' Enabled: true VersionAdded: '5.8.0' Include: - '**/spec/*.rb' Chef/Deprecations/UsesRunCommandHelper: Description: Use 'shell_out!' instead of the legacy 'run_command' helper for shelling out. The run_command helper was removed in Chef Infra Client 13. StyleGuide: 'chef_deprecations_usesruncommandhelper' Enabled: true VersionAdded: '5.9.0' Exclude: - '**/metadata.rb' - '**/Berksfile' - '**/Rakefile' Chef/Deprecations/ChefHandlerUsesSupports: Description: Use the type property instead of the deprecated supports property in the chef_handler resource. The supports property was removed in chef_handler cookbook version 3.0 (June 2017) and Chef Infra Client 14.0. StyleGuide: 'chef_deprecations_chefhandlerusessupports' Enabled: true VersionAdded: '5.9.0' Exclude: - '**/metadata.rb' Chef/Deprecations/DeprecatedYumRepositoryProperties: Description: With the release of Chef Infra Client 12.14 and the yum cookbook 3.0 several properties in the yum_repository resource were renamed. url -> baseurl, keyurl -> gpgkey, and mirrorexpire -> mirror_expire. StyleGuide: 'chef_deprecations_deprecatedyumrepositoryproperties' Enabled: true VersionAdded: '5.10.0' Exclude: - '**/metadata.rb' - '**/attributes/*.rb' - '**/Berksfile' Chef/Deprecations/EOLAuditModeUsage: Description: The beta Audit Mode feature in Chef Infra Client was removed in Chef Infra Client 15.0. StyleGuide: 'chef_deprecations_eolauditmodeusage' Enabled: true VersionAdded: '5.10.0' Exclude: - '**/metadata.rb' - '**/attributes/*.rb' - '**/Berksfile' Chef/Deprecations/ResourceInheritsFromCompatResource: Description: HWRP style resource should inherit from the 'Chef::Resource' class and not the 'ChefCompat::Resource' class from the deprecated compat_resource cookbook. StyleGuide: 'chef_deprecations_resourceinheritsfromcompatresource' Enabled: true VersionAdded: '5.10.0' Include: - '**/libraries/*.rb' Chef/Deprecations/VerifyPropertyUsesFileExpansion: Description: Use the 'path' variable in the verify property and not the 'file' variable which was removed in Chef Infra Client 13. StyleGuide: 'chef_deprecations_verifypropertyusesfileexpansion' Enabled: true VersionAdded: '5.10.0' Exclude: - '**/metadata.rb' - '**/attributes/*.rb' - '**/Berksfile' Chef/Deprecations/PoiseArchiveUsage: Description: The poise_archive resource in the deprecated poise-archive should be replaced with the archive_file resource found in Chef Infra Client 15+. StyleGuide: 'chef_deprecations_poisearchiveusage' Enabled: true VersionAdded: '5.11.0' Exclude: - '**/metadata.rb' - '**/attributes/*.rb' - '**/Berksfile' Chef/Deprecations/PartialSearchHelperUsage: Description: Legacy partial_search usage should be updated to use :filter_result in the search helper instead. StyleGuide: 'chef_deprecations_partialsearchhelperusage' Enabled: true VersionAdded: '5.11.0' Exclude: - '**/metadata.rb' Chef/Deprecations/SearchUsesPositionalParameters: Description: Don't use deprecated positional parameters in cookbook search queries. StyleGuide: 'chef_deprecations_searchusespositionalparameters' Enabled: true VersionAdded: '5.11.0' Exclude: - '**/metadata.rb' Chef/Deprecations/PartialSearchClassUsage: Description: Legacy Chef::PartialSearch class usage should be updated to use the search helper instead with the filter_result key. StyleGuide: 'chef_deprecations_partialsearchclassusage' Enabled: true VersionAdded: '5.11.0' Exclude: - '**/metadata.rb' Chef/Deprecations/Cheffile: Description: The Librarian-Chef depsolving project is no longer maintained and should not be used for cookbook depsolving. Consider using Policyfiles instead. StyleGuide: 'chef_deprecations_cheffile' Enabled: true VersionAdded: '5.12.0' Include: - '**/Cheffile' Chef/Deprecations/LegacyNotifySyntax: Description: Use the new-style notification syntax which allows you to notify resources defined later in a recipe or resource. StyleGuide: 'chef_deprecations_legacynotifysyntax' Enabled: true VersionAdded: '5.13.0' Exclude: - '**/metadata.rb' - '**/attributes/*.rb' - '**/Berksfile' Chef/Deprecations/NodeSetWithoutLevel: Description: When setting a node attribute in Chef Infra Client 11 and later you must specify the precedence level. StyleGuide: 'chef_deprecations_nodesetwithoutlevel' Enabled: true VersionAdded: '5.13.0' Exclude: - '**/metadata.rb' - '**/attributes/*.rb' Chef/Deprecations/ChefRewind: Description: Use delete_resource / edit_resource instead of functionality in the deprecated chef-rewind gem StyleGuide: 'chef_deprecations_chefrewind' Enabled: true VersionAdded: '5.14.0' Exclude: - '**/metadata.rb' - '**/attributes/*.rb' Chef/Deprecations/RubyBlockCreateAction: Description: Use the :run action in the ruby_block resource instead of the deprecated :create action StyleGuide: 'chef_deprecations_rubyblockcreateaction' Enabled: true VersionAdded: '5.16.0' Exclude: - '**/metadata.rb' - '**/attributes/*.rb' - '**/Berksfile' Chef/Deprecations/DeprecatedPlatformMethods: Description: Use provider_for_action or provides instead of the deprecated Chef::Platform methods in resources. StyleGuide: 'chef_deprecations_deprecatedplatformmethods' Enabled: true VersionAdded: '5.16.0' VersionChanged: '6.17.0' Include: - '**/libraries/*.rb' - '**/resources/*.rb' - '**/providers/*.rb' Chef/Deprecations/DeprecatedChefSpecPlatform: Description: Use currently supported platforms in ChefSpec listed at https://github.com/chefspec/fauxhai/blob/master/PLATFORMS.md. Fauxhai / ChefSpec will perform fuzzy matching on platform version so it's always best to be less specific ie. 10 instead of 10.3 StyleGuide: 'chef_deprecations_deprecatedchefspecplatform' Enabled: true VersionAdded: '5.20.0' Include: - '**/spec/**/*.rb' Chef/Deprecations/WindowsFeatureServermanagercmd: Description: The `windows_feature` resource no longer supports setting the `install_method` to `:servermanagercmd`. `:windows_feature_dism` or `:windows_feature_powershell` should be used instead. StyleGuide: 'chef_deprecations_windowsfeatureservermanagercmd' Enabled: true VersionAdded: '5.22.0' Exclude: - '**/metadata.rb' - '**/attributes/*.rb' - '**/Berksfile' Chef/Deprecations/DeprecatedWindowsVersionCheck: Description: Don't use the deprecated older_than_win_2012_or_8? helper. Windows versions before 2012 and 8 are now end of life and this helper will always return false. StyleGuide: 'chef_deprecations_deprecatedwindowsversioncheck' Enabled: true VersionAdded: '6.0.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Deprecations/ChefWindowsPlatformHelper: Description: Use `platform?('windows')` instead of the legacy `Chef::Platform.windows?` helper. StyleGuide: 'chef_deprecations_chefwindowsplatformhelper' Enabled: true VersionAdded: '6.0.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Deprecations/LogResourceNotifications: Description: In Chef Infra Client 16 the log resource no longer notifies when logging so notifications should not be triggered from log resources. Use the notify_group resource instead to aggregate notifications. StyleGuide: 'chef_deprecations_logresourcenotifications' Enabled: true VersionAdded: '6.0.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Deprecations/HWRPWithoutProvides: Description: In Chef Infra Client 16 and later a legacy HWRP resource must use `provides` to define how the resource is called in recipes or other resources. To maintain compatibility with Chef Infra Client < 16 use both `resource_name` and `provides`. StyleGuide: 'chef_deprecations_resourcewithoutnameorprovides' Enabled: true VersionAdded: '6.0.0' VersionChanged: '6.8.0' Include: - '**/libraries/*.rb' Chef/Deprecations/WindowsVersionHelpers: Description: Use node['platform_version'] data instead of the Windows::VersionHelper helper from the Windows cookbook. StyleGuide: 'chef_deprecations_windowsversionhelpers' Enabled: true VersionAdded: '5.4.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Deprecations/PowershellCookbookHelpers: Description: Use node['powershell']['version'] or the new powershell_version helper available in Chef Infra Client 16+ instead of the deprecated PowerShell cookbook helpers. StyleGuide: 'chef_deprecations_powershellcookbookhelpers' Enabled: true VersionAdded: '6.1.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Deprecations/DeprecatedShelloutMethods: Description: Many legacy specialized shell_out methods were replaced in Chef Infra Client 14.3 and removed in Chef Infra Client 15. Use shell_out and any additional options if necessary. StyleGuide: 'chef_deprecations_deprecatedshelloutmethods' Enabled: true VersionAdded: '6.3.0' Exclude: - '**/metadata.rb' - '**/attributes/*.rb' - '**/Berksfile' Chef/Deprecations/Ruby27KeywordArgumentWarnings: Description: Pass options to shell_out helpers without the brackets to avoid Ruby 2.7 deprecation warnings. StyleGuide: 'chef_deprecations_ruby27keywordargumentwarnings' Enabled: true VersionAdded: '6.5.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Deprecations/ResourceUsesOnlyResourceName: Description: Starting with Chef Infra Client 16, using `resource_name` without also using `provides` will result in resource failures. Use `provides` to change the name of the resource instead and omit `resource_name` entirely if it matches the name Chef Infra Client automatically assigns based on COOKBOOKNAME_FILENAME. StyleGuide: 'chef_deprecations_resourceusesonlyresourcename' Enabled: true VersionAdded: '6.7.0' Include: - '**/libraries/*.rb' - '**/resources/*.rb' Chef/Deprecations/ChefDKGenerators: Description: Chef Workstation 0.8 and later renamed the ChefDK module used when writing custom cookbook generators from ChefDK to ChefCLI. For compatibility with the latest Chef Workstation releases you'll need to reference the new class names. StyleGuide: 'chef_deprecations_chefdkgenerators' Enabled: true VersionAdded: '6.12.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Deprecations/ChefHandlerRecipe: Description: There is no need to include the empty and deprecated chef_handler::default recipe to use the chef_handler resource. StyleGuide: 'chef_deprecations_chefhandlerrecipe' Enabled: true VersionAdded: '6.12.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Deprecations/UseAutomaticResourceName: Description: The use_automatic_resource_name method was removed in Chef Infra Client 16. The resource name/provides should be set explicitly instead. StyleGuide: 'chef_deprecations_useautomaticresourcename' Enabled: true VersionAdded: '6.12.0' Include: - '**/libraries/*.rb' - '**/resources/*.rb' Chef/Deprecations/MacosUserdefaultsGlobalProperty: Description: The `global` property in the macos_userdefaults resource was deprecated in Chef Infra Client 16.3. Omitting the `domain` property will now set global defaults. StyleGuide: 'chef_deprecations_macosuserdefaultsglobalproperty' Enabled: true VersionAdded: '6.14.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Deprecations/CookbooksDependsOnSelf: Description: A cookbook cannot depend on itself in Chef Infra Client 13 or later. StyleGuide: 'chef_deprecations_cookbooksdependonself' Enabled: true VersionAdded: '5.2.0' VersionChanged: '6.16.0' Include: - '**/metadata.rb' Chef/Deprecations/ChefShellout: Description: Don't use the deprecated `Chef::ShellOut` class which was removed in Chef Infra Client 13. Use the `Mixlib::ShellOut` class instead, which behaves identically. StyleGuide: 'chef_deprecations_chefshellout' Enabled: true VersionAdded: '6.17.0' Exclude: - '**/metadata.rb' - '**/attributes/*.rb' - '**/Berksfile' Chef/Deprecations/ExecutePathProperty: Description: In Chef Infra Client 13 and later you must set path env vars in `execute` resources using the `environment` property not the legacy `path` property. StyleGuide: 'chef_deprecations_executepathproperty' Enabled: true VersionAdded: '6.17.0' Exclude: - '**/metadata.rb' - '**/attributes/*.rb' - '**/Berksfile' Chef/Deprecations/ExecuteRelativeCreatesWithoutCwd: Description: In Chef Infra Client 13 and later you must either specify an absolute path when using the `execute` resource's `creates` property or also use the `cwd` property. StyleGuide: 'chef_deprecations_executerelativecreateswithoutcwd' Enabled: true VersionAdded: '6.17.0' Exclude: - '**/metadata.rb' - '**/attributes/*.rb' - '**/Berksfile' Chef/Deprecations/WindowsPackageInstallerTypeString: Description: In Chef Infra Client 13 and later the `windows_package` resource's `installer_type` property must be a symbol. StyleGuide: 'chef_deprecations_windowspackageinstallertypestring' Enabled: true VersionAdded: '6.17.0' Exclude: - '**/metadata.rb' - '**/attributes/*.rb' - '**/Berksfile' Chef/Deprecations/UseYamlDump: Description: Chef Infra Client 16.5 introduced performance enhancements to Ruby library loading. Due to the underlying implementation of Ruby's `.to_yaml` method, it does not automatically load the `yaml` library and `YAML.dump()` should be used instead to properly load the `yaml` library. StyleGuide: 'chef_deprecations_useyamldump' Enabled: true VersionAdded: '6.21.0' Chef/Deprecations/LibrarianChefSpec: Description: The Librarian-Chef depsolving project is no longer maintained and ChefSpec should not use Librarian-Chef for cookbook depsolving. Consider using Policyfiles instead. StyleGuide: 'chef_deprecations_librarianchefspec' Enabled: true VersionAdded: '7.1.0' Include: - '**/specs/*.rb' Chef/Deprecations/FoodcriticTesting: Description: The Foodcritic cookbook linter has been deprecated and should no longer be used for validating cookbooks StyleGuide: 'chef_deprecations_foodcritictesting' Enabled: true VersionAdded: '7.1.0' Include: - '**/Rakefile' - '**/Gemfile' Chef/Deprecations/DeprecatedYumRepositoryActions: Description: With the release of Chef Infra Client 12.14 and the yum cookbook 3.0 several actions in the yum_repository resource actions were renamed. The `add` action became `create` and `delete` became `remove` to better match other resources in Chef Infra Client. StyleGuide: 'chef_deprecations_deprecatedyumrepositoryactions' Enabled: true VersionAdded: '7.3.0' Exclude: - '**/metadata.rb' - '**/attributes/*.rb' - '**/Berksfile' - '**/Rakefile' Chef/Deprecations/ChefSugarHelpers: Description: Do not use legacy chef-sugar helper methods, which will not be moved into Chef Infra Client itself. For a complete set of chef-sugar helpers now shipping in Chef Infra Client itself see https://github.com/chef/chef/tree/master/chef-utils#getting-started StyleGuide: 'chef_deprecations_chefsugarhelpers' Enabled: true VersionAdded: '7.3.0' Exclude: - '**/metadata.rb' - '**/Berksfile' - '**/Rakefile' Chef/Deprecations/HWRPWithoutUnifiedTrue: Description: Set `unified_mode true` in Chef Infra Client 15.3+ HWRP style custom resources to ensure they work correctly in Chef Infra Client 18 (April 2022) when Unified Mode becomes the default. StyleGuide: 'chef_deprecations_hwrpwithoutunifiedtrue' Enabled: true VersionAdded: '7.12.0' Include: - '**/libraries/*.rb' Chef/Deprecations/ResourceWithoutUnifiedTrue: Description: Set `unified_mode true` in Chef Infra Client 15.3+ custom resources to ensure they work correctly in Chef Infra Client 18 (April 2022) when Unified Mode becomes the default. StyleGuide: 'chef_deprecations_resourcewithoutunifiedtrue' Enabled: true VersionAdded: '7.12.0' Include: - '**/resources/*.rb' Exclude: - '**/spec/**/*.rb' ############################### # Chef/Modernize: Cleaning up legacy code and using new built-in resources ############################### Chef/Modernize: StyleGuideBaseURL: https://docs.chef.io/workstation/cookstyle/ Chef/Modernize/LegacyBerksfileSource: Description: Do not use legacy Berksfile community sources. Use Chef Supermarket instead. StyleGuide: 'chef_modernize_legacyberksfilesource' Enabled: true VersionAdded: '5.1.0' Include: - '**/Berksfile' Chef/Modernize/WhyRunSupportedTrue: Description: whyrun_supported? no longer needs to be set to true as it is the default in Chef 13+ StyleGuide: 'chef_modernize_whyrunsupportedtrue' Enabled: true VersionAdded: '5.1.0' Include: - '**/resources/*.rb' - '**/providers/*.rb' - '**/libraries/*.rb' Chef/Modernize/UnnecessaryDependsChef14: Description: Don't depend on cookbooks made obsolete by Chef Infra Client 14+. These community cookbooks contain resources that are now included in Chef Infra Client itself. StyleGuide: 'chef_modernize_unnecessarydependschef14' Enabled: true VersionAdded: '5.1.0' Include: - '**/metadata.rb' Chef/Modernize/RespondToInMetadata: Description: It is no longer necessary to use respond_to? in metadata.rb in Chef Infra Client 12.15 and later StyleGuide: 'chef_modernize_respondtoinmetadata' Enabled: true VersionAdded: '5.2.0' Include: - '**/metadata.rb' Chef/Modernize/RespondToResourceName: Description: respond_to?(:resource_name) in resources is no longer necessary in Chef Infra Client 12.5+ StyleGuide: 'chef_modernize_respondtoresourcename' Enabled: true VersionAdded: '5.2.0' Include: - '**/resources/*.rb' - '**/libraries/*.rb' Chef/Modernize/RespondToProvides: Description: respond_to?(:provides) in resources is no longer necessary in Chef Infra Client 12+ StyleGuide: 'chef_modernize_respondtoprovides' Enabled: true VersionAdded: '5.2.0' Include: - '**/providers/*.rb' - '**/resources/*.rb' - '**/libraries/*.rb' Chef/Modernize/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. StyleGuide: 'chef_modernize_setorreturninresources' Enabled: true VersionAdded: '5.2.0' Include: - '**/resources/*.rb' - '**/libraries/*.rb' Chef/Modernize/CustomResourceWithAttributes: Description: Custom Resources should contain properties not attributes. StyleGuide: 'chef_modernize_customresourcewithattributes' Enabled: true VersionAdded: '5.2.0' Include: - '**/resources/*.rb' Chef/Modernize/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. StyleGuide: 'chef_modernize_includingaptdefaultrecipe' Enabled: true VersionAdded: '5.3.0' Exclude: - '**/metadata.rb' Chef/Modernize/IncludingWindowsDefaultRecipe: Description: Do not include the Windows default recipe, which only installs win32 gems already included in Chef Infra Client StyleGuide: 'chef_modernize_includingwindowsdefaultrecipe' Enabled: true VersionAdded: '5.3.0' Exclude: - '**/metadata.rb' Chef/Modernize/DefinesChefSpecMatchers: Description: ChefSpec matchers are now auto generated by ChefSpec 7.1+ and do not need to be defined in a cookbook StyleGuide: 'chef_modernize_defineschefspecmatchers' Enabled: true VersionAdded: '5.3.0' Include: - '**/libraries/*.rb' Chef/Modernize/ExecuteAptUpdate: Description: Use the apt_update resource instead of the execute resource to run an apt-get update package cache update StyleGuide: 'chef_modernize_executeaptupdate' Enabled: true VersionAdded: '5.3.0' Exclude: - '**/metadata.rb' Chef/Modernize/MinitestHandlerUsage: Description: Use Chef InSpec for testing instead of the Minitest Handler cookbook pattern. StyleGuide: 'chef_modernize_minitesthandlerusage' Enabled: true VersionAdded: '5.4.0' Include: - '**/metadata.rb' Chef/Modernize/IncludingMixinShelloutInResources: Description: There is no need to include Chef::Mixin::ShellOut or Chef::Mixin::PowershellOut in resources or providers as this is already done by Chef Infra Client 12.4+. StyleGuide: 'chef_modernize_includingmixinshelloutinresources' Enabled: true VersionAdded: '5.4.0' Include: - '**/resources/*.rb' - '**/providers/*.rb' - '**/libraries/*.rb' Chef/Modernize/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+ StyleGuide: 'chef_modernize_usebuildessentialresource' Enabled: true VersionAdded: '5.1.0' Exclude: - '**/metadata.rb' Chef/Modernize/WindowsZipfileUsage: Description: Use the archive_file resource built into Chef Infra Client 15+ instead of the windows_zipfile from the Windows cookbook StyleGuide: 'chef_modernize_windowszipfileusage' Enabled: true VersionAdded: '5.4.0' Exclude: - '**/metadata.rb' Chef/Modernize/SevenZipArchiveResource: Description: Use the archive_file resource built into Chef Infra Client 15+ instead of the seven_zip_archive StyleGuide: 'chef_modernize_sevenziparchiveresource' Enabled: true VersionAdded: '5.5.0' Exclude: - '**/metadata.rb' Chef/Modernize/LibarchiveFileResource: Description: Use the archive_file resource built into Chef Infra Client 15+ instead of the libarchive file resource StyleGuide: 'chef_modernize_libarchivefileresource' Enabled: true VersionAdded: '5.5.0' Exclude: - '**/metadata.rb' Chef/Modernize/PowershellScriptExpandArchive: Description: Use the archive_file resource built into Chef Infra Client 15+ instead of using Expand-Archive in a powershell_script resource StyleGuide: 'chef_modernize_powershellscriptexpandarchive' Enabled: true VersionAdded: '5.5.0' Exclude: - '**/metadata.rb' Chef/Modernize/PowershellInstallPackage: Description: Use the package resource built into Chef Infra Client instead of using Install-Package in a powershell_script resource StyleGuide: 'chef_modernize_powershellinstallpackage' Enabled: true VersionAdded: '5.5.0' Exclude: - '**/metadata.rb' Chef/Modernize/PowershellInstallWindowsFeature: Description: Use the windows_feature resource built into Chef Infra Client 13+ instead of using Install-WindowsFeature or Add-WindowsFeature in a powershell_script resource StyleGuide: 'chef_modernize_powershellinstallwindowsfeature' Enabled: true VersionAdded: '5.5.0' Exclude: - '**/metadata.rb' Chef/Modernize/ShellOutToChocolatey: Description: Use the Chocolatey resources built into Chef Infra Client instead of shelling out to the choco command StyleGuide: 'chef_modernize_shellouttochocolatey' Enabled: true VersionAdded: '5.5.0' Exclude: - '**/metadata.rb' Chef/Modernize/CronManageResource: Description: The cron_manage resource was renamed to cron_access in the 6.1 release of the cron cookbook and later shipped in Chef Infra Client 14.4. The new resource name should be used. StyleGuide: 'chef_modernize_cronmanageresource' Enabled: true VersionAdded: '5.6.0' Exclude: - '**/metadata.rb' Chef/Modernize/UsesZypperRepo: Description: The zypper_repo resource was renamed zypper_repository when it was added to Chef Infra Client 13.3. StyleGuide: 'chef_modernize_useszypperrepo' Enabled: true VersionAdded: '5.6.0' Exclude: - '**/metadata.rb' Chef/Modernize/DependsOnZypperCookbook: Description: Don't include the zypper cookbook as the zypper_repository resource is built into Chef Infra Client 13.3+ StyleGuide: 'chef_modernize_dependsonzyppercookbook' Enabled: true VersionAdded: '5.6.0' Exclude: - '**/metadata.rb' Chef/Modernize/ExecuteTzUtil: Description: Use the timezone resource included in Chef Infra Client 14.6+ instead of shelling out to tzutil StyleGuide: 'chef_modernize_executetzutil' Enabled: true VersionAdded: '5.6.0' Exclude: - '**/metadata.rb' Chef/Modernize/OpensslRsaKeyResource: Description: The openssl_rsa_key resource was renamed to openssl_rsa_private_key in Chef Infra Client 14.0. The new resource name should be used. StyleGuide: 'chef_modernize_opensslrsakeyresource' Enabled: true VersionAdded: '5.6.0' Exclude: - '**/metadata.rb' Chef/Modernize/OpensslX509Resource: Description: The openssl_x509 resource was renamed to openssl_x509_certificate in Chef Infra Client 14.4. The new resource name should be used. StyleGuide: 'chef_modernize_opensslx509resource' Enabled: true VersionAdded: '5.6.0' Exclude: - '**/metadata.rb' Chef/Modernize/OsxConfigProfileResource: Description: The osx_config_profile resource was renamed to osx_profile. The new resource name should be used. StyleGuide: 'chef_modernize_osxconfigprofileresource' Enabled: true VersionAdded: '5.6.0' Exclude: - '**/metadata.rb' Chef/Modernize/SysctlParamResource: Description: The sysctl_param resource was renamed to sysctl when it was added to Chef Infra Client 14.0. The new resource name should be used. StyleGuide: 'chef_modernize_sysctlparamresource' Enabled: true VersionAdded: '5.6.0' Exclude: - '**/metadata.rb' Chef/Modernize/MacOsXUserdefaults: Description: The mac_os_x_userdefaults resource was renamed to macos_userdefaults when it was added to Chef Infra Client 14.0. The new resource name should be used. StyleGuide: 'chef_modernize_macosxuserdefaults' Enabled: true VersionAdded: '5.6.0' Exclude: - '**/metadata.rb' Chef/Modernize/PowerShellGuardInterpreter: Description: PowerShell is already set as the default guard interpreter for powershell_script resources in Chef Infra Client 13 and later and does not need to be specified. StyleGuide: 'chef_modernize_powershellguardinterpreter' Enabled: true VersionAdded: '5.9.0' Exclude: - '**/metadata.rb' Chef/Modernize/DefaultActionFromInitialize: Description: The default actions can now be specified using the `default_action` helper instead of using the @action variable in the resource provider initialize method. StyleGuide: 'chef_modernize_defaultactionfrominitialize' Enabled: true VersionAdded: '5.10.0' Include: - '**/resources/*.rb' - '**/providers/*.rb' - '**/libraries/*.rb' Chef/Modernize/ResourceNameFromInitialize: Description: The name of a resource can be set with the "resource_name" helper instead of using the initialize method. StyleGuide: 'chef_modernize_resourcenamefrominitialize' Enabled: true VersionAdded: '5.10.0' Include: - '**/resources/*.rb' - '**/providers/*.rb' - '**/libraries/*.rb' Chef/Modernize/Definitions: Description: Legacy Chef Infra definitions should be rewritten as custom resources to take full advantage of the Chef Infra feature set. StyleGuide: 'chef_modernize_definitions' Enabled: true VersionAdded: '5.11.0' Include: - '**/definitions/*.rb' Chef/Modernize/IfProvidesDefaultAction: Description: if defined?(default_action) is no longer necessary in Chef Infra resources as default_action shipped in Chef Infra Client 10.8. StyleGuide: 'chef_modernize_ifprovidesdefaultaction' Enabled: true VersionAdded: '5.12.0' Include: - '**/resources/*.rb' - '**/libraries/*.rb' Chef/Modernize/ZipfileResource: Description: Use the archive_file resource built into Chef Infra Client 15+ instead of the zipfile resource from the zipfile cookbook. StyleGuide: 'chef_modernize_zipfileresource' Enabled: true VersionAdded: '5.12.0' Chef/Modernize/UnnecessaryMixlibShelloutRequire: Description: Chef Infra Client 12.4 and later include mixlib/shellout automatically in resources and providers. StyleGuide: 'chef_modernize_unnecessarymixlibshelloutrequire' Enabled: true VersionAdded: '5.12.0' Include: - '**/resources/*.rb' - '**/providers/*.rb' Chef/Modernize/EmptyResourceInitializeMethod: Description: There is no need for an empty initialize method in a resource StyleGuide: 'chef_modernize_emptyresourceinitializemethod' Enabled: true VersionAdded: '5.13.0' Include: - '**/resources/*.rb' - '**/providers/*.rb' Chef/Modernize/ChefGemNokogiri: Description: The nokogiri gem ships in Chef Infra Client 12+ and does not need to be installed before being used. StyleGuide: 'chef_modernize_chefgemnokogiri' Enabled: true VersionAdded: '5.14.0' Exclude: - '**/metadata.rb' - '**/attributes/*.rb' Chef/Modernize/PropertyWithNameAttribute: Description: Resource property sets name_attribute not name_property StyleGuide: 'chef_modernize_propertywithnameattribute' Enabled: true VersionAdded: '5.1.0' VersionChanged: '5.15.0' Include: - '**/resources/*.rb' - '**/libraries/*.rb' Chef/Modernize/IncludingOhaiDefaultRecipe: Description: Use the ohai_plugin resource to ship custom Ohai plugins instead of using the ohai::default recipe. If you're not shipping custom Ohai plugins, then you can remove this recipe entirely. StyleGuide: 'chef_modernize_includingohaidefaultrecipe' Enabled: true VersionAdded: '5.4.0' VersionChanged: '5.15.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Modernize/AllowedActionsFromInitialize: Description: The allowed actions of a resource can be set with the "allowed_actions" helper instead of using the initialize method. StyleGuide: 'chef_modernize_allowedactionsfrominitialize' Enabled: true VersionAdded: '5.15.0' Include: - '**/resources/*.rb' - '**/libraries/*.rb' Chef/Modernize/FoodcriticComments: Description: Remove legacy code comments that disable Foodcritic rules. These comments are no longer necessary if you've migrated from Foodcritic to Cookstyle for cookbook linting. StyleGuide: 'chef_modernize_foodcriticcomments' Enabled: true VersionAdded: '5.16.0' Exclude: - '**/Berksfile' Chef/Modernize/ExecuteScExe: Description: Chef Infra Client 14.0 and later includes :create, :delete, and :configure actions with the full idempotency of the windows_service resource. See the windows_service documentation at https://docs.chef.io/resources/windows_service for additional details on creating services with the windows_service resource StyleGuide: 'chef_modernize_executescexe' Enabled: true VersionAdded: '5.16.0' Exclude: - '**/metadata.rb' - '**/attributes/*.rb' - '**/Berksfile' Chef/Modernize/WindowsScResource: Description: Chef Infra Client 14.0 and later includes :create, :delete, and :configure actions without the need for the sc cookbook dependency. See the windows_service documentation at https://docs.chef.io/resources/windows_service for additional details. StyleGuide: 'chef_modernize_windowsscresource' Enabled: true VersionAdded: '5.16.0' Exclude: - '**/metadata.rb' - '**/attributes/*.rb' - '**/Berksfile' Chef/Modernize/ExecuteSleep: Description: Chef Infra Client 15.5 and later include a chef_sleep resource that should be used to sleep between executing resources if necessary instead of using the bash or execute resources to run the sleep command. StyleGuide: 'chef_modernize_executesleep' Enabled: true VersionAdded: '5.16.0' Exclude: - '**/metadata.rb' - '**/attributes/*.rb' - '**/Berksfile' Chef/Modernize/DslIncludeInResource: Description: 'There is no need to include Chef::DSL::Recipe or Chef::DSL::IncludeRecipe classes in resources or providers as this is done automatically.' StyleGuide: 'chef_modernize_dslincludeinresource' Enabled: true VersionAdded: '5.17.0' Include: - '**/resources/*.rb' - '**/providers/*.rb' Chef/Modernize/ResourceForcingCompileTime: Description: The hostname, build_essential, chef_gem, and ohai_hint resources include 'compile_time' properties, which should be used to force the resources to run at compile time by setting `compile_time true`. StyleGuide: 'chef_modernize_resourceforcingcompiletime' Enabled: true VersionAdded: '5.18.0' Exclude: - '**/metadata.rb' - '**/attributes/*.rb' - '**/Berksfile' Chef/Modernize/ExecuteSysctl: Description: Chef Infra Client 14.0 and later includes a sysctl resource that should be used to idempotently load sysctl values instead of templating files and using execute to load them. StyleGuide: 'chef_modernize_executesysctl' Enabled: true VersionAdded: '5.18.0' Exclude: - '**/metadata.rb' - '**/attributes/*.rb' - '**/Berksfile' Chef/Modernize/SimplifyAptPpaSetup: Description: The apt_repository resource allows setting up PPAs without using the full URL to ppa.launchpad.net. StyleGuide: 'chef_modernize_simplifyaptppasetup' Enabled: true VersionAdded: '5.21.0' Exclude: - '**/metadata.rb' - '**/attributes/*.rb' - '**/Berksfile' Chef/Modernize/UseRequireRelative: Description: Instead of using require with a File.expand_path and __FILE__ use the simpler require_relative method. StyleGuide: 'chef_modernize_userequirerelative' Enabled: true VersionAdded: '5.22.0' Exclude: - '**/metadata.rb' - '**/attributes/*.rb' - '**/Berksfile' Chef/Modernize/NodeInitPackage: Description: Use node['init_package'] to check for systemd instead of reading the contents of '/proc/1/comm' StyleGuide: 'chef_modernize_nodeinitpackage' Enabled: true VersionAdded: '5.22.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Modernize/WindowsRegistryUAC: Description: Chef Infra Client 15.0 and later includes a windows_uac resource that should be used to set Windows UAC values instead of setting registry keys directly. StyleGuide: 'chef_modernize_windowsregistryuac' Enabled: true VersionAdded: '5.22.0' Exclude: - '**/metadata.rb' - '**/attributes/*.rb' - '**/Berksfile' Chef/Modernize/UseMultipackageInstalls: Description: Pass an array of packages to package resources instead of iterating over an array of packages when using multi-package capable package subsystem such as apt, yum, chocolatey, dnf, or zypper. Multi-package installs are faster and simplify logs. StyleGuide: 'chef_modernize_usemultipackageinstalls' Enabled: true VersionAdded: '6.0.0' Exclude: - '**/metadata.rb' - '**/attributes/*.rb' - '**/Berksfile' Chef/Modernize/ProvidesFromInitialize: Description: Provides should be set using the `provides` resource DSL method instead of instead of setting @provides in the initialize method. StyleGuide: 'chef_modernize_providesfrominitialize' Enabled: true VersionAdded: '6.0.0' Include: - '**/resources/*.rb' - '**/providers/*.rb' - '**/libraries/*.rb' Chef/Modernize/DatabagHelpers: Description: Use the `data_bag_item` helper instead of `Chef::DataBagItem.load` or `Chef::EncryptedDataBagItem.load`. StyleGuide: 'chef_modernize_databaghelpers' Enabled: true VersionAdded: '6.0.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Modernize/NodeRolesInclude: Description: Use `node.role?('foo')` to check if a node includes a role instead of `node['roles'].include?('foo')`. StyleGuide: 'chef_modernize_noderolesinclude' Enabled: true VersionAdded: '6.1.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Modernize/RespondToCompileTime: Description: There is no need to check if the chef_gem resource supports compile_time as Chef Infra Client 12.1 and later support the compile_time property. StyleGuide: 'chef_modernize_resondtocompiletime' Enabled: true VersionAdded: '6.3.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Modernize/ShellOutHelper: Description: Use the built-in shell_out helper available in Chef Infra Client 12.11+ instead of calling Mixlib::ShellOut.new('foo').run_command. StyleGuide: 'chef_modernize_shellouthelper' Enabled: true VersionAdded: '6.5.0' Exclude: - '**/metadata.rb' - '**/Berksfile' - '**/libraries/*.rb' Chef/Modernize/ConditionalUsingTest: Description: Use ::File.exist?('/foo/bar') instead of the slower 'test -f /foo/bar' which requires shelling out. StyleGuide: 'chef_modernize_conditionalusingtest' Enabled: true VersionAdded: '6.11.0' Exclude: - '**/metadata.rb' - '**/Berksfile' - '**/attributes/*.rb' Chef/Modernize/CronDFileOrTemplate: Description: Use the cron_d resource that ships with Chef Infra Client 14.4+ instead of manually creating the file with template, file, or cookbook_file resources StyleGuide: 'chef_modernize_crondfileortemplate' Enabled: true VersionAdded: '6.13.0' Exclude: - '**/metadata.rb' - '**/Berksfile' - '**/attributes/*.rb' Chef/Modernize/ActionMethodInResource: Description: Use the custom resource language's `action :my_action` blocks instead of creating actions with methods. StyleGuide: 'chef_modernize_actionmethodinresource' Enabled: true VersionAdded: '6.13.0' Include: - '**/resources/*.rb' - '**/providers/*.rb' ############################### # Chef/RedundantCode: Cleanup unnecessary code in your cookbooks regardless of Chef Infra Client release ############################### Chef/RedundantCode: StyleGuideBaseURL: https://docs.chef.io/workstation/cookstyle/ Chef/RedundantCode/ConflictsMetadata: Description: Don't use the deprecated 'conflicts' metadata value StyleGuide: 'chef_redundantcode_conflictsmetadata' Enabled: true VersionAdded: '5.1.0' VersionChanged: '5.15.0' Include: - '**/metadata.rb' Chef/RedundantCode/SuggestsMetadata: Description: The suggests metadata.rb method is not used and is unnecessary in cookbooks. StyleGuide: 'chef_redundantcode_suggestsmetadata' Enabled: true VersionAdded: '5.1.0' VersionChanged: '5.15.0' Include: - '**/metadata.rb' Chef/RedundantCode/ProvidesMetadata: Description: The provides metadata.rb method is not used and is unnecessary in cookbooks. StyleGuide: 'chef_redundantcode_providesmetadata' Enabled: true VersionAdded: '5.1.0' VersionChanged: '5.15.0' Include: - '**/metadata.rb' Chef/RedundantCode/ReplacesMetadata: Description: The replaces metadata.rb method is not used and is unnecessary in cookbooks. StyleGuide: 'chef_redundantcode_replacesmetadata' Enabled: true VersionAdded: '5.1.0' VersionChanged: '5.15.0' Include: - '**/metadata.rb' Chef/RedundantCode/AttributeMetadata: Description: The attribute metadata.rb method is not used and is unnecessary in cookbooks. StyleGuide: 'chef_redundantcode_attributemetadata' Enabled: true VersionAdded: '5.1.0' VersionChanged: '5.15.0' Include: - '**/metadata.rb' Chef/RedundantCode/LongDescriptionMetadata: Description: The long_description metadata.rb method is not used and is unnecessary in cookbooks StyleGuide: 'chef_redundantcode_longdescriptionmetadata' Enabled: true VersionAdded: '5.2.0' VersionChanged: '5.15.0' Include: - '**/metadata.rb' Chef/RedundantCode/RecipeMetadata: Description: The recipe metadata.rb method is not used and is unnecessary in cookbooks. Recipes should be documented in the README.md file instead. StyleGuide: 'chef_redundantcode_recipemetadata' Enabled: true VersionAdded: '5.6.0' VersionChanged: '5.15.0' Include: - '**/metadata.rb' Chef/RedundantCode/ResourceWithNothingAction: Description: There is no need to define a :nothing action in your resource as Chef Infra Client provides the :nothing action by default for every resource. StyleGuide: 'chef_redundantcode_resourcewithnothingaction' Enabled: true VersionAdded: '5.12.0' VersionChanged: '5.15.0' Include: - '**/libraries/*.rb' - '**/resources/*.rb' - '**/providers/*.rb' Chef/RedundantCode/UnnecessaryNameProperty: Description: There is no need to define a property named :name in a resource as Chef Infra defines that property for all resources by default. StyleGuide: 'chef_redundantcode_unnecessarynameproperty' Enabled: true VersionAdded: '5.8.0' VersionChanged: '5.15.0' Include: - '**/resources/*.rb' - '**/libraries/*.rb' Chef/RedundantCode/PropertyWithRequiredAndDefault: Description: Resource property should not be both required and have a default value StyleGuide: 'chef_redundantcode_propertywithrequiredanddefault' Enabled: true VersionAdded: '5.1.0' VersionChanged: '5.15.0' Include: - '**/resources/*.rb' - '**/libraries/*.rb' Chef/RedundantCode/NamePropertyIsRequired: Description: Resource properties marked as name properties should not also be required properties StyleGuide: 'chef_redundantcode_namepropertyisrequired' Enabled: true VersionAdded: '5.1.0' VersionChanged: '5.15.0' Include: - '**/resources/*.rb' - '**/libraries/*.rb' Chef/RedundantCode/CustomResourceWithAllowedActions: Description: It is not necessary to set `actions` or `allowed_actions` in custom resources as Chef Infra Client determines these automatically from the set of all actions defined in the resource. StyleGuide: 'chef_redundantcode_customresourcewithallowedactions' Enabled: true VersionAdded: '5.2.0' VersionChanged: '5.15.0' Include: - '**/resources/*.rb' Chef/RedundantCode/SensitivePropertyInResource: Description: Every Chef Infra resources already include a sensitive property with a default value of false. StyleGuide: 'chef_redundantcode_sensitivepropertyinresource' Enabled: true VersionAdded: '5.16.0' Include: - '**/resources/*.rb' - '**/libraries/*.rb' Chef/RedundantCode/UnnecessaryDesiredState: Description: 'There is no need to set a property to desired_state: true as all properties have a desired_state of true by default.' StyleGuide: 'chef_redundantcode_unnecessarydesiredstate' Enabled: true VersionAdded: '5.16.0' Include: - '**/resources/*.rb' - '**/libraries/*.rb' Chef/RedundantCode/AptRepositoryNotifiesAptUpdate: Description: There is no need to notify an apt-get update when an apt_repository is created as this is done automatically by the apt_repository resource. StyleGuide: 'chef_redundantcode_aptrepositorynotifiesaptupdate' Enabled: true VersionAdded: '5.17.0' Exclude: - '**/metadata.rb' - '**/attributes/*.rb' - '**/Berksfile' Chef/RedundantCode/AptRepositoryDistributionDefault: Description: There is no need to pass `distribution node['lsb']['codename']` to an apt_repository resource as this is done automatically by the apt_repository resource. StyleGuide: 'chef_redundantcode_aptrepositorydistributiondefault' Enabled: true VersionAdded: '5.17.0' Exclude: - '**/metadata.rb' - '**/attributes/*.rb' - '**/Berksfile' Chef/RedundantCode/GroupingMetadata: Description: The grouping metadata.rb method is not used and is unnecessary in cookbooks. StyleGuide: 'chef_redundantcode_groupingmetadata' Enabled: true VersionAdded: '5.19.0' Include: - '**/metadata.rb' Chef/RedundantCode/StringPropertyWithNilDefault: Description: Properties have a nil value by default so there is no need to set the default value to nil. StyleGuide: 'chef_redundantcode_stringpropertywithnildefault' Enabled: true VersionAdded: '5.21.0' Include: - '**/resources/*.rb' - '**/libraries/*.rb' Chef/RedundantCode/PropertySplatRegex: Description: There is no need to validate the input of properties in resources using a regex value that will always pass. StyleGuide: 'chef_redundantcode_propertysplatregex' Enabled: true VersionAdded: '5.21.0' Include: - '**/resources/*.rb' - '**/libraries/*.rb' Chef/RedundantCode/UseCreateIfMissing: Description: Use the :create_if_missing action instead of not_if with a ::File.exist(FOO) check. StyleGuide: 'chef_redundantcode_usecreateifmissing' Enabled: true VersionAdded: '6.2.0' Exclude: - '**/metadata.rb' - '**/attributes/*.rb' - '**/Berksfile' Chef/RedundantCode/OhaiAttributeToString: Description: Many Ohai node attributes are already strings and don't need to be cast to strings again StyleGuide: 'chef_redundantcode_ohaiattributetostring' Enabled: true VersionAdded: '6.10.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/RedundantCode/MultiplePlatformChecks: Description: You can pass multiple values to the platform? and platform_family? helpers instead of calling the helpers multiple times. StyleGuide: 'chef_redundantcode_multipleplatformchecks' Enabled: true VersionAdded: '6.10.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/RedundantCode/DoubleCompileTime: Description: If a resource includes the `compile_time` property there's no need to also use `.run_action(:some_action)` on the resource block StyleGuide: 'chef_redundantcode_doublecompiletime' Enabled: true VersionAdded: '6.13.0' Exclude: - '**/metadata.rb' - '**/attributes/*.rb' - '**/Berksfile' ############################### # Chef/Effortless: Migrating to new patterns ############################### Chef/Effortless: StyleGuideBaseURL: https://docs.chef.io/workstation/cookstyle/ Chef/Effortless/CookbookUsesSearch: Description: Cookbook uses search, which cannot be used in the Effortless Infra pattern StyleGuide: 'chef_effortless_cookbookusessearch' Enabled: false VersionAdded: '5.1.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Effortless/CookbookUsesDatabags: Description: Cookbook uses data bags, which cannot be used in the Effortless Infra pattern StyleGuide: 'chef_effortless_cookbookusesdatabags' Enabled: false VersionAdded: '5.1.0' Exclude: - '**/metadata.rb' - '**/Berksfile' # https://github.com/chef/cookstyle/issues/346 Chef/Effortless/ChefVaultUsed: Description: Cookbook uses Chef Vault, which cannot be used in the Effortless Infra pattern StyleGuide: 'chef_effortless_cookbookuseschefvault' Enabled: false VersionAdded: '6.19' Exclude: - '**/metadata.rb' - '**/Berksfile' # https://github.com/chef/cookstyle/issues/346 Chef/Effortless/DependsChefVault: Description: Cookbook depends on Chef Vault, which cannot be used in the Effortless Infra pattern StyleGuide: 'chef_effortless_cookbookdependschefvault' Enabled: false VersionAdded: '6.19' Include: - '**/metadata.rb' Chef/Effortless/CookbookUsesEnvironments: Description: Cookbook uses environments, which cannot be used in the Effortless Infra pattern StyleGuide: 'chef_effortless_cookbookusesenvironments' Enabled: false VersionAdded: '5.10.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Effortless/CookbookUsesPolicygroups: Description: Cookbook uses Policy Groups, which cannot be used in the Effortless Infra pattern StyleGuide: 'chef_effortless_cookbookusespolicygroups' Enabled: false VersionAdded: '5.10.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Effortless/CookbookUsesRoles: Description: Cookbook uses Roles, which cannot be used in the Effortless Infra pattern StyleGuide: 'chef_effortless_cookbookusesroles' Enabled: false VersionAdded: '5.10.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Effortless/SearchForEnvironmentsOrRoles: Description: Cookbook uses search with a node query that looks for a role or environment StyleGuide: 'chef_effortless_searchforenvironmentsorroles' Enabled: false VersionAdded: '5.11.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Effortless/Berksfile: Description: Policyfiles should be used for cookbook dependency solving instead of a Berkshelf Berksfile. StyleGuide: 'chef_effortless_berksfile' Enabled: false VersionAdded: '5.12.0' Include: - '**/Berksfile' #### The base rubocop 0.37 enabled.yml file we started with #### Layout/AccessModifierIndentation: 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 AllowAdjacentOneLineDefs: 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 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 Style/Proc: Enabled: true Style/RaiseArgs: Enabled: true # disabled for now as this breaks ruby_block resources Style/RedundantBegin: Enabled: false 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/IndentationStyle: Enabled: true Layout/TrailingEmptyLines: 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 Style/WhenThen: Enabled: true Style/WhileUntilDo: Enabled: true Style/WhileUntilModifier: Enabled: true Style/WordArray: Enabled: true Style/ZeroLengthPredicate: 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: AutoCorrect: true 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 AutoCorrect: 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 # file names don't matter in cookbooks Naming/FileName: Enabled: false # disable all the length cops as they're not appropriate for cookbooks Layout/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 Metrics/BlockNesting: Enabled: false Metrics/ParameterLists: Enabled: false # The warning message from this is misleading and can lead to wrong but syntactically valid code. Lint/SendWithMixinArgument: Enabled: false # this migrates old # rubocop: comments to use the latest namespaces, which prevents a ton of spam during cookstyle runs Migration/DepartmentName: Enabled: true # 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 # It doesn't matter if people use the friendly helpers or not for overall readability Style/NumericPredicate: Enabled: false # 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 # extend self and module_function are not the same. module_function makes all the methods private # and this rule will break any library that worked with extend self. Style/ModuleFunction: Enabled: false # Avoid using extra then statements in a multiline case Style/MultilineWhenThen: Enabled: true # .each_key is a lot more clear that .keys.each Style/HashEachMethods: Enabled: true # We want to catch this deprecation in cookbooks Lint/DeprecatedOpenSSLConstant: Enabled: true # This just isn't a big deal in the context of a cookbook Naming/AccessorMethodName: Enabled: false # Rescuing a particular exception twice isn't going to work Lint/DuplicateRescueException: Enabled: true # if b == 0 && b == 0 is invalid and we should flag it Lint/BinaryOperatorWithIdenticalOperands: Enabled: true # returning at the top level with an arg is invalid # @TODO we can enable this once this is fixed: https://github.com/rubocop-hq/rubocop/issues/8462 # Lint/TopLevelReturnWithArgument: # Enabled: true # simplify hash access that doesn't actually need .dig Style/SingleArgumentDig: Enabled: true # trying to access $2 when there is no $2 will always return nil Lint/OutOfRangeRegexpRef: Enabled: true # simplify how people coerce arrays Style/ArrayCoercion: Enabled: true # if your elseif is the same as your if you're gonna have a bad day Lint/DuplicateElsifCondition: Enabled: true # simplify attr_reader and attr_write into attr_accessor Style/BisectedAttrAccessor: Enabled: true # avoid assignments that aren't needed Style/RedundantAssignment: Enabled: true # alert on invalid ruby Lint/Syntax: Enabled: true # remove extra requires like 'thread' Lint/RedundantRequireStatement: Enabled: true # simplify stripping strings Style/Strip: Enabled: true # simplify how you warn Style/StderrPuts: Enabled: true # more code simplification Style/Sample: Enabled: true # simpler returns Style/ReturnNil: Enabled: true # use .sort when .sort_by isn't needed Style/RedundantSortBy: 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 # Ruby 2 makes these pointless Style/Encoding: Enabled: true # Use __dir__ to simplify things Style/Dir: Enabled: true # Use __FILE__ or __dir__ to simplify expand_paths Style/ExpandPathArguments: Enabled: true # Avoid a safe navigation operator if we don't need it Lint/RedundantSafeNavigation: Enabled: true # Avoid using blocks to remove nils from a Hash/Array Style/CollectionCompact: Enabled: true # eventually these constants are going to break code so fix them Lint/DeprecatedConstants: Enabled: true # always turn on deprecation cops from rubocop Lint/ErbNewArguments: Enabled: true