cookstyle 5.8.1 → 5.9.3
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 +23 -1
- data/cookstyle.gemspec +1 -2
- data/lib/cookstyle/version.rb +1 -1
- data/lib/rubocop/cop/chef/deprecation/chef_handler_supports.rb +56 -0
- data/lib/rubocop/cop/chef/deprecation/run_command_helper.rb +46 -0
- data/lib/rubocop/cop/chef/modernize/chef_14_resources.rb +3 -3
- data/lib/rubocop/cop/chef/modernize/powershell_guard_interpreter.rb +59 -0
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4f5eafb40f3af8be2a8af2d128ad4b9788e41c52ab1a410831143ab50d719be
|
4
|
+
data.tar.gz: a580aaee49df70685f9e1f0cf8ca6a71270d81b5277e37a497a572e06cf3aea3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1684945f60801dd046dc16c0b5d813863ae9dd0ec0616a681a23d86e12fe77c5a337d2bce0002a59041afafc2b02f0f3d1a99b338e39c43d940a8fd66302abcb
|
7
|
+
data.tar.gz: db367ba9d75c4dad58daf64759bb361c6da1141131b134d7a3c52e18a21e627f831ef59f274a38842871939a810e78945db0a8d3f821a322f7c3dae6d9323f9c
|
data/config/cookstyle.yml
CHANGED
@@ -499,6 +499,21 @@ ChefDeprecations/ChefSpecLegacyRunner:
|
|
499
499
|
Include:
|
500
500
|
- '**/spec/*.rb'
|
501
501
|
|
502
|
+
ChefDeprecations/UsesRunCommandHelper:
|
503
|
+
Description: Use 'shell_out!' instead of the legacy 'run_command' helper for shelling out. The run_command helper was removed in Chef Infra Client 13.
|
504
|
+
Enabled: true
|
505
|
+
VersionAdded: '5.9.0'
|
506
|
+
Exclude:
|
507
|
+
- '**/metadata.rb'
|
508
|
+
- 'Rakefile'
|
509
|
+
|
510
|
+
ChefDeprecations/ChefHandlerUsesSupports:
|
511
|
+
Description: Use the type property instead of the deprecated supports property in the chef_handler resource. The supports property was removed in chef_handler cookbook version 3.0 (June 2017) and Chef Infra Client 14.0.
|
512
|
+
Enabled: true
|
513
|
+
VersionAdded: '5.9.0'
|
514
|
+
Exclude:
|
515
|
+
- '**/metadata.rb'
|
516
|
+
|
502
517
|
###############################
|
503
518
|
# ChefModernize: Cleaning up legacy code and using new built-in resources
|
504
519
|
###############################
|
@@ -520,7 +535,7 @@ ChefModernize/WhyRunSupportedTrue:
|
|
520
535
|
- '**/libraries/*.rb'
|
521
536
|
|
522
537
|
ChefModernize/UnnecessaryDependsChef14:
|
523
|
-
Description: Don't depend on cookbooks made obsolete by Chef 14
|
538
|
+
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.
|
524
539
|
Enabled: true
|
525
540
|
VersionAdded: '5.1.0'
|
526
541
|
Include:
|
@@ -740,6 +755,13 @@ ChefModernize/MacOsXUserdefaults:
|
|
740
755
|
Exclude:
|
741
756
|
- '**/metadata.rb'
|
742
757
|
|
758
|
+
ChefModernize/PowerShellGuardInterpreter:
|
759
|
+
Description: PowerShell is already set as the default guard interpreter for powershell_script resources in Chef Infra Client 13 and later and does not need to be specified.
|
760
|
+
Enabled: true
|
761
|
+
VersionAdded: '5.9.0'
|
762
|
+
Exclude:
|
763
|
+
- '**/metadata.rb'
|
764
|
+
|
743
765
|
###############################
|
744
766
|
# Migrating to new patterns
|
745
767
|
###############################
|
data/cookstyle.gemspec
CHANGED
@@ -8,8 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Cookstyle::VERSION
|
9
9
|
spec.authors = ['Thom May', 'Tim Smith']
|
10
10
|
spec.email = ['thom@chef.io', 'tsmith@chef.io']
|
11
|
-
|
12
|
-
spec.summary = 'RuboCop configuration for Chef cookbooks'
|
11
|
+
spec.summary = 'Cookstyle is a code linting tool that helps you to write better Chef Infra cookbooks by detecting and automatically correcting style, syntax, and logic mistakes in your code.'
|
13
12
|
spec.homepage = 'https://github.com/chef/cookstyle'
|
14
13
|
spec.license = 'Apache-2.0'
|
15
14
|
spec.required_ruby_version = '>= 2.4'
|
data/lib/cookstyle/version.rb
CHANGED
@@ -0,0 +1,56 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: 2019, 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
|
+
|
18
|
+
module RuboCop
|
19
|
+
module Cop
|
20
|
+
module Chef
|
21
|
+
module ChefDeprecations
|
22
|
+
# Use the type property instead of the deprecated supports property in the chef_handler resource. The supports property was removed in chef_handler cookbook version 3.0 (June 2017) and Chef Infra Client 14.0.
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
#
|
26
|
+
# # bad
|
27
|
+
# chef_handler 'whatever' do
|
28
|
+
# supports start: true, report: true, exception: true
|
29
|
+
# end0
|
30
|
+
#
|
31
|
+
# # good
|
32
|
+
# chef_handler 'whatever' do
|
33
|
+
# type start: true, report: true, exception: true
|
34
|
+
# end
|
35
|
+
#
|
36
|
+
class ChefHandlerUsesSupports < Cop
|
37
|
+
include RuboCop::Chef::CookbookHelpers
|
38
|
+
|
39
|
+
MSG = 'Use the type property instead of the deprecated supports property in the chef_handler resource. The supports property was removed in chef_handler cookbook version 3.0 (June 2017) and Chef Infra Client 14.0.'.freeze
|
40
|
+
|
41
|
+
def on_block(node)
|
42
|
+
match_property_in_resource?('chef_handler', 'supports', node) do |prop_node|
|
43
|
+
add_offense(prop_node, location: :expression, message: MSG, severity: :refactor)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def autocorrect(node)
|
48
|
+
lambda do |corrector|
|
49
|
+
corrector.replace(node.loc.expression, "type #{node.arguments.first.source}")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: 2019, 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
|
+
# Use 'shell_out!' instead of the legacy 'run_command' helper for shelling out. The run_command helper was removed in Chef Infra Client 13.
|
22
|
+
#
|
23
|
+
# @example
|
24
|
+
#
|
25
|
+
# # bad
|
26
|
+
# run_command('/bin/foo')
|
27
|
+
#
|
28
|
+
# # good
|
29
|
+
# shell_out!('/bin/foo')
|
30
|
+
#
|
31
|
+
class UsesRunCommandHelper < Cop
|
32
|
+
MSG = "Use 'shell_out!' instead of the legacy 'run_command' helper for shelling out. The run_command helper was removed in Chef Infra Client 13.".freeze
|
33
|
+
|
34
|
+
def_node_matcher :calls_run_command?, '(send nil? :run_command ...)'
|
35
|
+
def_node_search :defines_run_command?, '(def :run_command ...)'
|
36
|
+
|
37
|
+
def on_send(node)
|
38
|
+
calls_run_command?(node) do
|
39
|
+
add_offense(node, location: :expression, message: MSG, severity: :refactor) unless defines_run_command?(processed_source.ast)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -18,7 +18,7 @@ module RuboCop
|
|
18
18
|
module Cop
|
19
19
|
module Chef
|
20
20
|
module ChefModernize
|
21
|
-
# Don't depend on cookbooks made obsolete by Chef 14
|
21
|
+
# 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.
|
22
22
|
#
|
23
23
|
# @example
|
24
24
|
#
|
@@ -32,10 +32,10 @@ module RuboCop
|
|
32
32
|
# depends 'sysctl'
|
33
33
|
#
|
34
34
|
class UnnecessaryDependsChef14 < Cop
|
35
|
-
MSG = "Don't depend on cookbooks made obsolete by Chef 14".freeze
|
35
|
+
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.".freeze
|
36
36
|
|
37
37
|
def_node_matcher :legacy_depends?, <<-PATTERN
|
38
|
-
(send nil? :depends (str {"build-essential" "chef_handler" "chef_hostname" "dmg" "mac_os_x" "swap" "sysctl"}))
|
38
|
+
(send nil? :depends (str {"build-essential" "chef_handler" "chef_hostname" "dmg" "mac_os_x" "swap" "sysctl"}) ... )
|
39
39
|
PATTERN
|
40
40
|
|
41
41
|
def on_send(node)
|
@@ -0,0 +1,59 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: 2019, 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
|
+
# PowerShell is already set as the default guard interpreter for powershell_script resources in Chef Infra Client 13 and later and does not need to be specified.
|
22
|
+
#
|
23
|
+
# @example
|
24
|
+
#
|
25
|
+
# # bad
|
26
|
+
# powershell_script 'whatever' do
|
27
|
+
# code "mkdir test_dir"
|
28
|
+
# guard_interpreter :powershell_script
|
29
|
+
# end
|
30
|
+
#
|
31
|
+
# # good
|
32
|
+
# powershell_script 'whatever' do
|
33
|
+
# code "mkdir test_dir"
|
34
|
+
# end
|
35
|
+
#
|
36
|
+
class PowerShellGuardInterpreter < Cop
|
37
|
+
include RuboCop::Chef::CookbookHelpers
|
38
|
+
include RangeHelp
|
39
|
+
|
40
|
+
MSG = 'PowerShell is already set as the default guard interpreter for powershell_script resources in Chef Infra Client 13 and later and does not need to be specified.'.freeze
|
41
|
+
|
42
|
+
def on_block(node)
|
43
|
+
match_property_in_resource?(:powershell_script, 'guard_interpreter', node) do |interpreter|
|
44
|
+
if interpreter.arguments.first.source == ':powershell_script'
|
45
|
+
add_offense(interpreter, location: :expression, message: MSG, severity: :refactor)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def autocorrect(node)
|
51
|
+
lambda do |corrector|
|
52
|
+
corrector.remove(range_with_surrounding_space(range: node.loc.expression, side: :left))
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
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.9.3
|
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: 2019-10-
|
12
|
+
date: 2019-10-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rubocop
|
@@ -70,6 +70,7 @@ files:
|
|
70
70
|
- lib/rubocop/cop/chef/correctness/tmp_path.rb
|
71
71
|
- lib/rubocop/cop/chef/correctness/unnecessary_name_property.rb
|
72
72
|
- lib/rubocop/cop/chef/deprecation/attribute_metadata.rb
|
73
|
+
- lib/rubocop/cop/chef/deprecation/chef_handler_supports.rb
|
73
74
|
- lib/rubocop/cop/chef/deprecation/chef_rest.rb
|
74
75
|
- lib/rubocop/cop/chef/deprecation/chefspec_coverage_report.rb
|
75
76
|
- lib/rubocop/cop/chef/deprecation/chefspec_legacy_runner.rb
|
@@ -98,6 +99,7 @@ files:
|
|
98
99
|
- lib/rubocop/cop/chef/deprecation/resource_uses_dsl_name_method.rb
|
99
100
|
- lib/rubocop/cop/chef/deprecation/resource_uses_provider_base_method.rb
|
100
101
|
- lib/rubocop/cop/chef/deprecation/resource_uses_updated_method.rb
|
102
|
+
- lib/rubocop/cop/chef/deprecation/run_command_helper.rb
|
101
103
|
- lib/rubocop/cop/chef/deprecation/suggests_metadata.rb
|
102
104
|
- lib/rubocop/cop/chef/deprecation/use_inline_resources.rb
|
103
105
|
- lib/rubocop/cop/chef/deprecation/user_supports_property.rb
|
@@ -123,6 +125,7 @@ files:
|
|
123
125
|
- lib/rubocop/cop/chef/modernize/openssl_x509_resource.rb
|
124
126
|
- lib/rubocop/cop/chef/modernize/osx_config_profile_resource.rb
|
125
127
|
- lib/rubocop/cop/chef/modernize/powershell_expand_archive.rb
|
128
|
+
- lib/rubocop/cop/chef/modernize/powershell_guard_interpreter.rb
|
126
129
|
- lib/rubocop/cop/chef/modernize/powershell_install_package.rb
|
127
130
|
- lib/rubocop/cop/chef/modernize/powershell_install_windowsfeature.rb
|
128
131
|
- lib/rubocop/cop/chef/modernize/resource_set_or_return.rb
|
@@ -168,5 +171,7 @@ requirements: []
|
|
168
171
|
rubygems_version: 3.0.3
|
169
172
|
signing_key:
|
170
173
|
specification_version: 4
|
171
|
-
summary:
|
174
|
+
summary: Cookstyle is a code linting tool that helps you to write better Chef Infra
|
175
|
+
cookbooks by detecting and automatically correcting style, syntax, and logic mistakes
|
176
|
+
in your code.
|
172
177
|
test_files: []
|