cookstyle 7.23.0 → 7.24.1
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 +4 -4
- data/config/cookstyle.yml +9 -0
- data/lib/cookstyle/version.rb +1 -1
- data/lib/rubocop/cop/chef/modernize/use_chef_language_cloud_helpers.rb +3 -0
- data/lib/rubocop/cop/chef/modernize/use_chef_language_env_helpers.rb +3 -0
- data/lib/rubocop/cop/chef/modernize/use_chef_language_systemd_helper.rb +60 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f15883e8b06ca175e673c9bc97a1d33f2e79da76a8f9a3a60ee0262868890ac3
|
4
|
+
data.tar.gz: 518d0db21d8525486fc3406898afecd84bb6d27b52ea49c155a4b8000af39cdb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53bde638d1b3829cfece0f84c9d9d25cc69c6d775181155ef154fcc40b310daefb1a01ed424db39e16fcff7fb61fe01469ee3b6cf8d1e320b2dd58f212b70145
|
7
|
+
data.tar.gz: d24b861cf7b56441c16e2be78fc97650ab093b70fc7734c8b3ee8fa889f2e60406026e23af3b19da3984c4050bf2c1e763d50d5f09a59c55af61bee4cc88e577
|
data/config/cookstyle.yml
CHANGED
@@ -1924,6 +1924,15 @@ Chef/Modernize/ClassEvalActionClass:
|
|
1924
1924
|
Include:
|
1925
1925
|
- '**/resources/*.rb'
|
1926
1926
|
|
1927
|
+
Chef/Modernize/UseChefLanguageSystemdHelper:
|
1928
|
+
Description: Chef Infra Client 15.5 and later include a `systemd?` helper for checking if a Linux system uses systemd.
|
1929
|
+
StyleGuide: 'chef_modernize_usecheflanguagesystemdhelper'
|
1930
|
+
Enabled: true
|
1931
|
+
VersionAdded: '7.24.0'
|
1932
|
+
Exclude:
|
1933
|
+
- '**/metadata.rb'
|
1934
|
+
- '**/Berksfile'
|
1935
|
+
|
1927
1936
|
###############################
|
1928
1937
|
# Chef/RedundantCode: Cleanup unnecessary code in your cookbooks regardless of Chef Infra Client release
|
1929
1938
|
###############################
|
data/lib/cookstyle/version.rb
CHANGED
@@ -49,6 +49,9 @@ module RuboCop
|
|
49
49
|
#
|
50
50
|
class UseChefLanguageCloudHelpers < Base
|
51
51
|
extend AutoCorrector
|
52
|
+
extend TargetChefVersion
|
53
|
+
|
54
|
+
minimum_target_chef_version '15.5'
|
52
55
|
|
53
56
|
MSG = 'Chef Infra Client 15.5 and later include cloud helpers to make detecting instances that run on public and private clouds easier.'
|
54
57
|
RESTRICT_ON_SEND = [:==, :[]].freeze
|
@@ -0,0 +1,60 @@
|
|
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
|
+
# Chef Infra Client 15.5 and later include a `systemd?` helper for checking if a Linux system uses systemd.
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
#
|
26
|
+
# #### incorrect
|
27
|
+
# node['init_package'] == 'systemd'
|
28
|
+
#
|
29
|
+
# #### correct
|
30
|
+
# systemd?
|
31
|
+
#
|
32
|
+
class UseChefLanguageSystemdHelper < Base
|
33
|
+
extend AutoCorrector
|
34
|
+
extend TargetChefVersion
|
35
|
+
|
36
|
+
minimum_target_chef_version '15.5'
|
37
|
+
|
38
|
+
MSG = 'Chef Infra Client 15.5 and later include a `systemd?` helper for checking if a Linux system uses systemd.'
|
39
|
+
RESTRICT_ON_SEND = [:==].freeze
|
40
|
+
|
41
|
+
def_node_matcher :node_init_package?, <<-PATTERN
|
42
|
+
(send
|
43
|
+
(send
|
44
|
+
(send nil? :node) :[]
|
45
|
+
(str "init_package")) :==
|
46
|
+
(str "systemd"))
|
47
|
+
PATTERN
|
48
|
+
|
49
|
+
def on_send(node)
|
50
|
+
node_init_package?(node) do |_cloud_name|
|
51
|
+
add_offense(node, message: MSG, severity: :refactor) do |corrector|
|
52
|
+
corrector.replace(node, 'systemd?')
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
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.24.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thom May
|
@@ -239,6 +239,7 @@ files:
|
|
239
239
|
- lib/rubocop/cop/chef/modernize/unnecessary_mixlib_shellout_require.rb
|
240
240
|
- lib/rubocop/cop/chef/modernize/use_chef_language_cloud_helpers.rb
|
241
241
|
- lib/rubocop/cop/chef/modernize/use_chef_language_env_helpers.rb
|
242
|
+
- lib/rubocop/cop/chef/modernize/use_chef_language_systemd_helper.rb
|
242
243
|
- lib/rubocop/cop/chef/modernize/use_multipackage_installs.rb
|
243
244
|
- lib/rubocop/cop/chef/modernize/use_require_relative.rb
|
244
245
|
- lib/rubocop/cop/chef/modernize/whyrun_supported_true.rb
|