cookstyle 7.15.1 → 7.16.1

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: af99d51e19e15818c6e7abfc5568ad41eb3177b22a12b100a3504dbc0eeb7a93
4
- data.tar.gz: 9aa6ba0fed844a339352cbd3f7df53f33a6a8de9dc43b4efd9fee5b4e5306ed6
3
+ metadata.gz: '029dae7e633891d64673dbd8098a21e80f6d2486d887dc01c593fed5c16d9677'
4
+ data.tar.gz: 2eb8ce0b238dc9c1783bca17b2800f0511c9f1ce02f7ff47d7a3857e7dc2bb5f
5
5
  SHA512:
6
- metadata.gz: 495d1fe5dd18b8af274968bbb5a191314f1b36489376b7190fd225a43bd496e77ec8a176e035200f66f8c2489a5cdf2a283eb9a8a49fdcd4a900aa46de403f5e
7
- data.tar.gz: b8f3bdc192e31b5bfd62e890a417c3b87e194197f4d8ab17381e5751a1ff6d1a0e2debf9af867dd36ece02cb0d07dcfabe0691922cbc4f0483fdc2d048615ce1
6
+ metadata.gz: 49abaf63bbf1c6e6a11909d4fcad7385256472ea66093459b371e67c438b022fb337554b265c9f55d2ccaaa2c904b4a1d6c91a8f4e936ac74d9017d1757b8975
7
+ data.tar.gz: c0ff0119835855ac64d543b15b586302da74659768926517fd107b0d3b4e3fba502b97d6fd5640a31eb4cd3a3b9544d29e418e0ae25900eda958e7deade23764
data/config/cookstyle.yml CHANGED
@@ -481,6 +481,14 @@ Chef/Correctness/OctalModeAsString:
481
481
  - '**/metadata.rb'
482
482
  - '**/Berksfile'
483
483
 
484
+ Chef/Correctness/MetadataMalformedDepends:
485
+ Description: Don't represent file modes as strings containing octal values. Use standard base 10 file modes instead.
486
+ StyleGuide: 'chef_correctness_metadatamalformeddepends'
487
+ Enabled: true
488
+ VersionAdded: '7.16'
489
+ Include:
490
+ - '**/metadata.rb'
491
+
484
492
  ###############################
485
493
  # Chef/Sharing: Issues that prevent sharing code with other teams or with the Chef community in general
486
494
  ###############################
@@ -1206,6 +1214,7 @@ Chef/Deprecations/ResourceWithoutUnifiedTrue:
1206
1214
  Include:
1207
1215
  - '**/resources/*.rb'
1208
1216
  Exclude:
1217
+ - '**/resources/_*.rb'
1209
1218
  - '**/spec/**/*.rb'
1210
1219
 
1211
1220
  Chef/Deprecations/PolicyfileCommunitySource:
@@ -2449,6 +2458,8 @@ Lint/HandleExceptions:
2449
2458
  Enabled: true
2450
2459
  Lint/ImplicitStringConcatenation:
2451
2460
  Enabled: true
2461
+ Exclude:
2462
+ - '**/metadata.rb' # this prevents conflicts with Chef/Correctness/MetadataMalformedDepends
2452
2463
  Lint/IneffectiveAccessModifier:
2453
2464
  Enabled: true
2454
2465
  Lint/LiteralAsCondition:
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  module Cookstyle
3
- VERSION = "7.15.1" # rubocop: disable Style/StringLiterals
4
- RUBOCOP_VERSION = '1.18.3'
3
+ VERSION = "7.16.1" # rubocop: disable Style/StringLiterals
4
+ RUBOCOP_VERSION = '1.18.4'
5
5
  end
