cookstyle 7.31.7 → 7.32.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: 0041f7691cd8703343c065df3ff9845f59018276336bf8fe0bf199a802533fc8
4
- data.tar.gz: 782fa56469ebdc5895320bcf4c815a1bb9964aced211c52b007b3945cb331adc
3
+ metadata.gz: 35037ddf834c7c995f3ae81181f923b8fc2c70b10686814beb82462558014fd8
4
+ data.tar.gz: 8f56143d1d34824560f24f41885a279299c5bef28913795b17531fea355e131f
5
5
  SHA512:
6
- metadata.gz: 6a67d211251cf6443c9cdd6fbc5cd696f13d3fdd178fa3ea8bef7bd6c3495869b935f0dd01083cf5ca8a9a705ad32370ea8e640c390dbeda9629ee260fe06234
7
- data.tar.gz: e7fac0be14547d1fb7ac86a61d8a23923d47d2958bc2f5df466eb487d4d67abd0f28b6f0d76afa4c803fc3f952981fa1c3fd3e03d5763d1eb63217665be3f64b
6
+ metadata.gz: d0fdf8339747df02c7c64f54f1e3a2366de8220f7e2fb5a8e96fed09c504e1e3dc54463c1fe2fa1dd408228c1dd5bc127b4441458db732d3d8a6587733521b0a
7
+ data.tar.gz: c56b19393c8d92fe54a5c80a8ab23eea7ada4fbac3fe301a870ece705900cfcd273f9c0fc0507dc3def3b7b0462572f888e849d3857bea3d452ad3fae9322170
data/config/cookstyle.yml CHANGED
@@ -2,11 +2,33 @@ AllCops:
2
2
  SuggestExtensions: false
3
3
  TargetRubyVersion: 2.5
4
4
  TargetChefVersion: ~
5
+ inherit_mode:
6
+ merge:
7
+ - Include
8
+ Include:
9
+ - '**/.delivery/project.toml' # required by Chef/Deprecations/Delivery
10
+ - '**/.delivery/config.json' # required by Chef/Deprecations/Delivery
11
+ - '**/.foodcritic'
5
12
  Exclude:
6
13
  - '**/files/**/*'
7
14
  - '**/vendor/**/*'
8
15
  - Guardfile
9
16
 
17
+ Layout:
18
+ Exclude:
19
+ - '**/.delivery/project.toml'
20
+ - '**/.delivery/config.json'
21
+
22
+ Lint:
23
+ Exclude:
24
+ - '**/.delivery/project.toml'
25
+ - '**/.delivery/config.json'
26
+
27
+ Style:
28
+ Exclude:
29
+ - '**/.delivery/project.toml'
30
+ - '**/.delivery/config.json'
31
+
10
32
  ###############################
11
33
  # Chef/Style: Making cookbooks look better
12
34
  ###############################
@@ -14,6 +36,9 @@ AllCops:
14
36
  Chef/Style:
15
37
  Enabled: true
16
38
  StyleGuideBaseURL: https://docs.chef.io/workstation/cookstyle/
39
+ Exclude:
40
+ - '**/.delivery/project.toml'
41
+ - '**/.delivery/config.json'
17
42
 
18
43
  Chef/Style/AttributeKeys:
19
44
  Description: Check which style of keys are used to access node attributes.
@@ -1216,6 +1241,14 @@ Chef/Deprecations/FoodcriticTesting:
1216
1241
  - '**/Rakefile'
1217
1242
  - '**/Gemfile'
1218
1243
 
1244
+ Chef/Deprecations/FoodcriticFile:
1245
+ Description: The Foodcritic cookbook linter has been deprecated and should no longer be used for validating cookbooks
1246
+ StyleGuide: 'chef_deprecations_foodcriticfile'
1247
+ Enabled: true
1248
+ VersionAdded: '7.32.0'
1249
+ Include:
1250
+ - '**/.foodcritic'
1251
+
1219
1252
  Chef/Deprecations/DeprecatedYumRepositoryActions:
1220
1253
  Description: With the release of Chef Infra Client 12.14 and the yum cookbook 3.0 several actions in the yum_repository resource actions were renamed. The `add` action became `create` and `delete` became `remove` to better match other resources in Chef Infra Client.
1221
1254
  StyleGuide: 'chef_deprecations_deprecatedyumrepositoryactions'
@@ -1265,12 +1298,13 @@ Chef/Deprecations/PolicyfileCommunitySource:
1265
1298
  - '**/Policyfile.rb'
1266
1299
 
1267
1300
  Chef/Deprecations/Delivery:
1268
- Description: Do not include a `.delivery` directory for the `delivery` command in your cookbooks. Chef Delivery (Workflow) went EOL Dec 31st 2021 and the delivery command was removed from Chef Workstation Feb 2022.
1301
+ Description: Do not include Chef Delivery (Workflow) configuration in your cookbooks. Chef Delivery (Workflow) went EOL Dec 31st 2021 and the delivery command was removed from Chef Workstation Feb 2022.
1269
1302
  StyleGuide: 'chef_deprecations_delivery'
