cookstyle 6.12.6 → 6.15.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -1
- data/config/cookstyle.yml +122 -41
- data/config/disable_all.yml +28 -4
- data/config/upstream.yml +96 -16
- data/cookstyle.gemspec +1 -0
- data/lib/cookstyle.rb +7 -7
- data/lib/cookstyle/version.rb +2 -2
- data/lib/rubocop/cop/chef/correctness/invalid_default_action.rb +48 -0
- data/lib/rubocop/cop/chef/correctness/invalid_platform_family_helper.rb +26 -3
- data/lib/rubocop/cop/chef/correctness/macos_userdefaults_invalid_type.rb +68 -0
- data/lib/rubocop/cop/chef/correctness/notifies_action_not_symbol.rb +4 -4
- data/lib/rubocop/cop/chef/correctness/supports_must_be_float.rb +52 -0
- data/lib/rubocop/cop/chef/deprecation/cheffile.rb +2 -2
- data/lib/rubocop/cop/chef/deprecation/deprecated_chefspec_platform.rb +6 -5
- data/lib/rubocop/cop/chef/deprecation/eol_audit_mode.rb +2 -2
- data/lib/rubocop/cop/chef/deprecation/macos_userdefaults_global_property.rb +61 -0
- data/lib/rubocop/cop/chef/deprecation/poise_archive.rb +4 -2
- data/lib/rubocop/cop/chef/deprecation/resource_uses_only_resource_name.rb +3 -3
- data/lib/rubocop/cop/chef/deprecation/ruby_27_keyword_argument_warnings.rb +6 -10
- data/lib/rubocop/cop/chef/effortless/node_environment.rb +1 -1
- data/lib/rubocop/cop/chef/effortless/node_roles.rb +3 -3
- data/lib/rubocop/cop/chef/modernize/action_method_in_resource.rb +57 -0
- data/lib/rubocop/cop/chef/modernize/allowed_actions_initializer.rb +2 -2
- data/lib/rubocop/cop/chef/modernize/cron_d_file_or_template.rb +88 -0
- data/lib/rubocop/cop/chef/modernize/default_action_initializer.rb +3 -3
- data/lib/rubocop/cop/chef/modernize/definitions.rb +1 -1
- data/lib/rubocop/cop/chef/modernize/provides_initializer.rb +3 -3
- data/lib/rubocop/cop/chef/modernize/resource_name_initializer.rb +2 -2
- data/lib/rubocop/cop/chef/modernize/use_multipackage_installs.rb +3 -3
- data/lib/rubocop/cop/chef/redundant/double_compile_time.rb +65 -0
- data/lib/rubocop/cop/chef/redundant/ohai_attribute_to_string.rb +3 -3
- data/lib/rubocop/cop/chef/sharing/empty_metadata_field.rb +1 -1
- data/lib/rubocop/cop/chef/sharing/include_property_descriptions.rb +5 -5
- data/lib/rubocop/cop/chef/sharing/include_resource_descriptions.rb +3 -3
- data/lib/rubocop/cop/chef/sharing/include_resource_examples.rb +2 -2
- data/lib/rubocop/cop/chef/style/file_mode.rb +38 -19
- data/lib/rubocop/cop/chef/style/unnecessary_platform_case_statement.rb +1 -1
- data/lib/rubocop/monkey_patches/{cop.rb → base.rb} +1 -1
- metadata +13 -6
data/cookstyle.gemspec
CHANGED
@@ -11,6 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.email = ['thom@chef.io', 'tsmith@chef.io']
|
12
12
|
spec.summary = 'Cookstyle is a code linting tool that helps you to write better Chef Infra cookbooks by detecting and automatically correcting style, syntax, and logic mistakes in your code.'
|
13
13
|
spec.license = 'Apache-2.0'
|
14
|
+
spec.homepage = 'https://docs.chef.io/workstation/cookstyle/'
|
14
15
|
spec.required_ruby_version = '>= 2.4'
|
15
16
|
|
16
17
|
# the gemspec and Gemfile are necessary for appbundling of the gem
|
data/lib/cookstyle.rb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require_relative 'cookstyle/version'
|
3
3
|
|
4
|
-
require 'pathname'
|
5
|
-
require 'yaml'
|
4
|
+
require 'pathname' unless defined?(Pathname)
|
5
|
+
require 'yaml' unless defined?(YAML)
|
6
6
|
|
7
7
|
# ensure the desired target version of RuboCop is gem activated
|
8
8
|
gem 'rubocop', "= #{Cookstyle::RUBOCOP_VERSION}"
|
9
9
|
require 'rubocop'
|
10
|
-
|
10
|
+
require_relative 'rubocop/monkey_patches/comment_config.rb'
|
11
11
|
|
12
12
|
# monkey patches needed for the TargetChefVersion config option
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
require_relative 'rubocop/monkey_patches/config.rb'
|
14
|
+
require_relative 'rubocop/monkey_patches/base.rb'
|
15
|
+
require_relative 'rubocop/monkey_patches/team.rb'
|
16
|
+
require_relative 'rubocop/monkey_patches/registry_cop.rb'
|
17
17
|
|
18
18
|
module RuboCop
|
19
19
|
class ConfigLoader
|
data/lib/cookstyle/version.rb
CHANGED
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Copyright:: 2020, 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
|
+
|
19
|
+
module RuboCop
|
20
|
+
module Cop
|
21
|
+
module Chef
|
22
|
+
# Default actions in resources should be symbols or an array of symbols.
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
#
|
26
|
+
# # bad
|
27
|
+
# default_action 'create'
|
28
|
+
#
|
29
|
+
# # good
|
30
|
+
# default_action :create
|
31
|
+
#
|
32
|
+
module ChefCorrectness
|
33
|
+
class InvalidDefaultAction < Cop
|
34
|
+
MSG = 'Default actions in resources should be symbols or an array of symbols.'
|
35
|
+
|
36
|
+
def_node_matcher :default_action?, '(send nil? :default_action $_)'
|
37
|
+
|
38
|
+
def on_send(node)
|
39
|
+
default_action?(node) do |match|
|
40
|
+
return if %i(send sym array).include?(match.type)
|
41
|
+
add_offense(node, location: :expression, message: MSG, severity: :refactor)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -33,6 +33,7 @@ module RuboCop
|
|
33
33
|
#
|
34
34
|
class InvalidPlatformFamilyHelper < Cop
|
35
35
|
include ::RuboCop::Chef::PlatformHelpers
|
36
|
+
include RangeHelp
|
36
37
|
|
37
38
|
MSG = 'Pass valid platform families to the platform_family? helper.'
|
38
39
|
|
@@ -41,9 +42,31 @@ module RuboCop
|
|
41
42
|
PATTERN
|
42
43
|
|
43
44
|
def on_send(node)
|
44
|
-
platform_family_helper?(node) do |
|
45
|
-
|
46
|
-
|
45
|
+
platform_family_helper?(node) do |plats|
|
46
|
+
plats.to_a.each do |p|
|
47
|
+
next unless INVALID_PLATFORM_FAMILIES.key?(p.value)
|
48
|
+
add_offense(p, location: :expression, message: MSG, severity: :refactor)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def autocorrect(node)
|
54
|
+
replacement_platform = INVALID_PLATFORM_FAMILIES[node.value]
|
55
|
+
all_passed_platforms = node.parent.arguments.map(&:value)
|
56
|
+
|
57
|
+
# see if we have a replacement platform in our hash. If not we can't autocorrect
|
58
|
+
if replacement_platform
|
59
|
+
# if the replacement platform was one of the other platforms passed we can just delete this bad platform
|
60
|
+
if all_passed_platforms.include?(replacement_platform)
|
61
|
+
all_passed_platforms.delete(node.value)
|
62
|
+
lambda do |corrector|
|
63
|
+
arg_range = node.parent.arguments.first.loc.expression.join(node.parent.arguments[-1].loc.expression.end)
|
64
|
+
corrector.replace(arg_range, all_passed_platforms.map { |x| "'#{x}'" }.join(', '))
|
65
|
+
end
|
66
|
+
else
|
67
|
+
lambda do |corrector|
|
68
|
+
corrector.replace(node.loc.expression, node.value.gsub(node.value, "'#{replacement_platform}'")) # gsub to retain quotes
|
69
|
+
end
|
47
70
|
end
|
48
71
|
end
|
49
72
|
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Copyright:: Copyright 2020, 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 ChefCorrectness
|
22
|
+
# The macos_userdefaults resource prior to Chef Infra Client 16.3 would silently continue if invalid types were passed resulting in unexpected behavior. Valid values are: "array", "bool", "dict", "float", "int", and "string".
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
#
|
26
|
+
# # bad
|
27
|
+
# macos_userdefaults 'set a value' do
|
28
|
+
# global true
|
29
|
+
# key 'key'
|
30
|
+
# type 'boolean'
|
31
|
+
# end
|
32
|
+
#
|
33
|
+
# # good
|
34
|
+
# macos_userdefaults 'set a value' do
|
35
|
+
# global true
|
36
|
+
# key 'key'
|
37
|
+
# type 'bool'
|
38
|
+
# end
|
39
|
+
#
|
40
|
+
class MacosUserdefaultsInvalidType < Base
|
41
|
+
include RuboCop::Chef::CookbookHelpers
|
42
|
+
extend RuboCop::Cop::AutoCorrector
|
43
|
+
|
44
|
+
VALID_VALUES = %w(array bool dict float int string).freeze
|
45
|
+
INVALID_VALUE_MAP = {
|
46
|
+
'boolean' => 'bool',
|
47
|
+
'str' => 'string',
|
48
|
+
'integer' => 'int',
|
49
|
+
}.freeze
|
50
|
+
|
51
|
+
MSG = 'The macos_userdefaults resource prior to Chef Infra Client 16.3 would silently continue if invalid types were passed resulting in unexpected behavior. Valid values are: "array", "bool", "dict", "float", "int", and "string".'
|
52
|
+
|
53
|
+
def on_block(node)
|
54
|
+
match_property_in_resource?(:macos_userdefaults, 'type', node) do |type|
|
55
|
+
type_val = method_arg_ast_to_string(type)
|
56
|
+
return if VALID_VALUES.include?(type_val)
|
57
|
+
add_offense(type.loc.expression, message: MSG, severity: :refactor) do |corrector|
|
58
|
+
if INVALID_VALUE_MAP[type_val]
|
59
|
+
corrector.replace(type.loc.expression, "type '#{INVALID_VALUE_MAP[type_val]}'")
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -25,20 +25,20 @@ module RuboCop
|
|
25
25
|
# @example
|
26
26
|
#
|
27
27
|
# # bad
|
28
|
-
# execute 'some
|
28
|
+
# execute 'some command' do
|
29
29
|
# notifies 'restart', 'service[httpd]', 'delayed'
|
30
30
|
# end
|
31
31
|
#
|
32
|
-
# execute 'some
|
32
|
+
# execute 'some command' do
|
33
33
|
# subscribes 'restart', 'service[httpd]', 'delayed'
|
34
34
|
# end
|
35
35
|
#
|
36
36
|
# # good
|
37
|
-
# execute 'some
|
37
|
+
# execute 'some command' do
|
38
38
|
# notifies :restart, 'service[httpd]', 'delayed'
|
39
39
|
# end
|
40
40
|
#
|
41
|
-
# execute 'some
|
41
|
+
# execute 'some command' do
|
42
42
|
# subscribes :restart, 'service[httpd]', 'delayed'
|
43
43
|
# end
|
44
44
|
#
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Copyright:: 2020, 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
|
+
|
19
|
+
module RuboCop
|
20
|
+
module Cop
|
21
|
+
module Chef
|
22
|
+
module ChefCorrectness
|
23
|
+
# Versions used in metadata.rb supports calls should be floats not integers.
|
24
|
+
#
|
25
|
+
# @example
|
26
|
+
#
|
27
|
+
# # bad
|
28
|
+
# supports 'redhat', '> 8'
|
29
|
+
#
|
30
|
+
# # good
|
31
|
+
# supports 'redhat', '> 8.0'
|
32
|
+
#
|
33
|
+
class SupportsMustBeFloat < Base
|
34
|
+
extend RuboCop::Cop::AutoCorrector
|
35
|
+
|
36
|
+
MSG = 'Versions used in metadata.rb supports calls should be floats not integers.'
|
37
|
+
|
38
|
+
def_node_matcher :supports_with_constraint?, '(send nil? :supports str $str)'
|
39
|
+
|
40
|
+
def on_send(node)
|
41
|
+
supports_with_constraint?(node) do |ver|
|
42
|
+
return if ver.source.include?('.')
|
43
|
+
add_offense(ver.loc.expression, message: MSG, severity: :refactor) do |corrector|
|
44
|
+
corrector.replace(ver.loc.expression, ver.source.gsub(ver.value, (ver.value + '.0')))
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -19,13 +19,13 @@
|
|
19
19
|
module RuboCop
|
20
20
|
module Cop
|
21
21
|
module Chef
|
22
|
-
# The
|
22
|
+
# The Librarian-Chef depsolving project is no longer maintained and a Cheffile should not be used for cookbook depsolving. Consider using Policyfiles instead. If the Policyfiles model is not compatible with your workflow you may find Berkshelf offers a more similar, and still supported, experience to Librarian-Chef.
|
23
23
|
#
|
24
24
|
module ChefDeprecations
|
25
25
|
class Cheffile < Cop
|
26
26
|
include RangeHelp
|
27
27
|
|
28
|
-
MSG = 'The
|
28
|
+
MSG = 'The Librarian-Chef depsolving project is no longer maintained and a Cheffile should not be used for cookbook depsolving. Consider using Policyfiles instead.'
|
29
29
|
|
30
30
|
def investigate(processed_source)
|
31
31
|
return if processed_source.blank?
|
@@ -65,25 +65,26 @@ module RuboCop
|
|
65
65
|
'opensuse' => {
|
66
66
|
'< 14' => true,
|
67
67
|
'~> 42.0' => true,
|
68
|
+
'= 15.0' => '15',
|
68
69
|
},
|
69
70
|
'debian' => {
|
70
71
|
'< 8' => true,
|
71
|
-
'> 8.0, < 8.
|
72
|
-
'> 9.0, < 9.
|
72
|
+
'> 8.0, < 8.11' => '8',
|
73
|
+
'> 9.0, < 9.11' => '9',
|
73
74
|
},
|
74
75
|
'centos' => {
|
75
76
|
'< 6.0' => true,
|
76
|
-
'~> 6.0, < 6.
|
77
|
+
'~> 6.0, < 6.10' => '6',
|
77
78
|
'~> 7.0, < 7.6 ' => '7',
|
78
79
|
},
|
79
80
|
'redhat' => {
|
80
81
|
'< 6.0' => true,
|
81
|
-
'~> 6.0, < 6.
|
82
|
+
'~> 6.0, < 6.10' => '6',
|
82
83
|
'~> 7.0, < 7.6' => '7',
|
83
84
|
},
|
84
85
|
'oracle' => {
|
85
86
|
'< 6.0' => true,
|
86
|
-
'~> 6.0, < 6.
|
87
|
+
'~> 6.0, < 6.10' => '6',
|
87
88
|
'~> 7.0, < 7.6 ' => '7',
|
88
89
|
},
|
89
90
|
}.freeze
|
@@ -19,7 +19,7 @@ module RuboCop
|
|
19
19
|
module Cop
|
20
20
|
module Chef
|
21
21
|
module ChefDeprecations
|
22
|
-
# The beta Audit Mode for Chef Infra Client was removed in Chef Infra Client 15.0. Users should instead use InSpec and the audit cookbook. See https://www.inspec.io/ for more
|
22
|
+
# The beta Audit Mode for Chef Infra Client was removed in Chef Infra Client 15.0. Users should instead use InSpec and the audit cookbook. See https://www.inspec.io/ for more information.
|
23
23
|
#
|
24
24
|
# @example
|
25
25
|
#
|
@@ -33,7 +33,7 @@ module RuboCop
|
|
33
33
|
# end
|
34
34
|
|
35
35
|
class EOLAuditModeUsage < Cop
|
36
|
-
MSG = 'The beta Audit Mode feature in Chef Infra Client was removed in Chef Infra Client 15.0. Users should instead use InSpec and the audit cookbook. See https://www.inspec.io/ for more
|
36
|
+
MSG = 'The beta Audit Mode feature in Chef Infra Client was removed in Chef Infra Client 15.0. Users should instead use InSpec and the audit cookbook. See https://www.inspec.io/ for more information.'
|
37
37
|
|
38
38
|
def_node_matcher :control_group?, '(send nil? :control_group ...)'
|
39
39
|
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Copyright:: Copyright 2020, 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
|
+
|
19
|
+
module RuboCop
|
20
|
+
module Cop
|
21
|
+
module Chef
|
22
|
+
module ChefDeprecations
|
23
|
+
# The `global` property in the macos_userdefaults resource was deprecated in Chef Infra Client 16.3. This property was never properly implemented and caused failures under many conditions. Omitting the `domain` property will now set global defaults.
|
24
|
+
#
|
25
|
+
# @example
|
26
|
+
#
|
27
|
+
# # bad
|
28
|
+
# macos_userdefaults 'set a value' do
|
29
|
+
# global true
|
30
|
+
# key 'key'
|
31
|
+
# value 'value'
|
32
|
+
# end
|
33
|
+
#
|
34
|
+
# # good
|
35
|
+
# macos_userdefaults 'set a value' do
|
36
|
+
# key 'key'
|
37
|
+
# value 'value'
|
38
|
+
# end
|
39
|
+
#
|
40
|
+
class MacosUserdefaultsGlobalProperty < Base
|
41
|
+
extend TargetChefVersion
|
42
|
+
include RangeHelp
|
43
|
+
include RuboCop::Chef::CookbookHelpers
|
44
|
+
extend AutoCorrector
|
45
|
+
|
46
|
+
minimum_target_chef_version '16.3'
|
47
|
+
|
48
|
+
MSG = 'The `global` property in the macos_userdefaults resource was deprecated in Chef Infra Client 16.3. Omitting the `domain` property will now set global defaults.'
|
49
|
+
|
50
|
+
def on_block(node)
|
51
|
+
match_property_in_resource?(:macos_userdefaults, 'global', node) do |global|
|
52
|
+
add_offense(global.loc.expression, message: MSG, severity: :warning) do |corrector|
|
53
|
+
corrector.remove(range_with_surrounding_space(range: global.loc.expression, side: :left))
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -25,16 +25,18 @@ module RuboCop
|
|
25
25
|
#
|
26
26
|
# # bad
|
27
27
|
# poise_archive 'https://example.com/myapp.tgz' do
|
28
|
-
# destination '/opt/
|
28
|
+
# destination '/opt/my_app'
|
29
29
|
# end
|
30
30
|
#
|
31
31
|
# # good
|
32
32
|
# archive_file 'https://example.com/myapp.tgz' do
|
33
|
-
# destination '/opt/
|
33
|
+
# destination '/opt/my_app'
|
34
34
|
# end
|
35
35
|
#
|
36
36
|
class PoiseArchiveUsage < Cop
|
37
37
|
include RuboCop::Chef::CookbookHelpers
|
38
|
+
extend TargetChefVersion
|
39
|
+
minimum_target_chef_version '15.0'
|
38
40
|
|
39
41
|
MSG = 'The poise_archive resource in the deprecated poise-archive should be replaced with the archive_file resource found in Chef Infra Client 15+'
|
40
42
|
|
@@ -39,9 +39,9 @@ module RuboCop
|
|
39
39
|
|
40
40
|
def_node_search :provides, '(send nil? :provides (sym $_) ...)'
|
41
41
|
|
42
|
-
# determine the cookbook name either by parsing
|
42
|
+
# determine the cookbook name either by parsing metadata.rb or by parsing metadata.json
|
43
43
|
#
|
44
|
-
# @
|
44
|
+
# @return [String] the cookbook name
|
45
45
|
def cookbook_name
|
46
46
|
cb_path = File.expand_path(File.join(processed_source.file_path, '../..'))
|
47
47
|
|
@@ -55,7 +55,7 @@ module RuboCop
|
|
55
55
|
|
56
56
|
# given a resource name make sure there's a provides that matches that name
|
57
57
|
#
|
58
|
-
# @
|
58
|
+
# @return [TrueClass, FalseClass]
|
59
59
|
def valid_provides?(resource_name)
|
60
60
|
provides_ast = provides(processed_source.ast)
|
61
61
|
return false unless provides_ast
|