cookstyle 5.1.19 → 5.2.17

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,66 @@
1
+ #
2
+ # Copyright:: 2019, Chef Software, Inc.
3
+ # Author:: Tim Smith (<tsmith@chef.io>)
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ module RuboCop
19
+ module Cop
20
+ module Chef
21
+ # In HWRPs and LWRPs you defined attributes, but custom resources changed the name to
22
+ # be properties to avoid confusion with chef recipe attributes. When writing a custom resource
23
+ # they should be called properties even though the two are aliased.
24
+ #
25
+ # @example
26
+ #
27
+ # # bad
28
+ # attribute :something, String
29
+ #
30
+ # action :create do
31
+ # # some action code because we're in a custom resource
32
+ # end
33
+ #
34
+ # # good
35
+ # property :something, String
36
+ #
37
+ # action :create do
38
+ # # some action code because we're in a custom resource
39
+ # end
40
+ #
41
+ class CustomResourceWithAttributes < Cop
42
+ MSG = 'Custom Resources should contain properties not attributes'.freeze
43
+
44
+ def_node_matcher :attribute?, <<-PATTERN
45
+ (send nil? $:attribute ... )
46
+ PATTERN
47
+
48
+ def_node_search :resource_actions?, <<-PATTERN
49
+ (block (send nil? :action ... ) ... )
50
+ PATTERN
51
+
52
+ def on_send(node)
53
+ attribute?(node) do
54
+ add_offense(node, location: :selector, message: MSG, severity: :refactor) if resource_actions?(processed_source.ast)
55
+ end
56
+ end
57
+
58
+ def autocorrect(node)
59
+ lambda do |corrector|
60
+ corrector.replace(node.loc.selector, 'property')
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,52 @@
1
+ #
2
+ # Copyright:: 2019, Chef Software, Inc.
3
+ # Author:: Tim Smith (<tsmith@chef.io>)
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+ module RuboCop
18
+ module Cop
19
+ module Chef
20
+ # It is not longer necessary respond_to?(:foo) in metadata. This was used to support new metadata
21
+ # methods in Chef 11 and early versions of Chef 12.
22
+ #
23
+ # @example
24
+ #
25
+ # # bad
26
+ # provides :foo if respond_to?(:provides)
27
+ #
28
+ # # good
29
+ # provides :foo
30
+ #
31
+ class RespondToProvides < Cop
32
+ MSG = 'respond_to?(:provides) in resources is no longer necessary in Chef Infra Client 12+'.freeze
33
+
34
+ def on_if(node)
35
+ if_respond_to_provides?(node) do
36
+ add_offense(node, location: :expression, message: MSG, severity: :refactor)
37
+ end
38
+ end
39
+
40
+ def_node_matcher :if_respond_to_provides?, <<~PATTERN
41
+ (if (send nil? :respond_to? ( :sym :provides ) ) ... )
42
+ PATTERN
43
+
44
+ def autocorrect(node)
45
+ lambda do |corrector|
46
+ corrector.replace(node.loc.expression, node.children[1].source)
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,53 @@
1
+ #
2
+ # Copyright:: 2019, Chef Software, Inc.
3
+ # Author:: Tim Smith (<tsmith@chef.io>)
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+ module RuboCop
18
+ module Cop
19
+ module Chef
20
+ # Chef 12.5 introduced the resource_name method for resources. Many cookbooks used
21
+ # respond_to?(:resource_name) to provide backwards compatibility with older chef-client
22
+ # releases. This backwards compatibility is no longer necessary.
23
+ #
24
+ # @example
25
+ #
26
+ # # bad
27
+ # resource_name :foo if respond_to?(:resource_name)
28
+ #
29
+ # # good
30
+ # resource_name :foo
31
+ #
32
+ class RespondToResourceName < Cop
33
+ MSG = 'respond_to?(:resource_name) in resources is no longer necessary in Chef Infra Client 12.5+'.freeze
34
+
35
+ def on_if(node)
36
+ if_respond_to_resource_name?(node) do
37
+ add_offense(node, location: :expression, message: MSG, severity: :refactor)
38
+ end
39
+ end
40
+
41
+ def_node_matcher :if_respond_to_resource_name?, <<~PATTERN
42
+ (if (send nil? :respond_to? ( :sym :resource_name ) ) ... )
43
+ PATTERN
44
+
45
+ def autocorrect(node)
46
+ lambda do |corrector|
47
+ corrector.replace(node.loc.expression, node.children[1].source)
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+ 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: 5.1.19
4
+ version: 5.2.17
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: 2019-08-08 00:00:00.000000000 Z
12
+ date: 2019-08-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -74,7 +74,12 @@ files:
74
74
  - lib/cookstyle/version.rb
