├── .expeditor ├── build.habitat.yml ├── build_docs.sh ├── buildkite │ ├── artifact.habitat.test.ps1 │ └── artifact.habitat.test.sh ├── config.yml ├── habitat-test.pipeline.yml └── update_version.sh ├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE │ ├── BUG_TEMPLATE.md │ ├── DESIGN_PROPOSAL.md │ ├── NEW_COP_REQUEST.md │ └── SUPPORT_QUESTION.md ├── dependabot.yml └── workflows │ ├── lint.yml │ └── unit.yml ├── .gitignore ├── .rspec ├── .rubocop.yml ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── DEVELOPER_GUIDE.md ├── Gemfile ├── LICENSE ├── README.md ├── RELEASE_NOTES.md ├── Rakefile ├── VERSION ├── WRITING_RULES.md ├── bin ├── cookstyle └── cookstyle-profile ├── config ├── chefstyle.yml ├── cookstyle.yml └── default.yml ├── cookstyle.gemspec ├── cspell.json ├── docs-chef-io ├── assets │ └── cookstyle │ │ ├── .gitkeep │ │ ├── cops_chef_correctness_blockguardwithonlystring.yml │ │ ├── cops_chef_correctness_chefapplicationfatal.yml │ │ ├── cops_chef_correctness_conditionalrubyshellout.yml │ │ ├── cops_chef_correctness_cookbookusesnodesave.yml │ │ ├── cops_chef_correctness_dnfpackageallowdowngrades.yml │ │ ├── cops_chef_correctness_incorrectlibraryinjection.yml │ │ ├── cops_chef_correctness_invalidcookbookname.yml │ │ ├── cops_chef_correctness_invaliddefaultaction.yml │ │ ├── cops_chef_correctness_invalidnotificationresource.yml │ │ ├── cops_chef_correctness_invalidnotificationtiming.yml │ │ ├── cops_chef_correctness_invalidplatformfamilyhelper.yml │ │ ├── cops_chef_correctness_invalidplatformfamilyincase.yml │ │ ├── cops_chef_correctness_invalidplatformhelper.yml │ │ ├── cops_chef_correctness_invalidplatformincase.yml │ │ ├── cops_chef_correctness_invalidplatformmetadata.yml │ │ ├── cops_chef_correctness_invalidplatformvalueforplatformfamilyhelper.yml │ │ ├── cops_chef_correctness_invalidplatformvalueforplatformhelper.yml │ │ ├── cops_chef_correctness_invalidversionmetadata.yml │ │ ├── cops_chef_correctness_lazyevalnodeattributedefaults.yml │ │ ├── cops_chef_correctness_lazyinresourceguard.yml │ │ ├── cops_chef_correctness_macosuserdefaultsinvalidtype.yml │ │ ├── cops_chef_correctness_malformedplatformvalueforplatformhelper.yml │ │ ├── cops_chef_correctness_metadatamalformeddepends.yml │ │ ├── cops_chef_correctness_metadatamissingname.yml │ │ ├── cops_chef_correctness_metadatamissingversion.yml │ │ ├── cops_chef_correctness_nodenormal.yml │ │ ├── cops_chef_correctness_nodenormalunless.yml │ │ ├── cops_chef_correctness_notifiesactionnotsymbol.yml │ │ ├── cops_chef_correctness_octalmodeasstring.yml │ │ ├── cops_chef_correctness_opensslpasswordhelpers.yml │ │ ├── cops_chef_correctness_powershellfileexists.yml │ │ ├── cops_chef_correctness_powershellscriptdeletefile.yml │ │ ├── cops_chef_correctness_propertywithouttype.yml │ │ ├── cops_chef_correctness_resourcesetsinternalproperties.yml │ │ ├── cops_chef_correctness_resourcesetsnameproperty.yml │ │ ├── cops_chef_correctness_resourcewithnoneaction.yml │ │ ├── cops_chef_correctness_scopedfileexist.yml │ │ ├── cops_chef_correctness_serviceresource.yml │ │ ├── cops_chef_correctness_supportsmustbefloat.yml │ │ ├── cops_chef_correctness_tmppath.yml │ │ ├── cops_chef_deprecations_chefdkgenerators.yml │ │ ├── cops_chef_deprecations_cheffile.yml │ │ ├── cops_chef_deprecations_chefhandlerrecipe.yml │ │ ├── cops_chef_deprecations_chefhandlerusessupports.yml │ │ ├── cops_chef_deprecations_chefrewind.yml │ │ ├── cops_chef_deprecations_chefshellout.yml │ │ ├── cops_chef_deprecations_chefspeccoveragereport.yml │ │ ├── cops_chef_deprecations_chefspeclegacyrunner.yml │ │ ├── cops_chef_deprecations_chefsugarhelpers.yml │ │ ├── cops_chef_deprecations_chefwindowsplatformhelper.yml │ │ ├── cops_chef_deprecations_chocolateypackageuninstallaction.yml │ │ ├── cops_chef_deprecations_cookbookdependsoncompatresource.yml │ │ ├── cops_chef_deprecations_cookbookdependsonpartialsearch.yml │ │ ├── cops_chef_deprecations_cookbookdependsonpoise.yml │ │ ├── cops_chef_deprecations_cookbooksdependsonself.yml │ │ ├── cops_chef_deprecations_delivery.yml │ │ ├── cops_chef_deprecations_dependsonchefnginxcookbook.yml │ │ ├── cops_chef_deprecations_dependsonchefreportingcookbook.yml │ │ ├── cops_chef_deprecations_dependsonomnibusupdatercookbook.yml │ │ ├── cops_chef_deprecations_deprecatedchefspecplatform.yml │ │ ├── cops_chef_deprecations_deprecatedplatformmethods.yml │ │ ├── cops_chef_deprecations_deprecatedshelloutmethods.yml │ │ ├── cops_chef_deprecations_deprecatedsudoactions.yml │ │ ├── cops_chef_deprecations_deprecatedwindowsversioncheck.yml │ │ ├── cops_chef_deprecations_deprecatedyumrepositoryactions.yml │ │ ├── cops_chef_deprecations_deprecatedyumrepositoryproperties.yml │ │ ├── cops_chef_deprecations_easyinstallresource.yml │ │ ├── cops_chef_deprecations_eolauditmodeusage.yml │ │ ├── cops_chef_deprecations_epicfail.yml │ │ ├── cops_chef_deprecations_erlcallresource.yml │ │ ├── cops_chef_deprecations_executepathproperty.yml │ │ ├── cops_chef_deprecations_executerelativecreateswithoutcwd.yml │ │ ├── cops_chef_deprecations_foodcriticfile.yml │ │ ├── cops_chef_deprecations_foodcritictesting.yml │ │ ├── cops_chef_deprecations_hwrpwithoutprovides.yml │ │ ├── cops_chef_deprecations_hwrpwithoutunifiedtrue.yml │ │ ├── cops_chef_deprecations_includingxmlrubyrecipe.yml │ │ ├── cops_chef_deprecations_includingyumdnfcompatrecipe.yml │ │ ├── cops_chef_deprecations_launchddeprecatedhashproperty.yml │ │ ├── cops_chef_deprecations_legacynotifysyntax.yml │ │ ├── cops_chef_deprecations_legacyyumcookbookrecipes.yml │ │ ├── cops_chef_deprecations_librarianchefspec.yml │ │ ├── cops_chef_deprecations_localedeprecatedlcallproperty.yml │ │ ├── cops_chef_deprecations_logresourcenotifications.yml │ │ ├── cops_chef_deprecations_macosuserdefaultsglobalproperty.yml │ │ ├── cops_chef_deprecations_namepropertywithdefaultvalue.yml │ │ ├── cops_chef_deprecations_nodedeepfetch.yml │ │ ├── cops_chef_deprecations_nodemethodsinsteadofattributes.yml │ │ ├── cops_chef_deprecations_nodeset.yml │ │ ├── cops_chef_deprecations_nodesetunless.yml │ │ ├── cops_chef_deprecations_nodesetwithoutlevel.yml │ │ ├── cops_chef_deprecations_partialsearchclassusage.yml │ │ ├── cops_chef_deprecations_partialsearchhelperusage.yml │ │ ├── cops_chef_deprecations_poisearchiveusage.yml │ │ ├── cops_chef_deprecations_policyfilecommunitysource.yml │ │ ├── cops_chef_deprecations_powershellcookbookhelpers.yml │ │ ├── cops_chef_deprecations_requirerecipe.yml │ │ ├── cops_chef_deprecations_resourceinheritsfromcompatresource.yml │ │ ├── cops_chef_deprecations_resourceoverridesprovidesmethod.yml │ │ ├── cops_chef_deprecations_resourceusesdslnamemethod.yml │ │ ├── cops_chef_deprecations_resourceusesonlyresourcename.yml │ │ ├── cops_chef_deprecations_resourceusesproviderbasemethod.yml │ │ ├── cops_chef_deprecations_resourceusesupdatedmethod.yml │ │ ├── cops_chef_deprecations_resourcewithoutunifiedtrue.yml │ │ ├── cops_chef_deprecations_ruby27keywordargumentwarnings.yml │ │ ├── cops_chef_deprecations_rubyblockcreateaction.yml │ │ ├── cops_chef_deprecations_searchusespositionalparameters.yml │ │ ├── cops_chef_deprecations_useautomaticresourcename.yml │ │ ├── cops_chef_deprecations_useinlineresourcesdefined.yml │ │ ├── cops_chef_deprecations_userdeprecatedsupportsproperty.yml │ │ ├── cops_chef_deprecations_useschefresthelpers.yml │ │ ├── cops_chef_deprecations_usesdeprecatedmixins.yml │ │ ├── cops_chef_deprecations_usesruncommandhelper.yml │ │ ├── cops_chef_deprecations_useyamldump.yml │ │ ├── cops_chef_deprecations_verifypropertyusesfileexpansion.yml │ │ ├── cops_chef_deprecations_windowsfeatureservermanagercmd.yml │ │ ├── cops_chef_deprecations_windowspackageinstallertypestring.yml │ │ ├── cops_chef_deprecations_windowstaskchangeaction.yml │ │ ├── cops_chef_deprecations_windowsversionhelpers.yml │ │ ├── cops_chef_effortless_berksfile.yml │ │ ├── cops_chef_effortless_chefvaultused.yml │ │ ├── cops_chef_effortless_cookbookusesdatabags.yml │ │ ├── cops_chef_effortless_cookbookusesenvironments.yml │ │ ├── cops_chef_effortless_cookbookusespolicygroups.yml │ │ ├── cops_chef_effortless_cookbookusesroles.yml │ │ ├── cops_chef_effortless_cookbookusessearch.yml │ │ ├── cops_chef_effortless_dependschefvault.yml │ │ ├── cops_chef_effortless_searchforenvironmentsorroles.yml │ │ ├── cops_chef_modernize_actionmethodinresource.yml │ │ ├── cops_chef_modernize_allowedactionsfrominitialize.yml │ │ ├── cops_chef_modernize_chefgemnokogiri.yml │ │ ├── cops_chef_modernize_classevalactionclass.yml │ │ ├── cops_chef_modernize_conditionalusingtest.yml │ │ ├── cops_chef_modernize_crondfileortemplate.yml │ │ ├── cops_chef_modernize_cronmanageresource.yml │ │ ├── cops_chef_modernize_customresourcewithattributes.yml │ │ ├── cops_chef_modernize_databaghelpers.yml │ │ ├── cops_chef_modernize_declareactionclass.yml │ │ ├── cops_chef_modernize_defaultactionfrominitialize.yml │ │ ├── cops_chef_modernize_defineschefspecmatchers.yml │ │ ├── cops_chef_modernize_definitions.yml │ │ ├── cops_chef_modernize_dependsonchefvaultcookbook.yml │ │ ├── cops_chef_modernize_dependsonchocolateycookbooks.yml │ │ ├── cops_chef_modernize_dependsonkernelmodulecookbook.yml │ │ ├── cops_chef_modernize_dependsonlocalecookbook.yml │ │ ├── cops_chef_modernize_dependsonopensslcookbook.yml │ │ ├── cops_chef_modernize_dependsontimezonelwrpcookbook.yml │ │ ├── cops_chef_modernize_dependsonwindowsfirewallcookbook.yml │ │ ├── cops_chef_modernize_dependsonzyppercookbook.yml │ │ ├── cops_chef_modernize_dslincludeinresource.yml │ │ ├── cops_chef_modernize_emptyresourceinitializemethod.yml │ │ ├── cops_chef_modernize_executeaptupdate.yml │ │ ├── cops_chef_modernize_executescexe.yml │ │ ├── cops_chef_modernize_executesleep.yml │ │ ├── cops_chef_modernize_executesysctl.yml │ │ ├── cops_chef_modernize_executetzutil.yml │ │ ├── cops_chef_modernize_foodcriticcomments.yml │ │ ├── cops_chef_modernize_ifprovidesdefaultaction.yml │ │ ├── cops_chef_modernize_includingaptdefaultrecipe.yml │ │ ├── cops_chef_modernize_includingmixinshelloutinresources.yml │ │ ├── cops_chef_modernize_includingohaidefaultrecipe.yml │ │ ├── cops_chef_modernize_includingwindowsdefaultrecipe.yml │ │ ├── cops_chef_modernize_legacyberksfilesource.yml │ │ ├── cops_chef_modernize_libarchivefileresource.yml │ │ ├── cops_chef_modernize_macosxuserdefaults.yml │ │ ├── cops_chef_modernize_minitesthandlerusage.yml │ │ ├── cops_chef_modernize_nodeinitpackage.yml │ │ ├── cops_chef_modernize_noderolesinclude.yml │ │ ├── cops_chef_modernize_opensslrsakeyresource.yml │ │ ├── cops_chef_modernize_opensslx509resource.yml │ │ ├── cops_chef_modernize_osxconfigprofileresource.yml │ │ ├── cops_chef_modernize_powershellguardinterpreter.yml │ │ ├── cops_chef_modernize_powershellinstallpackage.yml │ │ ├── cops_chef_modernize_powershellinstallwindowsfeature.yml │ │ ├── cops_chef_modernize_powershellscriptexpandarchive.yml │ │ ├── cops_chef_modernize_propertywithnameattribute.yml │ │ ├── cops_chef_modernize_providesfrominitialize.yml │ │ ├── cops_chef_modernize_resourceforcingcompiletime.yml │ │ ├── cops_chef_modernize_resourcenamefrominitialize.yml │ │ ├── cops_chef_modernize_respondtocompiletime.yml │ │ ├── cops_chef_modernize_respondtoinmetadata.yml │ │ ├── cops_chef_modernize_respondtoprovides.yml │ │ ├── cops_chef_modernize_respondtoresourcename.yml │ │ ├── cops_chef_modernize_setorreturninresources.yml │ │ ├── cops_chef_modernize_sevenziparchiveresource.yml │ │ ├── cops_chef_modernize_shellouthelper.yml │ │ ├── cops_chef_modernize_shellouttochocolatey.yml │ │ ├── cops_chef_modernize_simplifyaptppasetup.yml │ │ ├── cops_chef_modernize_sysctlparamresource.yml │ │ ├── cops_chef_modernize_unnecessarydependschef14.yml │ │ ├── cops_chef_modernize_unnecessarydependschef15.yml │ │ ├── cops_chef_modernize_unnecessarymixlibshelloutrequire.yml │ │ ├── cops_chef_modernize_usebuildessentialresource.yml │ │ ├── cops_chef_modernize_usecheflanguagecloudhelpers.yml │ │ ├── cops_chef_modernize_usecheflanguageenvhelpers.yml │ │ ├── cops_chef_modernize_usecheflanguagesystemdhelper.yml │ │ ├── cops_chef_modernize_usemultipackageinstalls.yml │ │ ├── cops_chef_modernize_userequirerelative.yml │ │ ├── cops_chef_modernize_useszypperrepo.yml │ │ ├── cops_chef_modernize_whyrunsupportedtrue.yml │ │ ├── cops_chef_modernize_windowsregistryuac.yml │ │ ├── cops_chef_modernize_windowsscresource.yml │ │ ├── cops_chef_modernize_windowszipfileusage.yml │ │ ├── cops_chef_modernize_zipfileresource.yml │ │ ├── cops_chef_redundantcode_aptrepositorydistributiondefault.yml │ │ ├── cops_chef_redundantcode_aptrepositorynotifiesaptupdate.yml │ │ ├── cops_chef_redundantcode_attributemetadata.yml │ │ ├── cops_chef_redundantcode_conflictsmetadata.yml │ │ ├── cops_chef_redundantcode_customresourcewithallowedactions.yml │ │ ├── cops_chef_redundantcode_doublecompiletime.yml │ │ ├── cops_chef_redundantcode_groupingmetadata.yml │ │ ├── cops_chef_redundantcode_longdescriptionmetadata.yml │ │ ├── cops_chef_redundantcode_multipleplatformchecks.yml │ │ ├── cops_chef_redundantcode_namepropertyisrequired.yml │ │ ├── cops_chef_redundantcode_ohaiattributetostring.yml │ │ ├── cops_chef_redundantcode_propertysplatregex.yml │ │ ├── cops_chef_redundantcode_propertywithrequiredanddefault.yml │ │ ├── cops_chef_redundantcode_providesmetadata.yml │ │ ├── cops_chef_redundantcode_recipemetadata.yml │ │ ├── cops_chef_redundantcode_replacesmetadata.yml │ │ ├── cops_chef_redundantcode_resourcewithnothingaction.yml │ │ ├── cops_chef_redundantcode_sensitivepropertyinresource.yml │ │ ├── cops_chef_redundantcode_stringpropertywithnildefault.yml │ │ ├── cops_chef_redundantcode_suggestsmetadata.yml │ │ ├── cops_chef_redundantcode_unnecessarydesiredstate.yml │ │ ├── cops_chef_redundantcode_unnecessarynameproperty.yml │ │ ├── cops_chef_redundantcode_usecreateifmissing.yml │ │ ├── cops_chef_ruby_gemspeclicense.yml │ │ ├── cops_chef_ruby_gemspecrequirerubygems.yml │ │ ├── cops_chef_ruby_legacypowershelloutmethods.yml │ │ ├── cops_chef_ruby_requirenethttps.yml │ │ ├── cops_chef_ruby_unlessdefinedrequire.yml │ │ ├── cops_chef_security_sshprivatekey.yml │ │ ├── cops_chef_sharing_defaultmetadatamaintainer.yml │ │ ├── cops_chef_sharing_emptymetadatafield.yml │ │ ├── cops_chef_sharing_includepropertydescriptions.yml │ │ ├── cops_chef_sharing_includeresourcedescriptions.yml │ │ ├── cops_chef_sharing_includeresourceexamples.yml │ │ ├── cops_chef_sharing_insecurecookbookurl.yml │ │ ├── cops_chef_sharing_invalidlicensestring.yml │ │ ├── cops_chef_style_attributekeys.yml │ │ ├── cops_chef_style_chefwhaaat.yml │ │ ├── cops_chef_style_commentformat.yml │ │ ├── cops_chef_style_commentsentencespacing.yml │ │ ├── cops_chef_style_copyrightcommentformat.yml │ │ ├── cops_chef_style_defaultcopyrightcomments.yml │ │ ├── cops_chef_style_filemode.yml │ │ ├── cops_chef_style_immediatenotificationtiming.yml │ │ ├── cops_chef_style_includerecipewithparentheses.yml │ │ ├── cops_chef_style_negatingonlyif.yml │ │ ├── cops_chef_style_overlycomplexsupportsdependsmetadata.yml │ │ ├── cops_chef_style_simplifyplatformmajorversioncheck.yml │ │ ├── cops_chef_style_trueclassfalseclassresourceproperties.yml │ │ ├── cops_chef_style_unnecessaryoscheck.yml │ │ ├── cops_chef_style_unnecessaryplatformcasestatement.yml │ │ ├── cops_chef_style_useplatformhelpers.yml │ │ ├── cops_inspec_deprecations_attributedefault.yml │ │ └── cops_inspec_deprecations_attributehelper.yml └── go.mod ├── docs ├── cops.md ├── cops_chef_correctness.md ├── cops_chef_deprecations.md ├── cops_chef_effortless.md ├── cops_chef_modernize.md ├── cops_chef_redundantcode.md ├── cops_chef_sharing.md └── cops_chef_style.md ├── habitat ├── plan.ps1 ├── plan.sh └── tests │ ├── test.ps1 │ └── test.sh ├── lib ├── cookstyle.rb ├── cookstyle │ ├── chefstyle.rb │ └── version.rb └── rubocop │ ├── chef.rb │ ├── chef │ ├── autocorrect_helpers.rb │ ├── cookbook_helpers.rb │ ├── cookbook_only.rb │ └── platform_helpers.rb │ ├── cop │ ├── chef │ │ ├── correctness │ │ │ ├── block_guard_clause_string_only.rb │ │ │ ├── chef_application_fatal.rb │ │ │ ├── conditional_ruby_shellout.rb │ │ │ ├── dnf_package_allow_downgrades.rb │ │ │ ├── incorrect_library_injection.rb │ │ │ ├── invalid_cookbook_name.rb │ │ │ ├── invalid_default_action.rb │ │ │ ├── invalid_notification_resource.rb │ │ │ ├── invalid_notification_timing.rb │ │ │ ├── invalid_platform_family_helper.rb │ │ │ ├── invalid_platform_family_values_in_case.rb │ │ │ ├── invalid_platform_helper.rb │ │ │ ├── invalid_platform_metadata.rb │ │ │ ├── invalid_platform_values_in_case.rb │ │ │ ├── invalid_value_for_platform_family_helper.rb │ │ │ ├── invalid_value_for_platform_helper.rb │ │ │ ├── invalid_version_metadata.rb │ │ │ ├── lazy_eval_node_attribute_defaults.rb │ │ │ ├── lazy_in_resource_guard.rb │ │ │ ├── macos_userdefaults_invalid_type.rb │ │ │ ├── malformed_value_for_platform.rb │ │ │ ├── metadata_malformed_version.rb │ │ │ ├── metadata_missing_name.rb │ │ │ ├── metadata_missing_version.rb │ │ │ ├── node_normal.rb │ │ │ ├── node_normal_unless.rb │ │ │ ├── node_save.rb │ │ │ ├── notifies_action_not_symbol.rb │ │ │ ├── octal_mode_as_string.rb │ │ │ ├── openssl_password_helpers.rb │ │ │ ├── powershell_delete_file.rb │ │ │ ├── powershell_file_exists.rb │ │ │ ├── property_without_type.rb │ │ │ ├── resource_sets_internal_properties.rb │ │ │ ├── resource_sets_name_property.rb │ │ │ ├── resource_with_none_action.rb │ │ │ ├── scoped_file_exist.rb │ │ │ ├── service_resource.rb │ │ │ ├── supports_must_be_float.rb │ │ │ └── tmp_path.rb │ │ ├── deprecation │ │ │ ├── cb_depends_on_self.rb │ │ │ ├── chef_handler_recipe.rb │ │ │ ├── chef_handler_supports.rb │ │ │ ├── chef_rest.rb │ │ │ ├── chef_rewind.rb │ │ │ ├── chef_shellout.rb │ │ │ ├── chef_sugar_helpers.rb │ │ │ ├── chef_windows_platform_helper.rb │ │ │ ├── chefdk_generators.rb │ │ │ ├── cheffile.rb │ │ │ ├── chefspec_coverage_report.rb │ │ │ ├── chefspec_legacy_runner.rb │ │ │ ├── chocolatey_package_uninstall_action.rb │ │ │ ├── delivery.rb │ │ │ ├── depends_chef_nginx_cookbook.rb │ │ │ ├── depends_chef_reporting_cookbook.rb │ │ │ ├── depends_compat_resource.rb │ │ │ ├── depends_omnibus_updater_cookbook.rb │ │ │ ├── depends_partial_search.rb │ │ │ ├── depends_poise.rb │ │ │ ├── deprecated_chefspec_platform.rb │ │ │ ├── deprecated_mixins.rb │ │ │ ├── deprecated_platform_methods.rb │ │ │ ├── deprecated_shellout_methods.rb │ │ │ ├── deprecated_sudo_actions.rb │ │ │ ├── deprecated_windows_version_check.rb │ │ │ ├── deprecated_yum_repository_actions.rb │ │ │ ├── deprecated_yum_repository_properties.rb │ │ │ ├── easy_install.rb │ │ │ ├── eol_audit_mode.rb │ │ │ ├── epic_fail.rb │ │ │ ├── erl_call.rb │ │ │ ├── execute_path_property.rb │ │ │ ├── execute_relative_creates_without_cwd.rb │ │ │ ├── foodcritic_file.rb │ │ │ ├── foodcritic_testing.rb │ │ │ ├── hwrp_without_provides.rb │ │ │ ├── hwrp_without_unified_mode_true.rb │ │ │ ├── inherits_compat_resource.rb │ │ │ ├── launchd_deprecated_hash_property.rb │ │ │ ├── legacy_notify_syntax.rb │ │ │ ├── legacy_yum_cookbook_recipes.rb │ │ │ ├── librarian_chefspec.rb │ │ │ ├── locale_lc_all_property.rb │ │ │ ├── log_resource_notifications.rb │ │ │ ├── macos_userdefaults_global_property.rb │ │ │ ├── name_property_and_default.rb │ │ │ ├── node_deep_fetch.rb │ │ │ ├── node_methods_not_attributes.rb │ │ │ ├── node_set.rb │ │ │ ├── node_set_unless.rb │ │ │ ├── node_set_without_level.rb │ │ │ ├── partial_search_class_usage.rb │ │ │ ├── partial_search_helper_usage.rb │ │ │ ├── poise_archive.rb │ │ │ ├── policyfile_community_source.rb │ │ │ ├── powershell_cookbook_helpers.rb │ │ │ ├── require_recipe.rb │ │ │ ├── resource_overrides_provides_method.rb │ │ │ ├── resource_uses_dsl_name_method.rb │ │ │ ├── resource_uses_only_resource_name.rb │ │ │ ├── resource_uses_provider_base_method.rb │ │ │ ├── resource_uses_updated_method.rb │ │ │ ├── resource_without_unified_mode_true.rb │ │ │ ├── ruby_27_keyword_argument_warnings.rb │ │ │ ├── ruby_block_create_action.rb │ │ │ ├── run_command_helper.rb │ │ │ ├── search_uses_positional_parameters.rb │ │ │ ├── use_automatic_resource_name.rb │ │ │ ├── use_inline_resources.rb │ │ │ ├── use_yaml_dump.rb │ │ │ ├── user_supports_property.rb │ │ │ ├── verify_property_file_expansion.rb │ │ │ ├── windows_feature_servermanagercmd.rb │ │ │ ├── windows_package_installer_type_string.rb │ │ │ ├── windows_task_change_action.rb │ │ │ ├── windows_version_helpers.rb │ │ │ ├── xml_ruby_recipe.rb │ │ │ └── yum_dnf_compat_recipe.rb │ │ ├── effortless │ │ │ ├── berksfile.rb │ │ │ ├── chef_vault_used.rb │ │ │ ├── data_bags.rb │ │ │ ├── depends_chef_vault.rb │ │ │ ├── node_environment.rb │ │ │ ├── node_policygroup.rb │ │ │ ├── node_roles.rb │ │ │ ├── search_for_environments_or_roles.rb │ │ │ └── search_used.rb │ │ ├── modernize │ │ │ ├── action_method_in_resource.rb │ │ │ ├── allowed_actions_initializer.rb │ │ │ ├── apt_default_recipe.rb │ │ │ ├── berksfile_source.rb │ │ │ ├── build_essential.rb │ │ │ ├── chef_14_resources.rb │ │ │ ├── chef_15_resources.rb │ │ │ ├── chef_gem_nokogiri.rb │ │ │ ├── class_eval_action_class.rb │ │ │ ├── compile_time_resources.rb │ │ │ ├── conditional_using_test.rb │ │ │ ├── cron_d_file_or_template.rb │ │ │ ├── cron_manage_resource.rb │ │ │ ├── databag_helpers.rb │ │ │ ├── declare_action_class.rb │ │ │ ├── default_action_initializer.rb │ │ │ ├── defines_chefspec_matchers.rb │ │ │ ├── definitions.rb │ │ │ ├── depends_chef_vault_cookbook.rb │ │ │ ├── depends_chocolatey_cookbooks.rb │ │ │ ├── depends_kernel_module_cookbook.rb │ │ │ ├── depends_locale_cookbook.rb │ │ │ ├── depends_openssl_cookbook.rb │ │ │ ├── depends_timezone_lwrp_cookbook.rb │ │ │ ├── depends_windows_firewall_cookbook.rb │ │ │ ├── depends_zypper_cookbook.rb │ │ │ ├── dsl_include_in_resource.rb │ │ │ ├── empty_resource_initialize.rb │ │ │ ├── execute_apt_update.rb │ │ │ ├── execute_sc_exe.rb │ │ │ ├── execute_sleep.rb │ │ │ ├── execute_sysctl.rb │ │ │ ├── execute_tzutil.rb │ │ │ ├── foodcritic_comments.rb │ │ │ ├── if_provides_default_action.rb │ │ │ ├── includes_mixin_shellout.rb │ │ │ ├── libarchive_file.rb │ │ │ ├── macos_user_defaults.rb │ │ │ ├── minitest_handler_usage.rb │ │ │ ├── node_init_package.rb │ │ │ ├── node_roles_include.rb │ │ │ ├── ohai_default_recipe.rb │ │ │ ├── openssl_rsa_key_resource.rb │ │ │ ├── openssl_x509_resource.rb │ │ │ ├── osx_config_profile_resource.rb │ │ │ ├── powershell_expand_archive.rb │ │ │ ├── powershell_guard_interpreter.rb │ │ │ ├── powershell_install_package.rb │ │ │ ├── powershell_install_windowsfeature.rb │ │ │ ├── property_with_name_attribute.rb │ │ │ ├── provides_initializer.rb │ │ │ ├── resource_name_initializer.rb │ │ │ ├── resource_set_or_return.rb │ │ │ ├── resource_with_attributes.rb │ │ │ ├── respond_to_compile_time.rb │ │ │ ├── respond_to_metadata.rb │ │ │ ├── respond_to_provides.rb │ │ │ ├── respond_to_resource_name.rb │ │ │ ├── sc_windows_resource.rb │ │ │ ├── seven_zip_archive.rb │ │ │ ├── shell_out_helper.rb │ │ │ ├── shellouts_to_chocolatey.rb │ │ │ ├── simplify_apt_ppa_setup.rb │ │ │ ├── sysctl_param_resource.rb │ │ │ ├── unnecessary_mixlib_shellout_require.rb │ │ │ ├── use_chef_language_cloud_helpers.rb │ │ │ ├── use_chef_language_env_helpers.rb │ │ │ ├── use_chef_language_systemd_helper.rb │ │ │ ├── use_multipackage_installs.rb │ │ │ ├── use_require_relative.rb │ │ │ ├── whyrun_supported_true.rb │ │ │ ├── windows_default_recipe.rb │ │ │ ├── windows_registry_uac.rb │ │ │ ├── windows_zipfile.rb │ │ │ ├── zipfile_resource.rb │ │ │ └── zypper_repo.rb │ │ ├── redundant │ │ │ ├── apt_repository_distribution_default.rb │ │ │ ├── apt_repository_notifies_apt_update.rb │ │ │ ├── attribute_metadata.rb │ │ │ ├── conflicts_metadata.rb │ │ │ ├── custom_resource_with_allowed_actions.rb │ │ │ ├── double_compile_time.rb │ │ │ ├── grouping_metadata.rb │ │ │ ├── long_description_metadata.rb │ │ │ ├── multiple_platform_checks.rb │ │ │ ├── name_property_and_required.rb │ │ │ ├── ohai_attribute_to_string.rb │ │ │ ├── property_splat_regex.rb │ │ │ ├── property_with_default_and_required.rb │ │ │ ├── provides_metadata.rb │ │ │ ├── recipe_metadata.rb │ │ │ ├── replaces_metadata.rb │ │ │ ├── resource_with_nothing_action.rb │ │ │ ├── sensitive_property_in_resource.rb │ │ │ ├── string_property_with_nil_default.rb │ │ │ ├── suggests_metadata.rb │ │ │ ├── unnecessary_desired_state.rb │ │ │ ├── unnecessary_name_property.rb │ │ │ └── use_create_if_missing.rb │ │ ├── security │ │ │ └── ssh_private_key.rb │ │ ├── sharing │ │ │ ├── default_maintainer_metadata.rb │ │ │ ├── empty_metadata_field.rb │ │ │ ├── include_property_descriptions.rb │ │ │ ├── include_resource_descriptions.rb │ │ │ ├── include_resource_examples.rb │ │ │ ├── insecure_cookbook_url.rb │ │ │ └── invalid_license_string.rb │ │ └── style │ │ │ ├── attribute_keys.rb │ │ │ ├── chef_whaaat.rb │ │ │ ├── comment_sentence_spacing.rb │ │ │ ├── comments_copyright_format.rb │ │ │ ├── comments_default_copyright.rb │ │ │ ├── comments_format.rb │ │ │ ├── file_mode.rb │ │ │ ├── immediate_notification_timing.rb │ │ │ ├── include_recipe_with_parentheses.rb │ │ │ ├── negating_only_if.rb │ │ │ ├── overly_complex_supports_depends_metadata.rb │ │ │ ├── simplify_platform_major_version_check.rb │ │ │ ├── true_false_resource_properties.rb │ │ │ ├── unnecessary_os_check.rb │ │ │ ├── unnecessary_platform_case_statement.rb │ │ │ └── use_platform_helpers.rb │ ├── chefstyle │ │ └── ruby │ │ │ ├── gemspec_license.rb │ │ │ ├── gemspec_require_rubygems.rb │ │ │ ├── legacy_powershell_out_methods.rb │ │ │ ├── require_net_https.rb │ │ │ └── unless_defined_require.rb │ ├── inspec │ │ └── deprecation │ │ │ ├── attribute_default.rb │ │ │ └── attribute_helper.rb │ └── target_chef_version.rb │ └── monkey_patches │ ├── allow_invalid_ruby.rb │ ├── base.rb │ ├── config.rb │ ├── directive_comment.rb │ ├── registry_cop.rb │ └── team.rb ├── spec ├── rubocop │ ├── chef │ │ └── cookbook_helpers_spec.rb │ ├── cop │ │ ├── chef │ │ │ ├── correctness │ │ │ │ ├── block_guard_clause_string_only_spec.rb │ │ │ │ ├── chef_application_fatal_spec.rb │ │ │ │ ├── conditional_ruby_shellout_spec.rb │ │ │ │ ├── dnf_package_allow_downgrades_spec.rb │ │ │ │ ├── incorrect_library_injection_spec.rb │ │ │ │ ├── invalid_cookbook_name_spec.rb │ │ │ │ ├── invalid_default_action_spec.rb │ │ │ │ ├── invalid_notification_resource_spec.rb │ │ │ │ ├── invalid_notification_timing_spec.rb │ │ │ │ ├── invalid_platform_family_helper_spec.rb │ │ │ │ ├── invalid_platform_family_values_in_case_spec.rb │ │ │ │ ├── invalid_platform_helper_spec.rb │ │ │ │ ├── invalid_platform_metadata_spec.rb │ │ │ │ ├── invalid_platform_values_in_case_spec.rb │ │ │ │ ├── invalid_value_for_platform_family_helper_spec.rb │ │ │ │ ├── invalid_value_for_platform_helper_spec.rb │ │ │ │ ├── invalid_version_metadata_spec.rb │ │ │ │ ├── lazy_eval_node_attribute_defaults_spec.rb │ │ │ │ ├── lazy_in_resource_guard_spec.rb │ │ │ │ ├── macos_userdefaults_invalid_type_spec.rb │ │ │ │ ├── malformed_value_for_platform_spec.rb │ │ │ │ ├── metadata_malformed_depends_spec.rb │ │ │ │ ├── metadata_missing_name_spec.rb │ │ │ │ ├── metadata_missing_version.rb │ │ │ │ ├── node_normal_spec.rb │ │ │ │ ├── node_normal_unless_spec.rb │ │ │ │ ├── node_save_spec.rb │ │ │ │ ├── notifies_action_not_symbol_spec.rb │ │ │ │ ├── octal_mode_as_string_spec.rb │ │ │ │ ├── openssl_password_helpers_spec.rb │ │ │ │ ├── powershell_delete_file_spec.rb │ │ │ │ ├── powershell_file_exists_spec.rb │ │ │ │ ├── property_without_type_spec.rb │ │ │ │ ├── resource_sets_internal_properties_spec.rb │ │ │ │ ├── resource_sets_name_property_spec.rb │ │ │ │ ├── resource_with_none_action_spec.rb │ │ │ │ ├── scoped_file_exist_spec.rb │ │ │ │ ├── service_resource_spec.rb │ │ │ │ ├── supports_must_be_float_spec.rb │ │ │ │ └── tmp_path_spec.rb │ │ │ ├── deprecation │ │ │ │ ├── cb_depends_on_self_spec.rb │ │ │ │ ├── chef_handler_recipe_spec.rb │ │ │ │ ├── chef_handler_supports_spec.rb │ │ │ │ ├── chef_rest_spec.rb │ │ │ │ ├── chef_rewind_spec.rb │ │ │ │ ├── chef_shellout_spec.rb │ │ │ │ ├── chef_sugar_helpers_spec.rb │ │ │ │ ├── chef_windows_platform_helper_spec.rb │ │ │ │ ├── chefdk_generators_spec.rb │ │ │ │ ├── cheffile_spec.rb │ │ │ │ ├── chefspec_coverage_report_spec.rb │ │ │ │ ├── chefspec_legacy_runner_spec.rb │ │ │ │ ├── chocolatey_package_uninstall_action_spec.rb │ │ │ │ ├── delivery_spec.rb │ │ │ │ ├── depends_chef_nginx_cookbook_spec.rb │ │ │ │ ├── depends_chef_reporting_cookbook_spec.rb │ │ │ │ ├── depends_compat_resource_spec.rb │ │ │ │ ├── depends_omnibus_updater_cookbook_spec.rb │ │ │ │ ├── depends_partial_search_spec.rb │ │ │ │ ├── depends_poise_spec.rb │ │ │ │ ├── deprecated_chefspec_platform_spec.rb │ │ │ │ ├── deprecated_mixins_spec.rb │ │ │ │ ├── deprecated_platform_methods_spec.rb │ │ │ │ ├── deprecated_shellout_methods_spec.rb │ │ │ │ ├── deprecated_sudo_actions_spec.rb │ │ │ │ ├── deprecated_windows_version_check_spec.rb │ │ │ │ ├── deprecated_yum_repository_actions_spec.rb │ │ │ │ ├── deprecated_yum_repository_properties_spec.rb │ │ │ │ ├── easy_install_spec.rb │ │ │ │ ├── eol_audit_mode_spec.rb │ │ │ │ ├── epic_fail_spec.rb │ │ │ │ ├── erl_call_spec.rb │ │ │ │ ├── execute_path_property_spec.rb │ │ │ │ ├── execute_relative_creates_without_cwd_spec.rb │ │ │ │ ├── foodcritic_file_spec.rb │ │ │ │ ├── foodcritic_testing_spec.rb │ │ │ │ ├── hwrp_without_provides_spec.rb │ │ │ │ ├── hwrp_without_unified_mode_true_spec.rb │ │ │ │ ├── inherits_compat_resource_spec.rb │ │ │ │ ├── launchd_deprecated_hash_property_spec.rb │ │ │ │ ├── legacy_notify_syntax_spec.rb │ │ │ │ ├── legacy_yum_cookbook_spec.rb │ │ │ │ ├── librarian_chefspec_spec.rb │ │ │ │ ├── locale_lc_all_property_spec.rb │ │ │ │ ├── log_resource_notification_spec.rb │ │ │ │ ├── macos_userdefaults_global_property_spec.rb │ │ │ │ ├── name_property_and_default_spec.rb │ │ │ │ ├── node_deep_fetch_spec.rb │ │ │ │ ├── node_methods_not_attributes_spec.rb │ │ │ │ ├── node_set_spec.rb │ │ │ │ ├── node_set_unless_spec.rb │ │ │ │ ├── node_set_without_level_spec.rb │ │ │ │ ├── partial_search_class_usage_spec.rb │ │ │ │ ├── partial_search_helper_usage_spec.rb │ │ │ │ ├── poise_archive_spec.rb │ │ │ │ ├── policyfile_community_source_spec.rb │ │ │ │ ├── powershell_cookbook_helpers_spec.rb │ │ │ │ ├── require_recipe_spec.rb │ │ │ │ ├── resource_overrides_provides_method_spec.rb │ │ │ │ ├── resource_uses_dsl_name_method_spec.rb │ │ │ │ ├── resource_uses_only_resource_name_spec.rb │ │ │ │ ├── resource_uses_provider_base_method_spec.rb │ │ │ │ ├── resource_uses_updated_method_spec.rb │ │ │ │ ├── resource_without_unified_mode_true_spec.rb │ │ │ │ ├── ruby_27_keyword_argument_warnings_spec.rb │ │ │ │ ├── ruby_block_create_action_spec.rb │ │ │ │ ├── run_command_helper_spec.rb │ │ │ │ ├── search_uses_positional_parameters_spec.rb │ │ │ │ ├── use_automatic_resource_name_spec.rb │ │ │ │ ├── use_inline_resources_spec.rb │ │ │ │ ├── use_yaml_dump_spec.rb │ │ │ │ ├── user_supports_property_spec.rb │ │ │ │ ├── verify_property_file_expansion_spec.rb │ │ │ │ ├── windows_feature_servermanagercmd_spec.rb │ │ │ │ ├── windows_package_installer_type_string_spec.rb │ │ │ │ ├── windows_task_change_action_spec.rb │ │ │ │ ├── windows_version_helpers_spec.rb │ │ │ │ ├── xml_ruby_recipe_spec.rb │ │ │ │ └── yum_dnf_compat_recipe_spec.rb │ │ │ ├── effortless │ │ │ │ ├── Berksfile_spec.rb │ │ │ │ ├── chef_vault_used_spec.rb │ │ │ │ ├── data_bag_used_spec.rb │ │ │ │ ├── depends_chef_vault_spec.rb │ │ │ │ ├── node_environment_spec.rb │ │ │ │ ├── node_policygroup_spec.rb │ │ │ │ ├── node_roles_spec.rb │ │ │ │ ├── search_for_environments_or_roles_spec.rb │ │ │ │ └── search_used_spec.rb │ │ │ ├── modernize │ │ │ │ ├── action_method_in_resource_spec.rb │ │ │ │ ├── allowed_actions_initializer_spec.rb │ │ │ │ ├── apt_default_recipe_spec.rb │ │ │ │ ├── berksfile_source_spec.rb │ │ │ │ ├── build_essential_spec.rb │ │ │ │ ├── chef_14_resources_spec.rb │ │ │ │ ├── chef_15_resources_spec.rb │ │ │ │ ├── chef_gem_nokogiri_spec.rb │ │ │ │ ├── class_eval_action_class_spec.rb │ │ │ │ ├── compile_time_resources_spec.rb │ │ │ │ ├── conditional_using_test_spec.rb │ │ │ │ ├── cron_d_file_or_template_spec.rb │ │ │ │ ├── cron_manage_resource_spec.rb │ │ │ │ ├── databag_helpers_spec.rb │ │ │ │ ├── declare_action_class_spec.rb │ │ │ │ ├── default_action_initializer_spec.rb │ │ │ │ ├── defines_chefspec_matchers_spec.rb │ │ │ │ ├── definitions_spec.rb │ │ │ │ ├── depends_chef_vault_cookbook_spec.rb │ │ │ │ ├── depends_chocolatey_cookbooks_spec.rb │ │ │ │ ├── depends_kernel_module_cookbook_spec.rb │ │ │ │ ├── depends_locale_cookbook_spec.rb │ │ │ │ ├── depends_openssl_cookbook_spec.rb │ │ │ │ ├── depends_timezone_lwrp_cookbook_spec.rb │ │ │ │ ├── depends_windows_firewall_cookbook_spec.rb │ │ │ │ ├── depends_zypper_cookbook_spec.rb │ │ │ │ ├── dsl_include_in_resource_spec.rb │ │ │ │ ├── empty_resource_initialize_spec.rb │ │ │ │ ├── execute_apt_update_spec.rb │ │ │ │ ├── execute_sc_exe_spec.rb │ │ │ │ ├── execute_sleep_spec.rb │ │ │ │ ├── execute_sysctl_spec.rb │ │ │ │ ├── execute_tzutil_spec.rb │ │ │ │ ├── foodcritic_comments_spec.rb │ │ │ │ ├── if_provides_default_action_spec.rb │ │ │ │ ├── includes_mixin_shellout_spec.rb │ │ │ │ ├── libarchive_file_spec.rb │ │ │ │ ├── macos_user_defaults_spec.rb │ │ │ │ ├── minitest_handler_usage_spec.rb │ │ │ │ ├── node_init_package_spec.rb │ │ │ │ ├── node_roles_include_spec.rb │ │ │ │ ├── ohai_default_recipe_spec.rb │ │ │ │ ├── openssl_rsa_key_resource_spec.rb │ │ │ │ ├── openssl_x509_resource_spec.rb │ │ │ │ ├── osx_config_profile_resource_spec.rb │ │ │ │ ├── powershell_expand_archive_spec.rb │ │ │ │ ├── powershell_guard_interpreter_spec.rb │ │ │ │ ├── powershell_install_package_spec.rb │ │ │ │ ├── powershell_install_windowsfeature_spec.rb │ │ │ │ ├── property_with_name_attribute_spec.rb │ │ │ │ ├── provides_initializer_spec.rb │ │ │ │ ├── resource_name_initializer_spec.rb │ │ │ │ ├── resource_set_or_return_spec.rb │ │ │ │ ├── resource_with_attributes_spec.rb │ │ │ │ ├── respond_to_compile_time_spec.rb │ │ │ │ ├── respond_to_metadata_spec.rb │ │ │ │ ├── respond_to_provides_spec.rb │ │ │ │ ├── respond_to_resource_name_spec.rb │ │ │ │ ├── sc_windows_resource_spec.rb │ │ │ │ ├── seven_zip_archive_spec.rb │ │ │ │ ├── shell_out_helper_spec.rb │ │ │ │ ├── shellout_to_chocolatey_spec.rb │ │ │ │ ├── simplify_apt_ppa_setup_spec.rb │ │ │ │ ├── systctl_param_resource_spec.rb │ │ │ │ ├── unnecessary_mixlib_shellout_require_spec.rb │ │ │ │ ├── use_chef_language_cloud_helpers_spec.rb │ │ │ │ ├── use_chef_language_env_helpers_spec.rb │ │ │ │ ├── use_chef_language_systemd_helper_spec.rb │ │ │ │ ├── use_multipackage_installs_spec.rb │ │ │ │ ├── use_require_relative_spec.rb │ │ │ │ ├── whyrun_supported_true_spec.rb │ │ │ │ ├── windows_default_recipe_spec.rb │ │ │ │ ├── windows_registry_uac_spec.rb │ │ │ │ ├── windows_zipfile_spec.rb │ │ │ │ ├── zipfile_resource_spec.rb │ │ │ │ └── zypper_repo_spec.rb │ │ │ ├── redundant │ │ │ │ ├── apt_repository_distribution_default_spec.rb │ │ │ │ ├── apt_repository_notifies_apt_update_spec.rb │ │ │ │ ├── attribute_metadata_spec.rb │ │ │ │ ├── conflicts_metadata_spec.rb │ │ │ │ ├── custom_resource_with_allowed_actions_spec.rb │ │ │ │ ├── double_compile_time_spec.rb │ │ │ │ ├── grouping_metadata_spec.rb │ │ │ │ ├── long_description_metadata_spec.rb │ │ │ │ ├── multiple_platform_checks_spec.rb │ │ │ │ ├── name_property_and_required_spec.rb │ │ │ │ ├── ohai_attribute_to_string_spec.rb │ │ │ │ ├── property_splat_regex_spec.rb │ │ │ │ ├── property_with_default_and_required_spec.rb │ │ │ │ ├── provides_metadata_spec.rb │ │ │ │ ├── recipe_metadata_spec.rb │ │ │ │ ├── replaces_metadata_spec.rb │ │ │ │ ├── resource_with_nothing_action_spec.rb │ │ │ │ ├── sensitive_property_in_resource_spec.rb │ │ │ │ ├── string_property_with_nil_default_spec.rb │ │ │ │ ├── suggests_metadata_spec.rb │ │ │ │ ├── unnecessary_desired_state_spec.rb │ │ │ │ ├── unnecessary_name_property_spec.rb │ │ │ │ └── use_create_if_missing_spec.rb │ │ │ ├── ruby │ │ │ │ ├── chefspec_license_spec.rb │ │ │ │ ├── gemspec_require_rubygems_spec.rb │ │ │ │ ├── legacy_powershell_out_methods_spec.rb │ │ │ │ ├── require_net_https_spec.rb │ │ │ │ └── unless_defined_require_spec.rb │ │ │ ├── security │ │ │ │ └── ssh_private_key_spec.rb │ │ │ ├── sharing │ │ │ │ ├── default_maintainer_metadata_spec.rb │ │ │ │ ├── empty_metadata_field_spec.rb │ │ │ │ ├── include_property_descriptions_spec.rb │ │ │ │ ├── include_resource_descriptions_spec.rb │ │ │ │ ├── include_resource_examples_spec.rb │ │ │ │ ├── insecure_cookbook_url_spec.rb │ │ │ │ └── invalid_license_string_spec.rb │ │ │ └── style │ │ │ │ ├── attribute_keys_spec.rb │ │ │ │ ├── file_mode_spec.rb │ │ │ │ ├── immediate_notification_timing_spec.rb │ │ │ │ ├── include_recipe_with_parentheses_spec.rb │ │ │ │ ├── negating_only_if_spec.rb │ │ │ │ ├── overly_complex_supports_depends_metadata_spec.rb │ │ │ │ ├── simplify_platform_major_version_check_spec.rb │ │ │ │ ├── true_false_resource_properties_spec.rb │ │ │ │ ├── unnecessary_os_check_spec.rb │ │ │ │ ├── unnecessary_platform_case_statement_spec.rb │ │ │ │ └── use_platform_helpers_spec.rb │ │ └── inspec │ │ │ ├── attribute_default_spec.rb │ │ │ └── attribute_helper_spec.rb │ └── monkey_patches │ │ ├── cookstyle_comment_spec.rb │ │ └── migration_departmentname_spec.rb ├── shared │ └── autocorrect_behavior.rb └── spec_helper.rb └── tasks ├── cops_documentation.rake ├── prof.rake └── spellcheck.rake /.expeditor/build.habitat.yml: -------------------------------------------------------------------------------- 1 | --- 2 | origin: chef 3 | 4 | expeditor: 5 | defaults: 6 | buildkite: 7 | retry: 8 | automatic: 9 | limit: 1 -------------------------------------------------------------------------------- /.expeditor/build_docs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ############################################################################ 4 | # What is this script? 5 | # 6 | # Cookstyle includes a docs directory with content that is autogenerated by 7 | # a rake task. This ensures that all cop documentation is current on each 8 | # merge to the repo. We live in the future. 9 | ############################################################################ 10 | 11 | bundle config set --local without debug profiling 12 | bundle install --jobs=7 --retry=3 13 | bundle exec rake generate_cops_yml_documentation 14 | bundle exec rake update_readme_cop_count 15 | 16 | # Once Expeditor finishes executing this script, it will commit the changes and push 17 | -------------------------------------------------------------------------------- /.expeditor/update_version.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # After a PR merge, Chef Expeditor will bump the PATCH version in the VERSION file. 4 | # It then executes this file to update any other files/components with that new version. 5 | # 6 | 7 | set -evx 8 | 9 | sed -i -r "s/^(\s*)VERSION = \".+\"/\1VERSION = \"$(cat VERSION)\"/" lib/cookstyle/version.rb 10 | 11 | # Once Expeditor finshes executing this script, it will commit the changes and push 12 | # the commit as a new tag corresponding to the value in the VERSION file. 13 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Order is important. The last matching pattern has the most precedence. 2 | 3 | * @chef/chef-infra-owners @chef/chef-infra-approvers @chef/chef-infra-reviewers 4 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/BUG_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: � Bug Report 3 | about: If something isn't working as expected �. 4 | labels: "Status: Untriaged, Type: Bug" 5 | --- 6 | 7 | # Version: 8 | 9 | [Version of the project installed] 10 | 11 | # Environment: 12 | 13 | [Details about the environment such as the Operating System, cookbook details, etc...] 14 | 15 | # Scenario: 16 | 17 | [What you are trying to achieve and you can't?] 18 | 19 | # Steps to Reproduce: 20 | 21 | [If you are filing an issue what are the things we need to do in order to repro your problem?] 22 | 23 | # Expected Result: 24 | 25 | [What are you expecting to happen as the consequence of above reproduction steps?] 26 | 27 | # Actual Result: 28 | 29 | [What actually happens after the reproduction steps?] 30 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/SUPPORT_QUESTION.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 🤗 Support Question 3 | about: If you have a question 💬, please check out our Slack! 4 | --- 5 | 6 | We use GitHub issues to track bugs and feature requests. If you need help please post to our Mailing List or join the Chef Community Slack. 7 | 8 | * Chef Community Slack at 9 | * Chef Mailing List 10 | 11 | Support issues opened here will be closed and redirected to Slack or Discourse. 12 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: bundler 4 | target-branch: "main" 5 | directory: "/" 6 | schedule: 7 | interval: daily 8 | time: "06:00" 9 | timezone: America/Los_Angeles 10 | open-pull-requests-limit: 10 11 | labels: 12 | - "Type: Chore" -------------------------------------------------------------------------------- /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: lint 3 | 4 | 'on': 5 | pull_request: 6 | push: 7 | branches: 8 | - main 9 | 10 | jobs: 11 | cookstyle: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v2 15 | - uses: ruby/setup-ruby@v1 16 | with: 17 | ruby-version: 3.4 18 | bundler-cache: true 19 | - uses: r7kamura/rubocop-problem-matchers-action@v1 # this shows the failures in the PR 20 | - run: bundle exec cookstyle 21 | -------------------------------------------------------------------------------- /.github/workflows/unit.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: unit 3 | 4 | 'on': 5 | pull_request: 6 | push: 7 | branches: 8 | - main 9 | 10 | jobs: 11 | test: 12 | strategy: 13 | fail-fast: false 14 | matrix: 15 | os: [windows-2019, ubuntu-latest] 16 | ruby: ['3.1', '3.4'] 17 | runs-on: ${{ matrix.os }} 18 | env: 19 | BUNDLE_WITHOUT: profiling debug docs 20 | name: Unit test on ${{ matrix.os }} with Ruby ${{ matrix.ruby }} 21 | steps: 22 | - uses: actions/checkout@v2 23 | - uses: ruby/setup-ruby@v1 24 | with: 25 | ruby-version: ${{ matrix.ruby }} 26 | bundler-cache: true 27 | - run: bundle exec rake spec 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.bundle/ 2 | /.yardoc 3 | /Gemfile.lock 4 | /_yardoc/ 5 | /coverage/ 6 | /doc/ 7 | /pkg/ 8 | /spec/reports/ 9 | /tmp/ 10 | /vendor/ 11 | *.gem 12 | 13 | # for tim's local testing 14 | /test.rb 15 | 16 | # spellcheck rake task 17 | chef_dictionary.txt 18 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --format documentation 2 | --color 3 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | # enable new cops for rubocop-performance 2 | AllCops: 3 | NewCops: enable 4 | 5 | Chef/Style/CommentFormat: 6 | Exclude: 7 | - 'lib/rubocop/cop/chef/comments_format.rb' 8 | 9 | # Chef/Modernize/FoodcriticComments itself include an example Foocritic comment which alerts 10 | Chef/Modernize/FoodcriticComments: 11 | Enabled: false 12 | 13 | # reduces memory usage 14 | Style/FrozenStringLiteralComment: 15 | Enabled: true 16 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | Please refer to the Chef Community Code of Conduct at https://www.progress.com/company/code-of-conduct 2 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Please refer to https://github.com/chef/chef/blob/main/CONTRIBUTING.md 2 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | source 'https://rubygems.org' 3 | 4 | # Specify your gem's dependencies in cookstyle.gemspec 5 | gemspec 6 | gem 'appbundler' 7 | group :debug do 8 | gem 'pry' 9 | end 10 | 11 | group :docs do 12 | gem 'yard' 13 | end 14 | 15 | group :profiling do 16 | platforms :ruby do 17 | gem 'memory_profiler' 18 | gem 'stackprof' 19 | end 20 | end 21 | 22 | group :development do 23 | gem 'rake' 24 | gem 'rspec', '>= 3.4' 25 | end 26 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 8.1.5 -------------------------------------------------------------------------------- /WRITING_RULES.md: -------------------------------------------------------------------------------- 1 | ## Helpful links when writing rules 2 | 3 | Parser library's list of node types: https://github.com/marcandre/parser/blob/master/lib/parser/meta.rb 4 | 5 | RuboCop's Creating a New Cop documentation (RuboCop specific, but useful): https://docs.rubocop.org/rubocop/development.html#create-a-new-cop 6 | 7 | RuboCop Node Pattern documentation: https://docs.rubocop.org/rubocop-ast/node_pattern.html 8 | 9 | RuboCop NodePattern class with query examples: https://github.com/rubocop/rubocop-ast/blob/master/lib/rubocop/ast/node_pattern.rb 10 | -------------------------------------------------------------------------------- /bin/cookstyle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | $LOAD_PATH.unshift File.join(__dir__, %w(.. lib)) 5 | 6 | if ARGV.include?('--chefstyle') 7 | ARGV.delete('--chefstyle') 8 | require 'cookstyle/chefstyle' 9 | else 10 | require 'cookstyle' 11 | end 12 | 13 | # force the fail level to :convention so that we can set all our new rules to 14 | # the lowest level of :refactor without failing everyone's CI jobs 15 | unless ARGV.include?('--fail-level') 16 | ARGV << '--fail-level' 17 | ARGV << 'C' 18 | end 19 | 20 | # we want to link to our docs 21 | unless ARGV.include?('--display-style-guide') 22 | ARGV << '--display-style-guide' 23 | end 24 | 25 | # if only -v is passed we'll get 4 args (-v, --fail-level. --display-style-guide, and C) 26 | if ARGV.size == 4 && %w(-v --version).include?(ARGV.first) 27 | puts "Cookstyle #{Cookstyle::VERSION}" 28 | print ' * RuboCop ' 29 | end 30 | 31 | load Gem.bin_path('rubocop', 'rubocop') 32 | -------------------------------------------------------------------------------- /bin/cookstyle-profile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | if ARGV.include?('-h') || ARGV.include?('--help') 5 | puts 'Usage: same as main `cookstyle` command but gathers profiling info' 6 | puts 'Additional option: `--memory` to print memory usage' 7 | exit(0) 8 | end 9 | with_mem = ARGV.delete('--memory') 10 | 11 | require 'stackprof' 12 | if with_mem 13 | require 'memory_profiler' 14 | MemoryProfiler.start 15 | end 16 | StackProf.start 17 | start = Process.clock_gettime(Process::CLOCK_MONOTONIC) 18 | begin 19 | load "#{__dir__}/cookstyle" 20 | ensure 21 | delta = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start 22 | puts "Finished in #{delta.round(1)} seconds" 23 | StackProf.stop 24 | if with_mem 25 | puts 'Building memory report...' 26 | report = MemoryProfiler.stop 27 | end 28 | Dir.mkdir('tmp') unless File.exist?('tmp') 29 | StackProf.results('tmp/stackprof.dump') 30 | report&.pretty_print(scale_bytes: true) 31 | end 32 | -------------------------------------------------------------------------------- /config/default.yml: -------------------------------------------------------------------------------- 1 | inherit_from: 2 | - cookstyle.yml 3 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chef/cookstyle/7e273dbee5d757311bd42541f5a05a8082f1bc30/docs-chef-io/assets/cookstyle/.gitkeep -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_correctness_blockguardwithonlystring.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: BlockGuardWithOnlyString 3 | full_name: Chef/Correctness/BlockGuardWithOnlyString 4 | department: Chef/Correctness 5 | description: A resource guard (not_if/only_if) that is a string should not be wrapped 6 | in `{}`. Wrapping a guard string in {} causes it to be executed as Ruby code which 7 | will always return true instead of a shell command that will actually run. 8 | autocorrection: true 9 | target_chef_version: All Versions 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | template '/etc/foo' do 16 | mode '0644' 17 | source 'foo.erb' 18 | only_if { 'test -f /etc/foo' } 19 | end 20 | ``` 21 | 22 | ### correct 23 | 24 | ```ruby 25 | template '/etc/foo' do 26 | mode '0644' 27 | source 'foo.erb' 28 | only_if 'test -f /etc/foo' 29 | end 30 | ``` 31 | version_added: 5.2.0 32 | enabled: true 33 | excluded_file_paths: 34 | - "**/attributes/*.rb" 35 | - "**/metadata.rb" 36 | - "**/Berksfile" 37 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_correctness_chefapplicationfatal.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ChefApplicationFatal 3 | full_name: Chef/Correctness/ChefApplicationFatal 4 | department: Chef/Correctness 5 | description: Use `raise` to force Chef Infra Client to fail instead of using `Chef::Application.fatal`, 6 | which masks the full stack trace of the failure and makes debugging difficult. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | Chef::Application.fatal!('Something horrible happened!') 15 | ``` 16 | 17 | ### correct 18 | 19 | ```ruby 20 | raise "Something horrible happened!" 21 | ``` 22 | version_added: 6.0.0 23 | enabled: true 24 | excluded_file_paths: 25 | - "**/metadata.rb" 26 | - "**/Berksfile" 27 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_correctness_cookbookusesnodesave.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: CookbookUsesNodeSave 3 | full_name: Chef/Correctness/CookbookUsesNodeSave 4 | department: Chef/Correctness 5 | description: Don't use node.save to save partial node data to the Chef Infra Server 6 | mid-run unless it's a requirement of cookbook design that can't be avoided. Node.save 7 | can result in failed Chef Infra runs appearing in search and increases load on the 8 | Chef Infra Server." 9 | autocorrection: false 10 | target_chef_version: All Versions 11 | examples: |2- 12 | 13 | ### incorrect 14 | 15 | ```ruby 16 | node.save 17 | ``` 18 | version_added: 5.5.0 19 | enabled: true 20 | excluded_file_paths: 21 | - "**/metadata.rb" 22 | - "**/Berksfile" 23 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_correctness_dnfpackageallowdowngrades.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: DnfPackageAllowDowngrades 3 | full_name: Chef/Correctness/DnfPackageAllowDowngrades 4 | department: Chef/Correctness 5 | description: The `dnf_package` resource does not support the `allow_downgrades` property. 6 | autocorrection: true 7 | target_chef_version: All Versions 8 | examples: |2- 9 | 10 | ### incorrect 11 | 12 | ```ruby 13 | dnf_package 'nginx' do 14 | version '1.2.3' 15 | allow_downgrades true 16 | end 17 | ``` 18 | 19 | ### correct 20 | 21 | ```ruby 22 | dnf_package 'nginx' do 23 | version '1.2.3' 24 | end 25 | ``` 26 | version_added: 5.16.0 27 | enabled: true 28 | excluded_file_paths: 29 | - "**/attributes/*.rb" 30 | - "**/metadata.rb" 31 | - "**/Berksfile" 32 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_correctness_incorrectlibraryinjection.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: IncorrectLibraryInjection 3 | full_name: Chef/Correctness/IncorrectLibraryInjection 4 | department: Chef/Correctness 5 | description: Libraries should be injected into the `Chef::DSL::Recipe` class and not 6 | `Chef::Recipe` or `Chef::Provider` classes directly. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | ::Chef::Recipe.send(:include, Filebeat::Helpers) 15 | ::Chef::Provider.send(:include, Filebeat::Helpers) 16 | ::Chef::Recipe.include Filebeat::Helpers 17 | ::Chef::Provider.include Filebeat::Helpers 18 | ``` 19 | 20 | ### correct 21 | 22 | ```ruby 23 | ::Chef::DSL::Recipe.send(:include, Filebeat::Helpers) # covers previous Recipe & Provider classes 24 | ``` 25 | version_added: 5.10.0 26 | enabled: true 27 | excluded_file_paths: 28 | - "**/metadata.rb" 29 | - "**/Berksfile" 30 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_correctness_invalidcookbookname.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: InvalidCookbookName 3 | full_name: Chef/Correctness/InvalidCookbookName 4 | department: Chef/Correctness 5 | description: Cookbook names should not contain invalid characters such as periods. 6 | autocorrection: false 7 | target_chef_version: All Versions 8 | examples: |2- 9 | 10 | ### incorrect 11 | 12 | ```ruby 13 | name 'foo.bar' 14 | ``` 15 | 16 | ### correct 17 | 18 | ```ruby 19 | name 'foo_bar' 20 | ``` 21 | version_added: '7.27' 22 | enabled: true 23 | included_file_paths: 24 | - "**/metadata.rb" 25 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_correctness_invaliddefaultaction.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: InvalidDefaultAction 3 | full_name: Chef/Correctness/InvalidDefaultAction 4 | department: Chef/Correctness 5 | description: Default actions in resources should be symbols or an array of symbols. 6 | autocorrection: false 7 | target_chef_version: All Versions 8 | examples: |2- 9 | 10 | ### incorrect 11 | 12 | ```ruby 13 | default_action 'create' 14 | ``` 15 | 16 | ### correct 17 | 18 | ```ruby 19 | default_action :create 20 | ``` 21 | version_added: 6.13.0 22 | enabled: true 23 | included_file_paths: 24 | - "**/libraries/*.rb" 25 | - "**/resources/*.rb" 26 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_correctness_invalidnotificationresource.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: InvalidNotificationResource 3 | full_name: Chef/Correctness/InvalidNotificationResource 4 | department: Chef/Correctness 5 | description: The resource to notify when calling `notifies` or `subscribes` must be 6 | a string. 7 | autocorrection: false 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | 15 | template '/etc/www/configures-apache.conf' do 16 | notifies :restart, service['apache'], :immediately 17 | end 18 | 19 | template '/etc/www/configures-apache.conf' do 20 | notifies :restart, service[apache], :immediately 21 | end 22 | ``` 23 | 24 | ### correct 25 | 26 | ```ruby 27 | 28 | template '/etc/www/configures-apache.conf' do 29 | notifies :restart, 'service[apache]', :immediately 30 | end 31 | ``` 32 | version_added: '7.28' 33 | enabled: true 34 | excluded_file_paths: 35 | - "**/attributes/*.rb" 36 | - "**/metadata.rb" 37 | - "**/Berksfile" 38 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_correctness_invalidnotificationtiming.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: InvalidNotificationTiming 3 | full_name: Chef/Correctness/InvalidNotificationTiming 4 | department: Chef/Correctness 5 | description: Valid notification timings are `:immediately`, `:immediate` (alias for 6 | :immediately), `:delayed`, and `:before`. 7 | autocorrection: false 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | 15 | template '/etc/www/configures-apache.conf' do 16 | notifies :restart, 'service[apache]', :nope 17 | end 18 | ``` 19 | 20 | ### correct 21 | 22 | ```ruby 23 | 24 | template '/etc/www/configures-apache.conf' do 25 | notifies :restart, 'service[apache]', :immediately 26 | end 27 | ``` 28 | version_added: 5.16.0 29 | enabled: true 30 | excluded_file_paths: 31 | - "**/attributes/*.rb" 32 | - "**/metadata.rb" 33 | - "**/Berksfile" 34 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_correctness_invalidplatformfamilyhelper.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: InvalidPlatformFamilyHelper 3 | full_name: Chef/Correctness/InvalidPlatformFamilyHelper 4 | department: Chef/Correctness 5 | description: 'Pass valid platform families to the `platform_family?` helper. See [Infra 6 | Language: Platform Family](https://docs.chef.io/infra_language/checking_platforms/#platform_family-values) 7 | for a complete list of platform families.' 8 | autocorrection: true 9 | target_chef_version: All Versions 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | platform_family?('redhat') 16 | platform_family?('sles') 17 | 18 | ### incorrect 19 | 20 | ```ruby 21 | platform_family?('rhel') 22 | platform_family?('suse') 23 | ``` 24 | version_added: 5.15.0 25 | enabled: true 26 | excluded_file_paths: 27 | - "**/metadata.rb" 28 | - "**/Berksfile" 29 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_correctness_invalidplatformfamilyincase.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: InvalidPlatformFamilyInCase 3 | full_name: Chef/Correctness/InvalidPlatformFamilyInCase 4 | department: Chef/Correctness 5 | description: 'Use valid platform family values in case statements. See [Infra Language: 6 | Platform Family](https://docs.chef.io/infra_language/checking_platforms/#platform_family-values) 7 | for a complete list of platform families.' 8 | autocorrection: true 9 | target_chef_version: All Versions 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | case node['platform_family'] 16 | when 'redhat' 17 | puts "I'm on a RHEL-like system" 18 | end 19 | ``` 20 | version_added: 6.6.0 21 | enabled: true 22 | excluded_file_paths: 23 | - "**/metadata.rb" 24 | - "**/Berksfile" 25 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_correctness_invalidplatformhelper.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: InvalidPlatformHelper 3 | full_name: Chef/Correctness/InvalidPlatformHelper 4 | department: Chef/Correctness 5 | description: 'Pass valid platforms to the `platform?` helper. See [Infra Language: 6 | Platform](https://docs.chef.io/infra_language/checking_platforms/#platform-values) 7 | for a list of many common platform values.' 8 | autocorrection: false 9 | target_chef_version: All Versions 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | platform?('darwin') 16 | platform?('rhel') 17 | platform?('sles') 18 | ``` 19 | 20 | ### correct 21 | 22 | ```ruby 23 | platform?('mac_os_x') 24 | platform?('redhat') 25 | platform?('suse') 26 | ``` 27 | version_added: 5.15.0 28 | enabled: true 29 | excluded_file_paths: 30 | - "**/metadata.rb" 31 | - "**/Berksfile" 32 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_correctness_invalidplatformincase.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: InvalidPlatformInCase 3 | full_name: Chef/Correctness/InvalidPlatformInCase 4 | department: Chef/Correctness 5 | description: 'Use valid platform values in case statements. See [Infra Language: Platform](https://docs.chef.io/infra_language/checking_platforms/#platform-values) 6 | for a list of many common platform values.' 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | case node['platform'] 15 | when 'rhel' 16 | puts "I'm on a Red Hat system!" 17 | end 18 | ``` 19 | version_added: 6.6.0 20 | enabled: true 21 | excluded_file_paths: 22 | - "**/metadata.rb" 23 | - "**/Berksfile" 24 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_correctness_invalidplatformmetadata.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: InvalidPlatformMetadata 3 | full_name: Chef/Correctness/InvalidPlatformMetadata 4 | department: Chef/Correctness 5 | description: 'metadata.rb `supports` methods should contain valid platforms. See [Infra 6 | Language: Platform](https://docs.chef.io/infra_language/checking_platforms/#platform-values) 7 | for a list of many common platform values.' 8 | autocorrection: true 9 | target_chef_version: All Versions 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | supports 'darwin' 16 | supports 'mswin' 17 | ``` 18 | 19 | ### correct 20 | 21 | ```ruby 22 | supports 'mac_os_x' 23 | supports 'windows' 24 | ``` 25 | version_added: 5.2.0 26 | enabled: true 27 | included_file_paths: 28 | - "**/metadata.rb" 29 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_correctness_invalidplatformvalueforplatformfamilyhelper.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: InvalidPlatformValueForPlatformFamilyHelper 3 | full_name: Chef/Correctness/InvalidPlatformValueForPlatformFamilyHelper 4 | department: Chef/Correctness 5 | description: 'Pass valid platform families to the value_for_platform_family helper. 6 | See [Infra Language: Platform Family](https://docs.chef.io/infra_language/checking_platforms/#platform_family-values) 7 | for a complete list of platform families.' 8 | autocorrection: false 9 | target_chef_version: All Versions 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | value_for_platform_family( 16 | %w(rhel sles) => 'foo', 17 | %w(mac) => 'foo' 18 | ) 19 | ``` 20 | 21 | ### correct 22 | 23 | ```ruby 24 | value_for_platform_family( 25 | %w(rhel suse) => 'foo', 26 | %w(mac_os_x) => 'foo' 27 | ) 28 | ``` 29 | version_added: 5.15.0 30 | enabled: true 31 | excluded_file_paths: 32 | - "**/metadata.rb" 33 | - "**/Berksfile" 34 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_correctness_invalidplatformvalueforplatformhelper.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: InvalidPlatformValueForPlatformHelper 3 | full_name: Chef/Correctness/InvalidPlatformValueForPlatformHelper 4 | department: Chef/Correctness 5 | description: 'Pass valid platforms to the value_for_platform helper. See [Infra Language: 6 | Platform](https://docs.chef.io/infra_language/checking_platforms/#platform-values) 7 | for a list of many common platform values.' 8 | autocorrection: false 9 | target_chef_version: All Versions 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | value_for_platform( 16 | %w(rhel mac_os_x_server) => { 'default' => 'foo' }, 17 | %w(sles) => { 'default' => 'bar' } 18 | )``` 19 | 20 | ### correct 21 | 22 | ```ruby 23 | value_for_platform( 24 | %w(redhat mac_os_x) => { 'default' => 'foo' }, 25 | %w(opensuseleap) => { 'default' => 'bar' } 26 | ) 27 | ``` 28 | version_added: 5.15.0 29 | enabled: true 30 | excluded_file_paths: 31 | - "**/metadata.rb" 32 | - "**/Berksfile" 33 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_correctness_invalidversionmetadata.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: InvalidVersionMetadata 3 | full_name: Chef/Correctness/InvalidVersionMetadata 4 | department: Chef/Correctness 5 | description: Cookbook metadata.rb version field should follow X.Y.Z version format. 6 | autocorrection: false 7 | target_chef_version: All Versions 8 | examples: |2- 9 | 10 | ### incorrect 11 | 12 | ```ruby 13 | version '1.2.3.4' 14 | ``` 15 | 16 | ### correct 17 | 18 | ```ruby 19 | version '1.2.3' 20 | ``` 21 | version_added: 5.8.0 22 | enabled: true 23 | included_file_paths: 24 | - "**/metadata.rb" 25 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_correctness_lazyevalnodeattributedefaults.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: LazyEvalNodeAttributeDefaults 3 | full_name: Chef/Correctness/LazyEvalNodeAttributeDefaults 4 | department: Chef/Correctness 5 | description: When setting a node attribute as the default value for a custom resource 6 | property, wrap the node attribute in `lazy {}` so that its value is available when 7 | the resource executes. 8 | autocorrection: true 9 | target_chef_version: All Versions 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | property :Something, String, default: node['hostname'] 16 | ``` 17 | 18 | ### correct 19 | 20 | ```ruby 21 | property :Something, String, default: lazy { node['hostname'] } 22 | ``` 23 | version_added: 6.6.0 24 | enabled: true 25 | included_file_paths: 26 | - "**/libraries/*.rb" 27 | - "**/resources/*.rb" 28 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_correctness_lazyinresourceguard.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: LazyInResourceGuard 3 | full_name: Chef/Correctness/LazyInResourceGuard 4 | department: Chef/Correctness 5 | description: Using `lazy {}` within a resource guard (not_if/only_if) will cause failures 6 | and is unnecessary as resource guards are always lazily evaluated. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | template '/etc/foo' do 15 | mode '0644' 16 | source 'foo.erb' 17 | only_if { lazy { ::File.exist?('/etc/foo')} } 18 | end 19 | ``` 20 | 21 | ### correct 22 | 23 | ```ruby 24 | template '/etc/foo' do 25 | mode '0644' 26 | source 'foo.erb' 27 | only_if { ::File.exist?('/etc/foo') } 28 | end 29 | ``` 30 | version_added: 6.18.0 31 | enabled: true 32 | excluded_file_paths: 33 | - "**/metadata.rb" 34 | - "**/Berksfile" 35 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_correctness_macosuserdefaultsinvalidtype.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: MacosUserdefaultsInvalidType 3 | full_name: Chef/Correctness/MacosUserdefaultsInvalidType 4 | department: Chef/Correctness 5 | description: 'The macos_userdefaults resource prior to Chef Infra Client 16.3 would 6 | silently continue if invalid types were passed resulting in unexpected behavior. 7 | Valid values are: "array", "bool", "dict", "float", "int", and "string".' 8 | autocorrection: true 9 | target_chef_version: All Versions 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | macos_userdefaults 'set a value' do 16 | global true 17 | key 'key' 18 | type 'boolean' 19 | end 20 | ``` 21 | 22 | ### correct 23 | 24 | ```ruby 25 | macos_userdefaults 'set a value' do 26 | global true 27 | key 'key' 28 | type 'bool' 29 | end 30 | ``` 31 | version_added: 6.14.0 32 | enabled: true 33 | excluded_file_paths: 34 | - "**/metadata.rb" 35 | - "**/Berksfile" 36 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_correctness_metadatamalformeddepends.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: MetadataMalformedDepends 3 | full_name: Chef/Correctness/MetadataMalformedDepends 4 | department: Chef/Correctness 5 | description: metadata.rb cookbook dependencies and version constraints should be comma 6 | separated. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | depends 'some_awesome_cookbook' '= 4.5.5' 15 | depends 'some_other_cool_cookbook' '< 8.0' 16 | ``` 17 | 18 | ### correct 19 | 20 | ```ruby 21 | depends 'some_awesome_cookbook', '= 4.5.5' 22 | depends 'some_other_cool_cookbook', '< 8.0' 23 | ``` 24 | version_added: '7.16' 25 | enabled: true 26 | included_file_paths: 27 | - "**/metadata.rb" 28 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_correctness_metadatamissingname.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: MetadataMissingName 3 | full_name: Chef/Correctness/MetadataMissingName 4 | department: Chef/Correctness 5 | description: metadata.rb needs to include the name method or it will fail on Chef 6 | Infra Client 12 and later. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |- 10 | ``` 11 | 12 | ### correct 13 | 14 | ```ruby 15 | name 'foo' 16 | ``` 17 | version_added: 5.2.0 18 | enabled: true 19 | included_file_paths: 20 | - "**/metadata.rb" 21 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_correctness_metadatamissingversion.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: MetadataMissingVersion 3 | full_name: Chef/Correctness/MetadataMissingVersion 4 | department: Chef/Correctness 5 | description: metadata.rb should define a version for the cookbook. 6 | autocorrection: true 7 | target_chef_version: All Versions 8 | examples: |- 9 | ``` 10 | 11 | ### correct 12 | 13 | ```ruby 14 | name 'foo' 15 | version '1.0.0' 16 | ``` 17 | version_added: '7.25' 18 | enabled: true 19 | included_file_paths: 20 | - "**/metadata.rb" 21 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_correctness_octalmodeasstring.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: OctalModeAsString 3 | full_name: Chef/Correctness/OctalModeAsString 4 | department: Chef/Correctness 5 | description: Don't represent file modes as Strings containing octal values. 6 | autocorrection: false 7 | target_chef_version: All Versions 8 | examples: |2- 9 | 10 | ### incorrect 11 | 12 | ```ruby 13 | file '/etc/some_file' do 14 | mode '0o755' 15 | end 16 | ``` 17 | 18 | ### correct 19 | 20 | ```ruby 21 | file '/etc/some_file' do 22 | mode '0755' 23 | end 24 | ``` 25 | version_added: 6.21.0 26 | enabled: true 27 | excluded_file_paths: 28 | - "**/attributes/*.rb" 29 | - "**/metadata.rb" 30 | - "**/Berksfile" 31 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_correctness_opensslpasswordhelpers.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: OpenSSLPasswordHelpers 3 | full_name: Chef/Correctness/OpenSSLPasswordHelpers 4 | department: Chef/Correctness 5 | description: |- 6 | The OpenSSL cookbook provides a deprecated `secure_password` helper in the `Opscode::OpenSSL::Password` class, which should no longer be used. This helper would generate a random password that would be used when a data bag or attribute was no present. The practice of generating passwords to be stored on the node is bad security as it exposes the password to anyone that can view the nodes, and deleting a node deletes the password. Passwords should be retrieved from a secure source for use in cookbooks. 7 | 8 | ### incorrect 9 | ::Chef::Recipe.send(:include, Opscode::OpenSSL::Password) 10 | basic_auth_password = secure_password 11 | autocorrection: false 12 | target_chef_version: All Versions 13 | examples: 14 | version_added: 6.6.0 15 | enabled: true 16 | excluded_file_paths: 17 | - "**/metadata.rb" 18 | - "**/Berksfile" 19 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_correctness_powershellfileexists.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: PowershellFileExists 3 | full_name: Chef/Correctness/PowershellFileExists 4 | department: Chef/Correctness 5 | description: Use Ruby's built-in `File.exist?('C:\somefile')` method instead of executing 6 | PowerShell's `Test-Path` cmdlet, which takes longer to load. 7 | autocorrection: false 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | powershell_out('Test-Path "C:\\Program Files\\LAPS\\CSE\\AdmPwd.dll"').stdout.strip == 'True' 15 | ``` 16 | 17 | ### correct 18 | 19 | ```ruby 20 | ::File.exist?('C:\Program Files\LAPS\CSE\AdmPwd.dll') 21 | ``` 22 | version_added: '7.19' 23 | enabled: true 24 | excluded_file_paths: 25 | - "**/metadata.rb" 26 | - "**/Berksfile" 27 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_correctness_powershellscriptdeletefile.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: PowershellScriptDeleteFile 3 | full_name: Chef/Correctness/PowershellScriptDeleteFile 4 | department: Chef/Correctness 5 | description: |- 6 | 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 7 | 8 | ### correct 9 | file 'C:\Windows\foo\bar.txt' do 10 | action :delete 11 | end 12 | autocorrection: false 13 | target_chef_version: All Versions 14 | examples: |2- 15 | 16 | ### incorrect 17 | 18 | ```ruby 19 | powershell_script 'Cleanup old files' do 20 | code 'Remove-Item C:\Windows\foo\bar.txt' 21 | only_if { ::File.exist?('C:\\Windows\\foo\\bar.txt') } 22 | end 23 | ``` 24 | version_added: 6.0.0 25 | enabled: true 26 | excluded_file_paths: 27 | - "**/attributes/*.rb" 28 | - "**/metadata.rb" 29 | - "**/Berksfile" 30 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_correctness_propertywithouttype.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: PropertyWithoutType 3 | full_name: Chef/Correctness/PropertyWithoutType 4 | department: Chef/Correctness 5 | description: Resource properties or attributes should always define a type to help 6 | users understand the correct allowed values. 7 | autocorrection: false 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | property :size, regex: /^\d+[KMGTP]$/ 15 | attribute :size, regex: /^\d+[KMGTP]$/ 16 | ``` 17 | 18 | ### correct 19 | 20 | ```ruby 21 | property :size, String, regex: /^\d+[KMGTP]$/ 22 | attribute :size, kind_of: String, regex: /^\d+[KMGTP]$/ 23 | ``` 24 | version_added: 6.18.0 25 | enabled: true 26 | included_file_paths: 27 | - "**/libraries/*.rb" 28 | - "**/resources/*.rb" 29 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_correctness_resourcesetsinternalproperties.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ResourceSetsInternalProperties 3 | full_name: Chef/Correctness/ResourceSetsInternalProperties 4 | department: Chef/Correctness 5 | description: Chef Infra Client uses properties in several resources to track state. 6 | These should not be set in recipes as they break the internal workings of the Chef 7 | Infra Client 8 | autocorrection: false 9 | target_chef_version: All Versions 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | service 'foo' do 16 | running true 17 | action [:start, :enable] 18 | end 19 | ``` 20 | 21 | ### correct 22 | 23 | ```ruby 24 | service 'foo' do 25 | action [:start, :enable] 26 | end 27 | ``` 28 | version_added: 5.5.0 29 | enabled: true 30 | excluded_file_paths: 31 | - "**/attributes/*.rb" 32 | - "**/metadata.rb" 33 | - "**/Berksfile" 34 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_correctness_resourcesetsnameproperty.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ResourceSetsNameProperty 3 | full_name: Chef/Correctness/ResourceSetsNameProperty 4 | department: Chef/Correctness 5 | description: Use name properties instead of setting the name property in a resource. 6 | Setting the name property directly causes notification and reporting issues. 7 | autocorrection: false 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | service 'foo' do 15 | name 'bar' 16 | end 17 | ``` 18 | 19 | ### correct 20 | 21 | ```ruby 22 | service 'foo' do 23 | service_name 'bar' 24 | end 25 | ``` 26 | version_added: 5.5.0 27 | enabled: true 28 | excluded_file_paths: 29 | - "**/attributes/*.rb" 30 | - "**/metadata.rb" 31 | - "**/Berksfile" 32 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_correctness_resourcewithnoneaction.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ResourceWithNoneAction 3 | full_name: Chef/Correctness/ResourceWithNoneAction 4 | department: Chef/Correctness 5 | description: The :nothing action is often typo'd as :none 6 | autocorrection: true 7 | target_chef_version: All Versions 8 | examples: |2- 9 | 10 | ### incorrect 11 | 12 | ```ruby 13 | service 'foo' do 14 | action :none 15 | end 16 | ``` 17 | 18 | ### correct 19 | 20 | ```ruby 21 | service 'foo' do 22 | action :nothing 23 | end 24 | ``` 25 | version_added: 5.5.0 26 | enabled: true 27 | excluded_file_paths: 28 | - "**/attributes/*.rb" 29 | - "**/metadata.rb" 30 | - "**/Berksfile" 31 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_correctness_scopedfileexist.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ScopedFileExist 3 | full_name: Chef/Correctness/ScopedFileExist 4 | department: Chef/Correctness 5 | description: Scope file exist to access the correct `File` class by using `::File.exist?` 6 | not `File.exist?`. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | not_if { File.exist?('/etc/foo/bar') } 15 | ``` 16 | 17 | ### correct 18 | 19 | ```ruby 20 | not_if { ::File.exist?('/etc/foo/bar') } 21 | ``` 22 | version_added: 5.15.0 23 | enabled: true 24 | excluded_file_paths: 25 | - "**/attributes/*.rb" 26 | - "**/metadata.rb" 27 | - "**/Berksfile" 28 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_correctness_serviceresource.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ServiceResource 3 | full_name: Chef/Correctness/ServiceResource 4 | department: Chef/Correctness 5 | description: Use a service resource to start and stop services 6 | autocorrection: false 7 | target_chef_version: All Versions 8 | examples: |2- 9 | 10 | ### incorrect 11 | 12 | ```ruby 13 | command "/etc/init.d/mysql start" 14 | command "/sbin/service/memcached start" 15 | ``` 16 | version_added: 5.0.0 17 | enabled: true 18 | excluded_file_paths: 19 | - "**/attributes/*.rb" 20 | - "**/metadata.rb" 21 | - "**/Berksfile" 22 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_correctness_supportsmustbefloat.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: SupportsMustBeFloat 3 | full_name: Chef/Correctness/SupportsMustBeFloat 4 | department: Chef/Correctness 5 | description: Versions used in metadata.rb supports calls should be floats not integers. 6 | autocorrection: true 7 | target_chef_version: All Versions 8 | examples: |2- 9 | 10 | ### incorrect 11 | 12 | ```ruby 13 | supports 'redhat', '> 8' 14 | ``` 15 | 16 | ### correct 17 | 18 | ```ruby 19 | supports 'redhat', '> 8.0' 20 | ``` 21 | version_added: 6.13.0 22 | enabled: true 23 | included_file_paths: 24 | - "**/metadata.rb" 25 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_correctness_tmppath.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: TmpPath 3 | full_name: Chef/Correctness/TmpPath 4 | department: Chef/Correctness 5 | description: Use file_cache_path rather than hard-coding system temp paths 6 | autocorrection: false 7 | target_chef_version: All Versions 8 | examples: |2- 9 | 10 | ### incorrect 11 | 12 | ```ruby 13 | remote_file '/tmp/large-file.tar.gz' do 14 | ``` 15 | 16 | ### correct 17 | 18 | ```ruby 19 | remote_file "#{Chef::Config[:file_cache_path]}/large-file.tar.gz" do 20 | ``` 21 | version_added: 5.0.0 22 | enabled: true 23 | excluded_file_paths: 24 | - "**/metadata.rb" 25 | - "**/Berksfile" 26 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_chefdkgenerators.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ChefDKGenerators 3 | full_name: Chef/Deprecations/ChefDKGenerators 4 | department: Chef/Deprecations 5 | description: Chef Workstation 0.8 and later renamed the `ChefDK` module used when 6 | writing custom cookbook generators from `ChefDK` to `ChefCLI`. For compatibility 7 | with the latest Chef Workstation releases you'll need to reference the new class 8 | names. 9 | autocorrection: true 10 | target_chef_version: All Versions 11 | examples: |2- 12 | 13 | ### incorrect 14 | 15 | ```ruby 16 | ChefDK::CLI 17 | ChefDK::Generator::TemplateHelper 18 | module ChefDK 19 | # some additional code 20 | end 21 | ``` 22 | 23 | ### correct 24 | 25 | ```ruby 26 | ChefCLI::CLI 27 | ChefCLI::Generator::TemplateHelper 28 | module ChefCLI 29 | # some additional code 30 | end 31 | ``` 32 | version_added: 6.12.0 33 | enabled: true 34 | excluded_file_paths: 35 | - "**/metadata.rb" 36 | - "**/Berksfile" 37 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_cheffile.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: Cheffile 3 | full_name: Chef/Deprecations/Cheffile 4 | department: Chef/Deprecations 5 | description: The Librarian-Chef depsolving project is no longer maintained and a Cheffile 6 | should not be used for cookbook depsolving. Consider using Policyfiles instead. 7 | If the Policyfiles model is not compatible with your workflow you may find Berkshelf 8 | offers a more similar, and still supported, experience to Librarian-Chef. 9 | autocorrection: false 10 | target_chef_version: All Versions 11 | examples: 12 | version_added: 5.12.0 13 | enabled: true 14 | included_file_paths: 15 | - "**/Cheffile" 16 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_chefhandlerrecipe.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ChefHandlerRecipe 3 | full_name: Chef/Deprecations/ChefHandlerRecipe 4 | department: Chef/Deprecations 5 | description: There is no need to include the empty and deprecated chef_handler::default 6 | recipe to use the chef_handler resource 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | include_recipe 'chef_handler' 15 | include_recipe 'chef_handler::default' 16 | ``` 17 | version_added: 6.12.0 18 | enabled: true 19 | excluded_file_paths: 20 | - "**/metadata.rb" 21 | - "**/Berksfile" 22 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_chefhandlerusessupports.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ChefHandlerUsesSupports 3 | full_name: Chef/Deprecations/ChefHandlerUsesSupports 4 | department: Chef/Deprecations 5 | description: Use the type `property` instead of the deprecated `supports` property 6 | in the `chef_handler` resource. The `supports` property was removed in `chef_handler` 7 | cookbook version 3.0 (June 2017) and Chef Infra Client 14.0. 8 | autocorrection: true 9 | target_chef_version: All Versions 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | chef_handler 'whatever' do 16 | supports start: true, report: true, exception: true 17 | end0 18 | ``` 19 | 20 | ### correct 21 | 22 | ```ruby 23 | chef_handler 'whatever' do 24 | type start: true, report: true, exception: true 25 | end 26 | ``` 27 | version_added: 5.9.0 28 | enabled: true 29 | excluded_file_paths: 30 | - "**/metadata.rb" 31 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_chefrewind.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ChefRewind 3 | full_name: Chef/Deprecations/ChefRewind 4 | department: Chef/Deprecations 5 | description: Use `delete_resource` or `edit_resource` helpers introduced in Chef Infra 6 | Client 12.10 instead of functionality in the deprecated `chef-rewind` gem 7 | autocorrection: true 8 | target_chef_version: 12.10+ 9 | examples: |2- 10 | 11 | chef_gem 'chef-rewind' 12 | 13 | require 'chef/rewind' 14 | 15 | rewind "user[postgres]" do 16 | home '/var/lib/pgsql/9.2' 17 | cookbook 'my-postgresql' 18 | end 19 | 20 | unwind "user[postgres]" 21 | ``` 22 | version_added: 5.14.0 23 | enabled: true 24 | excluded_file_paths: 25 | - "**/metadata.rb" 26 | - "**/attributes/*.rb" 27 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_chefshellout.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ChefShellout 3 | full_name: Chef/Deprecations/ChefShellout 4 | department: Chef/Deprecations 5 | description: Don't use the deprecated `Chef::ShellOut` class which was removed in 6 | Chef Infra Client 13. Use the `Mixlib::ShellOut` class instead, which behaves identically 7 | or convert to the simpler `shell_out` helper. 8 | autocorrection: true 9 | target_chef_version: All Versions 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | include Chef::ShellOut 16 | require 'chef/shellout' 17 | Chef::ShellOut.new('some_command') 18 | ``` 19 | 20 | ### correct 21 | 22 | ```ruby 23 | include Mixlib::ShellOut 24 | require 'mixlib/shellout' 25 | Mixlib::ShellOut.new('some_command') 26 | ``` 27 | version_added: 6.17.0 28 | enabled: true 29 | excluded_file_paths: 30 | - "**/metadata.rb" 31 | - "**/attributes/*.rb" 32 | - "**/Berksfile" 33 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_chefspeccoveragereport.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ChefSpecCoverageReport 3 | full_name: Chef/Deprecations/ChefSpecCoverageReport 4 | department: Chef/Deprecations 5 | description: Don't use the deprecated ChefSpec Coverage report functionality in your 6 | specs. This feature has been removed as coverage reports encourage cookbook authors 7 | to write ineffective specs. Focus on testing your logic instead of achieving 100% 8 | code coverage. 9 | autocorrection: true 10 | target_chef_version: All Versions 11 | examples: |2- 12 | 13 | ### incorrect 14 | 15 | ```ruby 16 | 17 | at_exit { ChefSpec::Coverage.report! } 18 | ``` 19 | version_added: 5.8.0 20 | enabled: true 21 | included_file_paths: 22 | - "**/spec/*.rb" 23 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_chefspeclegacyrunner.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ChefSpecLegacyRunner 3 | full_name: Chef/Deprecations/ChefSpecLegacyRunner 4 | department: Chef/Deprecations 5 | description: Use `ChefSpec::SoloRunner` or `ChefSpec::ServerRunner` instead of the 6 | deprecated `ChefSpec::Runner`. These new runners were introduced in ChefSpec 4.1 7 | (Oct 2014). 8 | autocorrection: true 9 | target_chef_version: All Versions 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | 16 | describe 'foo::default' do 17 | subject { ChefSpec::Runner.new.converge(described_recipe) } 18 | 19 | # some spec code 20 | end 21 | ``` 22 | 23 | ### correct 24 | 25 | ```ruby 26 | 27 | describe 'foo::default' do 28 | subject { ChefSpec::ServerRunner.new.converge(described_recipe) } 29 | 30 | # some spec code 31 | end 32 | ``` 33 | version_added: 5.8.0 34 | enabled: true 35 | included_file_paths: 36 | - "**/spec/*.rb" 37 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_chefsugarhelpers.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ChefSugarHelpers 3 | full_name: Chef/Deprecations/ChefSugarHelpers 4 | department: Chef/Deprecations 5 | description: Do not use legacy chef-sugar helper methods, which will not be moved 6 | into Chef Infra Client itself. For a complete set of chef-sugar helpers now shipping 7 | in Chef Infra Client itself see https://github.com/chef/chef/tree/main/chef-utils#getting-started 8 | autocorrection: false 9 | target_chef_version: All Versions 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | vagrant_key? 16 | vagrant_domain? 17 | vagrant_user? 18 | require_chef_gem 19 | best_ip_for(node) 20 | nexus? 21 | ios_xr? 22 | ruby_20? 23 | ruby_19? 24 | includes_recipe?('foo::bar') 25 | wrlinux? 26 | dev_null 27 | nexentacore_platform? 28 | opensolaris_platform? 29 | nexentacore? 30 | opensolaris? 31 | ``` 32 | version_added: 7.3.0 33 | enabled: true 34 | excluded_file_paths: 35 | - "**/metadata.rb" 36 | - "**/Berksfile" 37 | - "**/Rakefile" 38 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_chefwindowsplatformhelper.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ChefWindowsPlatformHelper 3 | full_name: Chef/Deprecations/ChefWindowsPlatformHelper 4 | department: Chef/Deprecations 5 | description: Use `platform?('windows')` instead of the legacy `Chef::Platform.windows?` 6 | helper 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | Chef::Platform.windows? 15 | ``` 16 | 17 | ### correct 18 | 19 | ```ruby 20 | platform?('windows') 21 | platform_family?('windows') 22 | ``` 23 | version_added: 6.0.0 24 | enabled: true 25 | excluded_file_paths: 26 | - "**/metadata.rb" 27 | - "**/Berksfile" 28 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_chocolateypackageuninstallaction.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ChocolateyPackageUninstallAction 3 | full_name: Chef/Deprecations/ChocolateyPackageUninstallAction 4 | department: Chef/Deprecations 5 | description: Use the `:remove` action in the `chocolatey_package` resource instead 6 | of `:uninstall` which was removed in Chef Infra Client 14+. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | chocolatey_package 'nginx' do 15 | action :uninstall 16 | end 17 | ``` 18 | 19 | ### correct 20 | 21 | ```ruby 22 | chocolatey_package 'nginx' do 23 | action :remove 24 | end 25 | ``` 26 | version_added: 5.5.0 27 | enabled: true 28 | excluded_file_paths: 29 | - "**/metadata.rb" 30 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_cookbookdependsoncompatresource.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: CookbookDependsOnCompatResource 3 | full_name: Chef/Deprecations/CookbookDependsOnCompatResource 4 | department: Chef/Deprecations 5 | description: Don't depend on the deprecated `compat_resource` cookbook made obsolete 6 | by Chef Infra Client 12.19+. 7 | autocorrection: true 8 | target_chef_version: 12.19+ 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | depends 'compat_resource' 15 | ``` 16 | version_added: 5.1.0 17 | enabled: true 18 | included_file_paths: 19 | - "**/metadata.rb" 20 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_cookbookdependsonpartialsearch.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: CookbookDependsOnPartialSearch 3 | full_name: Chef/Deprecations/CookbookDependsOnPartialSearch 4 | department: Chef/Deprecations 5 | description: Don't depend on the `partial_search` cookbook made obsolete by Chef Infra 6 | Client 13. 7 | autocorrection: false 8 | target_chef_version: 13.0+ 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | depends 'partial_search' 15 | ``` 16 | version_added: 5.1.0 17 | enabled: true 18 | included_file_paths: 19 | - "**/metadata.rb" 20 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_cookbookdependsonpoise.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: CookbookDependsOnPoise 3 | full_name: Chef/Deprecations/CookbookDependsOnPoise 4 | department: Chef/Deprecations 5 | description: Cookbooks should not depend on the deprecated Poise framework cookbooks. 6 | They should instead be refactored to use standard Chef Infra custom resources. 7 | autocorrection: false 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | depends 'poise' 15 | depends 'poise-service' 16 | depends 'poise-hoist' 17 | ``` 18 | version_added: 5.1.0 19 | enabled: true 20 | included_file_paths: 21 | - "**/metadata.rb" 22 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_cookbooksdependsonself.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: CookbooksDependsOnSelf 3 | full_name: Chef/Deprecations/CookbooksDependsOnSelf 4 | department: Chef/Deprecations 5 | description: Make sure a cookbook doesn't depend on itself. This will fail on Chef 6 | Infra Client 13+ 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | name 'foo' 15 | depends 'foo' 16 | ``` 17 | 18 | ### correct 19 | 20 | ```ruby 21 | name 'foo' 22 | ``` 23 | version_added: 5.2.0 24 | enabled: true 25 | included_file_paths: 26 | - "**/metadata.rb" 27 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_delivery.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: Delivery 3 | full_name: Chef/Deprecations/Delivery 4 | department: Chef/Deprecations 5 | description: |- 6 | The Delivery CLI from Chef Delivery/Workflow is no longer bundled with Chef Workstation as Chef Delivery is end of life as of Dec 31st 2021. 7 | 8 | Users of Delivery / Workflow would include a `.delivery` directory in their cookbooks. This directory would include Delivery local-mode configs 9 | or Delivery cookbooks. The contents of this directory are now obsolete and should be removed. 10 | autocorrection: false 11 | target_chef_version: All Versions 12 | examples: 13 | version_added: 7.31.0 14 | enabled: true 15 | included_file_paths: 16 | - "**/.delivery/project.toml" 17 | - "**/.delivery/config.json" 18 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_dependsonchefnginxcookbook.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: DependsOnChefNginxCookbook 3 | full_name: Chef/Deprecations/DependsOnChefNginxCookbook 4 | department: Chef/Deprecations 5 | description: Don't depend on the deprecated `chef_nginx` cookbook that was replaced 6 | by the `nginx` cookbook. The legacy chef_nginx cookbook may not be compatible with 7 | newer Chef Infra Client releases. 8 | autocorrection: true 9 | target_chef_version: All Versions 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | depends 'chef_nginx' 16 | ``` 17 | 18 | ### correct 19 | 20 | ```ruby 21 | depends 'nginx' 22 | ``` 23 | version_added: 7.20.0 24 | enabled: true 25 | included_file_paths: 26 | - "**/metadata.rb" 27 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_dependsonchefreportingcookbook.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: DependsOnChefReportingCookbook 3 | full_name: Chef/Deprecations/DependsOnChefReportingCookbook 4 | department: Chef/Deprecations 5 | description: Don't depend on the chef-reporting cookbook made obsolete by Chef Infra 6 | Client 11.6. This cookbook installs a gem that is not compatible with newer Chef 7 | Infra Client releases. 8 | autocorrection: true 9 | target_chef_version: All Versions 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | depends 'chef-reporting' 16 | ``` 17 | version_added: 7.20.0 18 | enabled: true 19 | included_file_paths: 20 | - "**/metadata.rb" 21 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_dependsonomnibusupdatercookbook.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: DependsOnOmnibusUpdaterCookbook 3 | full_name: Chef/Deprecations/DependsOnOmnibusUpdaterCookbook 4 | department: Chef/Deprecations 5 | description: Don't depend on the EOL `omnibus_updater` cookbook. This cookbook no 6 | longer works with newer Chef Infra Client releases and has been replaced with the 7 | more reliable `chef_client_updater` cookbook. 8 | autocorrection: true 9 | target_chef_version: All Versions 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | depends 'omnibus_updater' 16 | ``` 17 | 18 | ### correct 19 | 20 | ```ruby 21 | depends 'chef_client_updater' 22 | ``` 23 | version_added: 7.20.0 24 | enabled: true 25 | included_file_paths: 26 | - "**/metadata.rb" 27 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_deprecatedchefspecplatform.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: DeprecatedChefSpecPlatform 3 | full_name: Chef/Deprecations/DeprecatedChefSpecPlatform 4 | department: Chef/Deprecations 5 | description: Use currently supported platforms in ChefSpec listed at https://github.com/chef/fauxhai/blob/main/PLATFORMS.md. 6 | Fauxhai / ChefSpec will perform fuzzy matching on platform version values so it's 7 | always best to be less specific ie. 10 instead of 10.3 8 | autocorrection: true 9 | target_chef_version: All Versions 10 | examples: |2- 11 | 12 | let(:chef_run) { ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '14.04') } 13 | ``` 14 | version_added: 5.20.0 15 | enabled: true 16 | included_file_paths: 17 | - "**/spec/**/*.rb" 18 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_deprecatedsudoactions.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: DeprecatedSudoActions 3 | full_name: Chef/Deprecations/DeprecatedSudoActions 4 | department: Chef/Deprecations 5 | description: The `sudo` resource in the sudo cookbook 5.0 (2018) or Chef Infra Client 6 | 14 and later have replaced the existing `:install` and `:remove` actions with `:create` 7 | and `:delete` actions to better match other resources in Chef Infra. 8 | autocorrection: true 9 | target_chef_version: 14.0+ 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | sudo 'admins' do 16 | users 'bob' 17 | groups 'sysadmins, superusers' 18 | action :remove 19 | end 20 | ``` 21 | 22 | ### correct 23 | 24 | ```ruby 25 | sudo 'admins' do 26 | users 'bob' 27 | groups 'sysadmins, superusers' 28 | action :delete 29 | end 30 | ``` 31 | version_added: 7.18.0 32 | enabled: true 33 | excluded_file_paths: 34 | - "**/spec/**/*.rb" 35 | - "**/metadata.rb" 36 | - "**/attributes/*.rb" 37 | - "**/Berksfile" 38 | - "**/Rakefile" 39 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_deprecatedwindowsversioncheck.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: DeprecatedWindowsVersionCheck 3 | full_name: Chef/Deprecations/DeprecatedWindowsVersionCheck 4 | department: Chef/Deprecations 5 | description: Don't use the deprecated `older_than_win_2012_or_8?` helper. Windows 6 | versions before 2012 and 8 are now end of life and this helper will always return 7 | false. 8 | autocorrection: false 9 | target_chef_version: All Versions 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | if older_than_win_2012_or_8? 16 | # do some legacy things 17 | end 18 | ``` 19 | version_added: 6.0.0 20 | enabled: true 21 | excluded_file_paths: 22 | - "**/metadata.rb" 23 | - "**/Berksfile" 24 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_easyinstallresource.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: EasyInstallResource 3 | full_name: Chef/Deprecations/EasyInstallResource 4 | department: Chef/Deprecations 5 | description: Don't use the deprecated easy_install resource removed in Chef Infra 6 | Client 13. 7 | autocorrection: false 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | easy_install "my_thing" do 15 | bar 16 | end 17 | ``` 18 | version_added: 5.1.0 19 | enabled: true 20 | excluded_file_paths: 21 | - "**/attributes/*.rb" 22 | - "**/metadata.rb" 23 | - "**/Berksfile" 24 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_eolauditmodeusage.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: EOLAuditModeUsage 3 | full_name: Chef/Deprecations/EOLAuditModeUsage 4 | department: Chef/Deprecations 5 | description: The beta Audit Mode for Chef Infra Client was removed in Chef Infra Client 6 | 15.0. Users should instead use InSpec and the audit cookbook or the Compliance Phase 7 | introduced in Chef Infra Client 17. See https://www.inspec.io/ for more information. 8 | autocorrection: false 9 | target_chef_version: All Versions 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | control_group 'Baseline' do 16 | control 'SSH' do 17 | it 'should be listening on port 22' do 18 | expect(port(22)).to be_listening 19 | end 20 | end 21 | end 22 | ``` 23 | version_added: 5.10.0 24 | enabled: true 25 | excluded_file_paths: 26 | - "**/metadata.rb" 27 | - "**/attributes/*.rb" 28 | - "**/Berksfile" 29 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_epicfail.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: EpicFail 3 | full_name: Chef/Deprecations/EpicFail 4 | department: Chef/Deprecations 5 | description: Use `ignore_failure` in resources to continue when failures occur instead 6 | of the deprecated `epic_fail` property. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | package "foo" do 15 | epic_fail true 16 | end 17 | ``` 18 | 19 | ### correct 20 | 21 | ```ruby 22 | package "foo" do 23 | ignore_failure true 24 | end 25 | ``` 26 | version_added: 5.1.0 27 | enabled: true 28 | excluded_file_paths: 29 | - "**/attributes/*.rb" 30 | - "**/metadata.rb" 31 | - "**/Berksfile" 32 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_erlcallresource.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ErlCallResource 3 | full_name: Chef/Deprecations/ErlCallResource 4 | department: Chef/Deprecations 5 | description: Don't use the deprecated `erl_call` resource removed in Chef Infra Client 6 | 13." 7 | autocorrection: false 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | erl_call "foo" do 15 | bar 16 | end 17 | ``` 18 | version_added: 5.1.0 19 | enabled: true 20 | excluded_file_paths: 21 | - "**/attributes/*.rb" 22 | - "**/metadata.rb" 23 | - "**/Berksfile" 24 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_executepathproperty.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ExecutePathProperty 3 | full_name: Chef/Deprecations/ExecutePathProperty 4 | department: Chef/Deprecations 5 | description: In Chef Infra Client 13 and later you must set path env vars in execute 6 | resources using the `environment` property not the legacy `path` property. 7 | autocorrection: false 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | execute 'some_cmd' do 15 | path '/foo/bar' 16 | end 17 | ``` 18 | 19 | ### correct 20 | 21 | ```ruby 22 | execute 'some_cmd' do 23 | environment {path: '/foo/bar'} 24 | end 25 | ``` 26 | version_added: 6.17.0 27 | enabled: true 28 | excluded_file_paths: 29 | - "**/metadata.rb" 30 | - "**/attributes/*.rb" 31 | - "**/Berksfile" 32 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_executerelativecreateswithoutcwd.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ExecuteRelativeCreatesWithoutCwd 3 | full_name: Chef/Deprecations/ExecuteRelativeCreatesWithoutCwd 4 | department: Chef/Deprecations 5 | description: In Chef Infra Client 13 and later you must either specific an absolute 6 | path when using the `execute` resource's `creates` property or also use the `cwd` 7 | property. 8 | autocorrection: false 9 | target_chef_version: All Versions 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | execute 'some_cmd' do 16 | creates 'something' 17 | end 18 | ``` 19 | 20 | ### correct 21 | 22 | ```ruby 23 | execute 'some_cmd' do 24 | creates '/tmp/something' 25 | end 26 | 27 | execute 'some_cmd' do 28 | creates 'something' 29 | cwd '/tmp/' 30 | end 31 | ``` 32 | version_added: 6.17.0 33 | enabled: true 34 | excluded_file_paths: 35 | - "**/metadata.rb" 36 | - "**/attributes/*.rb" 37 | - "**/Berksfile" 38 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_foodcriticfile.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: FoodcriticFile 3 | full_name: Chef/Deprecations/FoodcriticFile 4 | department: Chef/Deprecations 5 | description: The Foodcritic cookbook linter has been deprecated and should no longer 6 | be used for validating cookbooks. Do not include the `.foodcritic` config file used 7 | by Foodcritic in your cookbooks. 8 | autocorrection: false 9 | target_chef_version: All Versions 10 | examples: 11 | version_added: 7.32.0 12 | enabled: true 13 | included_file_paths: 14 | - "**/.foodcritic" 15 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_foodcritictesting.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: FoodcriticTesting 3 | full_name: Chef/Deprecations/FoodcriticTesting 4 | department: Chef/Deprecations 5 | description: The Foodcritic cookbook linter has been deprecated and should no longer 6 | be used for validating cookbooks. 7 | autocorrection: false 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | gem 'foodcritic' 15 | require 'foodcritic' 16 | ``` 17 | version_added: 7.1.0 18 | enabled: true 19 | included_file_paths: 20 | - "**/Rakefile" 21 | - "**/Gemfile" 22 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_includingxmlrubyrecipe.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: IncludingXMLRubyRecipe 3 | full_name: Chef/Deprecations/IncludingXMLRubyRecipe 4 | department: Chef/Deprecations 5 | description: Do not include the deprecated xml::ruby recipe to install the nokogiri 6 | gem. Chef Infra Client 12 and later ships with nokogiri included. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | include_recipe 'xml::ruby' 15 | ``` 16 | version_added: 5.4.0 17 | enabled: true 18 | excluded_file_paths: 19 | - "**/attributes/*.rb" 20 | - "**/metadata.rb" 21 | - "**/Berksfile" 22 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_includingyumdnfcompatrecipe.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: IncludingYumDNFCompatRecipe 3 | full_name: Chef/Deprecations/IncludingYumDNFCompatRecipe 4 | department: Chef/Deprecations 5 | description: |- 6 | Don't include the deprecated yum DNF compatibility recipe, which is no longer necessary 7 | as Chef Infra Client includes DNF package support 8 | autocorrection: true 9 | target_chef_version: All Versions 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | include_recipe 'yum::dnf_yum_compat' 16 | ``` 17 | version_added: 5.3.0 18 | enabled: true 19 | excluded_file_paths: 20 | - "**/metadata.rb" 21 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_launchddeprecatedhashproperty.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: LaunchdDeprecatedHashProperty 3 | full_name: Chef/Deprecations/LaunchdDeprecatedHashProperty 4 | department: Chef/Deprecations 5 | description: The launchd resource's hash property was renamed to plist_hash in Chef 6 | Infra Client 13+ to avoid conflicts with Ruby's hash class. 7 | autocorrection: true 8 | target_chef_version: 12.19+ 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | launchd 'foo' do 15 | hash foo: 'bar' 16 | end 17 | ``` 18 | 19 | ### correct 20 | 21 | ```ruby 22 | launchd 'foo' do 23 | plist_hash foo: 'bar' 24 | end 25 | ``` 26 | version_added: 5.5.0 27 | enabled: true 28 | excluded_file_paths: 29 | - "**/metadata.rb" 30 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_legacyyumcookbookrecipes.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: LegacyYumCookbookRecipes 3 | full_name: Chef/Deprecations/LegacyYumCookbookRecipes 4 | department: Chef/Deprecations 5 | description: |- 6 | The Ohai default recipe previously allowed a user to ship custom Ohai plugins to a system by including them 7 | in a directory in the Ohai cookbook. This functionality was replaced with the ohai_plugin resource, which 8 | should be used instead as it doesn't require forking the ohai cookbook. 9 | autocorrection: false 10 | target_chef_version: All Versions 11 | examples: |2- 12 | 13 | ### incorrect 14 | 15 | ```ruby 16 | include_recipe 'yum::elrepo' 17 | include_recipe 'yum::epel' 18 | include_recipe 'yum::ius' 19 | include_recipe 'yum::remi' 20 | include_recipe 'yum::repoforge' 21 | include_recipe 'yum::yum' 22 | ``` 23 | version_added: 5.4.0 24 | enabled: true 25 | excluded_file_paths: 26 | - "**/metadata.rb" 27 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_librarianchefspec.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: LibrarianChefSpec 3 | full_name: Chef/Deprecations/LibrarianChefSpec 4 | department: Chef/Deprecations 5 | description: The Librarian-Chef depsolving project is no longer maintained and a Cheffile 6 | should not be used for cookbook depsolving. Consider using Policyfiles instead. 7 | autocorrection: false 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | require 'chefspec/librarian' 15 | ``` 16 | version_added: 7.1.0 17 | enabled: true 18 | included_file_paths: 19 | - "**/specs/*.rb" 20 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_localedeprecatedlcallproperty.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: LocaleDeprecatedLcAllProperty 3 | full_name: Chef/Deprecations/LocaleDeprecatedLcAllProperty 4 | department: Chef/Deprecations 5 | description: The local resource's lc_all property has been deprecated and will be 6 | removed in Chef Infra Client 17 7 | autocorrection: false 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | locale 'set locale' do 15 | lang 'en_gb.utf-8' 16 | lc_all 'en_gb.utf-8' 17 | end 18 | ``` 19 | version_added: 5.5.0 20 | enabled: true 21 | excluded_file_paths: 22 | - "**/metadata.rb" 23 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_macosuserdefaultsglobalproperty.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: MacosUserdefaultsGlobalProperty 3 | full_name: Chef/Deprecations/MacosUserdefaultsGlobalProperty 4 | department: Chef/Deprecations 5 | description: The `global` property in the macos_userdefaults resource was deprecated 6 | in Chef Infra Client 16.3. This property was never properly implemented and caused 7 | failures under many conditions. Omitting the `domain` property will now set global 8 | defaults. 9 | autocorrection: true 10 | target_chef_version: 16.3+ 11 | examples: |2- 12 | 13 | ### incorrect 14 | 15 | ```ruby 16 | macos_userdefaults 'set a value' do 17 | global true 18 | key 'key' 19 | value 'value' 20 | end 21 | ``` 22 | 23 | ### correct 24 | 25 | ```ruby 26 | macos_userdefaults 'set a value' do 27 | key 'key' 28 | value 'value' 29 | end 30 | ``` 31 | version_added: 6.14.0 32 | enabled: true 33 | excluded_file_paths: 34 | - "**/metadata.rb" 35 | - "**/Berksfile" 36 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_nodedeepfetch.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: NodeDeepFetch 3 | full_name: Chef/Deprecations/NodeDeepFetch 4 | department: Chef/Deprecations 5 | description: The node.deep_fetch method has been removed from Chef-Sugar, and must 6 | be replaced by the node.read API. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | node.deep_fetch("foo") 15 | ``` 16 | 17 | ### correct 18 | 19 | ```ruby 20 | node.read("foo") 21 | 22 | ### incorrect 23 | 24 | ```ruby 25 | node.deep_fetch!("foo") 26 | ``` 27 | 28 | ### correct 29 | 30 | ```ruby 31 | node.read!("foo") 32 | ``` 33 | version_added: 5.12.0 34 | enabled: true 35 | excluded_file_paths: 36 | - "**/metadata.rb" 37 | - "**/Berksfile" 38 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_nodemethodsinsteadofattributes.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: NodeMethodsInsteadofAttributes 3 | full_name: Chef/Deprecations/NodeMethodsInsteadofAttributes 4 | department: Chef/Deprecations 5 | description: Use node attributes to access data provided by Ohai instead of using 6 | node methods to access that data. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | node.fqdn 15 | node.platform 16 | node.platform_family 17 | node.platform_version 18 | node.hostname 19 | ``` 20 | 21 | ### correct 22 | 23 | ```ruby 24 | node['fqdn'] 25 | node['platform'] 26 | node['platform_family'] 27 | node['platform_version'] 28 | node['hostname'] 29 | ``` 30 | version_added: 5.4.0 31 | enabled: true 32 | excluded_file_paths: 33 | - "**/metadata.rb" 34 | - "**/Berksfile" 35 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_nodeset.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: NodeSet 3 | full_name: Chef/Deprecations/NodeSet 4 | department: Chef/Deprecations 5 | description: |- 6 | The `node.set` method has been removed in Chef Infra Client 13 and usage must be replaced with `node.normal`. 7 | 8 | This cop will autocorrect code to use node.normal, which is functionally identical to node.set, but we also discourage the use of that method as normal level attributes persist on the node even if the code setting the attribute is later removed. 9 | autocorrection: true 10 | target_chef_version: All Versions 11 | examples: |2- 12 | 13 | ### incorrect 14 | 15 | ```ruby 16 | node.set['foo'] = true 17 | ``` 18 | 19 | ### correct 20 | 21 | ```ruby 22 | node.normal['foo'] = true 23 | ``` 24 | version_added: 5.0.0 25 | enabled: true 26 | excluded_file_paths: 27 | - "**/metadata.rb" 28 | - "**/Berksfile" 29 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_nodesetunless.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: NodeSetUnless 3 | full_name: Chef/Deprecations/NodeSetUnless 4 | department: Chef/Deprecations 5 | description: |- 6 | The node.set_unless method has been removed in Chef Infra Client 13 and usage must be replaced with node.normal_unless. 7 | 8 | This cop will autocorrect code to use node.normal_unless, which is functionally identical to node.set_unless, but we also discourage the use of that method as normal level attributes persist on the node even if the code setting the attribute is later removed. 9 | autocorrection: true 10 | target_chef_version: All Versions 11 | examples: |2- 12 | 13 | ### incorrect 14 | 15 | ```ruby 16 | node.set_unless['foo'] = true 17 | ``` 18 | 19 | ### correct 20 | 21 | ```ruby 22 | node.normal_unless['foo'] = true 23 | ``` 24 | version_added: 5.1.0 25 | enabled: true 26 | excluded_file_paths: 27 | - "**/metadata.rb" 28 | - "**/Berksfile" 29 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_nodesetwithoutlevel.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: NodeSetWithoutLevel 3 | full_name: Chef/Deprecations/NodeSetWithoutLevel 4 | department: Chef/Deprecations 5 | description: When setting a node attribute in Chef Infra Client 11 and later you must 6 | specify the precedence level. 7 | autocorrection: false 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | node['foo']['bar'] = 1 15 | node['foo']['bar'] << 1 16 | node['foo']['bar'] += 1 17 | node['foo']['bar'] -= 1 18 | ``` 19 | 20 | ### correct 21 | 22 | ```ruby 23 | node.default['foo']['bar'] = 1 24 | node.default['foo']['bar'] << 1 25 | node.default['foo']['bar'] += 1 26 | node.default['foo']['bar'] -= 1 27 | ``` 28 | version_added: 5.13.0 29 | enabled: true 30 | excluded_file_paths: 31 | - "**/metadata.rb" 32 | - "**/attributes/*.rb" 33 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_poisearchiveusage.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: PoiseArchiveUsage 3 | full_name: Chef/Deprecations/PoiseArchiveUsage 4 | department: Chef/Deprecations 5 | description: The poise_archive resource in the deprecated poise-archive should be 6 | replaced with the archive_file resource found in Chef Infra Client 15+. 7 | autocorrection: false 8 | target_chef_version: 15.0+ 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | poise_archive 'https://example.com/myapp.tgz' do 15 | destination '/opt/my_app' 16 | end 17 | ``` 18 | 19 | ### correct 20 | 21 | ```ruby 22 | archive_file 'https://example.com/myapp.tgz' do 23 | destination '/opt/my_app' 24 | end 25 | ``` 26 | version_added: 5.11.0 27 | enabled: true 28 | excluded_file_paths: 29 | - "**/metadata.rb" 30 | - "**/attributes/*.rb" 31 | - "**/Berksfile" 32 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_policyfilecommunitysource.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: PolicyfileCommunitySource 3 | full_name: Chef/Deprecations/PolicyfileCommunitySource 4 | department: Chef/Deprecations 5 | description: The Policyfile source of `:community` has been replaced with `:supermarket` 6 | autocorrection: true 7 | target_chef_version: All Versions 8 | examples: |2- 9 | 10 | ### incorrect 11 | 12 | ```ruby 13 | default_source :community 14 | ``` 15 | 16 | ### correct 17 | 18 | ```ruby 19 | default_source :supermarket 20 | ``` 21 | version_added: 7.15.0 22 | enabled: true 23 | included_file_paths: 24 | - "**/Policyfile.rb" 25 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_powershellcookbookhelpers.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: PowershellCookbookHelpers 3 | full_name: Chef/Deprecations/PowershellCookbookHelpers 4 | department: Chef/Deprecations 5 | description: Use `node['powershell']['version']` or the new `powershell_version` helper 6 | available in Chef Infra Client 15.8+ instead of the deprecated PowerShell cookbook 7 | helpers 8 | autocorrection: true 9 | target_chef_version: All Versions 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | Powershell::VersionHelper.powershell_version?('4.0') 16 | ``` 17 | 18 | ### correct 19 | 20 | ```ruby 21 | node['powershell']['version'].to_f == 4.0 22 | 23 | # better (Chef Infra Client 15.8+) 24 | powershell_version == 4.0 25 | ``` 26 | version_added: 6.1.0 27 | enabled: true 28 | excluded_file_paths: 29 | - "**/metadata.rb" 30 | - "**/Berksfile" 31 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_requirerecipe.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: RequireRecipe 3 | full_name: Chef/Deprecations/RequireRecipe 4 | department: Chef/Deprecations 5 | description: Make sure to use include_recipe instead of require_recipe 6 | autocorrection: true 7 | target_chef_version: All Versions 8 | examples: |2- 9 | 10 | ### incorrect 11 | 12 | ```ruby 13 | require_recipe 'foo' 14 | ``` 15 | 16 | ### correct 17 | 18 | ```ruby 19 | include_recipe 'foo' 20 | ``` 21 | version_added: 5.2.0 22 | enabled: true 23 | excluded_file_paths: 24 | - "**/attributes/*.rb" 25 | - "**/metadata.rb" 26 | - "**/Berksfile" 27 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_resourceinheritsfromcompatresource.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ResourceInheritsFromCompatResource 3 | full_name: Chef/Deprecations/ResourceInheritsFromCompatResource 4 | department: Chef/Deprecations 5 | description: Resources written in the class based HWRP style should inherit from the 6 | 'Chef::Resource' class and not the 'ChefCompat::Resource' class from the deprecated 7 | compat_resource cookbook. 8 | autocorrection: true 9 | target_chef_version: All Versions 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | class AptUpdate < ChefCompat::Resource 16 | # some resource code 17 | end 18 | ``` 19 | 20 | ### correct 21 | 22 | ```ruby 23 | class AptUpdate < Chef::Resource 24 | # some resource code 25 | end 26 | 27 | # better 28 | Write a custom resource using the custom resource DSL and avoid class based HWRPs entirely 29 | ``` 30 | version_added: 5.10.0 31 | enabled: true 32 | included_file_paths: 33 | - "**/libraries/*.rb" 34 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_resourceoverridesprovidesmethod.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ResourceOverridesProvidesMethod 3 | full_name: Chef/Deprecations/ResourceOverridesProvidesMethod 4 | department: Chef/Deprecations 5 | description: Some providers in resources override the provides? method, used to check 6 | whether they are a valid provider on the current platform. In Chef Infra Client 7 | 13, this will cause an error. Instead use `provides :SOME_PROVIDER_NAME` to register 8 | the provider. 9 | autocorrection: false 10 | target_chef_version: All Versions 11 | examples: |2- 12 | 13 | ### incorrect 14 | 15 | ```ruby 16 | def provides? 17 | true 18 | end 19 | ``` 20 | 21 | ### correct 22 | 23 | ```ruby 24 | provides :SOME_PROVIDER_NAME 25 | ``` 26 | version_added: 5.7.0 27 | enabled: true 28 | included_file_paths: 29 | - "**/libraries/*.rb" 30 | - "**/providers/*.rb" 31 | - "**/resources/*.rb" 32 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_resourceusesdslnamemethod.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ResourceUsesDslNameMethod 3 | full_name: Chef/Deprecations/ResourceUsesDslNameMethod 4 | department: Chef/Deprecations 5 | description: Don't use the dsl_name method in a resource to find the name of the resource. 6 | Use the resource_name method instead. dsl_name was removed in Chef Infra Client 7 | 13 and will now result in an error. 8 | autocorrection: false 9 | target_chef_version: All Versions 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | my_resource = MyResource.dsl_name 16 | ``` 17 | 18 | ### correct 19 | 20 | ```ruby 21 | my_resource = MyResource.resource_name 22 | ``` 23 | version_added: 5.7.0 24 | enabled: true 25 | included_file_paths: 26 | - "**/libraries/*.rb" 27 | - "**/providers/*.rb" 28 | - "**/resources/*.rb" 29 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_resourceusesonlyresourcename.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ResourceUsesOnlyResourceName 3 | full_name: Chef/Deprecations/ResourceUsesOnlyResourceName 4 | department: Chef/Deprecations 5 | description: Starting with Chef Infra Client 16, using `resource_name` without also 6 | using `provides` will result in resource failures. Make sure to use both `resource_name` 7 | and `provides` to change the name of the resource. You can also omit `resource_name` 8 | entirely if the value set matches the name Chef Infra Client automatically assigns 9 | based on COOKBOOKNAME_FILENAME. 10 | autocorrection: true 11 | target_chef_version: All Versions 12 | examples: |2- 13 | 14 | ### incorrect 15 | 16 | ```ruby 17 | mycookbook/resources/myresource.rb: 18 | resource_name :mycookbook_myresource 19 | ``` 20 | version_added: 6.7.0 21 | enabled: true 22 | included_file_paths: 23 | - "**/libraries/*.rb" 24 | - "**/resources/*.rb" 25 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_resourceusesproviderbasemethod.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ResourceUsesProviderBaseMethod 3 | full_name: Chef/Deprecations/ResourceUsesProviderBaseMethod 4 | department: Chef/Deprecations 5 | description: The Resource.provider_base allows the developer to specify within a resource 6 | a module to load the resource's provider from. Instead, the provider should call 7 | provides to register itself, or the resource should call provider to specify the 8 | provider to use. 9 | autocorrection: false 10 | target_chef_version: All Versions 11 | examples: |2- 12 | 13 | ### incorrect 14 | 15 | ```ruby 16 | provider_base ::Chef::Provider::SomethingSomething 17 | ``` 18 | version_added: 5.7.0 19 | enabled: true 20 | included_file_paths: 21 | - "**/libraries/*.rb" 22 | - "**/resources/*.rb" 23 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_ruby27keywordargumentwarnings.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: Ruby27KeywordArgumentWarnings 3 | full_name: Chef/Deprecations/Ruby27KeywordArgumentWarnings 4 | department: Chef/Deprecations 5 | description: Pass options to shell_out helpers without the brackets to avoid Ruby 6 | 2.7 deprecation warnings. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | shell_out!('hostnamectl status', { returns: [0, 1] }) 15 | shell_out('hostnamectl status', { returns: [0, 1] }) 16 | ``` 17 | 18 | ### correct 19 | 20 | ```ruby 21 | shell_out!('hostnamectl status', returns: [0, 1]) 22 | shell_out('hostnamectl status', returns: [0, 1]) 23 | ``` 24 | version_added: 6.5.0 25 | enabled: true 26 | excluded_file_paths: 27 | - "**/metadata.rb" 28 | - "**/Berksfile" 29 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_rubyblockcreateaction.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: RubyBlockCreateAction 3 | full_name: Chef/Deprecations/RubyBlockCreateAction 4 | department: Chef/Deprecations 5 | description: Use the :run action in the ruby_block resource instead of the deprecated 6 | :create action 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | ruby_block 'my special ruby block' do 15 | block do 16 | puts 'running' 17 | end 18 | action :create 19 | end 20 | ``` 21 | 22 | ### correct 23 | 24 | ```ruby 25 | ruby_block 'my special ruby block' do 26 | block do 27 | puts 'running' 28 | end 29 | action :run 30 | end 31 | ``` 32 | version_added: 5.16.0 33 | enabled: true 34 | excluded_file_paths: 35 | - "**/metadata.rb" 36 | - "**/attributes/*.rb" 37 | - "**/Berksfile" 38 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_searchusespositionalparameters.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: SearchUsesPositionalParameters 3 | full_name: Chef/Deprecations/SearchUsesPositionalParameters 4 | department: Chef/Deprecations 5 | description: |- 6 | correct 7 | 8 | query(:node, '*:*') 9 | search(:node, '*:*', start: 0, rows: 1000, filter_result: { :ip_address => ["ipaddress"] }) 10 | search(:node, '*:*', start: 0, rows: 1000) 11 | search(:node, '*:*', start: 0) 12 | autocorrection: true 13 | target_chef_version: All Versions 14 | examples: 15 | version_added: 5.11.0 16 | enabled: true 17 | excluded_file_paths: 18 | - "**/metadata.rb" 19 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_useautomaticresourcename.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: UseAutomaticResourceName 3 | full_name: Chef/Deprecations/UseAutomaticResourceName 4 | department: Chef/Deprecations 5 | description: The use_automatic_resource_name method was removed in Chef Infra Client 6 | 16. The resource name/provides should be set explicitly instead. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | module MyCookbook 15 | class MyCookbookService < Chef::Resource 16 | use_automatic_resource_name 17 | provides :mycookbook_service 18 | 19 | # some additional code 20 | end 21 | end 22 | ``` 23 | version_added: 6.12.0 24 | enabled: true 25 | included_file_paths: 26 | - "**/libraries/*.rb" 27 | - "**/resources/*.rb" 28 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_useinlineresourcesdefined.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: UseInlineResourcesDefined 3 | full_name: Chef/Deprecations/UseInlineResourcesDefined 4 | department: Chef/Deprecations 5 | description: |- 6 | use_inline_resources became the default in Chef Infra Client 13+ and no longer needs 7 | to be called in resources 8 | autocorrection: true 9 | target_chef_version: All Versions 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | use_inline_resources 16 | use_inline_resources if defined?(use_inline_resources) 17 | use_inline_resources if respond_to?(:use_inline_resources) 18 | ``` 19 | version_added: 5.4.0 20 | enabled: true 21 | included_file_paths: 22 | - "**/libraries/*.rb" 23 | - "**/providers/*.rb" 24 | - "**/resources/*.rb" 25 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_userdeprecatedsupportsproperty.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: UserDeprecatedSupportsProperty 3 | full_name: Chef/Deprecations/UserDeprecatedSupportsProperty 4 | department: Chef/Deprecations 5 | description: The supports property was removed in Chef Infra Client 13 in favor of 6 | individual 'manage_home' and 'non_unique' properties. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | user "betty" do 15 | supports({ 16 | manage_home: true, 17 | non_unique: true 18 | }) 19 | end 20 | 21 | user 'betty' do 22 | supports :manage_home => true 23 | end 24 | ``` 25 | 26 | ### correct 27 | 28 | ```ruby 29 | user "betty" do 30 | manage_home true 31 | non_unique true 32 | end 33 | ``` 34 | version_added: 5.5.0 35 | enabled: true 36 | excluded_file_paths: 37 | - "**/metadata.rb" 38 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_useschefresthelpers.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: UsesChefRESTHelpers 3 | full_name: Chef/Deprecations/UsesChefRESTHelpers 4 | department: Chef/Deprecations 5 | description: The `Chef::REST` class was removed in Chef Infra Client 13. 6 | autocorrection: false 7 | target_chef_version: All Versions 8 | examples: |2- 9 | 10 | ### incorrect 11 | 12 | ```ruby 13 | require 'chef/rest' 14 | Chef::REST::RESTRequest.new(:GET, FOO, nil).call 15 | ``` 16 | version_added: 5.5.0 17 | enabled: true 18 | excluded_file_paths: 19 | - "**/metadata.rb" 20 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_usesdeprecatedmixins.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: UsesDeprecatedMixins 3 | full_name: Chef/Deprecations/UsesDeprecatedMixins 4 | department: Chef/Deprecations 5 | description: Don't use deprecated Mixins no longer included in Chef Infra Client 14 6 | and later. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | include Chef::Mixin::LanguageIncludeAttribute 15 | include Chef::Mixin::RecipeDefinitionDSLCore 16 | include Chef::Mixin::LanguageIncludeRecipe 17 | include Chef::Mixin::Language 18 | include Chef::DSL::Recipe::FullDSL 19 | require 'chef/mixin/language' 20 | require 'chef/mixin/language_include_attribute' 21 | require 'chef/mixin/language_include_recipe' 22 | ``` 23 | version_added: 5.4.0 24 | enabled: true 25 | included_file_paths: 26 | - "**/libraries/*.rb" 27 | - "**/providers/*.rb" 28 | - "**/resources/*.rb" 29 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_usesruncommandhelper.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: UsesRunCommandHelper 3 | full_name: Chef/Deprecations/UsesRunCommandHelper 4 | department: Chef/Deprecations 5 | description: Use 'shell_out!' instead of the legacy 'run_command' or 'run_command_with_systems_locale' 6 | helpers for shelling out. The run_command helper was removed in Chef Infra Client 7 | 13. 8 | autocorrection: false 9 | target_chef_version: All Versions 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | require 'chef/mixin/command' 16 | include Chef::Mixin::Command 17 | 18 | run_command('/bin/foo') 19 | run_command_with_systems_locale('/bin/foo') 20 | ``` 21 | 22 | ### correct 23 | 24 | ```ruby 25 | shell_out!('/bin/foo') 26 | ``` 27 | version_added: 5.9.0 28 | enabled: true 29 | excluded_file_paths: 30 | - "**/metadata.rb" 31 | - "**/Berksfile" 32 | - "**/Rakefile" 33 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_useyamldump.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: UseYamlDump 3 | full_name: Chef/Deprecations/UseYamlDump 4 | department: Chef/Deprecations 5 | description: Chef Infra Client 16.5 introduced performance enhancements to Ruby library 6 | loading. Due to the underlying implementation of Ruby's `.to_yaml` method, it does 7 | not automatically load the `yaml` library and `YAML.dump()` should be used instead 8 | to properly load the `yaml` library. 9 | autocorrection: true 10 | target_chef_version: All Versions 11 | examples: |2- 12 | 13 | ### incorrect 14 | 15 | ```ruby 16 | {"foo" => "bar"}.to_yaml 17 | ``` 18 | 19 | ### correct 20 | 21 | ```ruby 22 | YAML.dump({"foo" => "bar"}) 23 | ``` 24 | version_added: 6.21.0 25 | enabled: true 26 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_verifypropertyusesfileexpansion.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: VerifyPropertyUsesFileExpansion 3 | full_name: Chef/Deprecations/VerifyPropertyUsesFileExpansion 4 | department: Chef/Deprecations 5 | description: In Chef Infra Client 13 the "file" variable for use within the verify 6 | property was replaced with the "path" variable. 7 | autocorrection: true 8 | target_chef_version: 12.5+ 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | file '/etc/nginx.conf' do 15 | verify 'nginx -t -c %{file}' 16 | end 17 | ``` 18 | 19 | ### correct 20 | 21 | ```ruby 22 | file '/etc/nginx.conf' do 23 | verify 'nginx -t -c %{path}' 24 | end 25 | ``` 26 | version_added: 5.10.0 27 | enabled: true 28 | excluded_file_paths: 29 | - "**/metadata.rb" 30 | - "**/attributes/*.rb" 31 | - "**/Berksfile" 32 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_windowstaskchangeaction.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: WindowsTaskChangeAction 3 | full_name: Chef/Deprecations/WindowsTaskChangeAction 4 | department: Chef/Deprecations 5 | description: |- 6 | The :change action in the windows_task resource was removed when windows_task was added to Chef Infra Client 13+ 7 | The default action of :create should can now be used to create an update tasks. 8 | autocorrection: true 9 | target_chef_version: 13.0+ 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | windows_task 'chef ad-join leave start time' do 16 | task_name 'chef ad-join leave' 17 | start_day '06/09/2016' 18 | start_time '01:00' 19 | action [:change, :create] 20 | end 21 | ``` 22 | 23 | ### correct 24 | 25 | ```ruby 26 | windows_task 'chef ad-join leave start time' do 27 | task_name 'chef ad-join leave' 28 | start_day '06/09/2016' 29 | start_time '01:00' 30 | action :create 31 | end 32 | ``` 33 | version_added: 5.6.0 34 | enabled: true 35 | excluded_file_paths: 36 | - "**/metadata.rb" 37 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_deprecations_windowsversionhelpers.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: WindowsVersionHelpers 3 | full_name: Chef/Deprecations/WindowsVersionHelpers 4 | department: Chef/Deprecations 5 | description: Use node['platform_version'] and node['kernel'] data instead of the deprecated 6 | Windows::VersionHelper helpers from the Windows cookbook. 7 | autocorrection: true 8 | target_chef_version: 14.0+ 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | Windows::VersionHelper.nt_version 15 | Windows::VersionHelper.server_version? 16 | Windows::VersionHelper.core_version? 17 | Windows::VersionHelper.workstation_version? 18 | ``` 19 | 20 | ### correct 21 | 22 | ```ruby 23 | node['platform_version'].to_f 24 | node['kernel']['product_type'] == 'Server' 25 | node['kernel']['server_core'] 26 | node['kernel']['product_type'] == 'Workstation' 27 | ``` 28 | version_added: 5.4.0 29 | enabled: true 30 | excluded_file_paths: 31 | - "**/metadata.rb" 32 | - "**/Berksfile" 33 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_effortless_berksfile.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: Berksfile 3 | full_name: Chef/Effortless/Berksfile 4 | department: Chef/Effortless 5 | description: Policyfiles should be used for cookbook dependency solving instead of 6 | a Berkshelf Berksfile. 7 | autocorrection: false 8 | target_chef_version: All Versions 9 | examples: 10 | version_added: 5.12.0 11 | enabled: false 12 | included_file_paths: 13 | - "**/Berksfile" 14 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_effortless_chefvaultused.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ChefVaultUsed 3 | full_name: Chef/Effortless/ChefVaultUsed 4 | department: Chef/Effortless 5 | description: Chef Vault is not supported in the Effortless pattern, so usage of Chef 6 | Vault must be shifted to another secrets management solution before leveraging the 7 | Effortless pattern. 8 | autocorrection: false 9 | target_chef_version: All Versions 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | require 'chef-vault' 16 | 17 | ### incorrect 18 | 19 | ```ruby 20 | ChefVault::Item 21 | 22 | ### incorrect 23 | 24 | ```ruby 25 | include_recipe 'chef-vault' 26 | 27 | ### incorrect 28 | 29 | ```ruby 30 | chef_gem 'chef-vault' 31 | 32 | ### incorrect 33 | 34 | ```ruby 35 | chef_vault_item_for_environment(arg, arg1) 36 | 37 | ### incorrect 38 | 39 | ```ruby 40 | chef_vault_item(arg, arg1) 41 | ``` 42 | version_added: '6.19' 43 | enabled: false 44 | excluded_file_paths: 45 | - "**/metadata.rb" 46 | - "**/Berksfile" 47 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_effortless_cookbookusesdatabags.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: CookbookUsesDatabags 3 | full_name: Chef/Effortless/CookbookUsesDatabags 4 | department: Chef/Effortless 5 | description: Data bags cannot be used with the Effortless Infra pattern 6 | autocorrection: false 7 | target_chef_version: All Versions 8 | examples: |2- 9 | 10 | ### incorrect 11 | 12 | ```ruby 13 | data_bag_item('admins', login) 14 | data_bag(data_bag_name) 15 | ``` 16 | version_added: 5.1.0 17 | enabled: false 18 | excluded_file_paths: 19 | - "**/metadata.rb" 20 | - "**/Berksfile" 21 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_effortless_cookbookusesenvironments.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: CookbookUsesEnvironments 3 | full_name: Chef/Effortless/CookbookUsesEnvironments 4 | department: Chef/Effortless 5 | description: Neither Policyfiles or Effortless Infra which is based on Policyfiles 6 | supports Chef Environments 7 | autocorrection: false 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | node.environment == "production" 15 | node.chef_environment == "production" 16 | ``` 17 | version_added: 5.10.0 18 | enabled: false 19 | excluded_file_paths: 20 | - "**/metadata.rb" 21 | - "**/Berksfile" 22 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_effortless_cookbookusespolicygroups.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: CookbookUsesPolicygroups 3 | full_name: Chef/Effortless/CookbookUsesPolicygroups 4 | department: Chef/Effortless 5 | description: Effortless Infra does not support Policyfile's Policygroup feature 6 | autocorrection: false 7 | target_chef_version: All Versions 8 | examples: |2- 9 | 10 | ### incorrect 11 | 12 | ```ruby 13 | node.policy_group == "foo" 14 | ``` 15 | version_added: 5.10.0 16 | enabled: false 17 | excluded_file_paths: 18 | - "**/metadata.rb" 19 | - "**/Berksfile" 20 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_effortless_cookbookusesroles.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: CookbookUsesRoles 3 | full_name: Chef/Effortless/CookbookUsesRoles 4 | department: Chef/Effortless 5 | description: Neither Policyfiles or Effortless Infra which is based on Policyfiles 6 | supports Chef Infra Roles 7 | autocorrection: false 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | node.role?('web_server') 15 | node.roles.include?('web_server') 16 | ``` 17 | version_added: 5.10.0 18 | enabled: false 19 | excluded_file_paths: 20 | - "**/metadata.rb" 21 | - "**/Berksfile" 22 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_effortless_cookbookusessearch.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: CookbookUsesSearch 3 | full_name: Chef/Effortless/CookbookUsesSearch 4 | department: Chef/Effortless 5 | description: Search is not compatible with the Effortless Infra pattern 6 | autocorrection: false 7 | target_chef_version: All Versions 8 | examples: |2- 9 | 10 | ### incorrect 11 | 12 | ```ruby 13 | search(:node, 'run_list:recipe\[bacula\:\:server\]') 14 | ``` 15 | version_added: 5.1.0 16 | enabled: false 17 | excluded_file_paths: 18 | - "**/metadata.rb" 19 | - "**/Berksfile" 20 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_effortless_dependschefvault.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: DependsChefVault 3 | full_name: Chef/Effortless/DependsChefVault 4 | department: Chef/Effortless 5 | description: Chef Vault is not supported in the Effortless pattern, so usage of Chef 6 | Vault must be shifted to another secrets management solution before leveraging the 7 | Effortless pattern. 8 | autocorrection: false 9 | target_chef_version: All Versions 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | depends 'chef-vault' 16 | ``` 17 | version_added: '6.19' 18 | enabled: false 19 | included_file_paths: 20 | - "**/metadata.rb" 21 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_effortless_searchforenvironmentsorroles.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: SearchForEnvironmentsOrRoles 3 | full_name: Chef/Effortless/SearchForEnvironmentsOrRoles 4 | department: Chef/Effortless 5 | description: Policyfiles (and Effortless) do not use environments or roles so searching 6 | for those will need to be refactored before migrating to Policyfiles and the Effortless 7 | pattern. 8 | autocorrection: false 9 | target_chef_version: All Versions 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | search(:node, 'chef_environment:foo') 16 | search(:node, 'role:bar') 17 | ``` 18 | version_added: 5.11.0 19 | enabled: false 20 | excluded_file_paths: 21 | - "**/metadata.rb" 22 | - "**/Berksfile" 23 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_actionmethodinresource.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ActionMethodInResource 3 | full_name: Chef/Modernize/ActionMethodInResource 4 | department: Chef/Modernize 5 | description: Use the custom resource language's `action :my_action` blocks instead 6 | of creating actions with methods. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | def action_create 15 | # :create action code here 16 | end 17 | ``` 18 | 19 | ### correct 20 | 21 | ```ruby 22 | action :create do 23 | # :create action code here 24 | end 25 | ``` 26 | version_added: 6.13.0 27 | enabled: true 28 | included_file_paths: 29 | - "**/resources/*.rb" 30 | - "**/providers/*.rb" 31 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_chefgemnokogiri.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ChefGemNokogiri 3 | full_name: Chef/Modernize/ChefGemNokogiri 4 | department: Chef/Modernize 5 | description: The nokogiri gem ships in Chef Infra Client 12+ and does not need to 6 | be installed before being used 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | chef_gem 'nokogiri' 15 | ``` 16 | version_added: 5.14.0 17 | enabled: true 18 | excluded_file_paths: 19 | - "**/metadata.rb" 20 | - "**/attributes/*.rb" 21 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_classevalactionclass.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ClassEvalActionClass 3 | full_name: Chef/Modernize/ClassEvalActionClass 4 | department: Chef/Modernize 5 | description: In Chef Infra Client 12.9 and later it is no longer necessary to call 6 | the class_eval method on the action class block. 7 | autocorrection: true 8 | target_chef_version: 12.9+ 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | action_class.class_eval do 15 | foo 16 | end 17 | ``` 18 | 19 | ### correct 20 | 21 | ```ruby 22 | action_class do 23 | foo 24 | end 25 | ``` 26 | version_added: 7.23.0 27 | enabled: true 28 | included_file_paths: 29 | - "**/resources/*.rb" 30 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_conditionalusingtest.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ConditionalUsingTest 3 | full_name: Chef/Modernize/ConditionalUsingTest 4 | department: Chef/Modernize 5 | description: Use ::File.exist?('/foo/bar') instead of the slower 'test -f /foo/bar' 6 | which requires shelling out 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | only_if 'test -f /bin/foo' 15 | ``` 16 | 17 | ### correct 18 | 19 | ```ruby 20 | only_if { ::File.exist?('bin/foo') } 21 | ``` 22 | version_added: 6.11.0 23 | enabled: true 24 | excluded_file_paths: 25 | - "**/metadata.rb" 26 | - "**/Berksfile" 27 | - "**/attributes/*.rb" 28 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_cronmanageresource.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: CronManageResource 3 | full_name: Chef/Modernize/CronManageResource 4 | department: Chef/Modernize 5 | description: The cron_manage resource was renamed to cron_access in the 6.1 release 6 | of the cron cookbook, and later shipped in Chef Infra Client 14.4. The new resource 7 | name should be used. 8 | autocorrection: true 9 | target_chef_version: 14.4+ 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | cron_manage 'mike' 16 | ``` 17 | 18 | ### correct 19 | 20 | ```ruby 21 | cron_access 'mike' 22 | ``` 23 | version_added: 5.6.0 24 | enabled: true 25 | excluded_file_paths: 26 | - "**/metadata.rb" 27 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_customresourcewithattributes.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: CustomResourceWithAttributes 3 | full_name: Chef/Modernize/CustomResourceWithAttributes 4 | department: Chef/Modernize 5 | description: In HWRPs and LWRPs you defined attributes, but custom resources changed 6 | the name to be properties to avoid confusion with chef recipe attributes. When writing 7 | a custom resource they should be called properties even though the two are aliased. 8 | autocorrection: true 9 | target_chef_version: All Versions 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | attribute :something, String 16 | 17 | action :create do 18 | # some action code because we're in a custom resource 19 | end 20 | ``` 21 | 22 | ### correct 23 | 24 | ```ruby 25 | property :something, String 26 | 27 | action :create do 28 | # some action code because we're in a custom resource 29 | end 30 | ``` 31 | version_added: 5.2.0 32 | enabled: true 33 | included_file_paths: 34 | - "**/resources/*.rb" 35 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_databaghelpers.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: DatabagHelpers 3 | full_name: Chef/Modernize/DatabagHelpers 4 | department: Chef/Modernize 5 | description: Use the `data_bag_item` helper instead of `Chef::DataBagItem.load` or 6 | `Chef::EncryptedDataBagItem.load`. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | plain_text_data = Chef::DataBagItem.load('foo', 'bar') 15 | encrypted_data = Chef::EncryptedDataBagItem.load('foo2', 'bar2') 16 | ``` 17 | 18 | ### correct 19 | 20 | ```ruby 21 | plain_text_data = data_bag_item('foo', 'bar') 22 | encrypted_data = data_bag_item('foo2', 'bar2') 23 | ``` 24 | version_added: 6.0.0 25 | enabled: true 26 | excluded_file_paths: 27 | - "**/metadata.rb" 28 | - "**/Berksfile" 29 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_declareactionclass.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: DeclareActionClass 3 | full_name: Chef/Modernize/DeclareActionClass 4 | department: Chef/Modernize 5 | description: In Chef Infra Client 12.9 and later `action_class` can be used instead 6 | of `declare_action_class`. 7 | autocorrection: true 8 | target_chef_version: 12.9+ 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | declare_action_class do 15 | foo 16 | end 17 | ``` 18 | 19 | ### correct 20 | 21 | ```ruby 22 | action_class do 23 | foo 24 | end 25 | ``` 26 | version_added: 7.26.0 27 | enabled: true 28 | included_file_paths: 29 | - "**/resources/*.rb" 30 | - "**/libraries/*.rb" 31 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_defaultactionfrominitialize.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: DefaultActionFromInitialize 3 | full_name: Chef/Modernize/DefaultActionFromInitialize 4 | department: Chef/Modernize 5 | description: |- 6 | The default actions can now be specified using the `default_action` helper instead of using the @action variable in the resource provider initialize method. In general we recommend against writing HWRPs, but if HWRPs are necessary you should utilize as much of the resource DSL as possible. 7 | 8 | ### correct 9 | default_action :create 10 | autocorrection: true 11 | target_chef_version: All Versions 12 | examples: |2- 13 | 14 | ### incorrect 15 | 16 | ```ruby 17 | def initialize(*args) 18 | super 19 | @action = :create 20 | end 21 | 22 | ### incorrect 23 | 24 | ```ruby 25 | def initialize(*args) 26 | super 27 | @default_action = :create 28 | end 29 | ``` 30 | version_added: 5.10.0 31 | enabled: true 32 | included_file_paths: 33 | - "**/resources/*.rb" 34 | - "**/providers/*.rb" 35 | - "**/libraries/*.rb" 36 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_defineschefspecmatchers.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: DefinesChefSpecMatchers 3 | full_name: Chef/Modernize/DefinesChefSpecMatchers 4 | department: Chef/Modernize 5 | description: ChefSpec 7.1 and later auto generate ChefSpec matchers. Matchers in cookbooks 6 | can now be removed. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | if defined?(ChefSpec) 15 | def create_yum_repository(resource_name) 16 | ChefSpec::Matchers::ResourceMatcher.new(:yum_repository, :create, resource_name) 17 | end 18 | end 19 | ``` 20 | version_added: 5.3.0 21 | enabled: true 22 | included_file_paths: 23 | - "**/libraries/*.rb" 24 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_definitions.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: Definitions 3 | full_name: Chef/Modernize/Definitions 4 | department: Chef/Modernize 5 | description: In 2016 with Chef Infra Client 12.5 Custom Resources were introduced 6 | as a way of writing reusable resource code that could be shipped in cookbooks. Custom 7 | Resources offer many advantages of legacy Definitions including unit testing with 8 | ChefSpec, input validation, actions, common properties like not_if/only_if, and 9 | resource reporting. 10 | autocorrection: false 11 | target_chef_version: All Versions 12 | examples: 13 | version_added: 5.11.0 14 | enabled: true 15 | included_file_paths: 16 | - "**/definitions/*.rb" 17 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_dependsonchefvaultcookbook.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: DependsOnChefVaultCookbook 3 | full_name: Chef/Modernize/DependsOnChefVaultCookbook 4 | department: Chef/Modernize 5 | description: Don't depend on the chef-vault cookbook made obsolete by Chef Infra Client 6 | 16.0. The chef-vault gem and helpers are now included in Chef Infra Client itself. 7 | autocorrection: true 8 | target_chef_version: 16.0+ 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | depends 'chef-vault' 15 | ``` 16 | version_added: 7.20.0 17 | enabled: true 18 | included_file_paths: 19 | - "**/metadata.rb" 20 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_dependsonchocolateycookbooks.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: DependsOnChocolateyCookbooks 3 | full_name: Chef/Modernize/DependsOnChocolateyCookbooks 4 | department: Chef/Modernize 5 | description: Don't depend on the chocolatey_source or chocolatey_config cookbooks 6 | made obsolete by Chef Infra Client 14.3. The chocolatey_source and chocolatey_config 7 | resources are now included in Chef Infra Client itself. 8 | autocorrection: true 9 | target_chef_version: 14.3+ 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | depends 'chocolatey_source' 16 | depends 'chocolatey_config' 17 | ``` 18 | version_added: 7.20.0 19 | enabled: true 20 | included_file_paths: 21 | - "**/metadata.rb" 22 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_dependsonkernelmodulecookbook.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: DependsOnKernelModuleCookbook 3 | full_name: Chef/Modernize/DependsOnKernelModuleCookbook 4 | department: Chef/Modernize 5 | description: Don't depend on the kernel_module cookbook made obsolete by Chef Infra 6 | Client 14.3. The kernel_module resource is now included in Chef Infra Client itself. 7 | autocorrection: true 8 | target_chef_version: 14.3+ 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | depends 'kernel_module' 15 | ``` 16 | version_added: 7.19.0 17 | enabled: true 18 | included_file_paths: 19 | - "**/metadata.rb" 20 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_dependsonlocalecookbook.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: DependsOnLocaleCookbook 3 | full_name: Chef/Modernize/DependsOnLocaleCookbook 4 | department: Chef/Modernize 5 | description: Don't depend on the locale cookbook made obsolete by Chef Infra Client 6 | 14.5. The locale resource is now included in Chef Infra Client itself. 7 | autocorrection: true 8 | target_chef_version: 14.5+ 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | depends 'locale' 15 | ``` 16 | version_added: 7.19.0 17 | enabled: true 18 | included_file_paths: 19 | - "**/metadata.rb" 20 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_dependsonopensslcookbook.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: DependsOnOpensslCookbook 3 | full_name: Chef/Modernize/DependsOnOpensslCookbook 4 | department: Chef/Modernize 5 | description: Don't depend on the `openssl` cookbook which was made obsolete by Chef 6 | Infra Client 14.4. All `openssl_*` resources are now included directly in Chef Infra 7 | Client. 8 | autocorrection: true 9 | target_chef_version: 14.4+ 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | depends 'openssl' 16 | ``` 17 | version_added: 7.20.0 18 | enabled: true 19 | included_file_paths: 20 | - "**/metadata.rb" 21 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_dependsontimezonelwrpcookbook.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: DependsOnTimezoneLwrpCookbook 3 | full_name: Chef/Modernize/DependsOnTimezoneLwrpCookbook 4 | department: Chef/Modernize 5 | description: Don't depend on the timezone_lwrp cookbook made obsolete by Chef Infra 6 | Client 14.6. The timezone resource is now included in Chef Infra Client itself. 7 | autocorrection: true 8 | target_chef_version: 14.6+ 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | depends 'timezone_lwrp' 15 | ``` 16 | version_added: 7.19.0 17 | enabled: true 18 | included_file_paths: 19 | - "**/metadata.rb" 20 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_dependsonwindowsfirewallcookbook.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: DependsOnWindowsFirewallCookbook 3 | full_name: Chef/Modernize/DependsOnWindowsFirewallCookbook 4 | department: Chef/Modernize 5 | description: Don't depend on the windows_firewall cookbook made obsolete by Chef Infra 6 | Client 14.7. The windows_firewall resource is now included in Chef Infra Client 7 | itself. 8 | autocorrection: true 9 | target_chef_version: 14.7+ 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | depends 'windows_firewall' 16 | ``` 17 | version_added: 7.19.0 18 | enabled: true 19 | included_file_paths: 20 | - "**/metadata.rb" 21 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_dependsonzyppercookbook.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: DependsOnZypperCookbook 3 | full_name: Chef/Modernize/DependsOnZypperCookbook 4 | department: Chef/Modernize 5 | description: Don't depend on the zypper cookbook as the zypper_repository resource 6 | is built into Chef Infra Client 13.3+ 7 | autocorrection: true 8 | target_chef_version: 13.3+ 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | depends 'zypper' 15 | ``` 16 | version_added: 5.6.0 17 | enabled: true 18 | excluded_file_paths: 19 | - "**/metadata.rb" 20 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_dslincludeinresource.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: DslIncludeInResource 3 | full_name: Chef/Modernize/DslIncludeInResource 4 | department: Chef/Modernize 5 | description: Chef Infra Client 12.4+ includes the Chef::DSL::Recipe in the resource 6 | and provider classed by default so there is no need to include this DSL in your 7 | resources or providers. 8 | autocorrection: true 9 | target_chef_version: All Versions 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | include Chef::DSL::Recipe 16 | include Chef::DSL::IncludeRecipe 17 | ``` 18 | version_added: 5.17.0 19 | enabled: true 20 | included_file_paths: 21 | - "**/resources/*.rb" 22 | - "**/providers/*.rb" 23 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_emptyresourceinitializemethod.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: EmptyResourceInitializeMethod 3 | full_name: Chef/Modernize/EmptyResourceInitializeMethod 4 | department: Chef/Modernize 5 | description: There is no need for an empty initialize method in a resource 6 | autocorrection: true 7 | target_chef_version: All Versions 8 | examples: |2- 9 | 10 | ### incorrect 11 | 12 | ```ruby 13 | def initialize(*args) 14 | super 15 | end 16 | ``` 17 | version_added: 5.13.0 18 | enabled: true 19 | included_file_paths: 20 | - "**/resources/*.rb" 21 | - "**/providers/*.rb" 22 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_executeaptupdate.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ExecuteAptUpdate 3 | full_name: Chef/Modernize/ExecuteAptUpdate 4 | department: Chef/Modernize 5 | description: Instead of using the execute resource to run the `apt-get update` use 6 | Chef Infra Client's built-n apt_update resource which is available in Chef Infra 7 | Client 12.7 and later. 8 | autocorrection: true 9 | target_chef_version: All Versions 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | execute 'apt-get update' 16 | 17 | execute 'Apt all the apt cache' do 18 | command 'apt-get update' 19 | end 20 | 21 | execute 'some execute resource' do 22 | notifies :run, 'execute[apt-get update]', :immediately 23 | end 24 | ``` 25 | 26 | ### correct 27 | 28 | ```ruby 29 | apt_update 30 | 31 | apt_update 'update apt cache' 32 | 33 | execute 'some execute resource' do 34 | notifies :update, 'apt_update[update apt cache]', :immediately 35 | end 36 | ``` 37 | version_added: 5.3.0 38 | enabled: true 39 | excluded_file_paths: 40 | - "**/metadata.rb" 41 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_executescexe.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ExecuteScExe 3 | full_name: Chef/Modernize/ExecuteScExe 4 | department: Chef/Modernize 5 | description: Chef Infra Client 14.0 and later includes :create, :delete, and :configure 6 | actions with the full idempotency of the windows_service resource. See the windows_service 7 | documentation at https://docs.chef.io/resources/windows_service for additional details 8 | on creating services with the windows_service resource. 9 | autocorrection: false 10 | target_chef_version: 14.0+ 11 | examples: |2- 12 | 13 | ### incorrect 14 | 15 | ```ruby 16 | execute "Delete chef-client service" do 17 | command "sc.exe delete chef-client" 18 | action :run 19 | end 20 | ``` 21 | 22 | ### correct 23 | 24 | ```ruby 25 | windows_service 'chef-client' do 26 | action :delete 27 | end 28 | ``` 29 | version_added: 5.16.0 30 | enabled: true 31 | excluded_file_paths: 32 | - "**/metadata.rb" 33 | - "**/attributes/*.rb" 34 | - "**/Berksfile" 35 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_executesleep.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ExecuteSleep 3 | full_name: Chef/Modernize/ExecuteSleep 4 | department: Chef/Modernize 5 | description: Chef Infra Client 15.5 and later include a chef_sleep resource that should 6 | be used to sleep between executing resources if necessary instead of using the bash 7 | or execute resources to run the sleep command. 8 | autocorrection: false 9 | target_chef_version: 15.5+ 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | execute "sleep 60" do 16 | command "sleep 60" 17 | action :run 18 | end 19 | 20 | bash 'sleep' do 21 | user 'root' 22 | cwd '/tmp' 23 | code 'sleep 60' 24 | end 25 | ``` 26 | 27 | ### correct 28 | 29 | ```ruby 30 | chef_sleep '60' 31 | ``` 32 | version_added: 5.16.0 33 | enabled: true 34 | excluded_file_paths: 35 | - "**/metadata.rb" 36 | - "**/attributes/*.rb" 37 | - "**/Berksfile" 38 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_executesysctl.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ExecuteSysctl 3 | full_name: Chef/Modernize/ExecuteSysctl 4 | department: Chef/Modernize 5 | description: Chef Infra Client 14.0 and later includes a sysctl resource that should 6 | be used to idempotently load sysctl values instead of templating files and using 7 | execute to load them. 8 | autocorrection: false 9 | target_chef_version: 14.0+ 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | file '/etc/sysctl.d/ipv4.conf' do 16 | notifies :run, 'execute[sysctl -p /etc/sysctl.d/ipv4.conf]', :immediately 17 | content '9000 65500' 18 | end 19 | 20 | execute 'sysctl -p /etc/sysctl.d/ipv4.conf' do 21 | action :nothing 22 | end 23 | ``` 24 | 25 | ### correct 26 | 27 | ```ruby 28 | sysctl 'net.ipv4.ip_local_port_range' do 29 | value '9000 65500' 30 | end 31 | ``` 32 | version_added: 5.18.0 33 | enabled: true 34 | excluded_file_paths: 35 | - "**/metadata.rb" 36 | - "**/attributes/*.rb" 37 | - "**/Berksfile" 38 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_executetzutil.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ExecuteTzUtil 3 | full_name: Chef/Modernize/ExecuteTzUtil 4 | department: Chef/Modernize 5 | description: Instead of using the execute or powershell_script resources to run the 6 | `tzutil` command, use Chef Infra Client's built-in timezone resource which is available 7 | in Chef Infra Client 14.6 and later. 8 | autocorrection: false 9 | target_chef_version: 14.6+ 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | execute 'set tz' do 16 | command 'tzutil.exe /s UTC' 17 | end 18 | 19 | execute 'tzutil /s UTC' 20 | 21 | powershell_script 'set windows timezone' do 22 | code "tzutil.exe /s UTC" 23 | not_if { shell_out('tzutil.exe /g').stdout.include?('UTC') } 24 | end 25 | ``` 26 | 27 | ### correct 28 | 29 | ```ruby 30 | timezone 'UTC' 31 | ``` 32 | version_added: 5.6.0 33 | enabled: true 34 | excluded_file_paths: 35 | - "**/metadata.rb" 36 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_foodcriticcomments.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: FoodcriticComments 3 | full_name: Chef/Modernize/FoodcriticComments 4 | department: Chef/Modernize 5 | description: Remove legacy code comments that disable Foodcritic rules. These comments 6 | are no longer necessary if you've migrated from Foodcritic to Cookstyle for cookbook 7 | linting. 8 | autocorrection: true 9 | target_chef_version: All Versions 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | # ~FC013 16 | ``` 17 | version_added: 5.16.0 18 | enabled: true 19 | excluded_file_paths: 20 | - "**/Berksfile" 21 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_ifprovidesdefaultaction.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: IfProvidesDefaultAction 3 | full_name: Chef/Modernize/IfProvidesDefaultAction 4 | department: Chef/Modernize 5 | description: if defined?(default_action) is no longer necessary in Chef Resources 6 | as default_action shipped in Chef 10.8. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | default_action :foo if defined?(default_action) 15 | ``` 16 | 17 | ### correct 18 | 19 | ```ruby 20 | default_action :foo 21 | ``` 22 | version_added: 5.12.0 23 | enabled: true 24 | included_file_paths: 25 | - "**/resources/*.rb" 26 | - "**/libraries/*.rb" 27 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_includingaptdefaultrecipe.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: IncludingAptDefaultRecipe 3 | full_name: Chef/Modernize/IncludingAptDefaultRecipe 4 | department: Chef/Modernize 5 | description: For many users the apt::default cookbook is used only to update apt's 6 | package cache. Chef Infra Client 12.7 and later include an apt_update resource which 7 | should be used to perform this instead. Keep in mind that some users will want to 8 | stick with the apt::default recipe as it also installs packages necessary for using 9 | https repositories on Debian systems and manages some configuration files. 10 | autocorrection: false 11 | target_chef_version: 12.7+ 12 | examples: |2- 13 | 14 | ### incorrect 15 | 16 | ```ruby 17 | include_recipe 'apt::default' 18 | include_recipe 'apt' 19 | ``` 20 | 21 | ### correct 22 | 23 | ```ruby 24 | apt_update 25 | ``` 26 | version_added: 5.3.0 27 | enabled: true 28 | excluded_file_paths: 29 | - "**/metadata.rb" 30 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_includingmixinshelloutinresources.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: IncludingMixinShelloutInResources 3 | full_name: Chef/Modernize/IncludingMixinShelloutInResources 4 | department: Chef/Modernize 5 | description: There is no need to include Chef::Mixin::ShellOut or Chef::Mixin::PowershellOut 6 | in resources or providers as this is already done by Chef Infra Client 12.4+. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | require 'chef/mixin/shell_out' 15 | include Chef::Mixin::ShellOut 16 | require 'chef/mixin/powershell_out' 17 | include Chef::Mixin::PowershellOut 18 | ``` 19 | version_added: 5.4.0 20 | enabled: true 21 | included_file_paths: 22 | - "**/resources/*.rb" 23 | - "**/providers/*.rb" 24 | - "**/libraries/*.rb" 25 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_includingohaidefaultrecipe.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: IncludingOhaiDefaultRecipe 3 | full_name: Chef/Modernize/IncludingOhaiDefaultRecipe 4 | department: Chef/Modernize 5 | description: The Ohai default recipe previously allowed a user to ship custom Ohai 6 | plugins to a system by including them in a directory in the Ohai cookbook. This 7 | functionality was replaced with the ohai_plugin resource, which should be used instead 8 | as it doesn't require forking the ohai cookbook. 9 | autocorrection: false 10 | target_chef_version: All Versions 11 | examples: |2- 12 | 13 | ### incorrect 14 | 15 | ```ruby 16 | include_recipe 'ohai::default' 17 | include_recipe 'ohai' 18 | ``` 19 | version_added: 5.4.0 20 | enabled: true 21 | excluded_file_paths: 22 | - "**/metadata.rb" 23 | - "**/Berksfile" 24 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_includingwindowsdefaultrecipe.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: IncludingWindowsDefaultRecipe 3 | full_name: Chef/Modernize/IncludingWindowsDefaultRecipe 4 | department: Chef/Modernize 5 | description: Don't include the windows default recipe that is either full of gem install 6 | that are part of the Chef Infra Client, or empty (depends on version). 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | include_recipe 'windows::default' 15 | include_recipe 'windows' 16 | ``` 17 | version_added: 5.3.0 18 | enabled: true 19 | excluded_file_paths: 20 | - "**/metadata.rb" 21 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_legacyberksfilesource.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: LegacyBerksfileSource 3 | full_name: Chef/Modernize/LegacyBerksfileSource 4 | department: Chef/Modernize 5 | description: There have been many different valid community site / Supermarket URLs 6 | to use in a cookbook's Berksfile. These old URLs continue to function via redirects, 7 | but should be updated to point to the latest Supermarket URL. 8 | autocorrection: true 9 | target_chef_version: All Versions 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | source 'http://community.opscode.com/api/v3' 16 | source 'https://supermarket.getchef.com' 17 | source 'https://api.berkshelf.com' 18 | site :opscode 19 | ``` 20 | 21 | ### correct 22 | 23 | ```ruby 24 | source 'https://supermarket.chef.io' 25 | ``` 26 | version_added: 5.1.0 27 | enabled: true 28 | included_file_paths: 29 | - "**/Berksfile" 30 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_libarchivefileresource.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: LibarchiveFileResource 3 | full_name: Chef/Modernize/LibarchiveFileResource 4 | department: Chef/Modernize 5 | description: Use the archive_file resource built into Chef Infra Client 15+ instead 6 | of the libarchive_file resource from the libarchive cookbook. 7 | autocorrection: true 8 | target_chef_version: 15.0+ 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | depends 'libarchive' 15 | 16 | libarchive_file "C:\file.zip" do 17 | path 'C:\expand_here' 18 | end 19 | ``` 20 | 21 | ### correct 22 | 23 | ```ruby 24 | archive_file "C:\file.zip" do 25 | path 'C:\expand_here' 26 | end 27 | ``` 28 | version_added: 5.5.0 29 | enabled: true 30 | excluded_file_paths: 31 | - "**/metadata.rb" 32 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_macosxuserdefaults.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: MacOsXUserdefaults 3 | full_name: Chef/Modernize/MacOsXUserdefaults 4 | department: Chef/Modernize 5 | description: The mac_os_x_userdefaults resource was renamed to macos_userdefaults 6 | when it was added to Chef Infra Client 14.0. The new resource name should be used. 7 | autocorrection: true 8 | target_chef_version: 14.0+ 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | mac_os_x_userdefaults 'full keyboard access to all controls' do 15 | domain 'AppleKeyboardUIMode' 16 | global true 17 | value '2' 18 | end 19 | ``` 20 | 21 | ### correct 22 | 23 | ```ruby 24 | macos_userdefaults 'full keyboard access to all controls' do 25 | domain 'AppleKeyboardUIMode' 26 | global true 27 | value '2' 28 | end 29 | ``` 30 | version_added: 5.6.0 31 | enabled: true 32 | excluded_file_paths: 33 | - "**/metadata.rb" 34 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_minitesthandlerusage.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: MinitestHandlerUsage 3 | full_name: Chef/Modernize/MinitestHandlerUsage 4 | department: Chef/Modernize 5 | description: Use Chef InSpec for testing instead of the Minitest Handler cookbook 6 | pattern. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | depends 'minitest-handler' 15 | ``` 16 | version_added: 5.4.0 17 | enabled: true 18 | included_file_paths: 19 | - "**/metadata.rb" 20 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_noderolesinclude.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: NodeRolesInclude 3 | full_name: Chef/Modernize/NodeRolesInclude 4 | department: Chef/Modernize 5 | description: Use `node.role?('foo')` to check if a node includes a role instead of 6 | `node['roles'].include?('foo')`. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | node['roles'].include?('foo') 15 | ``` 16 | 17 | ### correct 18 | 19 | ```ruby 20 | node.role?('foo') 21 | ``` 22 | version_added: 6.1.0 23 | enabled: true 24 | excluded_file_paths: 25 | - "**/metadata.rb" 26 | - "**/Berksfile" 27 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_opensslrsakeyresource.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: OpensslRsaKeyResource 3 | full_name: Chef/Modernize/OpensslRsaKeyResource 4 | department: Chef/Modernize 5 | description: The openssl_rsa_key resource was renamed to openssl_rsa_private_key in 6 | Chef Infra Client 14.0. The new resource name should be used. 7 | autocorrection: true 8 | target_chef_version: 14.0+ 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | openssl_rsa_key '/etc/httpd/ssl/server.key' do 15 | key_length 2048 16 | end 17 | ``` 18 | 19 | ### correct 20 | 21 | ```ruby 22 | openssl_rsa_private_key '/etc/httpd/ssl/server.key' do 23 | key_length 2048 24 | end 25 | ``` 26 | version_added: 5.6.0 27 | enabled: true 28 | excluded_file_paths: 29 | - "**/metadata.rb" 30 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_opensslx509resource.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: OpensslX509Resource 3 | full_name: Chef/Modernize/OpensslX509Resource 4 | department: Chef/Modernize 5 | description: The openssl_x509 resource was renamed to openssl_x509_certificate in 6 | Chef Infra Client 14.4. The new resource name should be used. 7 | autocorrection: true 8 | target_chef_version: 14.4+ 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | openssl_x509 '/etc/httpd/ssl/mycert.pem' do 15 | common_name 'www.f00bar.com' 16 | org 'Foo Bar' 17 | org_unit 'Lab' 18 | country 'US' 19 | end 20 | ``` 21 | 22 | ### correct 23 | 24 | ```ruby 25 | openssl_x509_certificate '/etc/httpd/ssl/mycert.pem' do 26 | common_name 'www.f00bar.com' 27 | org 'Foo Bar' 28 | org_unit 'Lab' 29 | country 'US' 30 | end 31 | ``` 32 | version_added: 5.6.0 33 | enabled: true 34 | excluded_file_paths: 35 | - "**/metadata.rb" 36 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_osxconfigprofileresource.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: OsxConfigProfileResource 3 | full_name: Chef/Modernize/OsxConfigProfileResource 4 | department: Chef/Modernize 5 | description: The osx_config_profile resource was renamed to osx_profile. The new resource 6 | name should be used. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | osx_config_profile 'Install screensaver profile' do 15 | profile 'screensaver/com.company.screensaver.mobileconfig' 16 | end 17 | ``` 18 | 19 | ### correct 20 | 21 | ```ruby 22 | osx_profile 'Install screensaver profile' do 23 | profile 'screensaver/com.company.screensaver.mobileconfig' 24 | end 25 | ``` 26 | version_added: 5.6.0 27 | enabled: true 28 | excluded_file_paths: 29 | - "**/metadata.rb" 30 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_powershellinstallpackage.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: PowershellInstallPackage 3 | full_name: Chef/Modernize/PowershellInstallPackage 4 | department: Chef/Modernize 5 | description: |- 6 | Use the powershell_package resource built into Chef Infra Client instead of the powershell_script resource to run Install-Package 7 | 8 | ### correct 9 | powershell_package 'docker' 10 | autocorrection: false 11 | target_chef_version: 12.16+ 12 | examples: |2- 13 | 14 | ### incorrect 15 | 16 | ```ruby 17 | powershell_script 'Expand website' do 18 | code 'Install-Package -Name docker' 19 | end 20 | ``` 21 | version_added: 5.5.0 22 | enabled: true 23 | excluded_file_paths: 24 | - "**/metadata.rb" 25 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_powershellinstallwindowsfeature.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: PowershellInstallWindowsFeature 3 | full_name: Chef/Modernize/PowershellInstallWindowsFeature 4 | department: Chef/Modernize 5 | description: |- 6 | Use the windows_feature resource built into Chef Infra Client 14+ instead of the powershell_script resource to run Install-WindowsFeature or Add-WindowsFeature 7 | 8 | ### correct 9 | windows_feature 'Net-framework-Core' do 10 | action :install 11 | install_method :windows_feature_powershell 12 | end 13 | autocorrection: false 14 | target_chef_version: 14.0+ 15 | examples: |2- 16 | 17 | ### incorrect 18 | 19 | ```ruby 20 | powershell_script 'Install Feature' do 21 | code 'Install-WindowsFeature -Name "Net-framework-Core"' 22 | end 23 | ``` 24 | version_added: 5.5.0 25 | enabled: true 26 | excluded_file_paths: 27 | - "**/metadata.rb" 28 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_powershellscriptexpandarchive.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: PowershellScriptExpandArchive 3 | full_name: Chef/Modernize/PowershellScriptExpandArchive 4 | department: Chef/Modernize 5 | description: Use the archive_file resource built into Chef Infra Client 15+ instead 6 | of using the powershell_script resource to run Expand-Archive 7 | autocorrection: false 8 | target_chef_version: 15.0+ 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | powershell_script 'Expand website' do 15 | code 'Expand-Archive "C:\\file.zip" -DestinationPath "C:\\inetpub\\wwwroot\\" -Force' 16 | end 17 | ``` 18 | version_added: 5.5.0 19 | enabled: true 20 | excluded_file_paths: 21 | - "**/metadata.rb" 22 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_propertywithnameattribute.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: PropertyWithNameAttribute 3 | full_name: Chef/Modernize/PropertyWithNameAttribute 4 | department: Chef/Modernize 5 | description: When using properties in a custom resource you should use name_property 6 | not the legacy name_attribute from the days of attributes 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | property :bob, String, name_attribute: true 15 | ``` 16 | 17 | ### correct 18 | 19 | ```ruby 20 | property :bob, String, name_property: true 21 | ``` 22 | version_added: 5.1.0 23 | enabled: true 24 | included_file_paths: 25 | - "**/resources/*.rb" 26 | - "**/libraries/*.rb" 27 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_providesfrominitialize.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ProvidesFromInitialize 3 | full_name: Chef/Modernize/ProvidesFromInitialize 4 | department: Chef/Modernize 5 | description: Provides should be set using the `provides` resource DSL method instead 6 | of instead of setting @provides in the initialize method. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | def initialize(*args) 15 | super 16 | @provides = :foo 17 | end 18 | ``` 19 | 20 | ### correct 21 | 22 | ```ruby 23 | provides :foo 24 | ``` 25 | version_added: 6.0.0 26 | enabled: true 27 | included_file_paths: 28 | - "**/resources/*.rb" 29 | - "**/providers/*.rb" 30 | - "**/libraries/*.rb" 31 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_resourceforcingcompiletime.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ResourceForcingCompileTime 3 | full_name: Chef/Modernize/ResourceForcingCompileTime 4 | department: Chef/Modernize 5 | description: The hostname, build_essential, chef_gem, and ohai_hint resources include 6 | 'compile_time' properties, which should be used to force the resources to run at 7 | compile time by setting `compile_time true`. 8 | autocorrection: false 9 | target_chef_version: All Versions 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | build_essential 'install build tools' do 16 | action :nothing 17 | end.run_action(:install) 18 | ``` 19 | 20 | ### correct 21 | 22 | ```ruby 23 | build_essential 'install build tools' do 24 | compile_time true 25 | end 26 | ``` 27 | version_added: 5.18.0 28 | enabled: true 29 | excluded_file_paths: 30 | - "**/metadata.rb" 31 | - "**/attributes/*.rb" 32 | - "**/Berksfile" 33 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_resourcenamefrominitialize.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ResourceNameFromInitialize 3 | full_name: Chef/Modernize/ResourceNameFromInitialize 4 | department: Chef/Modernize 5 | description: |- 6 | The resource name can now be specified using the `resource_name` helper instead of using the @resource_name variable in the resource provider initialize method. In general we recommend against writing HWRPs, but if HWRPs are necessary you should utilize as much of the resource DSL as possible. 7 | 8 | ### correct 9 | resource_name :create 10 | autocorrection: true 11 | target_chef_version: All Versions 12 | examples: |2- 13 | 14 | ### incorrect 15 | 16 | ```ruby 17 | def initialize(*args) 18 | super 19 | @resource_name = :foo 20 | end 21 | ``` 22 | version_added: 5.10.0 23 | enabled: true 24 | included_file_paths: 25 | - "**/resources/*.rb" 26 | - "**/providers/*.rb" 27 | - "**/libraries/*.rb" 28 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_respondtoinmetadata.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: RespondToInMetadata 3 | full_name: Chef/Modernize/RespondToInMetadata 4 | department: Chef/Modernize 5 | description: It is not longer necessary respond_to?(:foo) or defined?(foo) in metadata. 6 | This was used to support new metadata methods in Chef 11 and early versions of Chef 7 | 12. 8 | autocorrection: true 9 | target_chef_version: 12.15+ 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | chef_version '>= 13' if respond_to?(:chef_version) 16 | chef_version '>= 13' if defined?(chef_version) 17 | chef_version '>= 13' unless defined?(Ridley::Chef::Cookbook::Metadata) 18 | if defined(chef_version) 19 | chef_version '>= 13' 20 | end 21 | ``` 22 | 23 | ### correct 24 | 25 | ```ruby 26 | chef_version '>= 13' 27 | ``` 28 | version_added: 5.2.0 29 | enabled: true 30 | included_file_paths: 31 | - "**/metadata.rb" 32 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_respondtoprovides.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: RespondToProvides 3 | full_name: Chef/Modernize/RespondToProvides 4 | department: Chef/Modernize 5 | description: In Chef Infra Client 12+ is is no longer necessary to gate the use of 6 | the provides methods in resources with `if respond_to?(:provides)` or `if defined? 7 | provides`. 8 | autocorrection: true 9 | target_chef_version: All Versions 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | provides :foo if respond_to?(:provides) 16 | 17 | provides :foo if defined? provides 18 | ``` 19 | 20 | ### correct 21 | 22 | ```ruby 23 | provides :foo 24 | ``` 25 | version_added: 5.2.0 26 | enabled: true 27 | included_file_paths: 28 | - "**/providers/*.rb" 29 | - "**/resources/*.rb" 30 | - "**/libraries/*.rb" 31 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_respondtoresourcename.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: RespondToResourceName 3 | full_name: Chef/Modernize/RespondToResourceName 4 | department: Chef/Modernize 5 | description: Chef Infra Client 12.5 introduced the resource_name method for resources. 6 | Many cookbooks used respond_to?(:resource_name) to provide backwards compatibility 7 | with older chef-client releases. This backwards compatibility is no longer necessary. 8 | autocorrection: true 9 | target_chef_version: All Versions 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | resource_name :foo if respond_to?(:resource_name) 16 | ``` 17 | 18 | ### correct 19 | 20 | ```ruby 21 | resource_name :foo 22 | ``` 23 | version_added: 5.2.0 24 | enabled: true 25 | included_file_paths: 26 | - "**/resources/*.rb" 27 | - "**/libraries/*.rb" 28 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_setorreturninresources.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: SetOrReturnInResources 3 | full_name: Chef/Modernize/SetOrReturnInResources 4 | department: Chef/Modernize 5 | description: set_or_return within a method should not be used to define property in 6 | a resource. Instead use the property method which properly validates and defines 7 | properties in a way that works with reporting and documentation functionality in 8 | Chef Infra Client 9 | autocorrection: false 10 | target_chef_version: All Versions 11 | examples: |2- 12 | 13 | ### incorrect 14 | 15 | ```ruby 16 | def severity(arg = nil) 17 | set_or_return( 18 | :severity, arg, 19 | :kind_of => String, 20 | :default => nil 21 | ) 22 | end 23 | ``` 24 | 25 | ### correct 26 | 27 | ```ruby 28 | property :severity, String 29 | ``` 30 | version_added: 5.2.0 31 | enabled: true 32 | included_file_paths: 33 | - "**/resources/*.rb" 34 | - "**/libraries/*.rb" 35 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_sevenziparchiveresource.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: SevenZipArchiveResource 3 | full_name: Chef/Modernize/SevenZipArchiveResource 4 | department: Chef/Modernize 5 | description: Use the archive_file resource built into Chef Infra Client 15+ instead 6 | of the seven_zip_archive 7 | autocorrection: false 8 | target_chef_version: 15.0+ 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | seven_zip_archive "C:\file.zip" do 15 | path 'C:\expand_here' 16 | end 17 | ``` 18 | version_added: 5.5.0 19 | enabled: true 20 | excluded_file_paths: 21 | - "**/metadata.rb" 22 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_shellouthelper.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ShellOutHelper 3 | full_name: Chef/Modernize/ShellOutHelper 4 | department: Chef/Modernize 5 | description: Use the built-in `shell_out` helper available in Chef Infra Client 12.11+ 6 | instead of calling `Mixlib::ShellOut.new('foo').run_command`. 7 | autocorrection: true 8 | target_chef_version: 12.11+ 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | Mixlib::ShellOut.new('foo').run_command 15 | ``` 16 | 17 | ### correct 18 | 19 | ```ruby 20 | shell_out('foo') 21 | ``` 22 | version_added: 6.5.0 23 | enabled: true 24 | excluded_file_paths: 25 | - "**/metadata.rb" 26 | - "**/Berksfile" 27 | - "**/libraries/*.rb" 28 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_shellouttochocolatey.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ShellOutToChocolatey 3 | full_name: Chef/Modernize/ShellOutToChocolatey 4 | department: Chef/Modernize 5 | description: |- 6 | Use the Chocolatey resources built into Chef Infra Client instead of shelling out to the choco command 7 | 8 | powershell_script 'add artifactory choco source' do 9 | code "choco source add -n=artifactory -s='https://mycorp.jfrog.io/mycorp/api/nuget/chocolatey-remote' -u foo -p bar"x 10 | not_if 'choco source list | findstr artifactory' 11 | end 12 | autocorrection: false 13 | target_chef_version: All Versions 14 | examples: |2- 15 | 16 | ### incorrect 17 | 18 | ```ruby 19 | execute 'install package foo' do 20 | command "choco install --source=artifactory \"foo\" -y --no-progress --ignore-package-exit-codes" 21 | end 22 | ``` 23 | version_added: 5.5.0 24 | enabled: true 25 | excluded_file_paths: 26 | - "**/metadata.rb" 27 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_sysctlparamresource.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: SysctlParamResource 3 | full_name: Chef/Modernize/SysctlParamResource 4 | department: Chef/Modernize 5 | description: The sysctl_param resource was renamed to sysctl when it was added to 6 | Chef Infra Client 14.0. The new resource name should be used. 7 | autocorrection: true 8 | target_chef_version: 14.0+ 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | sysctl_param 'fs.aio-max-nr' do 15 | value '1048576' 16 | end 17 | ``` 18 | 19 | ### correct 20 | 21 | ```ruby 22 | sysctl 'fs.aio-max-nr' do 23 | value '1048576' 24 | end 25 | ``` 26 | version_added: 5.6.0 27 | enabled: true 28 | excluded_file_paths: 29 | - "**/metadata.rb" 30 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_unnecessarydependschef14.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: UnnecessaryDependsChef14 3 | full_name: Chef/Modernize/UnnecessaryDependsChef14 4 | department: Chef/Modernize 5 | description: Don't depend on cookbooks made obsolete by Chef Infra Client 14.0+ These 6 | community cookbooks contain resources that are now included in Chef Infra Client 7 | itself. 8 | autocorrection: true 9 | target_chef_version: 14.0+ 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | depends 'build-essential' 16 | depends 'chef_handler' 17 | depends 'chef_hostname' 18 | depends 'dmg' 19 | depends 'mac_os_x' 20 | depends 'swap' 21 | depends 'sysctl' 22 | ``` 23 | version_added: 5.1.0 24 | enabled: true 25 | included_file_paths: 26 | - "**/metadata.rb" 27 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_unnecessarydependschef15.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: UnnecessaryDependsChef15 3 | full_name: Chef/Modernize/UnnecessaryDependsChef15 4 | department: Chef/Modernize 5 | description: Don't depend on cookbooks made obsolete by Chef Infra Client 15.0+. These 6 | community cookbooks contain resources that are now included in Chef Infra Client 7 | itself. 8 | autocorrection: true 9 | target_chef_version: 15.0+ 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | depends 'libarchive' 16 | depends 'windows_dns' 17 | depends 'windows_uac' 18 | depends 'windows_dfs' 19 | ``` 20 | version_added: 7.19.0 21 | enabled: true 22 | included_file_paths: 23 | - "**/metadata.rb" 24 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_unnecessarymixlibshelloutrequire.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: UnnecessaryMixlibShelloutRequire 3 | full_name: Chef/Modernize/UnnecessaryMixlibShelloutRequire 4 | department: Chef/Modernize 5 | description: Chef Infra Client 12.4+ includes mixlib/shellout automatically in resources 6 | and providers. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | require 'mixlib/shellout' 15 | ``` 16 | version_added: 5.12.0 17 | enabled: true 18 | included_file_paths: 19 | - "**/resources/*.rb" 20 | - "**/providers/*.rb" 21 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_usebuildessentialresource.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: UseBuildEssentialResource 3 | full_name: Chef/Modernize/UseBuildEssentialResource 4 | department: Chef/Modernize 5 | description: Use the build_essential resource from the build-essential cookbook 5.0+ 6 | or Chef Infra Client 14+ instead of using the build-essential::default recipe. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | depends 'build-essential' 15 | include_recipe 'build-essential::default' 16 | include_recipe 'build-essential' 17 | ``` 18 | 19 | ### correct 20 | 21 | ```ruby 22 | build_essential 'install compilation tools' 23 | ``` 24 | version_added: 5.1.0 25 | enabled: true 26 | excluded_file_paths: 27 | - "**/metadata.rb" 28 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_usecheflanguageenvhelpers.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: UseChefLanguageEnvHelpers 3 | full_name: Chef/Modernize/UseChefLanguageEnvHelpers 4 | department: Chef/Modernize 5 | description: Chef Infra Client 15.5 and later include a large number of new helpers 6 | in the Chef Infra Language to simplify checking the system configuration in recipes 7 | and resources. These should be used when possible over more complex attributes or 8 | ENV var comparisons. 9 | autocorrection: true 10 | target_chef_version: 15.5+ 11 | examples: |2- 12 | 13 | ### incorrect 14 | 15 | ```ruby 16 | ENV['CI'] 17 | ENV['TEST_KITCHEN'] 18 | ``` 19 | 20 | ### correct 21 | 22 | ```ruby 23 | ci? 24 | kitchen? 25 | ``` 26 | version_added: 7.21.0 27 | enabled: true 28 | included_file_paths: 29 | - "**/resources/*.rb" 30 | - "**/providers/*.rb" 31 | - "**/recipes/*.rb" 32 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_usecheflanguagesystemdhelper.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: UseChefLanguageSystemdHelper 3 | full_name: Chef/Modernize/UseChefLanguageSystemdHelper 4 | department: Chef/Modernize 5 | description: Chef Infra Client 15.5 and later include a `systemd?` helper for checking 6 | if a Linux system uses systemd. 7 | autocorrection: true 8 | target_chef_version: 15.5+ 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | node['init_package'] == 'systemd' 15 | ``` 16 | 17 | ### correct 18 | 19 | ```ruby 20 | systemd? 21 | ``` 22 | version_added: 7.24.0 23 | enabled: true 24 | excluded_file_paths: 25 | - "**/metadata.rb" 26 | - "**/Berksfile" 27 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_usemultipackageinstalls.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: UseMultipackageInstalls 3 | full_name: Chef/Modernize/UseMultipackageInstalls 4 | department: Chef/Modernize 5 | description: Pass an array of packages to package resources instead of iterating over 6 | an array of packages when using multi-package capable package subsystem such as 7 | apt, yum, chocolatey, dnf, or zypper. Multi-package installs are faster and simplify 8 | logs. 9 | autocorrection: true 10 | target_chef_version: All Versions 11 | examples: |2- 12 | 13 | ### incorrect 14 | 15 | ```ruby 16 | %w(bmon htop vim curl).each do |pkg| 17 | package pkg do 18 | action :install 19 | end 20 | end 21 | ``` 22 | 23 | ### correct 24 | 25 | ```ruby 26 | package %w(bmon htop vim curl) 27 | ``` 28 | version_added: 6.0.0 29 | enabled: true 30 | excluded_file_paths: 31 | - "**/metadata.rb" 32 | - "**/attributes/*.rb" 33 | - "**/Berksfile" 34 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_userequirerelative.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: UseRequireRelative 3 | full_name: Chef/Modernize/UseRequireRelative 4 | department: Chef/Modernize 5 | description: Instead of using require with a File.expand_path and __FILE__ use the 6 | simpler require_relative method. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | require File.expand_path('../../libraries/helpers', __FILE__) 15 | ``` 16 | 17 | ### correct 18 | 19 | ```ruby 20 | require_relative '../libraries/helpers' 21 | ``` 22 | version_added: 5.22.0 23 | enabled: true 24 | excluded_file_paths: 25 | - "**/metadata.rb" 26 | - "**/attributes/*.rb" 27 | - "**/Berksfile" 28 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_useszypperrepo.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: UsesZypperRepo 3 | full_name: Chef/Modernize/UsesZypperRepo 4 | department: Chef/Modernize 5 | description: The zypper_repo resource was renamed zypper_repository when it was added 6 | to Chef Infra Client 13.3. 7 | autocorrection: true 8 | target_chef_version: 13.3+ 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | zypper_repo 'apache' do 15 | baseurl 'http://download.opensuse.org/repositories/Apache' 16 | path '/openSUSE_Leap_42.2' 17 | type 'rpm-md' 18 | priority '100' 19 | end 20 | ``` 21 | 22 | ### correct 23 | 24 | ```ruby 25 | zypper_repository 'apache' do 26 | baseurl 'http://download.opensuse.org/repositories/Apache' 27 | path '/openSUSE_Leap_42.2' 28 | type 'rpm-md' 29 | priority '100' 30 | end 31 | ``` 32 | version_added: 5.6.0 33 | enabled: true 34 | excluded_file_paths: 35 | - "**/metadata.rb" 36 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_whyrunsupportedtrue.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: WhyRunSupportedTrue 3 | full_name: Chef/Modernize/WhyRunSupportedTrue 4 | department: Chef/Modernize 5 | description: whyrun_supported? no longer needs to be set to true as that is the default 6 | in Chef Infra Client 13+ 7 | autocorrection: true 8 | target_chef_version: 13.0+ 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | def whyrun_supported? 15 | true 16 | end 17 | ``` 18 | version_added: 5.1.0 19 | enabled: true 20 | included_file_paths: 21 | - "**/resources/*.rb" 22 | - "**/providers/*.rb" 23 | - "**/libraries/*.rb" 24 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_windowszipfileusage.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: WindowsZipfileUsage 3 | full_name: Chef/Modernize/WindowsZipfileUsage 4 | department: Chef/Modernize 5 | description: Use the archive_file resource built into Chef Infra Client 15+ instead 6 | of the windows_zipfile from the Windows cookbook 7 | autocorrection: false 8 | target_chef_version: 15.0+ 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | windows_zipfile 'C:\\files\\' do 15 | source 'C:\\Temp\\file.zip' 16 | end 17 | ``` 18 | version_added: 5.4.0 19 | enabled: true 20 | excluded_file_paths: 21 | - "**/metadata.rb" 22 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_modernize_zipfileresource.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ZipfileResource 3 | full_name: Chef/Modernize/ZipfileResource 4 | department: Chef/Modernize 5 | description: Use the archive_file resource built into Chef Infra Client 15+ instead 6 | of the zipfile resource from the zipfile cookbook. 7 | autocorrection: false 8 | target_chef_version: 15.0+ 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | zipfile "C:\file.zip" do 15 | path 'C:\expand_here' 16 | end 17 | ``` 18 | version_added: 5.12.0 19 | enabled: true 20 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_redundantcode_aptrepositorydistributiondefault.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: AptRepositoryDistributionDefault 3 | full_name: Chef/RedundantCode/AptRepositoryDistributionDefault 4 | department: Chef/RedundantCode 5 | description: There is no need to pass `distribution node['lsb']['codename']` to an 6 | apt_repository resource as this is done automatically by the apt_repository resource. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | apt_repository 'my repo' do 15 | uri 'http://packages.example.com/debian' 16 | components %w(stable main) 17 | deb_src false 18 | distribution node['lsb']['codename'] 19 | end 20 | ``` 21 | 22 | ### correct 23 | 24 | ```ruby 25 | apt_repository 'my repo' do 26 | uri 'http://packages.example.com/debian' 27 | components %w(stable main) 28 | deb_src false 29 | end 30 | ``` 31 | version_added: 5.17.0 32 | enabled: true 33 | excluded_file_paths: 34 | - "**/metadata.rb" 35 | - "**/attributes/*.rb" 36 | - "**/Berksfile" 37 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_redundantcode_aptrepositorynotifiesaptupdate.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: AptRepositoryNotifiesAptUpdate 3 | full_name: Chef/RedundantCode/AptRepositoryNotifiesAptUpdate 4 | department: Chef/RedundantCode 5 | description: There is no need to notify an apt-get update when an apt_repository is 6 | created as this is done automatically by the apt_repository resource. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | apt_repository 'my repo' do 15 | uri 'http://packages.example.com/debian' 16 | components %w(stable main) 17 | deb_src false 18 | notifies :run, 'execute[apt-get update]', :immediately 19 | end 20 | ``` 21 | 22 | ### correct 23 | 24 | ```ruby 25 | apt_repository 'my repo' do 26 | uri 'http://packages.example.com/debian' 27 | components %w(stable main) 28 | deb_src false 29 | end 30 | ``` 31 | version_added: 5.17.0 32 | enabled: true 33 | excluded_file_paths: 34 | - "**/metadata.rb" 35 | - "**/attributes/*.rb" 36 | - "**/Berksfile" 37 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_redundantcode_attributemetadata.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: AttributeMetadata 3 | full_name: Chef/RedundantCode/AttributeMetadata 4 | department: Chef/RedundantCode 5 | description: The attribute metadata.rb method is not used and is unnecessary in cookbooks. 6 | autocorrection: true 7 | target_chef_version: All Versions 8 | examples: |2- 9 | 10 | ### incorrect 11 | 12 | ```ruby in metadata.rb: 13 | 14 | attribute 'zookeeper_bridge/server', 15 | display_name: 'zookeeper server', 16 | description: 'Zookeeper server address.', 17 | type: 'string', 18 | required: 'optional', 19 | default: '"127.0.0.1:2181"' 20 | ``` 21 | version_added: 5.1.0 22 | enabled: true 23 | included_file_paths: 24 | - "**/metadata.rb" 25 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_redundantcode_conflictsmetadata.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ConflictsMetadata 3 | full_name: Chef/RedundantCode/ConflictsMetadata 4 | department: Chef/RedundantCode 5 | description: The conflicts metadata.rb method is not used and is unnecessary in cookbooks. 6 | autocorrection: true 7 | target_chef_version: All Versions 8 | examples: |2- 9 | 10 | ### incorrect 11 | 12 | ```ruby in metadata.rb: 13 | 14 | conflicts "another_cookbook" 15 | ``` 16 | version_added: 5.1.0 17 | enabled: true 18 | included_file_paths: 19 | - "**/metadata.rb" 20 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_redundantcode_customresourcewithallowedactions.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: CustomResourceWithAllowedActions 3 | full_name: Chef/RedundantCode/CustomResourceWithAllowedActions 4 | department: Chef/RedundantCode 5 | description: It is not necessary to set `actions` or `allowed_actions` in custom resources 6 | as Chef Infra Client determines these automatically from the set of all actions 7 | defined in the resource. 8 | autocorrection: true 9 | target_chef_version: All Versions 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | allowed_actions [:create, :remove] 16 | 17 | # also bad 18 | actions [:create, :remove] 19 | ``` 20 | version_added: 5.2.0 21 | enabled: true 22 | included_file_paths: 23 | - "**/resources/*.rb" 24 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_redundantcode_doublecompiletime.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: DoubleCompileTime 3 | full_name: Chef/RedundantCode/DoubleCompileTime 4 | department: Chef/RedundantCode 5 | description: If a resource includes the `compile_time` property there's no need to 6 | also use `.run_action(:some_action)` on the resource block 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | chef_gem 'deep_merge' do 15 | action :nothing 16 | compile_time true 17 | end.run_action(:install) 18 | ``` 19 | 20 | ### correct 21 | 22 | ```ruby 23 | chef_gem 'deep_merge' do 24 | action :install 25 | compile_time true 26 | end 27 | ``` 28 | version_added: 6.13.0 29 | enabled: true 30 | excluded_file_paths: 31 | - "**/metadata.rb" 32 | - "**/attributes/*.rb" 33 | - "**/Berksfile" 34 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_redundantcode_groupingmetadata.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: GroupingMetadata 3 | full_name: Chef/RedundantCode/GroupingMetadata 4 | department: Chef/RedundantCode 5 | description: The grouping metadata.rb method is not used and is unnecessary in cookbooks. 6 | autocorrection: true 7 | target_chef_version: All Versions 8 | examples: |2- 9 | 10 | ### incorrect 11 | 12 | ```ruby 13 | grouping 'windows_log_rotate', title: 'Demonstration cookbook with code to switch loggers' 14 | ``` 15 | version_added: 5.19.0 16 | enabled: true 17 | included_file_paths: 18 | - "**/metadata.rb" 19 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_redundantcode_longdescriptionmetadata.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: LongDescriptionMetadata 3 | full_name: Chef/RedundantCode/LongDescriptionMetadata 4 | department: Chef/RedundantCode 5 | description: The long_description metadata.rb method is not used and is unnecessary 6 | in cookbooks. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | long_description 'this is my cookbook and this description will never be seen' 15 | ``` 16 | version_added: 5.2.0 17 | enabled: true 18 | included_file_paths: 19 | - "**/metadata.rb" 20 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_redundantcode_multipleplatformchecks.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: MultiplePlatformChecks 3 | full_name: Chef/RedundantCode/MultiplePlatformChecks 4 | department: Chef/RedundantCode 5 | description: You can pass multiple values to the platform? and platform_family? helpers 6 | instead of calling the helpers multiple times. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | platform?('redhat') || platform?('ubuntu') 15 | platform_family?('debian') || platform_family?('rhel') 16 | ``` 17 | 18 | ### correct 19 | 20 | ```ruby 21 | platform?('redhat', 'ubuntu') 22 | platform_family?('debian', 'rhel') 23 | ``` 24 | version_added: 6.10.0 25 | enabled: true 26 | excluded_file_paths: 27 | - "**/metadata.rb" 28 | - "**/Berksfile" 29 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_redundantcode_ohaiattributetostring.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: OhaiAttributeToString 3 | full_name: Chef/RedundantCode/OhaiAttributeToString 4 | department: Chef/RedundantCode 5 | description: Many Ohai node attributes are already strings and don't need to be cast 6 | to strings again 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | node['platform'].to_s 15 | node['platform_family'].to_s 16 | node['platform_version'].to_s 17 | node['fqdn'].to_s 18 | node['hostname'].to_s 19 | node['os'].to_s 20 | node['name'].to_s 21 | ``` 22 | 23 | ### correct 24 | 25 | ```ruby 26 | node['platform'] 27 | node['platform_family'] 28 | node['platform_version'] 29 | node['fqdn'] 30 | node['hostname'] 31 | node['os'] 32 | node['name'] 33 | ``` 34 | version_added: 6.10.0 35 | enabled: true 36 | excluded_file_paths: 37 | - "**/metadata.rb" 38 | - "**/Berksfile" 39 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_redundantcode_propertysplatregex.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: PropertySplatRegex 3 | full_name: Chef/RedundantCode/PropertySplatRegex 4 | department: Chef/RedundantCode 5 | description: When a property has a type of String it can accept any string. There 6 | is no need to also validate string inputs against a regex that accept all values. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | property :config_file, String, regex: /.*/ 15 | attribute :config_file, String, regex: /.*/ 16 | ``` 17 | 18 | ### correct 19 | 20 | ```ruby 21 | property :config_file, String 22 | attribute :config_file, String 23 | ``` 24 | version_added: 5.21.0 25 | enabled: true 26 | included_file_paths: 27 | - "**/resources/*.rb" 28 | - "**/libraries/*.rb" 29 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_redundantcode_propertywithrequiredanddefault.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: PropertyWithRequiredAndDefault 3 | full_name: Chef/RedundantCode/PropertyWithRequiredAndDefault 4 | department: Chef/RedundantCode 5 | description: |- 6 | When using properties in a custom resource you shouldn't set a property to 7 | required and then provide a default value. If a property is required the 8 | user will always pass in a value and the default will never be used. In Chef 9 | Infra Client 13+ this became an error. 10 | autocorrection: true 11 | target_chef_version: All Versions 12 | examples: |2- 13 | 14 | ### incorrect 15 | 16 | ```ruby 17 | property :bob, String, required: true, default: 'foo' 18 | ``` 19 | 20 | ### correct 21 | 22 | ```ruby 23 | property :bob, String, required: true 24 | ``` 25 | version_added: 5.1.0 26 | enabled: true 27 | included_file_paths: 28 | - "**/resources/*.rb" 29 | - "**/libraries/*.rb" 30 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_redundantcode_providesmetadata.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ProvidesMetadata 3 | full_name: Chef/RedundantCode/ProvidesMetadata 4 | department: Chef/RedundantCode 5 | description: The provides metadata.rb method is not used and is unnecessary in cookbooks. 6 | autocorrection: true 7 | target_chef_version: All Versions 8 | examples: |2- 9 | 10 | ### incorrect 11 | 12 | ```ruby in metadata.rb: 13 | 14 | provides "some_thing" 15 | ``` 16 | version_added: 5.1.0 17 | enabled: true 18 | included_file_paths: 19 | - "**/metadata.rb" 20 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_redundantcode_recipemetadata.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: RecipeMetadata 3 | full_name: Chef/RedundantCode/RecipeMetadata 4 | department: Chef/RedundantCode 5 | description: The recipe metadata.rb method is not used and is unnecessary in cookbooks. 6 | Recipes should be documented in the cookbook's README.md file instead. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | recipe 'openldap::default', 'Install and configure OpenLDAP' 15 | ``` 16 | version_added: 5.6.0 17 | enabled: true 18 | included_file_paths: 19 | - "**/metadata.rb" 20 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_redundantcode_replacesmetadata.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ReplacesMetadata 3 | full_name: Chef/RedundantCode/ReplacesMetadata 4 | department: Chef/RedundantCode 5 | description: The replaces metadata.rb method is not used and is unnecessary in cookbooks. 6 | Replacements for existing cookbooks should be documented in the cookbook's README.md 7 | file instead. 8 | autocorrection: true 9 | target_chef_version: All Versions 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby in metadata.rb: 15 | 16 | replaces "another_cookbook" 17 | ``` 18 | version_added: 5.1.0 19 | enabled: true 20 | included_file_paths: 21 | - "**/metadata.rb" 22 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_redundantcode_resourcewithnothingaction.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ResourceWithNothingAction 3 | full_name: Chef/RedundantCode/ResourceWithNothingAction 4 | department: Chef/RedundantCode 5 | description: Chef Infra Client provides the :nothing action by default for every resource. 6 | There is no need to define a :nothing action in your resource code. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | action :nothing 15 | # let's do nothing 16 | end 17 | ``` 18 | version_added: 5.12.0 19 | enabled: true 20 | included_file_paths: 21 | - "**/libraries/*.rb" 22 | - "**/resources/*.rb" 23 | - "**/providers/*.rb" 24 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_redundantcode_sensitivepropertyinresource.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: SensitivePropertyInResource 3 | full_name: Chef/RedundantCode/SensitivePropertyInResource 4 | department: Chef/RedundantCode 5 | description: |- 6 | Every Chef Infra resource already includes a sensitive property with a default value of false. 7 | 8 | ### incorrect 9 | property :sensitive, [true, false], default: false 10 | autocorrection: true 11 | target_chef_version: All Versions 12 | examples: 13 | version_added: 5.16.0 14 | enabled: true 15 | included_file_paths: 16 | - "**/resources/*.rb" 17 | - "**/libraries/*.rb" 18 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_redundantcode_stringpropertywithnildefault.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: StringPropertyWithNilDefault 3 | full_name: Chef/RedundantCode/StringPropertyWithNilDefault 4 | department: Chef/RedundantCode 5 | description: Properties have a nil value by default so there is no need to set the 6 | default value to nil. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | property :config_file, String, default: nil 15 | property :config_file, [String, NilClass], default: nil 16 | ``` 17 | 18 | ### correct 19 | 20 | ```ruby 21 | property :config_file, String 22 | property :config_file, [String, NilClass] 23 | ``` 24 | version_added: 5.21.0 25 | enabled: true 26 | included_file_paths: 27 | - "**/resources/*.rb" 28 | - "**/libraries/*.rb" 29 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_redundantcode_suggestsmetadata.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: SuggestsMetadata 3 | full_name: Chef/RedundantCode/SuggestsMetadata 4 | department: Chef/RedundantCode 5 | description: The suggests metadata.rb method is not used and is unnecessary in cookbooks. 6 | autocorrection: true 7 | target_chef_version: All Versions 8 | examples: |2- 9 | 10 | ### incorrect 11 | 12 | ```ruby in metadata.rb: 13 | 14 | suggests "another_cookbook" 15 | ``` 16 | version_added: 5.1.0 17 | enabled: true 18 | included_file_paths: 19 | - "**/metadata.rb" 20 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_redundantcode_unnecessarydesiredstate.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: UnnecessaryDesiredState 3 | full_name: Chef/RedundantCode/UnnecessaryDesiredState 4 | department: Chef/RedundantCode 5 | description: 'There is no need to set a property/attribute to desired_state: true 6 | as all properties/attributes have a desired_state of true by default.' 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | property :foo, String, desired_state: true 15 | attribute :foo, String, desired_state: true 16 | ``` 17 | 18 | ### correct 19 | 20 | ```ruby 21 | property :foo, String 22 | attribute :foo, String 23 | ``` 24 | version_added: 5.16.0 25 | enabled: true 26 | included_file_paths: 27 | - "**/resources/*.rb" 28 | - "**/libraries/*.rb" 29 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_redundantcode_unnecessarynameproperty.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: UnnecessaryNameProperty 3 | full_name: Chef/RedundantCode/UnnecessaryNameProperty 4 | department: Chef/RedundantCode 5 | description: There is no need to define a property or attribute named :name in a resource 6 | as Chef Infra defines this on all resources by default. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | property :name, String 15 | property :name, String, name_property: true 16 | attribute :name, kind_of: String 17 | attribute :name, kind_of: String, name_attribute: true 18 | attribute :name, name_attribute: true, kind_of: String 19 | ``` 20 | version_added: 5.8.0 21 | enabled: true 22 | included_file_paths: 23 | - "**/resources/*.rb" 24 | - "**/libraries/*.rb" 25 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_ruby_gemspeclicense.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: GemspecLicense 3 | full_name: Chef/Ruby/GemspecLicense 4 | department: Chef/Ruby 5 | description: All gemspec files should define their license. 6 | autocorrection: false 7 | target_chef_version: All Versions 8 | examples: |2- 9 | 10 | # good 11 | spec.license = "Apache-2.0" 12 | ``` 13 | version_added: 14 | enabled: false 15 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_ruby_gemspecrequirerubygems.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: GemspecRequireRubygems 3 | full_name: Chef/Ruby/GemspecRequireRubygems 4 | department: Chef/Ruby 5 | description: Rubygems does not need to be required in a Gemspec. It's already loaded 6 | out of the box in Ruby now. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: 10 | version_added: 11 | enabled: false 12 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_ruby_legacypowershelloutmethods.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: LegacyPowershellOutMethods 3 | full_name: Chef/Ruby/LegacyPowershellOutMethods 4 | department: Chef/Ruby 5 | description: |- 6 | Use powershell_exec!/powershell_exec instead of powershell_out!/powershell_out. The new 7 | methods don't spawn 2 shells per shellout and instead use .NET bindings to call PS directly. 8 | autocorrection: false 9 | target_chef_version: All Versions 10 | examples: 11 | version_added: 12 | enabled: false 13 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_ruby_requirenethttps.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: RequireNetHttps 3 | full_name: Chef/Ruby/RequireNetHttps 4 | department: Chef/Ruby 5 | description: net/https is deprecated and just includes net/http and openssl. We should 6 | include those directly instead. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | # bad 12 | require 'net/https' 13 | 14 | # good 15 | require 'net/http' 16 | require 'openssl' 17 | ``` 18 | version_added: 19 | enabled: false 20 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_ruby_unlessdefinedrequire.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: UnlessDefinedRequire 3 | full_name: Chef/Ruby/UnlessDefinedRequire 4 | department: Chef/Ruby 5 | description: |- 6 | Rubygems is VERY slow to require gems even if they've already been loaded. To work around this 7 | wrap your require statement with an `if defined?()` check. 8 | autocorrection: true 9 | target_chef_version: All Versions 10 | examples: 11 | version_added: 12 | enabled: false 13 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_security_sshprivatekey.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: SshPrivateKey 3 | full_name: Chef/Security/SshPrivateKey 4 | department: Chef/Security 5 | description: Do not include plain text SSH private keys in your cookbook code. This 6 | sensitive data should be fetched from secrets management systems so that secrets 7 | are not uploaded in plain text to the Chef Infra Server or committed to source control 8 | systems. 9 | autocorrection: false 10 | target_chef_version: All Versions 11 | examples: |2- 12 | 13 | ### incorrect 14 | 15 | ```ruby 16 | file '/Users/bob_bobberson/.ssh/id_rsa' do 17 | content '-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----' 18 | mode '600' 19 | end 20 | ``` 21 | version_added: '7.28' 22 | enabled: true 23 | included_file_paths: 24 | - "**/libraries/*.rb" 25 | - "**/resources/*.rb" 26 | - "**/providers/*.rb" 27 | - "**/recipes/*.rb" 28 | - "**/attributes/*.rb" 29 | - "**/definitions/*.rb" 30 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_sharing_defaultmetadatamaintainer.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: DefaultMetadataMaintainer 3 | full_name: Chef/Sharing/DefaultMetadataMaintainer 4 | department: Chef/Sharing 5 | description: Metadata contains default maintainer information from the `chef generate 6 | cookbook` command. This should be updated to reflect that actual maintainer of the 7 | cookbook. 8 | autocorrection: false 9 | target_chef_version: All Versions 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | maintainer 'YOUR_COMPANY_NAME' 16 | maintainer_email 'YOUR_EMAIL' 17 | maintainer 'The Authors' 18 | maintainer_email 'you@example.com'``` 19 | 20 | ### correct 21 | 22 | ```ruby 23 | maintainer 'Bob Bobberson' 24 | maintainer_email 'bob@bobberson.com' 25 | ``` 26 | version_added: 5.4.0 27 | enabled: true 28 | included_file_paths: 29 | - "**/metadata.rb" 30 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_sharing_emptymetadatafield.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: EmptyMetadataField 3 | full_name: Chef/Sharing/EmptyMetadataField 4 | department: Chef/Sharing 5 | description: metadata.rb should not include fields with an empty string. Either don't 6 | include the field or add a value. 7 | autocorrection: false 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | license '' 15 | ``` 16 | 17 | ### correct 18 | 19 | ```ruby 20 | license 'Apache-2.0' 21 | ``` 22 | version_added: 5.8.0 23 | enabled: true 24 | included_file_paths: 25 | - "**/metadata.rb" 26 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_sharing_includepropertydescriptions.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: IncludePropertyDescriptions 3 | full_name: Chef/Sharing/IncludePropertyDescriptions 4 | department: Chef/Sharing 5 | description: Resource properties should include description fields to allow automated 6 | documentation. Requires Chef Infra Client 13.9 or later. 7 | autocorrection: false 8 | target_chef_version: 13.9+ 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | property :foo, String 15 | ``` 16 | 17 | ### correct 18 | 19 | ```ruby 20 | property :foo, String, description: "Set the important thing to..." 21 | ``` 22 | version_added: 6.1.0 23 | enabled: false 24 | included_file_paths: 25 | - "**/libraries/*.rb" 26 | - "**/resources/*.rb" 27 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_sharing_includeresourcedescriptions.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: IncludeResourceDescriptions 3 | full_name: Chef/Sharing/IncludeResourceDescriptions 4 | department: Chef/Sharing 5 | description: Resources should include description fields to allow automated documentation. 6 | Requires Chef Infra Client 13.9 or later. 7 | autocorrection: false 8 | target_chef_version: 13.9+ 9 | examples: |- 10 | ``` 11 | 12 | ### correct 13 | 14 | ```ruby 15 | resource_name :foo 16 | description "The foo resource is used to do..." 17 | ``` 18 | version_added: 6.1.0 19 | enabled: false 20 | included_file_paths: 21 | - "**/resources/*.rb" 22 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_sharing_includeresourceexamples.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: IncludeResourceExamples 3 | full_name: Chef/Sharing/IncludeResourceExamples 4 | department: Chef/Sharing 5 | description: Resources should include examples field to allow automated documentation. 6 | Requires Chef Infra Client 13.9 or later. 7 | autocorrection: false 8 | target_chef_version: 13.9+ 9 | examples: |- 10 | ``` 11 | 12 | ### correct 13 | 14 | ```ruby 15 | examples <<~DOC 16 | **Specify a global domain value** 17 | 18 | ```ruby 19 | macos_userdefaults 'full keyboard access to all controls' do 20 | key 'AppleKeyboardUIMode' 21 | value '2' 22 | end 23 | ``` 24 | DOC 25 | ``` 26 | version_added: 6.10.0 27 | enabled: false 28 | included_file_paths: 29 | - "**/resources/*.rb" 30 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_sharing_insecurecookbookurl.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: InsecureCookbookURL 3 | full_name: Chef/Sharing/InsecureCookbookURL 4 | department: Chef/Sharing 5 | description: Use secure Github and Gitlab URLs for source_url and issues_url 6 | autocorrection: true 7 | target_chef_version: All Versions 8 | examples: |2- 9 | 10 | ### incorrect 11 | 12 | ```ruby 13 | source_url 'http://github.com/something/something' 14 | source_url 'http://www.github.com/something/something' 15 | source_url 'http://www.gitlab.com/something/something' 16 | source_url 'http://gitlab.com/something/something' 17 | ``` 18 | 19 | ### correct 20 | 21 | ```ruby 22 | source_url 'http://github.com/something/something' 23 | source_url 'http://gitlab.com/something/something' 24 | ``` 25 | version_added: 5.1.0 26 | enabled: true 27 | included_file_paths: 28 | - "**/metadata.rb" 29 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_sharing_invalidlicensestring.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: InvalidLicenseString 3 | full_name: Chef/Sharing/InvalidLicenseString 4 | department: Chef/Sharing 5 | description: |- 6 | metadata.rb license field should include a SPDX compliant string or "all right reserved" (not case sensitive) 7 | 8 | list of valid SPDX.org license strings. To build an array run this ruby: 9 | ```ruby 10 | require 'json' 11 | require 'net/http' 12 | json_data = JSON.parse(Net::HTTP.get(URI('https://raw.githubusercontent.com/spdx/license-list-data/master/json/licenses.json'))) 13 | licenses = json_data['licenses'].map {|l| l['licenseId'] }.sort 14 | ``` 15 | autocorrection: true 16 | target_chef_version: All Versions 17 | examples: |2- 18 | 19 | ### incorrect 20 | 21 | ```ruby 22 | license 'Apache 2.0' 23 | ``` 24 | 25 | ### correct 26 | 27 | ```ruby 28 | license 'Apache-2.0' 29 | license 'all rights reserved' 30 | ``` 31 | version_added: 5.2.0 32 | enabled: true 33 | included_file_paths: 34 | - "**/metadata.rb" 35 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_style_attributekeys.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: AttributeKeys 3 | full_name: Chef/Style/AttributeKeys 4 | department: Chef/Style 5 | description: |- 6 | Check which style of keys are used to access node attributes. 7 | 8 | There are two supported styles: "symbols" and "strings". 9 | autocorrection: true 10 | target_chef_version: All Versions 11 | examples: |2- 12 | 13 | ### incorrect 14 | 15 | ```ruby 16 | node['foo'] 17 | node["foo"] 18 | ``` 19 | 20 | ### correct 21 | 22 | ```ruby 23 | node[:foo] 24 | ``` 25 | version_added: 5.0.0 26 | enabled: true 27 | excluded_file_paths: 28 | - "**/metadata.rb" 29 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_style_chefwhaaat.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ChefWhaaat 3 | full_name: Chef/Style/ChefWhaaat 4 | department: Chef/Style 5 | description: Checks for comments that mention "Chef" without context. Do you mean 6 | Chef Infra or Chef Software? 7 | autocorrection: false 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | Chef makes software 15 | Chef configures your systems 16 | ``` 17 | 18 | ### correct 19 | 20 | ```ruby 21 | Chef Software makes software 22 | Chef Infra configures your systems 23 | ``` 24 | version_added: 5.20.0 25 | enabled: false 26 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_style_commentformat.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: CommentFormat 3 | full_name: Chef/Style/CommentFormat 4 | department: Chef/Style 5 | description: Checks for incorrectly formatted headers 6 | autocorrection: true 7 | target_chef_version: All Versions 8 | examples: |2- 9 | 10 | ### incorrect 11 | 12 | ```ruby 13 | Copyright 2013-2016 Chef Software, Inc. 14 | Recipe default.rb 15 | Attributes default.rb 16 | License Apache2 17 | Cookbook tomcat 18 | Cookbook Name:: Tomcat 19 | Attributes File:: default 20 | ``` 21 | 22 | ### correct 23 | 24 | ```ruby 25 | Copyright:: 2013-2016 Chef Software, Inc. 26 | Recipe:: default.rb 27 | Attributes:: default.rb 28 | License:: Apache License, Version 2.0 29 | Cookbook:: Tomcat 30 | ``` 31 | version_added: 5.0.0 32 | enabled: true 33 | excluded_file_paths: 34 | - "**/Berksfile" 35 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_style_commentsentencespacing.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: CommentSentenceSpacing 3 | full_name: Chef/Style/CommentSentenceSpacing 4 | department: Chef/Style 5 | description: |- 6 | Replaces double spaces between sentences with a single space. 7 | Note: This is DISABLED by default. 8 | autocorrection: true 9 | target_chef_version: All Versions 10 | examples: 11 | version_added: 5.1.0 12 | enabled: false 13 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_style_copyrightcommentformat.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: CopyrightCommentFormat 3 | full_name: Chef/Style/CopyrightCommentFormat 4 | department: Chef/Style 5 | description: Checks for incorrectly formatted copyright comments. 6 | autocorrection: true 7 | target_chef_version: All Versions 8 | examples: |2- 9 | 10 | ### incorrect 11 | 12 | ```ruby 13 | Copyright:: 2013-2022 Opscode, Inc. 14 | Copyright:: 2013-2022 Chef Inc. 15 | Copyright:: 2013-2022 Chef Software Inc. 16 | Copyright:: 2009-2010 2013-2022 Chef Software Inc. 17 | Copyright:: Chef Software Inc. 18 | Copyright:: Tim Smith 19 | Copyright:: Copyright (c) 2015-2022 Chef Software, Inc. 20 | ``` 21 | 22 | ### correct 23 | 24 | ```ruby 25 | Copyright:: 2013-2022 Chef Software, Inc. 26 | Copyright:: 2013-2022 Tim Smith 27 | Copyright:: 2019 37Signals, Inc. 28 | ``` 29 | version_added: 5.0.0 30 | enabled: false 31 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_style_defaultcopyrightcomments.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: DefaultCopyrightComments 3 | full_name: Chef/Style/DefaultCopyrightComments 4 | department: Chef/Style 5 | description: Checks for default copyright comments from the chef generator cookbook 6 | command 7 | autocorrection: false 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | Copyright:: 2019 YOUR_NAME 15 | Copyright:: 2019 YOUR_COMPANY_NAME 16 | ``` 17 | 18 | ### correct 19 | 20 | ```ruby 21 | Copyright:: 2019 Tim Smith 22 | Copyright:: 2019 Chef Software, Inc. 23 | ``` 24 | version_added: 5.12.0 25 | enabled: true 26 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_style_immediatenotificationtiming.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: ImmediateNotificationTiming 3 | full_name: Chef/Style/ImmediateNotificationTiming 4 | department: Chef/Style 5 | description: Use :immediately instead of :immediate for resource notification timing. 6 | autocorrection: true 7 | target_chef_version: All Versions 8 | examples: |2- 9 | 10 | ### incorrect 11 | 12 | ```ruby 13 | 14 | template '/etc/www/configures-apache.conf' do 15 | notifies :restart, 'service[apache]', :immediate 16 | end 17 | ``` 18 | 19 | ### correct 20 | 21 | ```ruby 22 | 23 | template '/etc/www/configures-apache.conf' do 24 | notifies :restart, 'service[apache]', :immediately 25 | end 26 | ``` 27 | version_added: 5.16.0 28 | enabled: true 29 | excluded_file_paths: 30 | - "**/attributes/*.rb" 31 | - "**/metadata.rb" 32 | - "**/Berksfile" 33 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_style_includerecipewithparentheses.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: IncludeRecipeWithParentheses 3 | full_name: Chef/Style/IncludeRecipeWithParentheses 4 | department: Chef/Style 5 | description: There is no need to wrap the recipe in parentheses when using the include_recipe 6 | helper. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | include_recipe('foo::bar') 15 | ``` 16 | 17 | ### correct 18 | 19 | ```ruby 20 | include_recipe 'foo::bar' 21 | ``` 22 | version_added: 6.11.0 23 | enabled: true 24 | excluded_file_paths: 25 | - "**/attributes/*.rb" 26 | - "**/metadata.rb" 27 | - "**/Berksfile" 28 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_style_negatingonlyif.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: NegatingOnlyIf 3 | full_name: Chef/Style/NegatingOnlyIf 4 | department: Chef/Style 5 | description: Instead of using only_if conditionals with ! to negate the returned value, 6 | use not_if which is easier to read 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | package 'legacy-sysv-deps' do 15 | only_if { !systemd } 16 | end 17 | ``` 18 | 19 | ### correct 20 | 21 | ```ruby 22 | package 'legacy-sysv-deps' do 23 | not_if { systemd } 24 | end 25 | ``` 26 | version_added: 6.2.0 27 | enabled: true 28 | excluded_file_paths: 29 | - "**/metadata.rb" 30 | - "**/Berksfile" 31 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_style_overlycomplexsupportsdependsmetadata.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: OverlyComplexSupportsDependsMetadata 3 | full_name: Chef/Style/OverlyComplexSupportsDependsMetadata 4 | department: Chef/Style 5 | description: Don't loop over an array to set cookbook dependencies or supported platforms 6 | if you have fewer than three values to set. Setting multiple `supports` or `depends` 7 | values is simpler and easier to understand for new users. 8 | autocorrection: true 9 | target_chef_version: All Versions 10 | examples: |2- 11 | 12 | ### incorrect 13 | 14 | ```ruby 15 | 16 | %w( debian ubuntu ).each do |os| 17 | supports os 18 | end 19 | 20 | %w( apt yum ).each do |cb| 21 | depends cb 22 | end 23 | ``` 24 | 25 | ### correct 26 | 27 | ```ruby 28 | 29 | supports 'debian' 30 | supports 'ubuntu' 31 | 32 | depends 'apt' 33 | depends 'yum' 34 | ``` 35 | version_added: 5.19.0 36 | enabled: true 37 | included_file_paths: 38 | - "**/metadata.rb" 39 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_style_trueclassfalseclassresourceproperties.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: TrueClassFalseClassResourceProperties 3 | full_name: Chef/Style/TrueClassFalseClassResourceProperties 4 | department: Chef/Style 5 | description: When setting the allowed types for a resource to accept either true or 6 | false values it's much simpler to use true and false instead of TrueClass and FalseClass. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | property :foo, [TrueClass, FalseClass] 15 | ``` 16 | 17 | ### correct 18 | 19 | ```ruby 20 | property :foo, [true, false] 21 | ``` 22 | version_added: 5.16.0 23 | enabled: true 24 | included_file_paths: 25 | - "**/libraries/*.rb" 26 | - "**/resources/*.rb" 27 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_chef_style_unnecessaryplatformcasestatement.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: UnnecessaryPlatformCaseStatement 3 | full_name: Chef/Style/UnnecessaryPlatformCaseStatement 4 | department: Chef/Style 5 | description: Use the platform?() and platform_family?() helpers instead of a case 6 | statement that only includes a single when statement. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | case node['platform'] 15 | when 'ubuntu' 16 | log "We're on Ubuntu" 17 | apt_update 18 | end 19 | 20 | case node['platform_family'] 21 | when 'rhel' 22 | include_recipe 'yum' 23 | end 24 | ``` 25 | 26 | ### correct 27 | 28 | ```ruby 29 | if platform?('ubuntu') 30 | log "We're on Ubuntu" 31 | apt_update 32 | end 33 | 34 | include_recipe 'yum' if platform_family?('rhel') 35 | ``` 36 | version_added: 5.16.0 37 | enabled: true 38 | excluded_file_paths: 39 | - "**/metadata.rb" 40 | - "**/Berksfile" 41 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_inspec_deprecations_attributedefault.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: AttributeDefault 3 | full_name: InSpec/Deprecations/AttributeDefault 4 | department: InSpec/Deprecations 5 | description: The Chef InSpec inputs `default` option has been replaced with the `value` 6 | option. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | login_defs_umask = input('login_defs_umask', default: '077', description: 'Default umask to set in login.defs') 15 | ``` 16 | 17 | ### correct 18 | 19 | ```ruby 20 | login_defs_umask = input('login_defs_umask', value: '077', description: 'Default umask to set in login.defs') 21 | ``` 22 | version_added: 7.14.0 23 | enabled: true 24 | included_file_paths: 25 | - "**/controls/*.rb" 26 | -------------------------------------------------------------------------------- /docs-chef-io/assets/cookstyle/cops_inspec_deprecations_attributehelper.yml: -------------------------------------------------------------------------------- 1 | --- 2 | short_name: AttributeHelper 3 | full_name: InSpec/Deprecations/AttributeHelper 4 | department: InSpec/Deprecations 5 | description: Chef InSpec attributes have been renamed to inputs. Use the `input` method 6 | not the deprecation `attribute` method to access these values. 7 | autocorrection: true 8 | target_chef_version: All Versions 9 | examples: |2- 10 | 11 | ### incorrect 12 | 13 | ```ruby 14 | login_defs_umask = attribute('login_defs_umask', value: '077', description: 'Default umask to set in login.defs') 15 | ``` 16 | 17 | ### correct 18 | 19 | ```ruby 20 | login_defs_umask = input('login_defs_umask', value: '077', description: 'Default umask to set in login.defs') 21 | ``` 22 | version_added: 7.14.0 23 | enabled: true 24 | included_file_paths: 25 | - "**/controls/*.rb" 26 | -------------------------------------------------------------------------------- /docs-chef-io/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/chef/cookstyle/docs-chef-io 2 | 3 | go 1.14 4 | -------------------------------------------------------------------------------- /docs/cops.md: -------------------------------------------------------------------------------- 1 | These docs have been moved to docs.chef.io at https://docs.chef.io/workstation/cookstyle/cops/ 2 | -------------------------------------------------------------------------------- /docs/cops_chef_correctness.md: -------------------------------------------------------------------------------- 1 | These docs have been moved to docs.chef.io at https://docs.chef.io/workstation/cookstyle/cops/ 2 | -------------------------------------------------------------------------------- /docs/cops_chef_deprecations.md: -------------------------------------------------------------------------------- 1 | These docs have been moved to docs.chef.io at https://docs.chef.io/workstation/cookstyle/cops/ 2 | -------------------------------------------------------------------------------- /docs/cops_chef_effortless.md: -------------------------------------------------------------------------------- 1 | These docs have been moved to docs.chef.io at https://docs.chef.io/workstation/cookstyle/cops/ 2 | -------------------------------------------------------------------------------- /docs/cops_chef_modernize.md: -------------------------------------------------------------------------------- 1 | These docs have been moved to docs.chef.io at https://docs.chef.io/workstation/cookstyle/cops/ 2 | -------------------------------------------------------------------------------- /docs/cops_chef_redundantcode.md: -------------------------------------------------------------------------------- 1 | These docs have been moved to docs.chef.io at https://docs.chef.io/workstation/cookstyle/cops/ 2 | -------------------------------------------------------------------------------- /docs/cops_chef_sharing.md: -------------------------------------------------------------------------------- 1 | These docs have been moved to docs.chef.io at https://docs.chef.io/workstation/cookstyle/cops/ 2 | -------------------------------------------------------------------------------- /docs/cops_chef_style.md: -------------------------------------------------------------------------------- 1 | These docs have been moved to docs.chef.io at https://docs.chef.io/workstation/cookstyle/cops/ 2 | -------------------------------------------------------------------------------- /habitat/tests/test.ps1: -------------------------------------------------------------------------------- 1 | param ( 2 | [Parameter()] 3 | [string]$PackageIdentifier = $(throw "Usage: test.ps1 [test_pkg_ident] e.g. test.ps1 ci/user-windows/1.0.0/20190812103929") 4 | ) 5 | 6 | 7 | Write-Host "--- :fire: Smokish test" 8 | # Pester the Package 9 | $version=hab pkg exec "${pkg_ident}" cookstyle -v 10 | $actual_version=[Regex]::Match($version,"([0-9]+.[0-9]+.[0-9]+)").Value 11 | $package_version=$PackageIdentifier.split("/",4)[2] 12 | 13 | Write-Host "package_version $package_version actual version $actual_version" 14 | if ($package_version -eq $actual_version) 15 | { 16 | Write "cookstyle working fine" 17 | } 18 | else { 19 | Write-Error "cookstyle version not met expected $package_version actual version $actual_version " 20 | throw "cookstyle windows pipeline not working for hab pkg" 21 | } -------------------------------------------------------------------------------- /habitat/tests/test.sh: -------------------------------------------------------------------------------- 1 | 2 | set -euo pipefail 3 | 4 | 5 | project_root="$(git rev-parse --show-toplevel)" 6 | pkg_ident="$1" 7 | 8 | # print error message followed by usage and exit 9 | error () { 10 | local message="$1" 11 | 12 | echo -e "\nERROR: ${message}\n" >&2 13 | 14 | exit 1 15 | } 16 | 17 | [[ -n "$pkg_ident" ]] || error 'no hab package identity provided' 18 | 19 | package_version=$(awk -F / '{print $3}' <<<"$pkg_ident") 20 | echo $package_version 21 | 22 | cd "${project_root}" 23 | 24 | echo "--- :mag_right: Testing ${pkg_ident} executables" 25 | actual_version=$(hab pkg exec "${pkg_ident}" cookstyle -v | sed -n 's/^Cookstyle \([0-9.]*\).*$/\1/p') 26 | echo $actual_version 27 | [[ "$package_version" = "$actual_version" ]] || error "cookstyle version is not the expected version. Expected '$package_version', got '$actual_version'" -------------------------------------------------------------------------------- /lib/cookstyle/chefstyle.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | module Cookstyle 3 | CHEFSTYLE_CONFIG = true 4 | end 5 | require_relative '../cookstyle' 6 | -------------------------------------------------------------------------------- /lib/cookstyle/version.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | module Cookstyle 3 | VERSION = "8.1.5" # rubocop: disable Style/StringLiterals 4 | RUBOCOP_VERSION = '1.75.8' 5 | end 6 | -------------------------------------------------------------------------------- /lib/rubocop/chef.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | module RuboCop 3 | # RuboCop Chef project namespace 4 | module Chef 5 | PROJECT_ROOT = Pathname.new(__dir__).parent.parent.expand_path.freeze 6 | CONFIG_DEFAULT = PROJECT_ROOT.join('config', 'cookstyle.yml').freeze 7 | CONFIG = YAML.load(CONFIG_DEFAULT.read).freeze 8 | 9 | private_constant(*constants(false)) 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /lib/rubocop/cop/target_chef_version.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # shamelessly borrowed from rubocop-rails. Thanks! 4 | 5 | module RuboCop 6 | module Cop 7 | # Common functionality for checking target chef version. 8 | module TargetChefVersion 9 | def required_minimum_chef_version 10 | @minimum_target_chef_version 11 | end 12 | 13 | def minimum_target_chef_version(version) 14 | @minimum_target_chef_version = version 15 | end 16 | 17 | def support_target_chef_version?(version) 18 | Gem::Version.new(@minimum_target_chef_version) <= Gem::Version.new(version) 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/rubocop/monkey_patches/base.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | module RuboCop 3 | module Cop 4 | class Base 5 | # This is a copy of the #target_rails_version method from rubocop-rails 6 | def target_chef_version 7 | @config.target_chef_version 8 | end 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /lib/rubocop/monkey_patches/config.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module RuboCop 4 | class Config 5 | # This is a copy of the #target_rails_version method from RuboCop 6 | def target_chef_version 7 | @target_chef_version ||= 8 | if for_all_cops['TargetChefVersion'] 9 | for_all_cops['TargetChefVersion'].to_f 10 | else 11 | 99 # just set a high number so we don't need to update this later 12 | end 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /lib/rubocop/monkey_patches/directive_comment.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | module RuboCop 3 | # we're monkey patching the config regex to allow for "cookstyle: disable whatever" 4 | # in addition to the "rubocop: disable whatever that comes with RuboCop" 5 | class DirectiveComment 6 | remove_const(:DIRECTIVE_COMMENT_REGEXP) 7 | DIRECTIVE_COMMENT_REGEXP = Regexp.new( 8 | "# (?:rubocop|cookstyle) : ((?:disable|enable|todo))\\b #{COPS_PATTERN}" 9 | .gsub(' ', '\s*') 10 | ) 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /lib/rubocop/monkey_patches/registry_cop.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | module RuboCop 3 | module Cop 4 | class Registry 5 | # we monkeypatch this warning to replace rubocop with cookstyle 6 | def print_warning(name, path) 7 | message = "#{path}: Warning: no department given for #{name}." 8 | if path.end_with?('.rb') 9 | message += ' Run `cookstyle -a --only Migration/DepartmentName` to fix.' 10 | end 11 | warn message 12 | end 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /lib/rubocop/monkey_patches/team.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module RuboCop 4 | module Cop 5 | class Team 6 | def support_target_chef_version?(cop) 7 | return true unless cop.class.respond_to?(:support_target_chef_version?) 8 | 9 | cop.class.support_target_chef_version?(cop.target_chef_version) 10 | end 11 | 12 | ### START COOKSTYLE MODIFICATION 13 | def roundup_relevant_cops(processed_source) 14 | cops.select do |cop| 15 | next true if processed_source.comment_config.cop_opted_in?(cop) 16 | next false if cop.excluded_file?(processed_source.file_path) 17 | next false unless @registry.enabled?(cop, @config) 18 | 19 | support_target_ruby_version?(cop) && support_target_rails_version?(cop) && support_target_chef_version?(cop) 20 | end 21 | end 22 | ### END COOKSTYLE MODIFICATION 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /spec/rubocop/cop/chef/effortless/depends_chef_vault_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # 3 | # Copyright:: 2020, Chef Software, Inc. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | require 'spec_helper' 19 | 20 | describe RuboCop::Cop::Chef::Effortless::DependsChefVault, :config do 21 | it 'registers an offense when requiring chef-vault' do 22 | expect_offense(<<~RUBY) 23 | depends 'chef-vault' 24 | ^^^^^^^^^^^^^^^^^^^^ Chef Vault usage is not supported in the Effortless pattern 25 | RUBY 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /spec/shared/autocorrect_behavior.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | RSpec.shared_examples 'autocorrect' do |original, corrected| 3 | it "autocorrects `#{original}` to `#{corrected}`" do 4 | autocorrected = autocorrect_source(original, 'spec/foo_spec.rb') 5 | 6 | expect(autocorrected).to eql(corrected) 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | require 'rubocop' 3 | require 'rubocop/rspec/support' 4 | 5 | spec_helper_glob = File.expand_path('{support,shared}/*.rb', __dir__) 6 | Dir.glob(spec_helper_glob).each { |spec_file| require spec_file } 7 | 8 | RSpec.configure do |config| 9 | # Basic configuration 10 | config.run_all_when_everything_filtered = true 11 | config.filter_run(:focus) 12 | config.order = :random 13 | 14 | config.include RuboCop::RSpec::ExpectOffense 15 | end 16 | 17 | # small helper for use in let blocks 18 | def target_chef_version(version) 19 | RuboCop::Config.new('AllCops' => { 'TargetChefVersion' => version }) 20 | end 21 | 22 | require 'cookstyle' 23 | --------------------------------------------------------------------------------