@@ -0,0 +1,58 @@
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 Correctness
22
+ # metadata.rb cookbook dependencies and version constraints should be comma separated
23
+ #
24
+ # @example
25
+ #
26
+ # #### incorrect
27
+ # depends 'some_awesome_cookbook' '= 4.5.5'
28
+ # depends 'some_other_cool_cookbook' '< 8.0'
29
+ #
30
+ # #### correct
31
+ # depends 'some_awesome_cookbook', '= 4.5.5'
32
+ # depends 'some_other_cool_cookbook', '< 8.0'
33
+ #
34
+ class MetadataMalformedDepends < Base
35
+ extend RuboCop::Cop::AutoCorrector
36
+
37
+ RESTRICT_ON_SEND = [:depends].freeze
38
+ MSG = 'metadata.rb cookbook dependencies and version constraints should be comma separated'
39
+
40
+ def_node_matcher :depends_without_comma?, <<-PATTERN
41
+ (send nil? :depends
42
+ (dstr
43
+ $(str _ )
44
+ $(str _ )))
45
+ PATTERN
46
+
47
+ def on_send(node)
48
+ depends_without_comma?(node) do |cb, ver|
49
+ add_offense(node, message: MSG, severity: :refactor) do |corrector|
50
+ corrector.replace(node, "depends '#{cb.value}', '#{ver.value}'")
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  #
3
- # Copyright:: 2019, Chef Software Inc.
3
+ # Copyright:: 2019-2021, Chef Software Inc.
4
4
  # Author:: Tim Smith (<tsmith@chef.io>)
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -27,6 +27,7 @@ module RuboCop
27
27
  # name 'foo'
28
28
  #
29
29
  class MetadataMissingName < Base
30
+ extend AutoCorrector
30
31
  include RangeHelp
31
32
 
32
33
  MSG = 'metadata.rb needs to include the name method or it will fail on Chef Infra Client 12 and later.'
@@ -37,11 +38,10 @@ module RuboCop
37
38
  # Using range similar to RuboCop::Cop::Naming::Filename (file_name.rb)
38
39
  return if cb_name?(processed_source.ast)
39
40
  range = source_range(processed_source.buffer, 1, 0)
40
- add_offense(range, message: MSG, severity: :refactor) do |_corrector|
41
+ add_offense(range, message: MSG, severity: :refactor) do |corrector|
41
42
  path = processed_source.path
42
43
  cb_name = File.basename(File.dirname(path))
43
- metadata = IO.read(path)
44
- IO.write(path, "name '#{cb_name}'\n" + metadata)
44
+ corrector.insert_before(processed_source.ast, "name '#{cb_name}'\n")
45
45
  end
46
46
  end
47
47
  end
@@ -54,6 +54,9 @@ module RuboCop
54
54
  def_node_search :provides, '(send nil? :provides ...)'
55
55
 
56
56
  def on_new_investigation
57
+ # gracefully fail if the resource is empty
58
+ return if processed_source.ast.nil?
59
+
57
60
  # Using range similar to RuboCop::Cop::Naming::Filename (file_name.rb)
58
61
  return if unified_mode?(processed_source.ast)
59
62
  range = source_range(processed_source.buffer, 1, 0)
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.15.1
4
+ version: 7.16.1
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: 2021-07-06 00:00:00.000000000 Z
12
+ date: 2021-08-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rubocop
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - '='
19
19
  - !ruby/object:Gem::Version
20
- version: 1.18.3
20
+ version: 1.18.4
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - '='
26
26
  - !ruby/object:Gem::Version
27
- version: 1.18.3
27
+ version: 1.18.4
28
28
  description:
29
29
  email:
30
30
  - thom@chef.io
@@ -69,6 +69,7 @@ files:
69
69
  - lib/rubocop/cop/chef/correctness/lazy_in_resource_guard.rb
70
70
  - lib/rubocop/cop/chef/correctness/macos_userdefaults_invalid_type.rb
71
71
  - lib/rubocop/cop/chef/correctness/malformed_value_for_platform.rb
72
+ - lib/rubocop/cop/chef/correctness/metadata_malformed_version.rb
72
73
  - lib/rubocop/cop/chef/correctness/metadata_missing_name.rb
73
74
  - lib/rubocop/cop/chef/correctness/node_normal.rb
74
75
  - lib/rubocop/cop/chef/correctness/node_normal_unless.rb