cookstyle 7.18.0 → 7.19.0
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 +51 -2
- data/lib/cookstyle/version.rb +1 -1
- data/lib/rubocop/cop/chef/correctness/powershell_file_exists.rb +50 -0
- data/lib/rubocop/cop/chef/modernize/chef_14_resources.rb +2 -2
- data/lib/rubocop/cop/chef/modernize/chef_15_resources.rb +57 -0
- data/lib/rubocop/cop/chef/modernize/depends_kernel_module_cookbook.rb +54 -0
- data/lib/rubocop/cop/chef/modernize/depends_locale_cookbook.rb +54 -0
- data/lib/rubocop/cop/chef/modernize/depends_timezone_lwrp_cookbook.rb +54 -0
- data/lib/rubocop/cop/chef/modernize/depends_windows_firewall_cookbook.rb +54 -0
- data/lib/rubocop/cop/chef/modernize/libarchive_file.rb +4 -2
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61c40a5894885af02650005d23a37fd8409f68286e748b17d14e96ae0fe0243f
|
4
|
+
data.tar.gz: 367b410c6654f7513e80138a389870d75810e7020feefe46b9586e76dd1821f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2cced7f9b44a843941f8545bcbfa44996e5113227a6972be695f3acb86f2e7692c33f657f41617b12508a3523b3427612c55be6c071f56321819387efaf00a57
|
7
|
+
data.tar.gz: f0bbf8ce69ae9165c47a781654bca44904d2261269771fe117276ed9b63e6e857fe03717015e52100fa545d7c49c2a5658ca355d64a090dfc484ea6811a77b21
|
data/config/cookstyle.yml
CHANGED
@@ -489,6 +489,15 @@ Chef/Correctness/MetadataMalformedDepends:
|
|
489
489
|
Include:
|
490
490
|
- '**/metadata.rb'
|
491
491
|
|
492
|
+
Chef/Correctness/PowershellFileExists:
|
493
|
+
Description: Use Ruby's built-in `File.exist?('C:\somefile') instead of executing PowerShell's `Test-Path` cmdlet, which takes longer to load.
|
494
|
+
StyleGuide: 'chef_correctness_powershellfileexists'
|
495
|
+
Enabled: true
|
496
|
+
VersionAdded: '7.19'
|
497
|
+
Exclude:
|
498
|
+
- '**/metadata.rb'
|
499
|
+
- '**/Berksfile'
|
500
|
+
|
492
501
|
###############################
|
493
502
|
# Chef/Sharing: Issues that prevent sharing code with other teams or with the Chef community in general
|
494
503
|
###############################
|
@@ -1263,7 +1272,7 @@ Chef/Modernize/WhyRunSupportedTrue:
|
|
1263
1272
|
- '**/libraries/*.rb'
|
1264
1273
|
|
1265
1274
|
Chef/Modernize/UnnecessaryDependsChef14:
|
1266
|
-
Description: Don't depend on cookbooks made obsolete by Chef Infra Client 14+. These community cookbooks contain resources that are now included in Chef Infra Client itself.
|
1275
|
+
Description: Don't depend on cookbooks made obsolete by Chef Infra Client 14.0+. These community cookbooks contain resources that are now included in Chef Infra Client itself.
|
1267
1276
|
StyleGuide: 'chef_modernize_unnecessarydependschef14'
|
1268
1277
|
Enabled: true
|
1269
1278
|
VersionAdded: '5.1.0'
|
@@ -1389,7 +1398,7 @@ Chef/Modernize/SevenZipArchiveResource:
|
|
1389
1398
|
- '**/metadata.rb'
|
1390
1399
|
|
1391
1400
|
Chef/Modernize/LibarchiveFileResource:
|
1392
|
-
Description: Use the archive_file resource built into Chef Infra Client 15+ instead of the libarchive file resource
|
1401
|
+
Description: Use the archive_file resource built into Chef Infra Client 15+ instead of the libarchive file resource from the libarchive cookbook
|
1393
1402
|
StyleGuide: 'chef_modernize_libarchivefileresource'
|
1394
1403
|
Enabled: true
|
1395
1404
|
VersionAdded: '5.5.0'
|
@@ -1799,6 +1808,46 @@ Chef/Modernize/ActionMethodInResource:
|
|
1799
1808
|
- '**/resources/*.rb'
|
1800
1809
|
- '**/providers/*.rb'
|
1801
1810
|
|
1811
|
+
Chef/Modernize/UnnecessaryDependsChef15:
|
1812
|
+
Description: Don't depend on cookbooks made obsolete by Chef Infra Client 15.0+. These community cookbooks contain resources that are now included in Chef Infra Client itself.
|
1813
|
+
StyleGuide: 'chef_modernize_unnecessarydependschef15'
|
1814
|
+
Enabled: true
|
1815
|
+
VersionAdded: '7.19.0'
|
1816
|
+
Include:
|
1817
|
+
- '**/metadata.rb'
|
1818
|
+
|
1819
|
+
Chef/Modernize/DependsOnLocaleCookbook:
|
1820
|
+
Description: Don't depend on the locale cookbook made obsolete by Chef Infra Client 14.5. The locale resource is now included in Chef Infra Client itself.
|
1821
|
+
StyleGuide: 'chef_modernize_dependsonlocalecookbook'
|
1822
|
+
Enabled: true
|
1823
|
+
VersionAdded: '7.19.0'
|
1824
|
+
Include:
|
1825
|
+
- '**/metadata.rb'
|
1826
|
+
|
1827
|
+
Chef/Modernize/DependsOnTimezoneLwrpCookbook:
|
1828
|
+
Description: Don't depend on the timezone_lwrp cookbook made obsolete by Chef Infra Client 14.6. The timezone resource is now included in Chef Infra Client itself.
|
1829
|
+
StyleGuide: 'chef_modernize_dependsontimezonelwrpcookbook'
|
1830
|
+
Enabled: true
|
1831
|
+
VersionAdded: '7.19.0'
|
1832
|
+
Include:
|
1833
|
+
- '**/metadata.rb'
|
1834
|
+
|
1835
|
+
Chef/Modernize/DependsOnWindowsFirewallCookbook:
|
1836
|
+
Description: Don't depend on the windows_firewall cookbook made obsolete by Chef Infra Client 14.7. The windows_firewall resource is now included in Chef Infra Client itself.
|
1837
|
+
StyleGuide: 'chef_modernize_dependsonwindowsfirewallcookbook'
|
1838
|
+
Enabled: true
|
1839
|
+
VersionAdded: '7.19.0'
|
1840
|
+
Include:
|
1841
|
+
- '**/metadata.rb'
|
1842
|
+
|
1843
|
+
Chef/Modernize/DependsOnKernelModuleCookbook:
|
1844
|
+
Description: Don't depend on the kernel_module cookbook made obsolete by Chef Infra Client 14.3. The kernel_module resource is now included in Chef Infra Client itself.
|
1845
|
+
StyleGuide: 'chef_modernize_dependsonkernelmodulecookbook'
|
1846
|
+
Enabled: true
|
1847
|
+
VersionAdded: '7.19.0'
|
1848
|
+
Include:
|
1849
|
+
- '**/metadata.rb'
|
1850
|
+
|
1802
1851
|
###############################
|
1803
1852
|
# Chef/RedundantCode: Cleanup unnecessary code in your cookbooks regardless of Chef Infra Client release
|
1804
1853
|
###############################
|
data/lib/cookstyle/version.rb
CHANGED
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Copyright:: 2021, Chef Software, Inc.
|
4
|
+
# Author:: Tim Smith (<tsmith@chef.io>)
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
module RuboCop
|
19
|
+
module Cop
|
20
|
+
module Chef
|
21
|
+
module Correctness
|
22
|
+
# Use Ruby's built-in `File.exist?('C:\somefile') instead of executing PowerShell's `Test-Path` cmdlet, which takes longer to load.
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
#
|
26
|
+
# #### incorrect
|
27
|
+
# powershell_out('Test-Path "C:\\Program Files\\LAPS\\CSE\\AdmPwd.dll"').stdout.strip == 'True'
|
28
|
+
#
|
29
|
+
# #### correct
|
30
|
+
# ::File.exist?('C:\Program Files\LAPS\CSE\AdmPwd.dll')
|
31
|
+
#
|
32
|
+
class PowershellFileExists < Base
|
33
|
+
RESTRICT_ON_SEND = [:powershell_out, :powershell_out!].freeze
|
34
|
+
MSG = "Use Ruby's built-in `File.exist?('C:\somefile') instead of executing PowerShell's `Test-Path` cmdlet, which takes longer to load."
|
35
|
+
|
36
|
+
def_node_matcher :powershell_out_exists?, <<-PATTERN
|
37
|
+
(send nil? {:powershell_out :powershell_out!} (str $_))
|
38
|
+
PATTERN
|
39
|
+
|
40
|
+
def on_send(node)
|
41
|
+
powershell_out_exists?(node) do |exists_string|
|
42
|
+
return unless exists_string.match?(/^Test-Path/)
|
43
|
+
add_offense(node, message: MSG, severity: :refactor)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -19,7 +19,7 @@ module RuboCop
|
|
19
19
|
module Cop
|
20
20
|
module Chef
|
21
21
|
module Modernize
|
22
|
-
# Don't depend on cookbooks made obsolete by Chef Infra Client 14
|
22
|
+
# Don't depend on cookbooks made obsolete by Chef Infra Client 14.0+ These community cookbooks contain resources that are now included in Chef Infra Client itself.
|
23
23
|
#
|
24
24
|
# @example
|
25
25
|
#
|
@@ -39,7 +39,7 @@ module RuboCop
|
|
39
39
|
|
40
40
|
minimum_target_chef_version '14.0'
|
41
41
|
|
42
|
-
MSG = "Don't depend on cookbooks made obsolete by Chef Infra Client 14+. These community cookbooks contain resources that are now included in Chef Infra Client itself."
|
42
|
+
MSG = "Don't depend on cookbooks made obsolete by Chef Infra Client 14.0+. These community cookbooks contain resources that are now included in Chef Infra Client itself."
|
43
43
|
RESTRICT_ON_SEND = [:depends].freeze
|
44
44
|
|
45
45
|
def_node_matcher :legacy_depends?, <<-PATTERN
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Copyright:: 2021, Chef Software, Inc.
|
4
|
+
# Author:: Tim Smith (<tsmith@chef.io>)
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
module RuboCop
|
19
|
+
module Cop
|
20
|
+
module Chef
|
21
|
+
module Modernize
|
22
|
+
# Don't depend on cookbooks made obsolete by Chef Infra Client 15.0+. These community cookbooks contain resources that are now included in Chef Infra Client itself.
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
#
|
26
|
+
# #### incorrect
|
27
|
+
# depends 'libarchive'
|
28
|
+
# depends 'windows_dns'
|
29
|
+
# depends 'windows_uac'
|
30
|
+
# depends 'windows_dfs'
|
31
|
+
#
|
32
|
+
class UnnecessaryDependsChef15 < Base
|
33
|
+
extend AutoCorrector
|
34
|
+
extend TargetChefVersion
|
35
|
+
include RangeHelp
|
36
|
+
|
37
|
+
minimum_target_chef_version '15.0'
|
38
|
+
|
39
|
+
MSG = "Don't depend on cookbooks made obsolete by Chef Infra Client 15.0+. These community cookbooks contain resources that are now included in Chef Infra Client itself."
|
40
|
+
RESTRICT_ON_SEND = [:depends].freeze
|
41
|
+
|
42
|
+
def_node_matcher :legacy_depends?, <<-PATTERN
|
43
|
+
(send nil? :depends (str {"libarchive" "windows_dns" "windows_uac" "windows_dfs"}) ... )
|
44
|
+
PATTERN
|
45
|
+
|
46
|
+
def on_send(node)
|
47
|
+
legacy_depends?(node) do
|
48
|
+
add_offense(node, message: MSG, severity: :refactor) do |corrector|
|
49
|
+
corrector.remove(range_with_surrounding_space(range: node.loc.expression, side: :left))
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Copyright:: 2021, Chef Software, Inc.
|
4
|
+
# Author:: Tim Smith (<tsmith@chef.io>)
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
module RuboCop
|
19
|
+
module Cop
|
20
|
+
module Chef
|
21
|
+
module Modernize
|
22
|
+
# Don't depend on the kernel_module cookbook made obsolete by Chef Infra Client 14.3. The kernel_module resource is now included in Chef Infra Client itself.
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
#
|
26
|
+
# #### incorrect
|
27
|
+
# depends 'kernel_module'
|
28
|
+
#
|
29
|
+
class DependsOnKernelModuleCookbook < Base
|
30
|
+
extend AutoCorrector
|
31
|
+
extend TargetChefVersion
|
32
|
+
include RangeHelp
|
33
|
+
|
34
|
+
minimum_target_chef_version '14.3'
|
35
|
+
|
36
|
+
MSG = "Don't depend on the kernel_module cookbook made obsolete by Chef Infra Client 14.3. The kernel_module resource is now included in Chef Infra Client itself."
|
37
|
+
RESTRICT_ON_SEND = [:depends].freeze
|
38
|
+
|
39
|
+
def_node_matcher :legacy_depends?, <<-PATTERN
|
40
|
+
(send nil? :depends (str "kernel_module") ... )
|
41
|
+
PATTERN
|
42
|
+
|
43
|
+
def on_send(node)
|
44
|
+
legacy_depends?(node) do
|
45
|
+
add_offense(node, message: MSG, severity: :refactor) do |corrector|
|
46
|
+
corrector.remove(range_with_surrounding_space(range: node.loc.expression, side: :left))
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Copyright:: 2021, Chef Software, Inc.
|
4
|
+
# Author:: Tim Smith (<tsmith@chef.io>)
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
module RuboCop
|
19
|
+
module Cop
|
20
|
+
module Chef
|
21
|
+
module Modernize
|
22
|
+
# Don't depend on the locale cookbook made obsolete by Chef Infra Client 14.5. The locale resource is now included in Chef Infra Client itself.
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
#
|
26
|
+
# #### incorrect
|
27
|
+
# depends 'locale'
|
28
|
+
#
|
29
|
+
class DependsOnLocaleCookbook < Base
|
30
|
+
extend AutoCorrector
|
31
|
+
extend TargetChefVersion
|
32
|
+
include RangeHelp
|
33
|
+
|
34
|
+
minimum_target_chef_version '14.5'
|
35
|
+
|
36
|
+
MSG = "Don't depend on the locale cookbook made obsolete by Chef Infra Client 14.5. The locale resource is now included in Chef Infra Client itself."
|
37
|
+
RESTRICT_ON_SEND = [:depends].freeze
|
38
|
+
|
39
|
+
def_node_matcher :legacy_depends?, <<-PATTERN
|
40
|
+
(send nil? :depends (str "locale") ... )
|
41
|
+
PATTERN
|
42
|
+
|
43
|
+
def on_send(node)
|
44
|
+
legacy_depends?(node) do
|
45
|
+
add_offense(node, message: MSG, severity: :refactor) do |corrector|
|
46
|
+
corrector.remove(range_with_surrounding_space(range: node.loc.expression, side: :left))
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Copyright:: 2021, Chef Software, Inc.
|
4
|
+
# Author:: Tim Smith (<tsmith@chef.io>)
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
module RuboCop
|
19
|
+
module Cop
|
20
|
+
module Chef
|
21
|
+
module Modernize
|
22
|
+
# Don't depend on the timezone_lwrp cookbook made obsolete by Chef Infra Client 14.6. The timezone resource is now included in Chef Infra Client itself.
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
#
|
26
|
+
# #### incorrect
|
27
|
+
# depends 'timezone_lwrp'
|
28
|
+
#
|
29
|
+
class DependsOnTimezoneLwrpCookbook < Base
|
30
|
+
extend AutoCorrector
|
31
|
+
extend TargetChefVersion
|
32
|
+
include RangeHelp
|
33
|
+
|
34
|
+
minimum_target_chef_version '14.6'
|
35
|
+
|
36
|
+
MSG = "Don't depend on the timezone_lwrp cookbook made obsolete by Chef Infra Client 14.6. The timezone resource is now included in Chef Infra Client itself."
|
37
|
+
RESTRICT_ON_SEND = [:depends].freeze
|
38
|
+
|
39
|
+
def_node_matcher :legacy_depends?, <<-PATTERN
|
40
|
+
(send nil? :depends (str "timezone_lwrp") ... )
|
41
|
+
PATTERN
|
42
|
+
|
43
|
+
def on_send(node)
|
44
|
+
legacy_depends?(node) do
|
45
|
+
add_offense(node, message: MSG, severity: :refactor) do |corrector|
|
46
|
+
corrector.remove(range_with_surrounding_space(range: node.loc.expression, side: :left))
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Copyright:: 2021, Chef Software, Inc.
|
4
|
+
# Author:: Tim Smith (<tsmith@chef.io>)
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
module RuboCop
|
19
|
+
module Cop
|
20
|
+
module Chef
|
21
|
+
module Modernize
|
22
|
+
# Don't depend on the windows_firewall cookbook made obsolete by Chef Infra Client 14.7. The windows_firewall resource is now included in Chef Infra Client itself.
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
#
|
26
|
+
# #### incorrect
|
27
|
+
# depends 'windows_firewall'
|
28
|
+
#
|
29
|
+
class DependsOnWindowsFirewallCookbook < Base
|
30
|
+
extend AutoCorrector
|
31
|
+
extend TargetChefVersion
|
32
|
+
include RangeHelp
|
33
|
+
|
34
|
+
minimum_target_chef_version '14.7'
|
35
|
+
|
36
|
+
MSG = "Don't depend on the windows_firewall cookbook made obsolete by Chef Infra Client 14.7. The windows_firewall resource is now included in Chef Infra Client itself."
|
37
|
+
RESTRICT_ON_SEND = [:depends].freeze
|
38
|
+
|
39
|
+
def_node_matcher :legacy_depends?, <<-PATTERN
|
40
|
+
(send nil? :depends (str "windows_firewall") ... )
|
41
|
+
PATTERN
|
42
|
+
|
43
|
+
def on_send(node)
|
44
|
+
legacy_depends?(node) do
|
45
|
+
add_offense(node, message: MSG, severity: :refactor) do |corrector|
|
46
|
+
corrector.remove(range_with_surrounding_space(range: node.loc.expression, side: :left))
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -19,11 +19,13 @@ module RuboCop
|
|
19
19
|
module Cop
|
20
20
|
module Chef
|
21
21
|
module Modernize
|
22
|
-
# Use the archive_file resource built into Chef Infra Client 15+ instead of the libarchive_file resource.
|
22
|
+
# Use the archive_file resource built into Chef Infra Client 15+ instead of the libarchive_file resource from the libarchive cookbook.
|
23
23
|
#
|
24
24
|
# @example
|
25
25
|
#
|
26
26
|
# #### incorrect
|
27
|
+
# depends 'libarchive'
|
28
|
+
#
|
27
29
|
# libarchive_file "C:\file.zip" do
|
28
30
|
# path 'C:\expand_here'
|
29
31
|
# end
|
@@ -39,7 +41,7 @@ module RuboCop
|
|
39
41
|
|
40
42
|
minimum_target_chef_version '15.0'
|
41
43
|
|
42
|
-
MSG = 'Use the archive_file resource built into Chef Infra Client 15+ instead of the libarchive file resource'
|
44
|
+
MSG = 'Use the archive_file resource built into Chef Infra Client 15+ instead of the libarchive file resource from the libarchive cookbook'
|
43
45
|
RESTRICT_ON_SEND = [:libarchive_file, :notifies, :subscribes].freeze
|
44
46
|
|
45
47
|
def_node_matcher :notification_property?, <<-PATTERN
|
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: 7.
|
4
|
+
version: 7.19.0
|
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: 2021-08-
|
12
|
+
date: 2021-08-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rubocop
|
@@ -78,6 +78,7 @@ files:
|
|
78
78
|
- lib/rubocop/cop/chef/correctness/octal_mode_as_string.rb
|
79
79
|
- lib/rubocop/cop/chef/correctness/openssl_password_helpers.rb
|
80
80
|
- lib/rubocop/cop/chef/correctness/powershell_delete_file.rb
|
81
|
+
- lib/rubocop/cop/chef/correctness/powershell_file_exists.rb
|
81
82
|
- lib/rubocop/cop/chef/correctness/property_without_type.rb
|
82
83
|
- lib/rubocop/cop/chef/correctness/resource_sets_internal_properties.rb
|
83
84
|
- lib/rubocop/cop/chef/correctness/resource_sets_name_property.rb
|
@@ -175,6 +176,7 @@ files:
|
|
175
176
|
- lib/rubocop/cop/chef/modernize/berksfile_source.rb
|
176
177
|
- lib/rubocop/cop/chef/modernize/build_essential.rb
|
177
178
|
- lib/rubocop/cop/chef/modernize/chef_14_resources.rb
|
179
|
+
- lib/rubocop/cop/chef/modernize/chef_15_resources.rb
|
178
180
|
- lib/rubocop/cop/chef/modernize/chef_gem_nokogiri.rb
|
179
181
|
- lib/rubocop/cop/chef/modernize/compile_time_resources.rb
|
180
182
|
- lib/rubocop/cop/chef/modernize/conditional_using_test.rb
|
@@ -184,6 +186,10 @@ files:
|
|
184
186
|
- lib/rubocop/cop/chef/modernize/default_action_initializer.rb
|
185
187
|
- lib/rubocop/cop/chef/modernize/defines_chefspec_matchers.rb
|
186
188
|
- lib/rubocop/cop/chef/modernize/definitions.rb
|
189
|
+
- lib/rubocop/cop/chef/modernize/depends_kernel_module_cookbook.rb
|
190
|
+
- lib/rubocop/cop/chef/modernize/depends_locale_cookbook.rb
|
191
|
+
- lib/rubocop/cop/chef/modernize/depends_timezone_lwrp_cookbook.rb
|
192
|
+
- lib/rubocop/cop/chef/modernize/depends_windows_firewall_cookbook.rb
|
187
193
|
- lib/rubocop/cop/chef/modernize/depends_zypper_cookbook.rb
|
188
194
|
- lib/rubocop/cop/chef/modernize/dsl_include_in_resource.rb
|
189
195
|
- lib/rubocop/cop/chef/modernize/empty_resource_initialize.rb
|