cookstyle 5.2.17 → 5.3.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5b693c3f963fdd6689770744a4ba49fc1461c9312976cfcef2947ff938b04bc9
4
- data.tar.gz: 629951dbaa3f1c0e3e116b42f0848415b524886351f67eda55c1f7208715de6f
3
+ metadata.gz: e6af19177bab0492d840cc42ab0b2afffaaf31c1a16492a6235811d362390f2f
4
+ data.tar.gz: '01748b9bfbfcc03c1d99d4e09c24db484b76fa1c12010c48d6cb37c5ed3416bc'
5
5
  SHA512:
6
- metadata.gz: 92a8fca655802ef1627025fca46a23531290aba1bd7240805ba74d648b775d876bf72a5ae955b35c47852110ca05492882afb6334124b79eda310165e8930645
7
- data.tar.gz: da43f5422b02cb8d57d15b13b2390f7d9064a80c4ec0b58fce0371b81eb1ab3a0ba68928475316466b52ae9f05eb7af74fa33a33be2fddd64a60da4134995ca8
6
+ metadata.gz: 6c84f45e06ffb944c0990ebed2d03b6a19d99c78b09c5e01fd8e16d27719c82d074364805b9e936ff793f4da805edcd706d1da7f0a16507526478603d409767c
7
+ data.tar.gz: 9a78e7d098beb29896f63861867766b7744bb4e5262a2aec903caed0399c9659c0c25d249a232e57795707200c0eba0bb2b5b9a7ec8b0d90fca1c66ee87f2606
@@ -293,6 +293,41 @@ Chef/CustomResourceWithAllowedActions:
293
293
  Include:
294
294
  - '**/resources/*.rb'
295
295
 
296
+ Chef/IncludingAptDefaultRecipe:
297
+ Description: Do not include the Apt default recipe to update package cache. Instead use the apt_update resource, which is built into Chef Infra Client 12.7 and later.
298
+ Enabled: true
299
+ VersionAdded: '5.3.0'
300
+ Exclude:
301
+ - '**/metadata.rb'
302
+
303
+ Chef/IncludingWindowsDefaultRecipe:
304
+ Description: Do not include the Windows default recipe, which only installs win32 gems already included in Chef Infra Client
305
+ Enabled: true
306
+ VersionAdded: '5.3.0'
307
+ Exclude:
308
+ - '**/metadata.rb'
309
+
310
+ Chef/IncludingYumDNFCompatRecipe:
311
+ Description: Do not include the yum::dnf_yum_compat default recipe to install yum on dnf systems. Chef Infra Client now includes built in support for DNF.
312
+ Enabled: true
313
+ VersionAdded: '5.3.0'
314
+ Exclude:
315
+ - '**/metadata.rb'
316
+
317
+ Chef/DefinesChefSpecMatchers:
318
+ Description: ChefSpec matchers are now auto generated by ChefSpec 7.1+ and do not need to be defined in a cookbook
319
+ Enabled: true
320
+ VersionAdded: '5.3.0'
321
+ Include:
322
+ - '**/libraries/*.rb'
323
+
324
+ Chef/ExecuteAptUpdate:
325
+ Description: Use the apt_update resource instead of the execute resource to run an apt-get update package cache update
326
+ Enabled: true
327
+ VersionAdded: '5.3.0'
328
+ Exclude:
329
+ - '**/metadata.rb'
330
+
296
331
  ###############################
297
332
  # Detecting code that breaks Chef
298
333
  ###############################
@@ -1,4 +1,4 @@
1
1
  module Cookstyle
2
- VERSION = "5.2.17".freeze # rubocop: disable Style/StringLiterals
2
+ VERSION = "5.3.6".freeze # rubocop: disable Style/StringLiterals
3
3
  RUBOCOP_VERSION = '0.72.0'.freeze
4
4
  end
