Hey everyone,
This week's new release of Cookstyle is out with 5 new Chef Infra cops bringing our total to 184 Chef Infra specific cops!
ChefModernize/NodeRolesInclude
The ChefModernize/NodeRolesInclude
cop detects cookbooks that use node['roles'].include?('foo')
to see if a particular role has been applied to a node. Use the simpler node.role?('foo')
helper instead.
Enabled by default
: True
Autocorrects
: Yes
ChefDeprecations/PowershellCookbookHelpers
The ChefDeprecations/PowershellCookbookHelpers
cop detects cookbooks that use the deprecated Powershell::VersionHelper.powershell_version?
helper from the powershell
cookbook. Chef Infra Client provides information on the installed PowerShell release at node['powershell']['version']
and Chef Infra Client 15.8 and later includes a new powershell_version
method which should be used when possible.
Enabled by default
: True
Autocorrects
: Yes
ChefCorrectness/ConditionalRubyShellout
The ChefCorrectness/ConditionalRubyShellout
cop detects resources that use unnecessary Ruby code in not_if
and only_if
conditionals to shellout when a string can be used to avoid additional complexity.
Shelling out with ruby:
cookbook_file '/logs/foo/error.log' do
only_if { system('wget https://www.bar.com/foobar.txt -O /dev/null') }
end
Shelling out without Ruby:
cookbook_file '/logs/foo/error.log' do
only_if 'wget https://www.bar.com/foobar.txt -O /dev/null'
end
Enabled by default
: True
Autocorrects
: Yes
ChefSharing/IncludePropertyDescriptions
The ChefSharing/IncludePropertyDescriptions
cop detects resource properties that don't include a description value. The chef-resource-inspector
command displays the description value in resource properties and that description can be used to automatically generate documentation.
Enabled by default
: False
Autocorrects
: No
ChefSharing/IncludeResourceDescriptions
The ChefSharing/IncludeResourceDescriptions
cop detects resources that don't include a description. The chef-resource-inspector
command displays the description value in resources and that description can be used to automatically generate documentation.
Enabled by default
: False
Autocorrects
: No
Other Changes
-
ChefModernize/PowershellInstallWindowsFeature
now correctly identifies the required Chef Infra Client release as 14.0 and later. - The
WindowsVersionHelper
cop has been moved to theChefDeprecations
department and now includes autocorrection for each of the helpers it identifies.
Enjoy,
Tim