cookstyle 6.18.8 → 6.19.5
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 +19 -0
- data/config/upstream.yml +14 -3
- data/lib/cookstyle.rb +0 -3
- data/lib/cookstyle/version.rb +2 -2
- data/lib/rubocop/cop/chef/correctness/block_guard_clause_string_only.rb +1 -1
- data/lib/rubocop/cop/chef/correctness/chef_application_fatal.rb +1 -1
- data/lib/rubocop/cop/chef/correctness/conditional_ruby_shellout.rb +1 -1
- data/lib/rubocop/cop/chef/correctness/incorrect_library_injection.rb +18 -37
- data/lib/rubocop/cop/chef/correctness/invalid_platform_family_values_in_case.rb +1 -1
- data/lib/rubocop/cop/chef/correctness/invalid_platform_metadata.rb +2 -2
- data/lib/rubocop/cop/chef/correctness/invalid_platform_values_in_case.rb +1 -1
- data/lib/rubocop/cop/chef/correctness/lazy_eval_node_attribute_defaults.rb +1 -1
- data/lib/rubocop/cop/chef/correctness/lazy_in_resource_guard.rb +1 -1
- data/lib/rubocop/cop/chef/correctness/macos_userdefaults_invalid_type.rb +2 -2
- data/lib/rubocop/cop/chef/correctness/notifies_action_not_symbol.rb +1 -1
- data/lib/rubocop/cop/chef/correctness/resource_with_none_action.rb +1 -1
- data/lib/rubocop/cop/chef/correctness/scoped_file_exist.rb +1 -1
- data/lib/rubocop/cop/chef/correctness/supports_must_be_float.rb +2 -2
- data/lib/rubocop/cop/chef/deprecation/chef_handler_supports.rb +1 -1
- data/lib/rubocop/cop/chef/deprecation/chef_rewind.rb +2 -2
- data/lib/rubocop/cop/chef/deprecation/chef_shellout.rb +1 -1
- data/lib/rubocop/cop/chef/deprecation/chef_windows_platform_helper.rb +1 -1
- data/lib/rubocop/cop/chef/deprecation/chefdk_generators.rb +1 -1
- data/lib/rubocop/cop/chef/deprecation/chefspec_coverage_report.rb +1 -1
- data/lib/rubocop/cop/chef/deprecation/chefspec_legacy_runner.rb +1 -1
- data/lib/rubocop/cop/chef/deprecation/deprecated_chefspec_platform.rb +1 -1
- data/lib/rubocop/cop/chef/deprecation/deprecated_yum_repository_properties.rb +1 -1
- data/lib/rubocop/cop/chef/deprecation/epic_fail.rb +1 -1
- data/lib/rubocop/cop/chef/deprecation/execute_path_property.rb +1 -1
- data/lib/rubocop/cop/chef/deprecation/execute_relative_creates_without_cwd.rb +1 -1
- data/lib/rubocop/cop/chef/deprecation/inherits_compat_resource.rb +1 -1
- data/lib/rubocop/cop/chef/deprecation/legacy_notify_syntax.rb +1 -1
- data/lib/rubocop/cop/chef/deprecation/node_methods_not_attributes.rb +1 -1
- data/lib/rubocop/cop/chef/deprecation/powershell_cookbook_helpers.rb +1 -1
- data/lib/rubocop/cop/chef/deprecation/ruby_27_keyword_argument_warnings.rb +2 -2
- data/lib/rubocop/cop/chef/deprecation/ruby_block_create_action.rb +2 -2
- data/lib/rubocop/cop/chef/deprecation/search_uses_positional_parameters.rb +1 -1
- data/lib/rubocop/cop/chef/deprecation/user_supports_property.rb +1 -1
- data/lib/rubocop/cop/chef/deprecation/windows_package_installer_type_string.rb +1 -1
- data/lib/rubocop/cop/chef/deprecation/windows_task_change_action.rb +2 -2
- data/lib/rubocop/cop/chef/deprecation/windows_version_helpers.rb +4 -4
- data/lib/rubocop/cop/chef/deprecation/xml_ruby_recipe.rb +1 -1
- data/lib/rubocop/cop/chef/effortless/chef_vault_used.rb +89 -0
- data/lib/rubocop/cop/chef/effortless/depends_chef_vault.rb +49 -0
- data/lib/rubocop/cop/chef/modernize/action_method_in_resource.rb +2 -2
- data/lib/rubocop/cop/chef/modernize/berksfile_source.rb +2 -2
- data/lib/rubocop/cop/chef/modernize/build_essential.rb +1 -1
- data/lib/rubocop/cop/chef/modernize/conditional_using_test.rb +1 -1
- data/lib/rubocop/cop/chef/modernize/cron_manage_resource.rb +1 -1
- data/lib/rubocop/cop/chef/modernize/databag_helpers.rb +1 -1
- data/lib/rubocop/cop/chef/modernize/foodcritic_comments.rb +1 -1
- data/lib/rubocop/cop/chef/modernize/if_provides_default_action.rb +1 -1
- data/lib/rubocop/cop/chef/modernize/libarchive_file.rb +2 -2
- data/lib/rubocop/cop/chef/modernize/macos_user_defaults.rb +1 -1
- data/lib/rubocop/cop/chef/modernize/node_init_package.rb +3 -3
- data/lib/rubocop/cop/chef/modernize/node_roles_include.rb +1 -1
- data/lib/rubocop/cop/chef/modernize/openssl_rsa_key_resource.rb +1 -1
- data/lib/rubocop/cop/chef/modernize/openssl_x509_resource.rb +1 -1
- data/lib/rubocop/cop/chef/modernize/osx_config_profile_resource.rb +1 -1
- data/lib/rubocop/cop/chef/modernize/property_with_name_attribute.rb +1 -1
- data/lib/rubocop/cop/chef/modernize/respond_to_compile_time.rb +1 -1
- data/lib/rubocop/cop/chef/modernize/respond_to_metadata.rb +5 -5
- data/lib/rubocop/cop/chef/modernize/respond_to_provides.rb +1 -1
- data/lib/rubocop/cop/chef/modernize/respond_to_resource_name.rb +1 -1
- data/lib/rubocop/cop/chef/modernize/shell_out_helper.rb +1 -1
- data/lib/rubocop/cop/chef/modernize/simplify_apt_ppa_setup.rb +1 -1
- data/lib/rubocop/cop/chef/modernize/sysctl_param_resource.rb +1 -1
- data/lib/rubocop/cop/chef/modernize/use_multipackage_installs.rb +1 -1
- data/lib/rubocop/cop/chef/modernize/use_require_relative.rb +1 -1
- data/lib/rubocop/cop/chef/modernize/zypper_repo.rb +1 -1
- data/lib/rubocop/cop/chef/redundant/double_compile_time.rb +1 -1
- data/lib/rubocop/cop/chef/redundant/multiple_platform_checks.rb +1 -1
- data/lib/rubocop/cop/chef/redundant/ohai_attribute_to_string.rb +1 -1
- data/lib/rubocop/cop/chef/redundant/use_create_if_missing.rb +1 -1
- data/lib/rubocop/cop/chef/sharing/include_property_descriptions.rb +1 -1
- data/lib/rubocop/cop/chef/sharing/insecure_cookbook_url.rb +1 -1
- data/lib/rubocop/cop/chef/sharing/invalid_license_string.rb +1 -1
- data/lib/rubocop/cop/chef/style/attribute_keys.rb +1 -1
- data/lib/rubocop/cop/chef/style/chef_whaaat.rb +1 -1
- data/lib/rubocop/cop/chef/style/comment_sentence_spacing.rb +2 -2
- data/lib/rubocop/cop/chef/style/comments_copyright_format.rb +2 -2
- data/lib/rubocop/cop/chef/style/comments_default_copyright.rb +1 -1
- data/lib/rubocop/cop/chef/style/comments_format.rb +6 -13
- data/lib/rubocop/cop/chef/style/file_mode.rb +2 -2
- data/lib/rubocop/cop/chef/style/immediate_notification_timing.rb +2 -2
- data/lib/rubocop/cop/chef/style/include_recipe_with_parentheses.rb +2 -2
- data/lib/rubocop/cop/chef/style/negating_only_if.rb +2 -2
- data/lib/rubocop/cop/chef/style/overly_complex_supports_depends_metadata.rb +2 -2
- data/lib/rubocop/cop/chef/style/simplify_platform_major_version_check.rb +1 -1
- data/lib/rubocop/cop/chef/style/true_false_resource_properties.rb +2 -2
- data/lib/rubocop/cop/chef/style/unnecessary_os_check.rb +4 -4
- data/lib/rubocop/cop/chef/style/unnecessary_platform_case_statement.rb +2 -2
- data/lib/rubocop/cop/chef/style/use_platform_helpers.rb +6 -6
- metadata +6 -5
- data/lib/rubocop/monkey_patches/rescue_ensure_alignment.rb +0 -22
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 47388999a2aa49c2d130f1a553e2d17efec6090b4207e39557fc78acb8c4e5a8
|
|
4
|
+
data.tar.gz: c622b97ecf8c86b337c7bc63ff444c4b305a6a249cc40c598ea800a1ba9cae67
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4b1f192f83d65beb1360ff7df9648176bbc54398b39eb7e8791f0342f5152e5361bae374514fcb60134cb6348101c78047ab53d57efcfad3cccfa60e03de2234
|
|
7
|
+
data.tar.gz: db704725caa2dbfa226e6693bee8ced4adeaaf45d531c5665ff3c602cb7d9b3392676917d814f44b5bb4e7fb015c3c52ce94e812b6ef017fd117210d0ff35252
|
data/config/cookstyle.yml
CHANGED
|
@@ -1929,6 +1929,25 @@ ChefEffortless/CookbookUsesDatabags:
|
|
|
1929
1929
|
Exclude:
|
|
1930
1930
|
- '**/metadata.rb'
|
|
1931
1931
|
- '**/Berksfile'
|
|
1932
|
+
|
|
1933
|
+
# https://github.com/chef/cookstyle/issues/346
|
|
1934
|
+
ChefEffortless/ChefVaultUsed:
|
|
1935
|
+
Description: Cookbook uses Chef Vault, which cannot be used in the Effortless Infra pattern
|
|
1936
|
+
StyleGuide: '#chefeffortlesscookbookuseschefvault'
|
|
1937
|
+
Enabled: false
|
|
1938
|
+
VersionAdded: '6.19'
|
|
1939
|
+
Exclude:
|
|
1940
|
+
- '**/metadata.rb'
|
|
1941
|
+
- '**/Berksfile'
|
|
1942
|
+
|
|
1943
|
+
# https://github.com/chef/cookstyle/issues/346
|
|
1944
|
+
ChefEffortless/DependsChefVault:
|
|
1945
|
+
Description: Cookbook depends on Chef Vault, which cannot be used in the Effortless Infra pattern
|
|
1946
|
+
StyleGuide: '#chefeffortlesscookbookdependschefvault'
|
|
1947
|
+
Enabled: false
|
|
1948
|
+
VersionAdded: '6.19'
|
|
1949
|
+
Include:
|
|
1950
|
+
- '**/metadata.rb'
|
|
1932
1951
|
|
|
1933
1952
|
ChefEffortless/CookbookUsesEnvironments:
|
|
1934
1953
|
Description: Cookbook uses environments, which cannot be used in the Effortless Infra pattern
|
data/config/upstream.yml
CHANGED
|
@@ -2463,7 +2463,7 @@ Style/ArrayCoercion:
|
|
|
2463
2463
|
with a variable you want to treat as an Array, but you're not certain it's an array.
|
|
2464
2464
|
StyleGuide: '#array-coercion'
|
|
2465
2465
|
Safe: false
|
|
2466
|
-
Enabled:
|
|
2466
|
+
Enabled: false
|
|
2467
2467
|
VersionAdded: '0.88'
|
|
2468
2468
|
|
|
2469
2469
|
Style/ArrayJoin:
|
|
@@ -2863,7 +2863,8 @@ Style/DateTime:
|
|
|
2863
2863
|
StyleGuide: '#date--time'
|
|
2864
2864
|
Enabled: false
|
|
2865
2865
|
VersionAdded: '0.51'
|
|
2866
|
-
VersionChanged: '0.
|
|
2866
|
+
VersionChanged: '0.92'
|
|
2867
|
+
SafeAutoCorrect: false
|
|
2867
2868
|
AllowCoercion: false
|
|
2868
2869
|
|
|
2869
2870
|
Style/DefWithParentheses:
|
|
@@ -3283,11 +3284,16 @@ Style/IpAddresses:
|
|
|
3283
3284
|
Description: "Don't include literal IP addresses in code."
|
|
3284
3285
|
Enabled: false
|
|
3285
3286
|
VersionAdded: '0.58'
|
|
3286
|
-
VersionChanged: '0.
|
|
3287
|
+
VersionChanged: '0.91'
|
|
3287
3288
|
# Allow addresses to be permitted
|
|
3288
3289
|
AllowedAddresses:
|
|
3289
3290
|
- "::"
|
|
3290
3291
|
# :: is a valid IPv6 address, but could potentially be legitimately in code
|
|
3292
|
+
Exclude:
|
|
3293
|
+
- '**/*.gemfile'
|
|
3294
|
+
- '**/Gemfile'
|
|
3295
|
+
- '**/gems.rb'
|
|
3296
|
+
- '**/*.gemspec'
|
|
3291
3297
|
|
|
3292
3298
|
Style/KeywordParametersOrder:
|
|
3293
3299
|
Description: 'Enforces that optional keyword parameters are placed at the end of the parameters list.'
|
|
@@ -3720,6 +3726,8 @@ Style/OptionalBooleanParameter:
|
|
|
3720
3726
|
Enabled: pending
|
|
3721
3727
|
Safe: false
|
|
3722
3728
|
VersionAdded: '0.89'
|
|
3729
|
+
AllowedMethods:
|
|
3730
|
+
- respond_to_missing?
|
|
3723
3731
|
|
|
3724
3732
|
Style/OrAssignment:
|
|
3725
3733
|
Description: 'Recommend usage of double pipe equals (||=) where applicable.'
|
|
@@ -3988,6 +3996,8 @@ Style/SafeNavigation:
|
|
|
3988
3996
|
This cop transforms usages of a method call safeguarded by
|
|
3989
3997
|
a check for the existence of the object to
|
|
3990
3998
|
safe navigation (`&.`).
|
|
3999
|
+
Auto-correction is unsafe as it assumes the object will
|
|
4000
|
+
be `nil` or truthy, but never `false`.
|
|
3991
4001
|
Enabled: true
|
|
3992
4002
|
VersionAdded: '0.43'
|
|
3993
4003
|
VersionChanged: '0.77'
|
|
@@ -4000,6 +4010,7 @@ Style/SafeNavigation:
|
|
|
4000
4010
|
- presence
|
|
4001
4011
|
- try
|
|
4002
4012
|
- try!
|
|
4013
|
+
SafeAutoCorrect: false
|
|
4003
4014
|
|
|
4004
4015
|
Style/Sample:
|
|
4005
4016
|
Description: >-
|
data/lib/cookstyle.rb
CHANGED
|
@@ -15,9 +15,6 @@ require_relative 'rubocop/monkey_patches/base'
|
|
|
15
15
|
require_relative 'rubocop/monkey_patches/team'
|
|
16
16
|
require_relative 'rubocop/monkey_patches/registry_cop'
|
|
17
17
|
|
|
18
|
-
# @TODO remove this monkeypatch after we upgrade from 0.91.0
|
|
19
|
-
require_relative 'rubocop/monkey_patches/rescue_ensure_alignment'
|
|
20
|
-
|
|
21
18
|
module RuboCop
|
|
22
19
|
class ConfigLoader
|
|
23
20
|
RUBOCOP_HOME.gsub!(
|
data/lib/cookstyle/version.rb
CHANGED
|
@@ -50,7 +50,7 @@ module RuboCop
|
|
|
50
50
|
block_guard_with_only_string?(node) do
|
|
51
51
|
add_offense(node, message: MSG, severity: :refactor) do |corrector|
|
|
52
52
|
new_val = "#{node.method_name} #{node.body.source}"
|
|
53
|
-
corrector.replace(node
|
|
53
|
+
corrector.replace(node, new_val)
|
|
54
54
|
end
|
|
55
55
|
end
|
|
56
56
|
end
|
|
@@ -44,7 +44,7 @@ module RuboCop
|
|
|
44
44
|
def on_send(node)
|
|
45
45
|
application_fatal?(node) do |val|
|
|
46
46
|
add_offense(node, message: MSG, severity: :refactor) do |corrector|
|
|
47
|
-
corrector.replace(node
|
|
47
|
+
corrector.replace(node, "raise(#{val.source})")
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
50
|
end
|
|
@@ -58,7 +58,7 @@ module RuboCop
|
|
|
58
58
|
def on_block(node)
|
|
59
59
|
conditional_shellout?(node) do |type, val|
|
|
60
60
|
add_offense(node, message: MSG, severity: :refactor) do |corrector|
|
|
61
|
-
corrector.replace(node
|
|
61
|
+
corrector.replace(node, "#{type} #{val.source}")
|
|
62
62
|
end
|
|
63
63
|
end
|
|
64
64
|
end
|
|
@@ -38,51 +38,32 @@ module RuboCop
|
|
|
38
38
|
|
|
39
39
|
MSG = 'Libraries should be injected into the Chef::DSL::Recipe class and not Chef::Recipe or Chef::Provider classes directly.'
|
|
40
40
|
|
|
41
|
-
def_node_search :
|
|
42
|
-
(send
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
41
|
+
def_node_search :correct_injection?, <<-PATTERN
|
|
42
|
+
{(send
|
|
43
|
+
(const
|
|
44
|
+
(const
|
|
45
|
+
(const {cbase nil?} :Chef) :DSL) :Recipe) :send
|
|
46
|
+
(sym :include)
|
|
47
|
+
... )
|
|
48
|
+
(send
|
|
49
|
+
(const
|
|
50
|
+
(const
|
|
51
|
+
(const {cbase nil?} :Chef) :DSL) :Recipe) :include
|
|
52
|
+
... )}
|
|
48
53
|
PATTERN
|
|
49
54
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
(const
|
|
54
|
-
(const {cbase nil?} :Chef) :DSL) :Recipe) :include
|
|
55
|
-
... )
|
|
55
|
+
def_node_matcher :legacy_injection?, <<-PATTERN
|
|
56
|
+
{(send (const (const {cbase nil?} :Chef) {:Recipe :Provider}) :send (sym :include) ... )
|
|
57
|
+
(send (const (const {cbase nil?} :Chef) {:Recipe :Provider}) :include ... )}
|
|
56
58
|
PATTERN
|
|
57
59
|
|
|
58
|
-
def_node_matcher :legacy_class_sends?, <<-PATTERN
|
|
59
|
-
(send (const (const {cbase nil?} :Chef) {:Recipe :Provider}) :send (sym :include) ... )
|
|
60
|
-
PATTERN
|
|
61
|
-
|
|
62
|
-
def_node_matcher :legacy_class_include?, <<-PATTERN
|
|
63
|
-
(send (const (const {cbase nil?} :Chef) {:Recipe :Provider}) :include ... )
|
|
64
|
-
PATTERN
|
|
65
|
-
|
|
66
|
-
# @todo: This is highly repetitive and could be simplified into a single node_matcher
|
|
67
|
-
# call with some matcher magic that should be figured out
|
|
68
60
|
def on_send(node)
|
|
69
|
-
|
|
70
|
-
add_offense(node, message: MSG, severity: :refactor) do |corrector|
|
|
71
|
-
if node.parent && correct_send?(node.parent)
|
|
72
|
-
corrector.remove(range_with_surrounding_space(range: node.loc.expression, side: :left))
|
|
73
|
-
else
|
|
74
|
-
corrector.replace(node.loc.expression,
|
|
75
|
-
node.source.gsub(/Chef::(Provider|Recipe)/, 'Chef::DSL::Recipe'))
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
legacy_class_include?(node) do
|
|
61
|
+
legacy_injection?(node) do
|
|
81
62
|
add_offense(node, message: MSG, severity: :refactor) do |corrector|
|
|
82
|
-
if node.parent &&
|
|
63
|
+
if node.parent && correct_injection?(node.parent)
|
|
83
64
|
corrector.remove(range_with_surrounding_space(range: node.loc.expression, side: :left))
|
|
84
65
|
else
|
|
85
|
-
corrector.replace(node
|
|
66
|
+
corrector.replace(node,
|
|
86
67
|
node.source.gsub(/Chef::(Provider|Recipe)/, 'Chef::DSL::Recipe'))
|
|
87
68
|
end
|
|
88
69
|
end
|
|
@@ -56,7 +56,7 @@ module RuboCop
|
|
|
56
56
|
range = range_with_surrounding_comma(range_with_surrounding_space(range: con.loc.expression, side: :left), :both)
|
|
57
57
|
corrector.remove(range)
|
|
58
58
|
else
|
|
59
|
-
corrector.replace(con
|
|
59
|
+
corrector.replace(con, "'#{new_value}'")
|
|
60
60
|
end
|
|
61
61
|
end
|
|
62
62
|
end
|
|
@@ -56,7 +56,7 @@ module RuboCop
|
|
|
56
56
|
add_offense(plat, message: MSG, severity: :refactor) do |corrector|
|
|
57
57
|
correct_string = corrected_platform_source(plat)
|
|
58
58
|
next unless correct_string
|
|
59
|
-
corrector.replace(plat
|
|
59
|
+
corrector.replace(plat, correct_string)
|
|
60
60
|
end
|
|
61
61
|
end
|
|
62
62
|
end
|
|
@@ -68,7 +68,7 @@ module RuboCop
|
|
|
68
68
|
add_offense(plat, message: MSG, severity: :refactor) do |corrector|
|
|
69
69
|
correct_string = corrected_platform_source(plat)
|
|
70
70
|
next unless correct_string
|
|
71
|
-
corrector.replace(plat
|
|
71
|
+
corrector.replace(plat, correct_string)
|
|
72
72
|
end
|
|
73
73
|
end
|
|
74
74
|
end
|
|
@@ -55,7 +55,7 @@ module RuboCop
|
|
|
55
55
|
range = range_with_surrounding_comma(range_with_surrounding_space(range: con.loc.expression, side: :left), :both)
|
|
56
56
|
corrector.remove(range)
|
|
57
57
|
else
|
|
58
|
-
corrector.replace(con
|
|
58
|
+
corrector.replace(con, "'#{new_value}'")
|
|
59
59
|
end
|
|
60
60
|
end
|
|
61
61
|
end
|
|
@@ -43,7 +43,7 @@ module RuboCop
|
|
|
43
43
|
def on_send(node)
|
|
44
44
|
non_lazy_node_attribute_default?(node) do |default|
|
|
45
45
|
add_offense(default, message: MSG, severity: :refactor) do |corrector|
|
|
46
|
-
corrector.replace(default
|
|
46
|
+
corrector.replace(default, "lazy { #{default.source} }")
|
|
47
47
|
end
|
|
48
48
|
end
|
|
49
49
|
end
|
|
@@ -56,7 +56,7 @@ module RuboCop
|
|
|
56
56
|
def on_block(node)
|
|
57
57
|
lazy_in_guard?(node) do |type, code|
|
|
58
58
|
add_offense(node, message: MSG, severity: :refactor) do |corrector|
|
|
59
|
-
corrector.replace(node
|
|
59
|
+
corrector.replace(node, "#{type} { #{code.source} }")
|
|
60
60
|
end
|
|
61
61
|
end
|
|
62
62
|
end
|
|
@@ -54,9 +54,9 @@ module RuboCop
|
|
|
54
54
|
match_property_in_resource?(:macos_userdefaults, 'type', node) do |type|
|
|
55
55
|
type_val = method_arg_ast_to_string(type)
|
|
56
56
|
return if VALID_VALUES.include?(type_val)
|
|
57
|
-
add_offense(type
|
|
57
|
+
add_offense(type, message: MSG, severity: :refactor) do |corrector|
|
|
58
58
|
next unless INVALID_VALUE_MAP[type_val]
|
|
59
|
-
corrector.replace(type
|
|
59
|
+
corrector.replace(type, "type '#{INVALID_VALUE_MAP[type_val]}'")
|
|
60
60
|
end
|
|
61
61
|
end
|
|
62
62
|
end
|
|
@@ -53,7 +53,7 @@ module RuboCop
|
|
|
53
53
|
return unless notifies_property.node_parts[2].str_type?
|
|
54
54
|
|
|
55
55
|
add_offense(notifies_property, message: MSG, severity: :refactor) do |corrector|
|
|
56
|
-
corrector.replace(notifies_property.first_argument
|
|
56
|
+
corrector.replace(notifies_property.first_argument,
|
|
57
57
|
":#{notifies_property.node_parts[2].value}")
|
|
58
58
|
end
|
|
59
59
|
end
|
|
@@ -45,7 +45,7 @@ module RuboCop
|
|
|
45
45
|
action_node.arguments.each do |action|
|
|
46
46
|
next unless action.source == ':none'
|
|
47
47
|
add_offense(action, message: MSG, severity: :refactor) do |corrector|
|
|
48
|
-
corrector.replace(action
|
|
48
|
+
corrector.replace(action, ':nothing')
|
|
49
49
|
end
|
|
50
50
|
end
|
|
51
51
|
end
|
|
@@ -41,8 +41,8 @@ module RuboCop
|
|
|
41
41
|
def on_send(node)
|
|
42
42
|
supports_with_constraint?(node) do |ver|
|
|
43
43
|
return if ver.source.include?('.')
|
|
44
|
-
add_offense(ver
|
|
45
|
-
corrector.replace(ver
|
|
44
|
+
add_offense(ver, message: MSG, severity: :refactor) do |corrector|
|
|
45
|
+
corrector.replace(ver, ver.source.gsub(ver.value, (ver.value + '.0')))
|
|
46
46
|
end
|
|
47
47
|
end
|
|
48
48
|
end
|
|
@@ -45,7 +45,7 @@ module RuboCop
|
|
|
45
45
|
add_offense(prop_node, message: MSG, severity: :warning) do |corrector|
|
|
46
46
|
# make sure to delete leading and trailing {}s that would create invalid ruby syntax
|
|
47
47
|
extracted_val = prop_node.arguments.first.source.gsub(/{|}/, '')
|
|
48
|
-
corrector.replace(prop_node
|
|
48
|
+
corrector.replace(prop_node, "type #{extracted_val}")
|
|
49
49
|
end
|
|
50
50
|
end
|
|
51
51
|
end
|
|
@@ -79,7 +79,7 @@ module RuboCop
|
|
|
79
79
|
|
|
80
80
|
rewind_resources?(node) do |string|
|
|
81
81
|
add_offense(node, message: MSG, severity: :warning) do |corrector|
|
|
82
|
-
corrector.replace(node
|
|
82
|
+
corrector.replace(node, node.source.gsub(string.to_s, MAPPING[string]))
|
|
83
83
|
end
|
|
84
84
|
end
|
|
85
85
|
end
|
|
@@ -88,7 +88,7 @@ module RuboCop
|
|
|
88
88
|
match_property_in_resource?(:chef_gem, 'package_name', node) do |pkg_name|
|
|
89
89
|
next unless pkg_name.arguments&.first&.str_content == 'chef-rewind'
|
|
90
90
|
add_offense(node, message: MSG, severity: :warning) do |corrector|
|
|
91
|
-
corrector.remove(node
|
|
91
|
+
corrector.remove(node) if pkg_name.arguments&.first&.str_content == 'chef-rewind'
|
|
92
92
|
end
|
|
93
93
|
end
|
|
94
94
|
end
|
|
@@ -75,7 +75,7 @@ module RuboCop
|
|
|
75
75
|
|
|
76
76
|
shellout_new?(node) do
|
|
77
77
|
add_offense(node, message: MSG, severity: :warning) do |corrector|
|
|
78
|
-
corrector.replace(node
|
|
78
|
+
corrector.replace(node, node.source.gsub('Chef::ShellOut', 'Mixlib::ShellOut'))
|
|
79
79
|
end
|
|
80
80
|
end
|
|
81
81
|
end
|
|
@@ -43,7 +43,7 @@ module RuboCop
|
|
|
43
43
|
def on_send(node)
|
|
44
44
|
chef_platform_windows?(node) do
|
|
45
45
|
add_offense(node, message: MSG, severity: :warning) do |corrector|
|
|
46
|
-
corrector.replace(node
|
|
46
|
+
corrector.replace(node, "platform?('windows')")
|
|
47
47
|
end
|
|
48
48
|
end
|
|
49
49
|
end
|
|
@@ -47,7 +47,7 @@ module RuboCop
|
|
|
47
47
|
return unless node.const_name == 'ChefDK' && (node.parent&.module_type? || node.parent&.const_type?)
|
|
48
48
|
|
|
49
49
|
add_offense(node, message: MSG, severity: :warning) do |corrector|
|
|
50
|
-
corrector.replace(node
|
|
50
|
+
corrector.replace(node, node.source.gsub('ChefDK', 'ChefCLI'))
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
53
|
end
|
|
@@ -51,7 +51,7 @@ module RuboCop
|
|
|
51
51
|
def on_const(node)
|
|
52
52
|
chefspec_runner?(node) do
|
|
53
53
|
add_offense(node, message: MSG, severity: :warning) do |corrector|
|
|
54
|
-
corrector.replace(node
|
|
54
|
+
corrector.replace(node, 'ChefSpec::ServerRunner')
|
|
55
55
|
end
|
|
56
56
|
end
|
|
57
57
|
end
|
|
@@ -120,7 +120,7 @@ module RuboCop
|
|
|
120
120
|
next unless legacy_chefspec_platform(plat.value, ver.value)
|
|
121
121
|
add_offense(node, message: MSG, severity: :warning) do |corrector|
|
|
122
122
|
if replacement = replacement_string(plat.value, ver.value) # rubocop: disable Lint/AssignmentInCondition
|
|
123
|
-
corrector.replace(ver
|
|
123
|
+
corrector.replace(ver, "'#{replacement}'")
|
|
124
124
|
end
|
|
125
125
|
end
|
|
126
126
|
end
|
|
@@ -54,7 +54,7 @@ module RuboCop
|
|
|
54
54
|
%w(url keyurl mirrorexpire).each do |prop|
|
|
55
55
|
match_property_in_resource?(:yum_repository, prop, node) do |prop_node|
|
|
56
56
|
add_offense(prop_node, message: MSG, severity: :warning) do |corrector|
|
|
57
|
-
corrector.replace(prop_node
|
|
57
|
+
corrector.replace(prop_node, prop_node.source
|
|
58
58
|
.gsub(/^url/, 'baseurl')
|
|
59
59
|
.gsub(/^keyurl/, 'gpgkey')
|
|
60
60
|
.gsub(/^mirrorexpire/, 'mirror_expire'))
|
|
@@ -41,7 +41,7 @@ module RuboCop
|
|
|
41
41
|
|
|
42
42
|
def on_block(node)
|
|
43
43
|
match_property_in_resource?(:execute, 'path', node) do |offense|
|
|
44
|
-
add_offense(offense
|
|
44
|
+
add_offense(offense, message: MSG, severity: :warning) # @todo: we could probably autocorrect this with some work
|
|
45
45
|
end
|
|
46
46
|
end
|
|
47
47
|
end
|