75
75
  - lib/rubocop/chef.rb
76
76
  - lib/rubocop/chef/cookbook_only.rb
77
+ - lib/rubocop/cop/chef/correctness/block_guard_clause_string_only.rb
78
+ - lib/rubocop/cop/chef/correctness/cb_depends_on_self.rb
77
79
  - lib/rubocop/cop/chef/correctness/insecure_cookbook_url.rb
80
+ - lib/rubocop/cop/chef/correctness/invalid_license_string.rb
81
+ - lib/rubocop/cop/chef/correctness/invalid_platform_metadata.rb
82
+ - lib/rubocop/cop/chef/correctness/metadata_missing_name.rb
78
83
  - lib/rubocop/cop/chef/correctness/name_property_and_required.rb
79
84
  - lib/rubocop/cop/chef/correctness/node_normal.rb
80
85
  - lib/rubocop/cop/chef/correctness/node_normal_unless.rb
@@ -90,16 +95,24 @@ files:
90
95
  - lib/rubocop/cop/chef/deprecation/easy_install.rb
91
96
  - lib/rubocop/cop/chef/deprecation/epic_fail.rb
92
97
  - lib/rubocop/cop/chef/deprecation/erl_call.rb
98
+ - lib/rubocop/cop/chef/deprecation/long_description_metadata.rb
93
99
  - lib/rubocop/cop/chef/deprecation/node_set.rb
94
100
  - lib/rubocop/cop/chef/deprecation/node_set_unless.rb
95
101
  - lib/rubocop/cop/chef/deprecation/provides_metadata.rb
96
102
  - lib/rubocop/cop/chef/deprecation/replaces_metadata.rb
103
+ - lib/rubocop/cop/chef/deprecation/require_recipe.rb
104
+ - lib/rubocop/cop/chef/deprecation/respond_to_metadata.rb
97
105
  - lib/rubocop/cop/chef/deprecation/suggests_metadata.rb
98
106
  - lib/rubocop/cop/chef/effortless/data_bags.rb
99
107
  - lib/rubocop/cop/chef/effortless/search_used.rb
100
108
  - lib/rubocop/cop/chef/modernize/berksfile_source.rb
101
109
  - lib/rubocop/cop/chef/modernize/build_essential.rb
102
110
  - lib/rubocop/cop/chef/modernize/chef_14_resources.rb
111
+ - lib/rubocop/cop/chef/modernize/resource_set_or_return.rb
112
+ - lib/rubocop/cop/chef/modernize/resource_with_allowed_action.rb
113
+ - lib/rubocop/cop/chef/modernize/resource_with_attributes.rb
114
+ - lib/rubocop/cop/chef/modernize/respond_to_provides.rb
115
+ - lib/rubocop/cop/chef/modernize/respond_to_resource_name.rb
103
116
  - lib/rubocop/cop/chef/modernize/why_run_supported_true.rb
104
117
  - lib/rubocop/cop/chef/style/attribute_keys.rb
105
118
  - lib/rubocop/cop/chef/style/comment_sentence_spacing.rb