1270
1303
  Enabled: true
1271
1304
  VersionAdded: '7.31.0'
1272
1305
  Include:
1273
- - '**/metadata.rb'
1306
+ - '**/.delivery/project.toml'
1307
+ - '**/.delivery/config.json'
1274
1308
 
1275
1309
  Chef/Deprecations/DeprecatedSudoActions:
1276
1310
  Description: The `sudo` resource in the sudo cookbook 5.0 (2018) or Chef Infra Client 14 and later have replaced the existing `:install` and `:remove` actions with `:create` and `:delete` actions to better match other resources in Chef Infra.
@@ -1954,7 +1988,7 @@ Chef/Modernize/UseChefLanguageCloudHelpers:
1954
1988
  - '**/resources/*.rb'
1955
1989
  - '**/providers/*.rb'
1956
1990
  - '**/recipes/*.rb'
1957
-
1991
+
1958
1992
  Chef/Modernize/ClassEvalActionClass:
1959
1993
  Description: In Chef Infra Client 12.9 and later it is no longer necessary to call the class_eval method on the action class block.
1960
1994
  StyleGuide: 'chef_modernize_classevalactionclass'
@@ -2332,7 +2366,7 @@ Chef/Security/SshPrivateKey:
2332
2366
  - '**/recipes/*.rb'
2333
2367
  - '**/attributes/*.rb'
2334
2368
  - '**/definitions/*.rb'
2335
-
2369
+
2336
2370
  #### The base rubocop 0.37 enabled.yml file we started with ####
2337
2371
 
2338
2372
  Layout/AccessModifierIndentation:
@@ -3094,4 +3128,4 @@ Style/FileRead:
3094
3128
 
3095
3129
  # reduce file write complexity
3096
3130
  Style/FileWrite:
3097
- Enabled: true
3131
+ Enabled: true
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  module Cookstyle
3
- VERSION = "7.31.7" # rubocop: disable Style/StringLiterals
3
+ VERSION = "7.32.1" # rubocop: disable Style/StringLiterals
4
4
  RUBOCOP_VERSION = '1.25.1'
5
5
  end
@@ -25,12 +25,12 @@ module RuboCop
25
25
  #
26
26
  # #### incorrect
27
27
  # platform?('darwin')
28
- # platform?('rhel)
28
+ # platform?('rhel')
29
29
  # platform?('sles')
30
30
  #
31
31
  # #### correct
32
32
  # platform?('mac_os_x')
33
- # platform?('redhat)
33
+ # platform?('redhat')
34
34
  # platform?('suse')
35
35
  #
36
36
  class InvalidPlatformHelper < Base
@@ -27,14 +27,14 @@ module RuboCop
27
27
  # ChefDK::CLI
28
28
  # ChefDK::Generator::TemplateHelper
29
29
  # module ChefDK
30
- # ...
30
+ # # some additional code
31
31
  # end
32
32
  #
33
33
  # #### correct
34
34
  # ChefCLI::CLI
35
35
  # ChefCLI::Generator::TemplateHelper
36
36
  # module ChefCLI
37
- # ...
37
+ # # some additional code
38
38
  # end
39
39
  #
40
40
  class ChefDKGenerators < Base
@@ -27,16 +27,20 @@ module RuboCop
27
27
  class Delivery < Base
28
28
  include RangeHelp
29
29
 
30
- MSG = 'Do not include a `.delivery` directory for the `delivery` command in your cookbooks. Chef Delivery (Workflow) went EOL Dec 31st 2021 and the delivery command was removed from Chef Workstation Feb 2022.'
30
+ MSG = 'Do not include Chef Delivery (Workflow) configuration in your cookbooks. It went EOL Dec 31st 2021 and the delivery command was removed from Chef Workstation Feb 2022.'
31
31
 
32
- def on_new_investigation
33
- return unless File.exist?(File.join(File.dirname(processed_source.path) + '/.delivery'))
32
+ def on_other_file
33
+ return unless processed_source.path.end_with?('/.delivery/project.toml', '/.delivery/config.json')
34
34
 
35
35
  # Using range similar to RuboCop::Cop::Naming::Filename (file_name.rb)
36
36
  range = source_range(processed_source.buffer, 1, 0)
37
37
 
38
38
  add_offense(range, severity: :warning)
39
39
  end
40
+
41
+ # An empty / simple TOML file can also be syntatically valid Ruby, so
42
+ # RuboCop may start an investigation instead of calling on_other_file.
43
+ alias_method :on_new_investigation, :on_other_file
40
44
  end
41
45
  end
42
46
  end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # Copyright:: 2022, Chef Software Inc.
