cookstyle 7.17.0 → 7.18.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0c717dffb3528a52a96f90cdfc26f3230a0b621314b1ede81ee2bc907f6e6afa
4
- data.tar.gz: 6ffb9d37305d351d6c0512dd070516ebb8d741ba178358cdf38c05ae4c470d4f
3
+ metadata.gz: e1efe7fb1177e49d1ee5f83fef4238438ad397342bf04e4aa1efa705b567ebc2
4
+ data.tar.gz: 0a5899ba6f505c59470620c738affb9a5642258ede37d690fb6270b81b89c8d1
5
5
  SHA512:
6
- metadata.gz: 2eb06bb46004aa146557e2aae9b95065ad238820b5e832c2bad1fe7c13ce652d43adfd3a18073051b4a575ddfd54b719cd2c5af93e1557fac6e8b987d5801392
7
- data.tar.gz: ccf7386507af4bee4e860a40ecc82e0e5a916de30eb3cc2d3e1a4550736f541018546310779c347b0e18db6c9afca6294840d3ed9ee86ab19070d0bf423dbf2e
6
+ metadata.gz: e96d0dc478cb7ff1b75d04bbeee4bd35b66a88f4f930b738f92edbb908df7f002878688253a28473da39ccac587c950fa4c694e5f3f400d693ae54340029a5cd
7
+ data.tar.gz: adf2a361b46f9c47c47343990a677bac16161f1d53b76f23cadea0ba22b708d6d131f227350a058a42d9be690fedf0f264f0f4231f4d7bb9fa2bf088c1cef802
data/config/cookstyle.yml CHANGED
@@ -1225,6 +1225,18 @@ Chef/Deprecations/PolicyfileCommunitySource:
1225
1225
  Include:
1226
1226
  - '**/Policyfile.rb'
1227
1227
 
1228
+ Chef/Deprecations/DeprecatedSudoActions:
1229
+ Description: The `sudo` resource in the sudo cookbook 5.0 (2018) or Chef Infra Client 14 and later have replaced the existing `:install` and `:remove` actions with `:create` and `:delete` actions to better match other resources in Chef Infra.
1230
+ StyleGuide: 'chef_deprecations_deprecatedsudoactions'
1231
+ Enabled: true
1232
+ VersionAdded: '7.18.0'
1233
+ Exclude:
1234
+ - '**/spec/**/*.rb'
1235
+ - '**/metadata.rb'
1236
+ - '**/attributes/*.rb'
1237
+ - '**/Berksfile'
1238
+ - '**/Rakefile'
1239
+
1228
1240
  ###############################
1229
1241
  # Chef/Modernize: Cleaning up legacy code and using new built-in resources
1230
1242
  ###############################
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  module Cookstyle
3
- VERSION = "7.17.0" # rubocop: disable Style/StringLiterals
3
+ VERSION = "7.18.0" # rubocop: disable Style/StringLiterals
4
4
  RUBOCOP_VERSION = '1.19.0'
5
5
  end
@@ -0,0 +1,65 @@
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 Deprecations
22
+ # The `sudo` resource in the sudo cookbook 5.0 (2018) or Chef Infra Client 14 and later have replaced the existing `:install` and `:remove` actions with `:create` and `:delete` actions to better match other resources in Chef Infra.
23
+ #
24
+ # @example
25
+ #
26
+ # #### incorrect
27
+ # sudo 'admins' do
28
+ # users 'bob'
29
+ # groups 'sysadmins, superusers'
30
+ # action :remove
31
+ # end
32
+ #
33
+ # #### correct
34
+ # sudo 'admins' do
35
+ # users 'bob'
36
+ # groups 'sysadmins, superusers'
37
+ # action :delete
38
+ # end
39
+ #
40
+ class DeprecatedSudoActions < Base
41
+ include RuboCop::Chef::CookbookHelpers
42
+ extend TargetChefVersion
43
+ extend AutoCorrector
44
+
45
+ minimum_target_chef_version '14.0'
46
+
47
+ MSG = 'The `sudo` resource in the sudo cookbook 5.0 (2018) or Chef Infra Client 14 and later have replaced the existing `:install` and `:remove` actions with `:create` and `:delete` actions to better match other resources in Chef Infra.'
48
+
49
+ def on_block(node)
50
+ match_property_in_resource?(:sudo, 'action', node) do |prop_node|
51
+ next unless prop_node.arguments.first.sym_type?
52
+ next unless [s(:sym, :install), s(:sym, :remove)].include?(prop_node.arguments.first)
53
+
54
+ add_offense(prop_node, message: MSG, severity: :warning) do |corrector|
55
+ corrector.replace(prop_node, prop_node.source
56
+ .gsub('install', 'create')
57
+ .gsub('remove', 'delete'))
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
65
+ 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: 7.17.0
4
+ version: 7.18.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 00:00:00.000000000 Z
12
+ date: 2021-08-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rubocop
@@ -106,6 +106,7 @@ files:
106
106
  - lib/rubocop/cop/chef/deprecation/deprecated_mixins.rb
107
107
  - lib/rubocop/cop/chef/deprecation/deprecated_platform_methods.rb
108
108
  - lib/rubocop/cop/chef/deprecation/deprecated_shellout_methods.rb
109
+ - lib/rubocop/cop/chef/deprecation/deprecated_sudo_actions.rb
109
110
  - lib/rubocop/cop/chef/deprecation/deprecated_windows_version_check.rb
110
111
  - lib/rubocop/cop/chef/deprecation/deprecated_yum_repository_actions.rb
111
112
  - lib/rubocop/cop/chef/deprecation/deprecated_yum_repository_properties.rb