cookstyle 6.4.4 → 6.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8a8c9e4e7d09afb290f4d894de9960bd1a0ffc1ed116321a5887a49206453029
4
- data.tar.gz: 53389b9ed11b1571f8ce3e8fd108150594d5cb2c6c7e5ef0fc14b3ba2633d8ad
3
+ metadata.gz: 84025c0a2c14cea15521215fabb39dd043ad6de8f1bb712ffa66fd0350287b5f
4
+ data.tar.gz: 1df6c910b7d68aeb649a4e372964047ee059b5220a3db4d1ee3d2a69013c288f
5
5
  SHA512:
6
- metadata.gz: 9a5a62cc80a0ebc6af299114f25b1d47af14dc857dc206e5281ee167f49207b8399a962addc8b942c8e14bd7055ea97830861e2419ad05da179e961d25c4ccec
7
- data.tar.gz: cc44d7eb2418c84131f1916de9a15b83fcd5511ccbc3e19e2eb2103f53e09fd3df2d0828dda31e4b0affe43087abc009d0ec35052e1e63a6aca884ec1c51b2ea
6
+ metadata.gz: f71145c0012b288b97112ba4bf0e0255b53f2e0d2e6d8e460bd182eaa7d8f41213cd91420e7b759b1c8cd7883ee5727b54dc7aa7cc54d93986691b3f8d729e78
7
+ data.tar.gz: 4ec0deaaf4c3aad4de6f88c988c90f502682c6f944d19c199a82c735cbee651c2e3b1088bcef5ebe694674a6d04d44735d6792aba005059336f4bde83631f4c2
@@ -834,6 +834,14 @@ ChefDeprecations/DeprecatedShelloutMethods:
834
834
  - '**/attributes/*.rb'
835
835
  - '**/Berksfile'
836
836
 
837
+ ChefDeprecations/Ruby27KeywordArgumentWarnings:
838
+ Description: Pass options to shell_out helpers without the brackets to avoid Ruby 2.7 deprecation warnings.
839
+ Enabled: true
840
+ VersionAdded: '6.5.0'
841
+ Exclude:
842
+ - '**/metadata.rb'
843
+ - '**/Berksfile'
844
+
837
845
  ###############################
838
846
  # ChefModernize: Cleaning up legacy code and using new built-in resources
839
847
  ###############################
@@ -1293,6 +1301,15 @@ ChefModernize/RespondToCompileTime:
1293
1301
  - '**/metadata.rb'
1294
1302
  - '**/Berksfile'
1295
1303
 
1304
+ ChefModernize/ShellOutHelper:
1305
+ Description: Use the built-in shell_out helper available in Chef Infra Client 12.11+ instead of calling Mixlib::ShellOut.new('foo').run_command.
1306
+ Enabled: true
1307
+ VersionAdded: '6.5.0'
1308
+ Exclude:
1309
+ - '**/metadata.rb'
1310
+ - '**/Berksfile'
1311
+ - '**/libraries/*.rb'
1312
+
1296
1313
  ###############################
1297
1314
  # ChefRedundantCode: Cleanup unnecessary code in your cookbooks regardless of Chef Infra Client release
1298
1315
  ###############################
@@ -1,4 +1,4 @@
1
1
  module Cookstyle
2
- VERSION = "6.4.4".freeze # rubocop: disable Style/StringLiterals
2
+ VERSION = "6.5.3".freeze # rubocop: disable Style/StringLiterals
3
3
  RUBOCOP_VERSION = '0.83.0'.freeze
4
4
  end
@@ -47,22 +47,28 @@ module RuboCop
47
47
  '> 16.04, < 18.04' => true,
48
48
  },
49
49
  'fedora' => {
50
- '< 30' => '30',
50
+ '< 31' => '31',
51
51
  },
52
52
  'freebsd' => {
53
- '< 11' => '12',
53
+ '~> 11.0, < 11.2' => '11',
54
+ '= 12.0' => '12',
55
+ '< 11' => true,
54
56
  },
55
57
  'mac_os_x' => {
56
58
  '< 10.12' => '10.15',
57
59
  },
60
+ 'suse' => {
61
+ '~> 12.0, < 12.4' => '12',
62
+ '< 12' => true,
63
+ },
58
64
  'opensuse' => {
59
65
  '< 14' => true,
60
66
  '~> 42.0' => true,
61
67
  },
62
68
  'debian' => {
63
69
  '< 8' => true,
64
- '> 8.0, < 8.9' => '8',
65
- '> 9.0, < 9.8' => '9',
70
+ '> 8.0, < 8.10' => '8',
71
+ '> 9.0, < 9.9' => '9',
66
72
  },