4
+ # Author:: Tim Smith (<tsmith84@gmail.com>)
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 Deprecations
22
+ # The Foodcritic cookbook linter has been deprecated and should no longer be used for validating cookbooks. Do not include the `.foodcritic` config file used by Foodcritic in your cookbooks.
23
+ #
24
+ class FoodcriticFile < Base
25
+ include RangeHelp
26
+
27
+ MSG = 'Do not include the `.foodcritic` config file for the deprecated Foodcritic cookbook linter.'
28
+
29
+ def on_new_investigation
30
+ return unless processed_source.path.end_with?('.foodcritic')
31
+
32
+ # Using range similar to RuboCop::Cop::Naming::Filename (file_name.rb)
33
+ range = source_range(processed_source.buffer, 1, 0)
34
+
35
+ add_offense(range, severity: :warning)
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -30,7 +30,7 @@ module RuboCop
30
30
  #
31
31
  # #### correct
32
32
  # action :foo do
33
- # converge_by('resource did something) do
33
+ # converge_by('resource did something') do
34
34
  # # code that causes the resource to converge
35
35
  # end
36
36
  #
@@ -28,7 +28,8 @@ module RuboCop
28
28
  # class MyCookbookService < Chef::Resource
29
29
  # use_automatic_resource_name
30
30
  # provides :mycookbook_service
31
- # ...
31
+ #
32
+ # # some additional code
32
33
  # end
33
34
  # end
34
35
  #
@@ -33,6 +33,8 @@ module RuboCop
33
33
  #
34
34
  # # check to see if we're on RHEL 7 on a RHEL 7.6 node where node['platform_version] is 7.6.1810
35
35
  # if node['platform_version'].to_i == 7
36
+ # # some code
37
+ # end
36
38
  #
37
39
  class SimplifyPlatformMajorVersionCheck < Base
38
40
  extend AutoCorrector
@@ -19,7 +19,7 @@ module RuboCop
19
19
  module Cop
20
20
  module InSpec
21
21
  module Deprecations
22
- # The InSpec inputs `default` option has been replaced with the `value` option.
22
+ # The Chef InSpec inputs `default` option has been replaced with the `value` option.
23
23
  #
24
24
  # @example
25
25
  #
@@ -19,7 +19,7 @@ module RuboCop
19
19
  module Cop
20
20
  module InSpec
21
21
  module Deprecations
22
- # InSpec attributes have been renamed to inputs. Use the `input` method not the deprecation `attribute` method to access these values.
22
+ # Chef InSpec attributes have been renamed to inputs. Use the `input` method not the deprecation `attribute` method to access these values.
23
23
  #
24
24
  # @example
25
25
  #
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+ require 'rubocop/rspec/expect_offense'
3
+ # rubocop:disable Lint/DuplicateMethods
4
+
5
+ module RuboCop
6
+ module RSpec
7
+ module ExpectOffense
8
+ # Yields to a block with `parse_processed_source` patched to not raise an
9
+ # exception.
10
+ #
11
+ # RSpec's `expect_offense` helper calls a method called
12
+ # `parse_processed_source` that parses source code and raises an exception
13
+ # if it is not valid Ruby. Raising an exception prevents RuboCop from
14
+ # calling the cop's `on_other_file` method for checking non-Ruby files.
15
+ def allow_invalid_ruby(&block)
16
+ alias :parse_processed_source :_parse_invalid_source
17
+ yield block
18
+ alias :parse_processed_source :_orig_parse_processed_source
19
+ end
20
+
21
+ alias :_orig_parse_processed_source :parse_processed_source
22
+
23
+ def _parse_invalid_source(source, file = nil)
24
+ parse_source(source, file)
25
+ end
26
+ end
27
+ end
28
+ 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: 7.31.7
4
+ version: 7.32.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: 2022-02-17 00:00:00.000000000 Z
12
+ date: 2022-02-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rubocop
@@ -124,6 +124,7 @@ files:
124
124
  - lib/rubocop/cop/chef/deprecation/erl_call.rb
125
125
  - lib/rubocop/cop/chef/deprecation/execute_path_property.rb
126
126
  - lib/rubocop/cop/chef/deprecation/execute_relative_creates_without_cwd.rb
127
+ - lib/rubocop/cop/chef/deprecation/foodcritic_file.rb
127
128
  - lib/rubocop/cop/chef/deprecation/foodcritic_testing.rb
128
129
  - lib/rubocop/cop/chef/deprecation/hwrp_without_provides.rb
129
130
  - lib/rubocop/cop/chef/deprecation/hwrp_without_unified_mode_true.rb
@@ -303,6 +304,7 @@ files:
303
304
  - lib/rubocop/cop/inspec/deprecation/attribute_default.rb
304
305
  - lib/rubocop/cop/inspec/deprecation/attribute_helper.rb
305
306
  - lib/rubocop/cop/target_chef_version.rb
307
+ - lib/rubocop/monkey_patches/allow_invalid_ruby.rb
306
308
  - lib/rubocop/monkey_patches/base.rb
307
309
  - lib/rubocop/monkey_patches/config.rb
308
310
  - lib/rubocop/monkey_patches/directive_comment.rb