cookstyle 5.21.9 → 5.22.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/cookstyle.yml +35 -4
- data/lib/cookstyle/version.rb +1 -1
- data/lib/rubocop/chef/cookbook_only.rb +1 -1
- data/lib/rubocop/cop/chef/deprecation/windows_feature_servermanagercmd.rb +57 -0
- data/lib/rubocop/cop/chef/modernize/execute_apt_update.rb +31 -1
- data/lib/rubocop/cop/chef/modernize/node_init_package.rb +79 -0
- data/lib/rubocop/cop/chef/modernize/use_require_relative.rb +61 -0
- data/lib/rubocop/cop/chef/modernize/windows_registry_uac.rb +71 -0
- data/lib/rubocop/cop/chef/style/true_false_resource_properties.rb +6 -17
- data/lib/rubocop/cop/chef/style/unnecessary_os_check.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dad51325bcc35540eeba663b24105674daa20a35d198427a9331be5d02ca3e3b
|
4
|
+
data.tar.gz: 83e2ab6a718092d10ec8ce423e14c995e5a64bc696cd99b3a447144cf2a10fdb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56cba25a342b3f48f69160838cc03807640b11864ba43c5915c715520b1dd751f6ff263e89fd79d8414f3d9b206adbfa441833373dbcb5aed46e0beb32518b74
|
7
|
+
data.tar.gz: 45af6528c08c91fc29f83542d407a081cd0d6897c9fb42b63a51ad512ca0895aa4e48019fc6bb41fe34a4436cbf58b4c64b1306ae41a6f9faec6c2ec855378fb
|
data/config/cookstyle.yml
CHANGED
@@ -717,6 +717,15 @@ ChefDeprecations/DeprecatedChefSpecPlatform:
|
|
717
717
|
Include:
|
718
718
|
- '**/spec/**/*.rb'
|
719
719
|
|
720
|
+
ChefDeprecations/WindowsFeatureServermanagercmd:
|
721
|
+
Description: The `windows_feature` resource no longer supports setting the `install_method` to `:servermanagercmd`. `:windows_feature_dism` or `:windows_feature_powershell` should be used instead.
|
722
|
+
Enabled: true
|
723
|
+
VersionAdded: '5.22.0'
|
724
|
+
Exclude:
|
725
|
+
- '**/metadata.rb'
|
726
|
+
- '**/attributes/*.rb'
|
727
|
+
- '**/Berksfile'
|
728
|
+
|
720
729
|
###############################
|
721
730
|
# ChefModernize: Cleaning up legacy code and using new built-in resources
|
722
731
|
###############################
|
@@ -1115,6 +1124,32 @@ ChefModernize/SimplifyAptPpaSetup:
|
|
1115
1124
|
- '**/attributes/*.rb'
|
1116
1125
|
- '**/Berksfile'
|
1117
1126
|
|
1127
|
+
ChefModernize/UseRequireRelative:
|
1128
|
+
Description: Instead of using require with a File.expand_path and __FILE__ use the simpler require_relative method.
|
1129
|
+
Enabled: true
|
1130
|
+
VersionAdded: '5.22.0'
|
1131
|
+
Exclude:
|
1132
|
+
- '**/metadata.rb'
|
1133
|
+
- '**/attributes/*.rb'
|
1134
|
+
- '**/Berksfile'
|
1135
|
+
|
1136
|
+
ChefModernize/NodeInitPackage:
|
1137
|
+
Description: Use node['init_package'] to check for systemd instead of reading the contents of '/proc/1/comm'
|
1138
|
+
Enabled: true
|
1139
|
+
VersionAdded: '5.22.0'
|
1140
|
+
Exclude:
|
1141
|
+
- '**/metadata.rb'
|
1142
|
+
- '**/Berksfile'
|
1143
|
+
|
1144
|
+
ChefModernize/WindowsRegistryUAC:
|
1145
|
+
Description: Chef Infra Client 15.0 and later includes a windows_uac resource that should be used to set Windows UAC values instead of setting registry keys directly.
|
1146
|
+
Enabled: true
|
1147
|
+
VersionAdded: '5.22.0'
|
1148
|
+
Exclude:
|
1149
|
+
- '**/metadata.rb'
|
1150
|
+
- '**/attributes/*.rb'
|
1151
|
+
- '**/Berksfile'
|
1152
|
+
|
1118
1153
|
###############################
|
1119
1154
|
# ChefRedundantCode: Cleanup unnecessary code in your cookbooks regardless of Chef Infra Client release
|
1120
1155
|
###############################
|
@@ -1472,8 +1507,6 @@ Style/MethodCallParentheses:
|
|
1472
1507
|
Enabled: true
|
1473
1508
|
Style/MethodDefParentheses:
|
1474
1509
|
Enabled: true
|
1475
|
-
Naming/MethodName:
|
1476
|
-
Enabled: true
|
1477
1510
|
Style/MultilineBlockChain:
|
1478
1511
|
Enabled: true
|
1479
1512
|
Layout/MultilineBlockLayout:
|
@@ -1624,8 +1657,6 @@ Style/TrailingUnderscoreVariable:
|
|
1624
1657
|
Enabled: true
|
1625
1658
|
Style/VariableInterpolation:
|
1626
1659
|
Enabled: true
|
1627
|
-
Naming/VariableName:
|
1628
|
-
Enabled: true
|
1629
1660
|
Style/WhenThen:
|
1630
1661
|
Enabled: true
|
1631
1662
|
Style/WhileUntilDo:
|
data/lib/cookstyle/version.rb
CHANGED
@@ -0,0 +1,57 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: 2020, Chef Software, Inc.
|
3
|
+
# Author:: Tim Smith (<tsmith@chef.io>)
|
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
|
+
module RuboCop
|
18
|
+
module Cop
|
19
|
+
module Chef
|
20
|
+
module ChefDeprecations
|
21
|
+
# The `windows_feature` resource no longer supports setting the `install_method` to `:servermanagercmd`. `:windows_feature_dism` or `:windows_feature_powershell` should be used instead.
|
22
|
+
#
|
23
|
+
# @example
|
24
|
+
#
|
25
|
+
# # bad
|
26
|
+
# windows_feature 'DHCP' do
|
27
|
+
# install_method :servermanagercmd
|
28
|
+
# end
|
29
|
+
#
|
30
|
+
# # good
|
31
|
+
# windows_feature 'DHCP' do
|
32
|
+
# install_method :windows_feature_dism
|
33
|
+
# end
|
34
|
+
#
|
35
|
+
# windows_feature 'DHCP' do
|
36
|
+
# install_method :windows_feature_powershell
|
37
|
+
# end
|
38
|
+
#
|
39
|
+
# windows_feature_dism 'DHCP'
|
40
|
+
#
|
41
|
+
# windows_feature_powershell 'DHCP'
|
42
|
+
#
|
43
|
+
class WindowsFeatureServermanagercmd < Cop
|
44
|
+
include RuboCop::Chef::CookbookHelpers
|
45
|
+
|
46
|
+
MSG = 'The `windows_feature` resource no longer supports setting the `install_method` to `:servermanagercmd`. `:windows_feature_dism` or `:windows_feature_powershell` should be used instead.'.freeze
|
47
|
+
|
48
|
+
def on_block(node)
|
49
|
+
match_property_in_resource?(:windows_feature, :install_method, node) do |prop_node|
|
50
|
+
add_offense(prop_node, location: :expression, message: MSG, severity: :refactor) if prop_node.source.match?(/:servermanagercmd/)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright:: 2019, Chef Software, Inc.
|
2
|
+
# Copyright:: 2019-2020, Chef Software, Inc.
|
3
3
|
# Author:: Tim Smith (<tsmith@chef.io>)
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -24,9 +24,23 @@ module RuboCop
|
|
24
24
|
# # bad
|
25
25
|
# execute 'apt-get update'
|
26
26
|
#
|
27
|
+
# execute 'Apt all the apt cache' do
|
28
|
+
# command 'apt-get update'
|
29
|
+
# end
|
30
|
+
#
|
31
|
+
# execute 'some execute resource' do
|
32
|
+
# notifies :run, 'execute[apt-get update]', :immediately
|
33
|
+
# end
|
34
|
+
#
|
27
35
|
# # good
|
28
36
|
# apt_update
|
29
37
|
#
|
38
|
+
# apt_update 'update apt cache'
|
39
|
+
#
|
40
|
+
# execute 'some execute resource' do
|
41
|
+
# notifies :update, 'apt_update[update apt cache]', :immediately
|
42
|
+
# end
|
43
|
+
#
|
30
44
|
class ExecuteAptUpdate < Cop
|
31
45
|
MSG = 'Use the apt_update resource instead of the execute resource to run an apt-get update package cache update'.freeze
|
32
46
|
|
@@ -34,10 +48,26 @@ module RuboCop
|
|
34
48
|
(send nil? :execute (str "apt-get update"))
|
35
49
|
PATTERN
|
36
50
|
|
51
|
+
def_node_matcher :notification_property?, <<-PATTERN
|
52
|
+
(send nil? {:notifies :subscribes} (sym _) $(...) (sym _))
|
53
|
+
PATTERN
|
54
|
+
|
55
|
+
def_node_matcher :execute_command?, <<-PATTERN
|
56
|
+
(send nil? :command $str)
|
57
|
+
PATTERN
|
58
|
+
|
37
59
|
def on_send(node)
|
38
60
|
execute_apt_update?(node) do
|
39
61
|
add_offense(node, location: :expression, message: MSG, severity: :refactor)
|
40
62
|
end
|
63
|
+
|
64
|
+
notification_property?(node) do |val|
|
65
|
+
add_offense(val, location: :expression, message: MSG, severity: :refactor) if val.str_content&.start_with?('execute[apt-get update]')
|
66
|
+
end
|
67
|
+
|
68
|
+
execute_command?(node) do |val|
|
69
|
+
add_offense(node, location: :expression, message: MSG, severity: :refactor) if val.str_content == 'apt-get update'
|
70
|
+
end
|
41
71
|
end
|
42
72
|
end
|
43
73
|
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: 2020, Chef Software, Inc.
|
3
|
+
# Author:: Tim Smith (<tsmith@chef.io>)
|
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
|
+
module RuboCop
|
18
|
+
module Cop
|
19
|
+
module Chef
|
20
|
+
module ChefModernize
|
21
|
+
# Use node['init_package'] to check for systemd instead of reading the contents of '/proc/1/comm'
|
22
|
+
#
|
23
|
+
# @example
|
24
|
+
#
|
25
|
+
# # bad
|
26
|
+
# ::File.open('/proc/1/comm').gets.chomp == 'systemd'
|
27
|
+
# ::File.open('/proc/1/comm').chomp == 'systemd'
|
28
|
+
# File.open('/proc/1/comm').gets.chomp == 'systemd'
|
29
|
+
# File.open('/proc/1/comm').chomp == 'systemd'
|
30
|
+
# File.exist?('/proc/1/comm') && File.open('/proc/1/comm').chomp == 'systemd'
|
31
|
+
#
|
32
|
+
# IO.read('/proc/1/comm').chomp == 'systemd'
|
33
|
+
# IO.read('/proc/1/comm').gets.chomp == 'systemd'
|
34
|
+
# ::IO.read('/proc/1/comm').chomp == 'systemd'
|
35
|
+
# ::IO.read('/proc/1/comm').gets.chomp == 'systemd'
|
36
|
+
# File.exist?('/proc/1/comm') && File.open('/proc/1/comm').chomp == 'systemd'
|
37
|
+
#
|
38
|
+
# # good
|
39
|
+
# node['init_package'] == 'systemd'
|
40
|
+
#
|
41
|
+
class NodeInitPackage < Cop
|
42
|
+
MSG = "Use node['init_package'] to check for systemd instead of reading the contents of '/proc/1/comm'".freeze
|
43
|
+
|
44
|
+
def_node_matcher :file_reads_proc_1_comm?, <<-PATTERN
|
45
|
+
(send (const {(cbase) nil?} {:File :IO}) {:open :read} (str "/proc/1/comm"))
|
46
|
+
PATTERN
|
47
|
+
|
48
|
+
def_node_matcher :proc_1_comm_exists?, <<-PATTERN
|
49
|
+
(send
|
50
|
+
(const
|
51
|
+
{(cbase) nil?} :File) :exist?
|
52
|
+
(str "/proc/1/comm"))
|
53
|
+
PATTERN
|
54
|
+
|
55
|
+
def_node_matcher :compare_init_system?, <<-PATTERN
|
56
|
+
(send
|
57
|
+
(send {#file_reads_proc_1_comm? (send #file_reads_proc_1_comm? :gets) } :chomp)
|
58
|
+
:== (str "systemd"))
|
59
|
+
PATTERN
|
60
|
+
|
61
|
+
def on_send(node)
|
62
|
+
compare_init_system?(node) do
|
63
|
+
# if there's a ::File.exist?('/proc/1/comm') check first we want to match that as well
|
64
|
+
node = node.parent if node.parent&.and_type? && proc_1_comm_exists?(node.parent.conditions.first)
|
65
|
+
|
66
|
+
add_offense(node, location: :expression, message: MSG, severity: :refactor)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def autocorrect(node)
|
71
|
+
lambda do |corrector|
|
72
|
+
corrector.replace(node.loc.expression, "node['init_package'] == 'systemd'")
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: 2020, Chef Software Inc.
|
3
|
+
# Author:: Tim Smith (<tsmith@chef.io>)
|
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
|
+
module RuboCop
|
18
|
+
module Cop
|
19
|
+
module Chef
|
20
|
+
module ChefModernize
|
21
|
+
# Instead of using require with a File.expand_path and __FILE__ use the simpler require_relative method.
|
22
|
+
#
|
23
|
+
# @example
|
24
|
+
#
|
25
|
+
# # bad
|
26
|
+
# require File.expand_path('../../libraries/helpers', __FILE__)
|
27
|
+
#
|
28
|
+
# # good
|
29
|
+
# require_relative '../libraries/helpers'
|
30
|
+
#
|
31
|
+
class UseRequireRelative < Cop
|
32
|
+
MSG = 'Instead of using require with a File.expand_path and __FILE__ use the simpler require_relative method.'.freeze
|
33
|
+
|
34
|
+
def_node_matcher :require_with_expand_path?, <<-PATTERN
|
35
|
+
(send nil? :require
|
36
|
+
(send
|
37
|
+
(const nil? :File) :expand_path
|
38
|
+
$( str ... )
|
39
|
+
$( str ... )))
|
40
|
+
PATTERN
|
41
|
+
|
42
|
+
def on_send(node)
|
43
|
+
require_with_expand_path?(node) do |_file, path|
|
44
|
+
add_offense(node, location: :expression, message: MSG, severity: :refactor) if path.source == '__FILE__'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def autocorrect(node)
|
49
|
+
lambda do |corrector|
|
50
|
+
require_with_expand_path?(node) do |file, _path|
|
51
|
+
corrected_value = file.value
|
52
|
+
corrected_value.slice!(%r{^../}) # take the first ../ off the path
|
53
|
+
corrector.replace(node.loc.expression, "require_relative '#{corrected_value}'")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: 2020, Chef Software, Inc.
|
3
|
+
# Author:: Tim Smith (<tsmith@chef.io>)
|
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
|
+
module RuboCop
|
18
|
+
module Cop
|
19
|
+
module Chef
|
20
|
+
module ChefModernize
|
21
|
+
# Chef Infra Client 15.0 and later includes a windows_uac resource that should be used to set Windows UAC values instead of setting registry keys directly.
|
22
|
+
#
|
23
|
+
# # bad
|
24
|
+
# registry_key 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System' do
|
25
|
+
# values [{ name: 'EnableLUA', type: :dword, data: 0 },
|
26
|
+
# { name: 'PromptOnSecureDesktop', type: :dword, data: 0 },
|
27
|
+
# { name: 'ConsentPromptBehaviorAdmin', type: :dword, data: 0 },
|
28
|
+
# ]
|
29
|
+
# action :create
|
30
|
+
# end
|
31
|
+
#
|
32
|
+
# # good
|
33
|
+
# windows_uac 'Set Windows UAC settings' do
|
34
|
+
# enable_uac false
|
35
|
+
# prompt_on_secure_desktop true
|
36
|
+
# consent_behavior_admins :no_prompt
|
37
|
+
# end
|
38
|
+
#
|
39
|
+
class WindowsRegistryUAC < Cop
|
40
|
+
include RuboCop::Chef::CookbookHelpers
|
41
|
+
extend TargetChefVersion
|
42
|
+
|
43
|
+
minimum_target_chef_version '15.0'
|
44
|
+
|
45
|
+
MSG = 'Chef Infra Client 15.0 and later includes a windows_uac resource that should be used to set Windows UAC values instead of setting registry keys directly.'.freeze
|
46
|
+
|
47
|
+
# non block execute resources
|
48
|
+
def on_send(node)
|
49
|
+
return unless node.method_name == :registry_key
|
50
|
+
|
51
|
+
# use source instead of .value in case there's string interpolation which adds a complex dstr type
|
52
|
+
# with a nested string and a begin. Source allows us to avoid a lot of defensive programming here
|
53
|
+
if node&.arguments.first&.source.match?(/HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System/i)
|
54
|
+
add_offense(node, location: :expression, message: MSG, severity: :refactor)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# block execute resources
|
59
|
+
def on_block(node)
|
60
|
+
match_property_in_resource?(:registry_key, 'key', node) do |key_prop|
|
61
|
+
property_data = method_arg_ast_to_string(key_prop)
|
62
|
+
if property_data && property_data.match?(/HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System/i)
|
63
|
+
add_offense(node, location: :expression, message: MSG, severity: :refactor)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -24,39 +24,28 @@ module RuboCop
|
|
24
24
|
#
|
25
25
|
# # bad
|
26
26
|
# property :foo, [TrueClass, FalseClass]
|
27
|
-
# attribute :foo, kind_of: [TrueClass, FalseClass]
|
28
27
|
#
|
29
28
|
# # good
|
30
29
|
# property :foo, [true, false]
|
31
|
-
# attribute :foo, kind_of: [true, false]
|
32
30
|
#
|
33
31
|
class TrueClassFalseClassResourceProperties < Cop
|
34
32
|
MSG = "When setting the allowed types for a resource to accept either true or false values it's much simpler to use true and false instead of TrueClass and FalseClass.".freeze
|
35
33
|
|
36
|
-
def_node_matcher :trueclass_falseclass_array?, <<-PATTERN
|
37
|
-
(array (const nil? :TrueClass) (const nil? :FalseClass))
|
38
|
-
PATTERN
|
39
|
-
|
40
|
-
def_node_matcher :tf_in_kind_of_hash?, <<-PATTERN
|
41
|
-
(hash (pair (sym :kind_of) #trueclass_falseclass_array? ))
|
42
|
-
PATTERN
|
43
|
-
|
44
34
|
def_node_matcher :trueclass_falseclass_property?, <<-PATTERN
|
45
|
-
(send nil? {:property :attribute} (sym _)
|
46
|
-
|
47
|
-
${#tf_in_kind_of_hash? #trueclass_falseclass_array? } ... )
|
35
|
+
(send nil? {:property :attribute} (sym _) $(array (const nil? :TrueClass) (const nil? :FalseClass)) ... )
|
48
36
|
PATTERN
|
49
37
|
|
50
38
|
def on_send(node)
|
51
|
-
trueclass_falseclass_property?(node) do
|
52
|
-
add_offense(
|
39
|
+
trueclass_falseclass_property?(node) do
|
40
|
+
add_offense(node, location: :expression, message: MSG, severity: :refactor)
|
53
41
|
end
|
54
42
|
end
|
55
43
|
|
56
44
|
def autocorrect(node)
|
57
45
|
lambda do |corrector|
|
58
|
-
|
59
|
-
|
46
|
+
trueclass_falseclass_property?(node) do |types|
|
47
|
+
corrector.replace(types.loc.expression, '[true, false]')
|
48
|
+
end
|
60
49
|
end
|
61
50
|
end
|
62
51
|
end
|
@@ -18,7 +18,7 @@ module RuboCop
|
|
18
18
|
module Cop
|
19
19
|
module Chef
|
20
20
|
module ChefStyle
|
21
|
-
# Use the platform_family?() helpers instead of node['os] == 'foo' for platform_families that match
|
21
|
+
# Use the platform_family?() helpers instead of node['os] == 'foo' for platform_families that match one-to-one with OS values. These helpers are easier to read and can accept multiple platform arguments, which greatly simplifies complex platform logic. All values of `os` from Ohai match one-to-one with `platform_family` values except for `linux`, which has no single equivalent `plaform_family`.
|
22
22
|
#
|
23
23
|
# @example
|
24
24
|
#
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cookstyle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.22.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thom May
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-02-
|
12
|
+
date: 2020-02-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rubocop
|
@@ -115,6 +115,7 @@ files:
|
|
115
115
|
- lib/rubocop/cop/chef/deprecation/use_inline_resources.rb
|
116
116
|
- lib/rubocop/cop/chef/deprecation/user_supports_property.rb
|
117
117
|
- lib/rubocop/cop/chef/deprecation/verify_property_file_expansion.rb
|
118
|
+
- lib/rubocop/cop/chef/deprecation/windows_feature_servermanagercmd.rb
|
118
119
|
- lib/rubocop/cop/chef/deprecation/windows_task_change_action.rb
|
119
120
|
- lib/rubocop/cop/chef/deprecation/xml_ruby_recipe.rb
|
120
121
|
- lib/rubocop/cop/chef/deprecation/yum_dnf_compat_recipe.rb
|
@@ -150,6 +151,7 @@ files:
|
|
150
151
|
- lib/rubocop/cop/chef/modernize/libarchive_file.rb
|
151
152
|
- lib/rubocop/cop/chef/modernize/macos_user_defaults.rb
|
152
153
|
- lib/rubocop/cop/chef/modernize/minitest_handler_usage.rb
|
154
|
+
- lib/rubocop/cop/chef/modernize/node_init_package.rb
|
153
155
|
- lib/rubocop/cop/chef/modernize/ohai_default_recipe.rb
|
154
156
|
- lib/rubocop/cop/chef/modernize/openssl_rsa_key_resource.rb
|
155
157
|
- lib/rubocop/cop/chef/modernize/openssl_x509_resource.rb
|
@@ -171,8 +173,10 @@ files:
|
|
171
173
|
- lib/rubocop/cop/chef/modernize/simplify_apt_ppa_setup.rb
|
172
174
|
- lib/rubocop/cop/chef/modernize/systctl_param_resource.rb
|
173
175
|
- lib/rubocop/cop/chef/modernize/unnecessary_mixlib_shellout_require.rb
|
176
|
+
- lib/rubocop/cop/chef/modernize/use_require_relative.rb
|
174
177
|
- lib/rubocop/cop/chef/modernize/whyrun_supported_true.rb
|
175
178
|
- lib/rubocop/cop/chef/modernize/windows_default_recipe.rb
|
179
|
+
- lib/rubocop/cop/chef/modernize/windows_registry_uac.rb
|
176
180
|
- lib/rubocop/cop/chef/modernize/windows_version_helper.rb
|
177
181
|
- lib/rubocop/cop/chef/modernize/windows_zipfile.rb
|
178
182
|
- lib/rubocop/cop/chef/modernize/zipfile_resource.rb
|