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 +4 -4
- data/config/cookstyle.yml +12 -0
- data/lib/cookstyle/version.rb +1 -1
- data/lib/rubocop/cop/chef/deprecation/deprecated_sudo_actions.rb +65 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1efe7fb1177e49d1ee5f83fef4238438ad397342bf04e4aa1efa705b567ebc2
|
4
|
+
data.tar.gz: 0a5899ba6f505c59470620c738affb9a5642258ede37d690fb6270b81b89c8d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
###############################
|
data/lib/cookstyle/version.rb
CHANGED
@@ -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.
|
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
|
+
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
|