67
73
  'centos' => {
68
74
  '< 6.0' => true,
@@ -0,0 +1,59 @@
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
+
18
+ module RuboCop
19
+ module Cop
20
+ module Chef
21
+ module ChefDeprecations
22
+ # Pass options to shell_out helpers without the brackets to avoid Ruby 2.7 deprecation warnings.
23
+ #
24
+ # @example
25
+ #
26
+ # # bad
27
+ # shell_out!('hostnamectl status', { returns: [0, 1] })
28
+ # shell_out('hostnamectl status', { returns: [0, 1] })
29
+ #
30
+ # # good
31
+ # shell_out!('hostnamectl status', returns: [0, 1])
32
+ # shell_out('hostnamectl status', returns: [0, 1])
33
+ #
34
+ class Ruby27KeywordArgumentWarnings < Cop
35
+ include RuboCop::Chef::CookbookHelpers
36
+
37
+ MSG = 'Pass options to shell_out helpers without the brackets to avoid Ruby 2.7 deprecation warnings.'.freeze
38
+
39
+ def_node_matcher :positional_shellout?, <<-PATTERN
40
+ (send nil? {:shell_out :shell_out!} ... $(hash ... ))
41
+ PATTERN
42
+
43
+ def on_send(node)
44
+ positional_shellout?(node) do |h|
45
+ add_offense(h, location: :expression, message: MSG, severity: :refactor) if h.braces?
46
+ end
47
+ end
48
+
49
+ def autocorrect(node)
50
+ lambda do |corrector|
51
+ # @todo when we drop ruby 2.4 support we can convert to to just delete_prefix delete_suffix
52
+ corrector.replace(node.loc.expression, node.loc.expression.source.gsub(/^{/, '').gsub(/}$/, ''))
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,64 @@
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 ChefModernize
22
+ # Use the built-in `shell_out` helper available in Chef Infra Client 12.11+ instead of calling `Mixlib::ShellOut.new('foo').run_command`.
23
+ #
24
+ # @example
25
+ #
26
+ # # bad
27
+ # Mixlib::ShellOut.new('foo').run_command
28
+ #
29
+ # # good
30
+ # shell_out('foo')
31
+ #
32
+ class ShellOutHelper < Cop
33
+ extend TargetChefVersion
34
+
35
+ minimum_target_chef_version '12.11'
36
+
37
+ MSG = "Use the built-in `shell_out` helper available in Chef Infra Client 12.11+ instead of calling `Mixlib::ShellOut.new('foo').run_command`.".freeze
38
+
39
+ def_node_matcher :mixlib_shellout_run_cmd?, <<-PATTERN
40
+ (send
41
+ (send
42
+ (const
43
+ (const nil? :Mixlib) :ShellOut) :new
44
+ $(...)) :run_command)
45
+ PATTERN
46
+
47
+ def on_send(node)
48
+ mixlib_shellout_run_cmd?(node) do
49
+ add_offense(node, location: :expression, message: MSG, severity: :refactor)
50
+ end
51
+ end
52
+
53
+ def autocorrect(node)
54
+ mixlib_shellout_run_cmd?(node) do |cmd|
55
+ lambda do |corrector|
56
+ corrector.replace(node.loc.expression, "shell_out(#{cmd.loc.expression.source})")
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ 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: 6.4.4
4
+ version: 6.5.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: 2020-05-12 00:00:00.000000000 Z
12
+ date: 2020-05-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rubocop
@@ -118,6 +118,7 @@ files:
118
118
  - lib/rubocop/cop/chef/deprecation/resource_uses_provider_base_method.rb
119
119
  - lib/rubocop/cop/chef/deprecation/resource_uses_updated_method.rb
120
120
  - lib/rubocop/cop/chef/deprecation/resource_without_name_or_provides.rb
121
+ - lib/rubocop/cop/chef/deprecation/ruby_27_keyword_argument_warnings.rb
121
122
  - lib/rubocop/cop/chef/deprecation/ruby_block_create_action.rb
122
123
  - lib/rubocop/cop/chef/deprecation/run_command_helper.rb
123
124
  - lib/rubocop/cop/chef/deprecation/search_uses_positional_parameters.rb
@@ -183,6 +184,7 @@ files:
183
184
  - lib/rubocop/cop/chef/modernize/respond_to_resource_name.rb
184
185
  - lib/rubocop/cop/chef/modernize/sc_windows_resource.rb
185
186
  - lib/rubocop/cop/chef/modernize/seven_zip_archive.rb
187
+ - lib/rubocop/cop/chef/modernize/shell_out_helper.rb
186
188
  - lib/rubocop/cop/chef/modernize/shellouts_to_chocolatey.rb
187
189
  - lib/rubocop/cop/chef/modernize/simplify_apt_ppa_setup.rb
188
190
  - lib/rubocop/cop/chef/modernize/systctl_param_resource.rb