@@ -440,6 +440,7 @@ module RuboCop
440
440
  COMMON_TYPOS = {
441
441
  "all_rights": 'all rights reserved',
442
442
  "apache 2.0": 'Apache-2.0',
443
+ "apache v2.0": 'Apache-2.0',
443
444
  "apache license version 2.0": 'Apache-2.0',
444
445
  "apache2": 'Apache-2.0',
445
446
  "mit": 'MIT',
@@ -29,8 +29,14 @@ module RuboCop
29
29
  class LongDescriptionMetadata < Cop
30
30
  MSG = 'The long_description metadata.rb method is not used and is unnecessary in cookbooks'.freeze
31
31
 
32
+ def_node_matcher :long_description?, <<-PATTERN
33
+ (send nil? :long_description ... )
34
+ PATTERN
35
+
32
36
  def on_send(node)
33
- add_offense(node, location: :expression, message: MSG, severity: :refactor) if node.method_name == :long_description
37
+ long_description?(node) do
38
+ add_offense(node, location: :expression, message: MSG, severity: :refactor) if node.method_name == :long_description
39
+ end
34
40
  end
35
41
 
36
42
  def autocorrect(node)
@@ -0,0 +1,47 @@
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
+ # Don't include the apt default recipe to update apt's package cache when you can
21
+ # use the apt_update resource built into Chef Infra Client 12.7 and later.
22
+ #
23
+ # @example
24
+ #
25
+ # # bad
26
+ # include_recipe 'apt::default'
27
+ # include_recipe 'apt'
28
+ #
29
+ # # good
30
+ # apt_update
31
+ #
32
+ class IncludingAptDefaultRecipe < Cop
33
+ MSG = 'Do not include the Apt default recipe to update package cache. Instead use the apt_update resource, which is built into Chef Infra Client 12.7 and later.'.freeze
34
+
35
+ def_node_matcher :apt_recipe_usage?, <<-PATTERN
36
+ (send nil? :include_recipe (str {"apt" "apt::default"}))
37
+ PATTERN
38
+
39
+ def on_send(node)
40
+ apt_recipe_usage?(node) do
41
+ add_offense(node, location: :expression, message: MSG, severity: :refactor)
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ 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
+ # ChefSpec 7.1 and later auto generate ChefSpec matchers. Matchers in cookbooks can now be removed.
21
+ #
22
+ # @example
23
+ #
24
+ # # bad
25
+ # if defined?(ChefSpec)
26
+ # def create_yum_repository(resource_name)
27
+ # ChefSpec::Matchers::ResourceMatcher.new(:yum_repository, :create, resource_name)
28
+ # end
29
+ # end
30
+ #
31
+ class DefinesChefSpecMatchers < Cop
32
+ MSG = 'ChefSpec matchers are now auto generated by ChefSpec 7.1+ and do not need to be defined in a cookbook'.freeze
33
+
34
+ def_node_matcher :chefspec_matcher?, <<-PATTERN
35
+ (if ( :defined? (const nil? :ChefSpec)) ... )
36
+ PATTERN
37
+
38
+ def on_if(node)
39
+ chefspec_matcher?(node) do
40
+ add_offense(node, location: :expression, message: MSG, severity: :refactor)
41
+ end
42
+ end
43
+
44
+ def autocorrect(node)
45
+ lambda do |corrector|
46
+ corrector.remove(node.loc.expression)
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,44 @@
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
+ # Instead of using the execute resource to to run the `apt-get update` use Chef Infra Client's built-n
21
+ # apt_update resource which is available in Chef Infra Client 12.7 and later.
22
+ #
23
+ # # bad
24
+ # execute 'apt-get update'
25
+ #
26
+ # # good
27
+ # apt_update
28
+ #
29
+ class ExecuteAptUpdate < Cop
30
+ MSG = 'Use the apt_update resource instead of the execute resource to run an apt-get update package cache update'.freeze
31
+
32
+ def_node_matcher :execute_apt_update?, <<-PATTERN
33
+ (send nil? :execute (str "apt-get update"))
34
+ PATTERN
35
+
36
+ def on_send(node)
37
+ execute_apt_update?(node) do
38
+ add_offense(node, location: :expression, message: MSG, severity: :refactor)
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,50 @@
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
+ # Don't include the windows default recipe that is either full of gem install that are part
21
+ # of the Chef Infra Client, or empty (depends on version).
22
+ #
23
+ # @example
24
+ #
25
+ # # bad
26
+ # include_recipe 'windows::default'
27
+ # include_recipe 'windows'
28
+ #
29
+ class IncludingWindowsDefaultRecipe < Cop
30
+ MSG = 'Do not include the Windows default recipe, which only installs win32 gems already included in Chef Infra Client'.freeze
31
+
32
+ def_node_matcher :windows_recipe_usage?, <<-PATTERN
33
+ (send nil? :include_recipe (str {"windows" "windows::default"}))
34
+ PATTERN
35
+
36
+ def on_send(node)
37
+ windows_recipe_usage?(node) do
38
+ add_offense(node, location: :expression, message: MSG, severity: :refactor)
39
+ end
40
+ end
41
+
42
+ def autocorrect(node)
43
+ lambda do |corrector|
44
+ corrector.remove(node.loc.expression)
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,49 @@
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
+ # Don't include the yum DNF compatibility recipe, which is no longer necessary
21
+ # as Chef Infra Client includes DNF package support
22
+ #
23
+ # @example
24
+ #
25
+ # # bad
26
+ # include_recipe 'yum::dnf_yum_compat'
27
+ #
28
+ class IncludingYumDNFCompatRecipe < Cop
29
+ MSG = 'Do not include the yum::dnf_yum_compat default recipe to install yum on dnf systems. Chef Infra Client now includes built in support for DNF packages.'.freeze
30
+
31
+ def_node_matcher :yum_dnf_compat_recipe_usage?, <<-PATTERN
32
+ (send nil? :include_recipe (str "yum::dnf_yum_compat"))
33
+ PATTERN
34
+
35
+ def on_send(node)
36
+ yum_dnf_compat_recipe_usage?(node) do
37
+ add_offense(node, location: :expression, message: MSG, severity: :refactor)
38
+ end
39
+ end
40
+
41
+ def autocorrect(node)
42
+ lambda do |corrector|
43
+ corrector.remove(node.loc.expression)
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -56,7 +56,8 @@ module RuboCop
56
56
  def autocorrect(comment)
57
57
  # Extract the type and the actual value. Strip out "Name" or "File"
58
58
  # 'Cookbook Name' should be 'Cookbook'. Also skip a :: if present
59
- match = /^# ?([A-Za-z]+)\s?(?:Name|File)?(?:::)?\s(.*)/.match(comment.text)
59
+ # https://rubular.com/r/Do9fpLWXlCmvdJ
60
+ match = /^#\s*([A-Za-z]+)\s?(?:Name|File)?(?:::)?\s(.*)/.match(comment.text)
60
61
  comment_type, value = match.captures
61
62
  correct_comment = "# #{comment_type}:: #{value}"
62
63
 
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.2.17
4
+ version: 5.3.6
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-15 00:00:00.000000000 Z
12
+ date: 2019-08-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -105,15 +105,20 @@ files:
105
105
  - lib/rubocop/cop/chef/deprecation/suggests_metadata.rb
106
106
  - lib/rubocop/cop/chef/effortless/data_bags.rb
107
107
  - lib/rubocop/cop/chef/effortless/search_used.rb
108
+ - lib/rubocop/cop/chef/modernize/apt_default_recipe.rb
108
109
  - lib/rubocop/cop/chef/modernize/berksfile_source.rb
109
110
  - lib/rubocop/cop/chef/modernize/build_essential.rb
110
111
  - lib/rubocop/cop/chef/modernize/chef_14_resources.rb
112
+ - lib/rubocop/cop/chef/modernize/defines_chefspec_matchers.rb
113
+ - lib/rubocop/cop/chef/modernize/execute_apt_update.rb
111
114
  - lib/rubocop/cop/chef/modernize/resource_set_or_return.rb
112
115
  - lib/rubocop/cop/chef/modernize/resource_with_allowed_action.rb
113
116
  - lib/rubocop/cop/chef/modernize/resource_with_attributes.rb
114
117
  - lib/rubocop/cop/chef/modernize/respond_to_provides.rb
115
118
  - lib/rubocop/cop/chef/modernize/respond_to_resource_name.rb
116
119
  - lib/rubocop/cop/chef/modernize/why_run_supported_true.rb
120
+ - lib/rubocop/cop/chef/modernize/windows_default_recipe.rb
121
+ - lib/rubocop/cop/chef/modernize/yum_dnf_compat_recipe.rb
117
122
  - lib/rubocop/cop/chef/style/attribute_keys.rb
118
123
  - lib/rubocop/cop/chef/style/comment_sentence_spacing.rb
119
124
  - lib/rubocop/cop/chef/style/comments_copyright_format.rb