AllCops: TargetRubyVersion: 2.4 TargetChefVersion: ~ Exclude: - '/**/files/**/*' - '/**/vendor/**/*' - Guardfile ############################### # Chef/Style: Making cookbooks look better ############################### Chef/Style: StyleGuideBaseURL: https://github.com/chef/cookstyle/blob/master/docs/cops_chef_style.md Chef/Style/AttributeKeys: Description: Check which style of keys are used to access node attributes. StyleGuide: '#chefstyleattributekeys' 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: '#chefstylecopyrightcommentformat' Enabled: false VersionAdded: '5.0.0' Chef/Style/CommentSentenceSpacing: Description: Use a single space after sentences in comments StyleGuide: '#chefstylecommentsentencespacing' Enabled: false VersionAdded: '5.1.0' Chef/Style/CommentFormat: Description: Use Chef's unique format for comment headers StyleGuide: '#chefstylecommentformat' 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: '#chefstylefilemode' 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: '#chefstyleuseplatformhelpers' 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: '#chefstylesimplifyplatformmajorversioncheck' 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: '#chefstyledefaultcopyrightcomments' 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: '#chefstyleunnecessaryplatformcasestatement' Enabled: true VersionAdded: '5.16.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Style/ImmediateNotificationTiming: Description: Use :immediately instead of :immediate for resource notification timing. StyleGuide: '#chefstyleimmediatenotificationtiming' 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: '#chefstyletrueclassfalseclassresourceproperties' 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: '#chefstyleovercomplexsupportsdependsmetadata' 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: '#chefstylechefwhaaat' 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: '#chefstyleunnecessaryoscheck' 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: '#chefstylenegatingonlyif' 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://github.com/chef/cookstyle/blob/master/docs/cops_chef_correctness.md Chef/Correctness/ServiceResource: Description: Use a service resource to start and stop services instead of execute resources StyleGuide: '#chefcorrectnessserviceresource' Enabled: true VersionAdded: '5.0.0' Exclude: - '**/attributes/*.rb' - '**/metadata.rb' - '**/Berksfile' Chef/Correctness/NodeNormal: Description: Do not use the node.normal method StyleGuide: '#chefcorrectnessnodenormal' Enabled: true VersionAdded: '5.1.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Correctness/NodeNormalUnless: Description: Do not use the node.normal_unless method 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: '#chefcorrectnessnodenormalunless' Enabled: true VersionAdded: '5.0.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Correctness/InvalidPlatformMetadata: Description: metadata.rb "supports" platform is invalid StyleGuide: '#chefcorrectnessinvalidplatformmetadata' 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: '#chefcorrectnesscookbookusesnodesave' 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: '#chefcorrectnessmetadatamissingname' 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 be executed as Ruby code which will always returns true instead of a shell command that will actually run. StyleGuide: '#chefcorrectnessblockguardwithonlystring' 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: '#chefcorrectnessresourcesetsinternalproperties' 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: '#chefcorrectnessresourcesetsnameproperty' 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: '#chefcorrectnessresourcewithnoneaction' 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: '#chefcorrectnessinvalidversionmetadata' 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: '#chefcorrectnessnotifiesactionnotsymbol' 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: '#chefcorrectnessincorrectlibraryinjection' Enabled: true VersionAdded: '5.10.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Correctness/InvalidPlatformHelper: Description: Pass valid platforms to the platform? helper. StyleGuide: '#chefcorrectnessinvalidplatformhelper' Enabled: true VersionAdded: '5.15.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Correctness/InvalidPlatformFamilyHelper: Description: Pass valid platform families to the platform_family? helper. StyleGuide: '#chefcorrectnessinvalidplatformfamilyhelper' 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: '#chefcorrectnessscopedfileexist' 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: '#chefcorrectnessinvalidplatformvalueforplatformfamilyhelper' Enabled: true VersionAdded: '5.15.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Correctness/InvalidPlatformValueForPlatformHelper: Description: Pass valid platforms to the value_for_platform helper. StyleGuide: '#chefcorrectnessinvalidplatformvalueforplatformhelper' 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: '#chefcorrectnessinvalidnotificationtiming' 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: '#chefcorrectnessmalformedplatformvalueforplatformhelper' Enabled: true VersionAdded: '5.16.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Correctness/DnfPackageAllowDowngrades: Description: dnf_package does not support the allow_downgrades property StyleGuide: '#chefcorrectnessdnfpackageallowdowngrades' 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: '#chefcorrectnesschefapplicationfatal' 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: '#chefcorrectnesspowershellscriptdeletefiles' 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: '#chefcorrectnessconditionalrubyshellout' 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: '#chefcorrectnesslazyevalnodeattributedefaults' 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: '#chefcorrectnessopensslpasswordhelpers' Enabled: true VersionAdded: '6.6.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Correctness/InvalidPlatformFamilyInCase: Description: Use valid platform family values in case statements. StyleGuide: '#chefcorrectnessinvalidplatformfamilyincase' Enabled: true VersionAdded: '6.6.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Correctness/InvalidPlatformInCase: Description: Use valid platform values in case statements. StyleGuide: '#chefcorrectnessinvalidplatformincase' 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: '#chefcorrectnessinvaliddefaultaction' 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: '#chefcorrectnesssupportsmustbefloat' 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: '#chefcorrectnessmacosuserdefaultsinvalidtype' 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: '#chefcorrectnesslazyinresourceguard' 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: '#chefcorrectnesspropertywithouttype' 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: '#chefcorrectnessoctalmodeasstring' 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://github.com/chef/cookstyle/blob/master/docs/cops_chef_sharing.md Chef/Sharing/InsecureCookbookURL: Description: Insecure http Github or Gitlab URLs for metadata source_url/issues_url fields StyleGuide: '#chefsharinginsecurecookbookurl' 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: '#chefsharinginvalidlicensestring' 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: '#chefsharingdefaultmetadatamaintainer' 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: '#chefsharingemptymetadatafield' 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: '#chefsharingincludepropetydescriptions' 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: '#chefsharingincluderesourcedescriptions' 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: '#chefsharingincluderesourceexamples' Enabled: false VersionAdded: '6.10.0' Include: - '**/resources/*.rb' ############################### # Chef/Deprecations: Resolving Deprecations that block upgrading Chef Infra Client ############################### Chef/Deprecations: StyleGuideBaseURL: https://github.com/chef/cookstyle/blob/master/docs/cops_chef_deprecations.md Chef/Deprecations/NodeDeepFetch: Description: Do not use the deprecated chef-sugar node.deep_fetch methods StyleGuide: '#chefdeprecationsnodedeepfetch' Enabled: true VersionAdded: '5.12.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Deprecations/NodeSet: Description: Do not use the deprecated node.set method StyleGuide: '#chefdeprecationsnodeset' Enabled: true VersionAdded: '5.0.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Deprecations/NodeSetUnless: Description: Do not use the deprecated node.set_unless method StyleGuide: '#chefdeprecationsnodesetunless' Enabled: true VersionAdded: '5.1.0' Exclude: - '**/metadata.rb' - '**/Berksfile' Chef/Deprecations/EpicFail: Description: Use ignore_failure method instead of the deprecated epic_fail method StyleGuide: '#chefdeprecationsepicfail' 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: '#chefdeprecationscookbookdependsonpoise' 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: '#chefdeprecationscookbookdependsoncompatresource' 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: '#chefdeprecationscookbookdependsonpartialsearch' 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: '#chefdeprecationseasyinstallresource' 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: '#chefdeprecationserlcallresource' 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: '#chefdeprecationsrequirerecipe' 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: '#chefdeprecationsnodemethodsinsteadofattributes' 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: '#chefdeprecationsusesdeprecatedmixins' 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: '#chefdeprecationsincludingxmlrubyrecipe' 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: '#chefdeprecationslegacyyumcookbookrecipes' 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: '#chefdeprecationsuseschefresthelpers' 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: '#chefdeprecationschocolateypackageuninstallaction' 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: '#chefdeprecationslaunchddeprecatedhashproperty' 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: '#chefdeprecationslocaledeprecatedlcallproperty' 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: '#chefdeprecationsuserdeprecatedsupportsproperty' 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: '#chefdeprecationsuseinlineresourcesdefined' 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: '#chefdeprecationsincludingyumdnfcompatrecipe' 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: '#chefdeprecationswindowstaskchangeaction' 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: '#chefdeprecationsresourceoverridesprovidesmethod' 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: '#chefdeprecationsresourceusesdslnamemethod' 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: '#chefdeprecationsresourceusesupdatedmethod' 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: '#chefdeprecationsnamepropertywithdefaultvalue' 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: '#chefdeprecationsresourceusesproviderbasemethod' 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: '#chefdeprecationschefspeccoveragereport' 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: '#chefdeprecationschefspeclegacyrunner' 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: '#chefdeprecationsusesruncommandhelper' Enabled: true VersionAdded: '5.9.0' Exclude: - '**/metadata.rb' - '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: '#chefdeprecationschefhandlerusessupports' 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: '#chefdeprecationsdeprecatedyumrepositoryproperties' Enabled: true VersionAdded: '5.10.0' Exclude: - '**/metadata.rb' Chef/Deprecations/EOLAuditModeUsage: Description: The beta Audit Mode feature in Chef Infra Client was removed in Chef Infra Client 15.0. Users should instead use InSpec and the audit cookbook. See https://www.inspec.io/ for more informmation. StyleGuide: '#chefdeprecationseolauditmodeusage' Enabled: true VersionAdded: '5.10.0' Exclude: - '**/metadata.rb' 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: '#chefdeprecationsresourceinheritsfromcompatresource' 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: '#chefdeprecationsverifypropertyusesfileexpansion' Enabled: true VersionAdded: '5.10.0' Exclude: - '**/metadata.rb' 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: '#chefdeprecationspoisearchiveusage' Enabled: true VersionAdded: '5.11.0' Chef/Deprecations/PartialSearchHelperUsage: Description: Legacy partial_search usage should be updated to use :filter_result in the search helper instead. StyleGuide: '#chefdeprecationspartialsearchhelperusage' Enabled: true VersionAdded: '5.11.0' Exclude: - '**/metadata.rb' Chef/Deprecations/SearchUsesPositionalParameters: Description: Don't use deprecated positional parameters in cookbook search queries. StyleGuide: '#chefdeprecationssearchusespositionalparameters' 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: '#chefdeprecationspartialsearchclassusage' Enabled: true VersionAdded: '5.11.0' Exclude: - '**/metadata.rb' Chef/Deprecations/Cheffile: Description: The Libarian-Chef depsolving project is no longer maintained and should not be used for cookbook depsolving. Consider using Policyfiles instead. StyleGuide: '#chefdeprecationscheffile' 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: '#chefdeprecationslegacynotifysyntax' Enabled: true VersionAdded: '5.13.0' Exclude: - '**/metadata.rb' Chef/Deprecations/NodeSetWithoutLevel: Description: When setting a node attribute in Chef Infra Client 11 and later you must specify the precedence level. StyleGuide: '#chefdeprecationsnodesetwithoutlevel' 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: '#chefdeprecationschefrewind' 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: '#chefdeprecationsrubyblockcreateaction' 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: '#chefdeprecationsdeprecatedplatformmethods' 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: '#chefdeprecationsdeprecatedchefspecplatform' 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: '#chefdeprecationswindowsfeatureservermanagercmd' 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: '#chefdeprecationsdeprecatedwindowsversioncheck' 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: '#chefdeprecationschefwindowsplatformhelper' 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: '#chefdeprecationslogresourcenotifications' 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: '#chefdeprecationsresourcewithoutnameorprovides' 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: '#chefdeprecationswindowsversionhelpers' 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: '#chefdeprecationspowershellcookbookhelpers' 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: '#chefdeprecationsdeprecatedshelloutmethods' 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: '#chefdeprecationsruby27keywordargumentwarnings' 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: '#chefdeprecationsresourceusesonlyresourcename' 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: '#chefdeprecationschefdkgenerators' 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 in order to use the chef_handler resource. StyleGuide: '#chefdeprecationschefhandlerrecipe' 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: '#chefdeprecationsuseautomaticresourcename' 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: '#chefdeprecationsmacosuserdefaultsglobalproperty' 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: '#chefdeprecationscookbooksdependonself' Enabled: true VersionAdded: '5.2.0' VersionChanged: '6.16.0' Include: - '**/metadata.rb' Chef/Deprecations/ChefShellout: Description: Don't use deprecated Chef::ShellOut which was removed in Chef Infra Client 13. Use Mixlib::ShellOut instead, which behaves identically. StyleGuide: '#chefdeprecationschefshellout' 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: '#chefdeprecationsexecutepathproperty' 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: '#chefdeprecationsexecuterelativecreateswithoutcwd' 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: '#chefdeprecationswindowspackageinstallertypestring' 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: '#chefdeprecationsuseyamldump' 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: '#chefdeprecationslibrarianchefspec' 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: '#chefdeprecationsfoodcritictesting' Enabled: true VersionAdded: '7.1.0' Include: - '**/Rakefile' - '**/Gemfile' ############################### # Chef/Modernize: Cleaning up legacy code and using new built-in resources ############################### Chef/Modernize: StyleGuideBaseURL: https://github.com/chef/cookstyle/blob/master/docs/cops_chef_modernize.md Chef/Modernize/LegacyBerksfileSource: Description: Do not use legacy Berksfile community sources. Use Chef Supermarket instead. StyleGuide: '#chefmodernizelegacyberksfilesource' 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: '#chefmodernizewhyrunsupportedtrue' 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: '#chefmodernizeunnecessarydependschef14' 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: '#chefmodernizerespondtoinmetadata' 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: '#chefmodernizerespondtoresourcename' 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: '#chefmodernizerespondtoprovides' Enabled: true VersionAdded: '5.2.0' Include: - '**/providers/*.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: '#chefmodernizesetorreturninresources' Enabled: true VersionAdded: '5.2.0' Include: - '**/resources/*.rb' - '**/libraries/*.rb' Chef/Modernize/CustomResourceWithAttributes: Description: Custom Resources should contain properties not attributes. StyleGuide: '#chefmodernizecustomresourcewithattributes' 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: '#chefmodernizeincludingaptdefaultrecipe' 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: '#chefmodernizeincludingwindowsdefaultrecipe' 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: '#chefmodernizedefineschefspecmatchers' 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: '#chefmodernizeexecuteaptupdate' 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: '#chefmodernizeminitesthandlerusage' 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: '#chefmodernizeincludingmixinshelloutinresources' 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: '#chefmodernizeusebuildessentialresource' 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: '#chefmodernizewindowszipfileusage' 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: '#chefmodernizesevenziparchiveresource' 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: '#chefmodernizelibarchivefileresource' 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: '#chefmodernizepowershellscriptexpandarchive' 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: '#chefmodernizepowershellinstallpackage' 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: '#chefmodernizepowershellinstallwindowsfeature' 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: '#chefmodernizeshellouttochocolatey' 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: '#chefmodernizecronmanageresource' 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: '#chefmodernizeuseszypperrepo' 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: '#chefmodernizedependsonzyppercookbook' 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: '#chefmodernizeexecutetzutil' 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: '#chefmodernizeopensslrsakeyresource' 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: '#chefmodernizeopensslx509resource' 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: '#chefmodernizeosxconfigprofileresource' 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: '#chefmodernizesysctlparamresource' 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: '#chefmodernizemacosxuserdefaults' 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: '#chefmodernizepowershellguardinterpreter' 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: '#chefmodernizedefaultactionfrominitialize' 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: '#chefmodernizeresourcenamefrominitialize' 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: '#chefmodernizedefinitions' 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: '#chefmodernizeifprovidesdefaultaction' 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: '#chefmodernizezipfileresource' 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: '#chefmodernizeunnecessarymixlibshelloutrequire' 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: '#chefmodernizeemptyresourceinitializemethod' 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: '#chefmodernizechefgemnokogiri' Enabled: true VersionAdded: '5.14.0' Exclude: - '**/metadata.rb' - '**/attributes/*.rb' Chef/Modernize/PropertyWithNameAttribute: Description: Resource property sets name_attribute not name_property StyleGuide: '#chefmodernizepropertywithnameattribute' 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: '#chefmodernizeincludingohaidefaultrecipe' 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: '#chefmodernizeallowedactionsfrominitialize' 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: '#chefmodernizefoodcriticcomments' 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/resource_windows_service.html for additional details on creating services with the windows_service resource StyleGuide: '#chefmodernizeexecutescexe' 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/resource_windows_service.html for additional details. StyleGuide: '#chefmodernizewindowsscresource' 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: '#chefmodernizeexecutesleep' 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: '#chefmodernizedslincludeinresource' 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: '#chefmodernizeresourceforcingcompiletime' 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: '#chefmodernizeexecutesysctl' 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: '#chefmodernizesimplifyaptppasetup' 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: '#chefmodernizeuserequirerelative' 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: '#chefmodernizenodeinitpackage' 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: '#chefmodernizewindowsregistryuac' 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: '#chefmodernizeusemultipackageinstalls' 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: '#chefmodernizeprovidesfrominitialize' 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: '#chefmodernizedatabaghelpers' 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: '#chefmodernizenoderolesinclude' 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: '#chefmodernizeresondtocompiletime' 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: '#chefmodernizeshellouthelper' 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: '#chefmodernizeconditionalusingtest' 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: '#chefmodernizecrondfileortemplate' 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: '#chefmodernizeactionmethodinresource' Enabled: true VersionAdded: '6.13.0' Include: - '**/resources/*.rb' - '**/providers/*.rb' - '**/libraries/*.rb' ############################### # Chef/RedundantCode: Cleanup unnecessary code in your cookbooks regardless of Chef Infra Client release ############################### Chef/RedundantCode: StyleGuideBaseURL: https://github.com/chef/cookstyle/blob/master/docs/cops_chef_redundantcode.md Chef/RedundantCode/ConflictsMetadata: Description: Don't use the deprecated 'conflicts' metadata value StyleGuide: '#chefredundantcodeconflictsmetadata' 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: '#chefredundantcodesuggestsmetadata' 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: '#chefredundantcodeprovidesmetadata' 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: '#chefredundantcodereplacesmetadata' 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: '#chefredundantcodeattributemetadata' 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: '#chefredundantcodelongdescriptionmetadata' 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: '#chefredundantcoderecipemetadata' 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: '#chefredundantcoderesourcewithnothingaction' 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: '#chefredundantcodeunnecessarynameproperty' 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: '#chefredundantcodepropertywithrequiredanddefault' 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: '#chefredundantcodenamepropertyisrequired' 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: '#chefredundantcodecustomresourcewithallowedactions' 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: '#chefredundantcodesensitivepropertyinresource' 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: '#chefredundantcodeunnecessarydesiredstate' 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: '#chefredundantcodeaptrepositorynotifiesaptupdate' 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: '#chefredundantcodeaptrepositorydistributiondefault' 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: '#chefredundantcodegroupingmetadata' 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: '#chefredundantcodestringpropertywithnildefault' 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: '#chefredundantcodepropertysplatregex' 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: '#chefredundantcodeusecreateifmissing' 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: '#chefredundantcodeohaiattributetostring' 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: '#chefredundantcodemultipleplatformchecks' 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: '#chefredundantcodedoublecompiletime' Enabled: true VersionAdded: '6.13.0' Exclude: - '**/metadata.rb' - '**/attributes/*.rb' - '**/Berksfile' ############################### # Chef/Effortless: Migrating to new patterns ############################### Chef/Effortless: StyleGuideBaseURL: https://github.com/chef/cookstyle/blob/master/docs/cops_chef_effortless.md Chef/Effortless/CookbookUsesSearch: Description: Cookbook uses search, which cannot be used in the Effortless Infra pattern StyleGuide: '#chefeffortlesscookbookusessearch' 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: '#chefeffortlesscookbookusesdatabags' 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: '#chefeffortlesscookbookuseschefvault' 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: '#chefeffortlesscookbookdependschefvault' 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: '#chefeffortlesscookbookusesenvironments' 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: '#chefeffortlesscookbookusespolicygroups' 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: '#chefeffortlesscookbookusesroles' 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: '#chefeffortlesssearchforenvironmentsorroles' 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: '#chefeffortlessberksfile' 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 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 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/IndentationStyle: 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 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 # This updates how we send helpers into the Chef recipe/resource classes and makes WAY more sense # Chef::Recipe.send(:include, ::Apt::Helpers) -> Chef::Recipe.include ::Apt::Helpers Lint/SendWithMixinArgument: Enabled: true # 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 acccess 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