cookstyle 7.11.3 → 7.12.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/config/cookstyle.yml +16 -0
  3. data/lib/cookstyle/version.rb +1 -1
  4. data/lib/rubocop/cop/chef/correctness/invalid_default_action.rb +10 -11
  5. data/lib/rubocop/cop/chef/correctness/invalid_platform_metadata.rb +0 -1
  6. data/lib/rubocop/cop/chef/correctness/invalid_version_metadata.rb +0 -1
  7. data/lib/rubocop/cop/chef/correctness/lazy_eval_node_attribute_defaults.rb +0 -1
  8. data/lib/rubocop/cop/chef/correctness/metadata_missing_name.rb +9 -10
  9. data/lib/rubocop/cop/chef/correctness/notifies_action_not_symbol.rb +0 -1
  10. data/lib/rubocop/cop/chef/correctness/resource_sets_name_property.rb +0 -1
  11. data/lib/rubocop/cop/chef/correctness/resource_with_none_action.rb +0 -1
  12. data/lib/rubocop/cop/chef/correctness/service_resource.rb +0 -1
  13. data/lib/rubocop/cop/chef/correctness/supports_must_be_float.rb +0 -1
  14. data/lib/rubocop/cop/chef/correctness/tmp_path.rb +0 -1
  15. data/lib/rubocop/cop/chef/deprecation/cb_depends_on_self.rb +11 -12
  16. data/lib/rubocop/cop/chef/deprecation/chef_handler_recipe.rb +0 -1
  17. data/lib/rubocop/cop/chef/deprecation/chef_handler_supports.rb +0 -1
  18. data/lib/rubocop/cop/chef/deprecation/chef_rest.rb +0 -1
  19. data/lib/rubocop/cop/chef/deprecation/chef_rewind.rb +0 -1
  20. data/lib/rubocop/cop/chef/deprecation/chef_shellout.rb +0 -1
  21. data/lib/rubocop/cop/chef/deprecation/chef_sugar_helpers.rb +22 -23
  22. data/lib/rubocop/cop/chef/deprecation/chefdk_generators.rb +0 -1
  23. data/lib/rubocop/cop/chef/deprecation/cheffile.rb +2 -3
  24. data/lib/rubocop/cop/chef/deprecation/chefspec_coverage_report.rb +0 -1
  25. data/lib/rubocop/cop/chef/deprecation/chefspec_legacy_runner.rb +0 -1
  26. data/lib/rubocop/cop/chef/deprecation/chocolatey_package_uninstall_action.rb +0 -1
  27. data/lib/rubocop/cop/chef/deprecation/deprecated_chefspec_platform.rb +0 -1
  28. data/lib/rubocop/cop/chef/deprecation/deprecated_mixins.rb +0 -1
  29. data/lib/rubocop/cop/chef/deprecation/deprecated_platform_methods.rb +0 -1
  30. data/lib/rubocop/cop/chef/deprecation/deprecated_shellout_methods.rb +0 -1
  31. data/lib/rubocop/cop/chef/deprecation/easy_install.rb +0 -1
  32. data/lib/rubocop/cop/chef/deprecation/eol_audit_mode.rb +0 -1
  33. data/lib/rubocop/cop/chef/deprecation/epic_fail.rb +0 -1
  34. data/lib/rubocop/cop/chef/deprecation/erl_call.rb +0 -1
  35. data/lib/rubocop/cop/chef/deprecation/execute_path_property.rb +0 -1
  36. data/lib/rubocop/cop/chef/deprecation/execute_relative_creates_without_cwd.rb +0 -1
  37. data/lib/rubocop/cop/chef/deprecation/hwrp_without_provides.rb +0 -1
  38. data/lib/rubocop/cop/chef/deprecation/hwrp_without_unified_mode_true.rb +86 -0
  39. data/lib/rubocop/cop/chef/deprecation/inherits_compat_resource.rb +0 -1
  40. data/lib/rubocop/cop/chef/deprecation/log_resource_notifications.rb +0 -1
  41. data/lib/rubocop/cop/chef/deprecation/macos_userdefaults_global_property.rb +0 -1
  42. data/lib/rubocop/cop/chef/deprecation/require_recipe.rb +0 -1
  43. data/lib/rubocop/cop/chef/deprecation/resource_without_unified_mode_true.rb +84 -0
  44. data/lib/rubocop/cop/chef/deprecation/ruby_27_keyword_argument_warnings.rb +0 -1
  45. data/lib/rubocop/cop/chef/deprecation/ruby_block_create_action.rb +0 -1
  46. data/lib/rubocop/cop/chef/deprecation/windows_package_installer_type_string.rb +0 -1
  47. data/lib/rubocop/cop/chef/effortless/berksfile.rb +0 -1
  48. data/lib/rubocop/cop/chef/effortless/chef_vault_used.rb +0 -2
  49. data/lib/rubocop/cop/chef/effortless/depends_chef_vault.rb +0 -2
  50. data/lib/rubocop/cop/chef/modernize/chef_gem_nokogiri.rb +0 -1
  51. data/lib/rubocop/cop/chef/modernize/foodcritic_comments.rb +0 -1
  52. data/lib/rubocop/cop/chef/modernize/includes_mixin_shellout.rb +0 -1
  53. data/lib/rubocop/cop/chef/modernize/libarchive_file.rb +0 -1
  54. data/lib/rubocop/cop/chef/modernize/resource_set_or_return.rb +0 -1
  55. data/lib/rubocop/cop/chef/modernize/resource_with_attributes.rb +0 -1
  56. data/lib/rubocop/cop/chef/modernize/seven_zip_archive.rb +0 -1
  57. data/lib/rubocop/cop/chef/modernize/shell_out_helper.rb +0 -1
  58. data/lib/rubocop/cop/chef/modernize/simplify_apt_ppa_setup.rb +0 -1
  59. data/lib/rubocop/cop/chef/modernize/unnecessary_mixlib_shellout_require.rb +0 -1
  60. data/lib/rubocop/cop/chef/modernize/zipfile_resource.rb +0 -1
  61. data/lib/rubocop/cop/chef/redundant/attribute_metadata.rb +0 -1
  62. data/lib/rubocop/cop/chef/redundant/conflicts_metadata.rb +0 -1
  63. data/lib/rubocop/cop/chef/redundant/custom_resource_with_allowed_actions.rb +0 -1
  64. data/lib/rubocop/cop/chef/redundant/grouping_metadata.rb +0 -1
  65. data/lib/rubocop/cop/chef/redundant/long_description_metadata.rb +0 -1
  66. data/lib/rubocop/cop/chef/redundant/multiple_platform_checks.rb +0 -1
  67. data/lib/rubocop/cop/chef/redundant/ohai_attribute_to_string.rb +0 -1
  68. data/lib/rubocop/cop/chef/redundant/provides_metadata.rb +0 -1
  69. data/lib/rubocop/cop/chef/redundant/recipe_metadata.rb +0 -1
  70. data/lib/rubocop/cop/chef/redundant/replaces_metadata.rb +0 -1
  71. data/lib/rubocop/cop/chef/redundant/suggests_metadata.rb +0 -1
  72. data/lib/rubocop/cop/chef/sharing/default_maintainer_metadata.rb +0 -1
  73. data/lib/rubocop/cop/chef/sharing/empty_metadata_field.rb +0 -1
  74. data/lib/rubocop/cop/chef/sharing/invalid_license_string.rb +0 -1
  75. data/lib/rubocop/cop/chef/style/attribute_keys.rb +0 -1
  76. data/lib/rubocop/cop/chef/style/chef_whaaat.rb +0 -1
  77. data/lib/rubocop/cop/chef/style/comment_sentence_spacing.rb +0 -1
  78. data/lib/rubocop/cop/chef/style/comments_copyright_format.rb +0 -1
  79. data/lib/rubocop/cop/chef/style/comments_default_copyright.rb +0 -1
  80. data/lib/rubocop/cop/chef/style/comments_format.rb +0 -1
  81. data/lib/rubocop/cop/chef/style/file_mode.rb +0 -1
  82. data/lib/rubocop/cop/chef/style/include_recipe_with_parentheses.rb +0 -1
  83. metadata +4 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2da2b22b8cbec39156ae6f213739615fac386c943b19062270624f49733692eb
4
- data.tar.gz: e294eddf92cf044629ad569af5f2cef1775044c599952a546529212e79bceb45
3
+ metadata.gz: 68835852d8021cee74896aa171d78ca5b540fca9fdee42632719d867910c107e
4
+ data.tar.gz: f71d3a8f4bc874dd86f81b0b01d4caa929ba62c2bf2222ca66a3e726eb398611
5
5
  SHA512:
6
- metadata.gz: cf63786305a68c636fabd90f597b8f11e3936cf70180899435d3a520d45227fdfd007fe862facbe7a584413bcf6d00b8cc43fa3a56ec7ef986a96a5f7b798673
7
- data.tar.gz: fef011328aae08ad9bf62a8f6b772da9a20e28baa8ef1c4fbcdd251269a9d62f2e15df1f79794c1fc84fcfb7c4c341fad910ff1e2689a4446a763fae254f889b
6
+ metadata.gz: a8ce79400b3866f0ac4b5b94ed0eb39da7a7b19dcd6dcf5fb0e6347affc31a70c0d56d8e2d671b776cea74465b6c715a20d9d88b3941291655ed01833c38796b
7
+ data.tar.gz: 1d324b44b1ce454718685eb5339e14d4063072b2d66dec6707091a871aa1fbef6f8eb4a13aeee683552b4b6d54f0821b5fa82493b4bde31d62aac48e9577a396
data/config/cookstyle.yml CHANGED
@@ -1190,6 +1190,22 @@ Chef/Deprecations/ChefSugarHelpers:
1190
1190
  - '**/Berksfile'
1191
1191
  - '**/Rakefile'
1192
1192
 
1193
+ Chef/Deprecations/HWRPWithoutUnifiedTrue:
1194
+ Description: Set `unified_mode true` in Chef Infra Client 15.3+ HWRP style custom resources to ensure they work correctly in Chef Infra Client 18 (April 2022) when Unified Mode becomes the default.
1195
+ StyleGuide: 'chef_deprecations_hwrpwithoutunifiedtrue'
1196
+ Enabled: true
1197
+ VersionAdded: '7.12.0'
1198
+ Include:
1199
+ - '**/libraries/*.rb'
1200
+
1201
+ Chef/Deprecations/ResourceWithoutUnifiedTrue:
1202
+ Description: Set `unified_mode true` in Chef Infra Client 15.3+ custom resources to ensure they work correctly in Chef Infra Client 18 (April 2022) when Unified Mode becomes the default.
1203
+ StyleGuide: 'chef_deprecations_resourcewithoutunifiedtrue'
1204
+ Enabled: true
1205
+ VersionAdded: '7.12.0'
1206
+ Include:
1207
+ - '**/resources/*.rb'
1208
+
1193
1209
  ###############################
1194
1210
  # Chef/Modernize: Cleaning up legacy code and using new built-in resources
1195
1211
  ###############################
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  module Cookstyle
3
- VERSION = "7.11.3" # rubocop: disable Style/StringLiterals
3
+ VERSION = "7.12.2" # rubocop: disable Style/StringLiterals
4
4
  RUBOCOP_VERSION = '1.14.0'
5
5
  end
@@ -15,21 +15,20 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
22
- # Default actions in resources should be symbols or an array of symbols.
23
- #
24
- # @example
25
- #
26
- # #### incorrect
27
- # default_action 'create'
28
- #
29
- # #### correct
30
- # default_action :create
31
- #
32
21
  module Correctness
22
+ # Default actions in resources should be symbols or an array of symbols.
23
+ #
24
+ # @example
25
+ #
26
+ # #### incorrect
27
+ # default_action 'create'
28
+ #
29
+ # #### correct
30
+ # default_action :create
31
+ #
33
32
  class InvalidDefaultAction < Base
34
33
  MSG = 'Default actions in resources should be symbols or an array of symbols.'
35
34
  RESTRICT_ON_SEND = [:default_action].freeze
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,28 +15,27 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
22
- # metadata.rb needs to include the name method or it will fail on Chef Infra Client 12 and later.
23
- #
24
- # @example
25
- #
26
- # #### correct
27
- # name 'foo'
28
- #
29
21
  module Correctness
22
+ # metadata.rb needs to include the name method or it will fail on Chef Infra Client 12 and later.
23
+ #
24
+ # @example
25
+ #
26
+ # #### correct
27
+ # name 'foo'
28
+ #
30
29
  class MetadataMissingName < Base
31
30
  include RangeHelp
32
31
 
33
32
  MSG = 'metadata.rb needs to include the name method or it will fail on Chef Infra Client 12 and later.'
34
33
 
35
- def_node_search :cb_name, '(send nil? :name str ...)'
34
+ def_node_search :cb_name?, '(send nil? :name str ...)'
36
35
 
37
36
  def on_new_investigation
38
37
  # Using range similar to RuboCop::Cop::Naming::Filename (file_name.rb)
39
- return if cb_name(processed_source.ast).any?
38
+ return if cb_name?(processed_source.ast)
40
39
  range = source_range(processed_source.buffer, 1, 0)
41
40
  add_offense(range, message: MSG, severity: :refactor) do |_corrector|
42
41
  path = processed_source.path
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -14,7 +14,6 @@
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
16
  #
17
-
18
17
  module RuboCop
19
18
  module Cop
20
19
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -14,7 +14,6 @@
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
16
  #
17
-
18
17
  module RuboCop
19
18
  module Cop
20
19
  module Chef
@@ -15,22 +15,21 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
22
- # Make sure a cookbook doesn't depend on itself. This will fail on Chef Infra Client 13+
23
- #
24
- # @example
25
- #
26
- # #### incorrect
27
- # name 'foo'
28
- # depends 'foo'
29
- #
30
- # #### correct
31
- # name 'foo'
32
- #
33
21
  module Deprecations
22
+ # Make sure a cookbook doesn't depend on itself. This will fail on Chef Infra Client 13+
23
+ #
24
+ # @example
25
+ #
26
+ # #### incorrect
27
+ # name 'foo'
28
+ # depends 'foo'
29
+ #
30
+ # #### correct
31
+ # name 'foo'
32
+ #
34
33
  class CookbooksDependsOnSelf < Base
35
34
  extend AutoCorrector
36
35
  include RangeHelp
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,33 +15,32 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
22
- # Do not use legacy chef-sugar helper methods, which will not be moved into Chef Infra Client itself. For a complete set of chef-sugar helpers now shipping in Chef Infra Client itself see https://github.com/chef/chef/tree/master/chef-utils#getting-started
23
- #
24
- # @example
25
- #
26
- # #### incorrect
27
- # vagrant_key?
28
- # vagrant_domain?
29
- # vagrant_user?
30
- # require_chef_gem
31
- # best_ip_for(node)
32
- # nexus?
33
- # ios_xr?
34
- # ruby_20?
35
- # ruby_19?
36
- # includes_recipe?('foo::bar')
37
- # wrlinux?
38
- # dev_null
39
- # nexentacore_platform?
40
- # opensolaris_platform?
41
- # nexentacore?
42
- # opensolaris?
43
- #
44
21
  module Deprecations
22
+ # Do not use legacy chef-sugar helper methods, which will not be moved into Chef Infra Client itself. For a complete set of chef-sugar helpers now shipping in Chef Infra Client itself see https://github.com/chef/chef/tree/master/chef-utils#getting-started
23
+ #
24
+ # @example
25
+ #
26
+ # #### incorrect
27
+ # vagrant_key?
28
+ # vagrant_domain?
29
+ # vagrant_user?
30
+ # require_chef_gem
31
+ # best_ip_for(node)
32
+ # nexus?
33
+ # ios_xr?
34
+ # ruby_20?
35
+ # ruby_19?
36
+ # includes_recipe?('foo::bar')
37
+ # wrlinux?
38
+ # dev_null
39
+ # nexentacore_platform?
40
+ # opensolaris_platform?
41
+ # nexentacore?
42
+ # opensolaris?
43
+ #
45
44
  class ChefSugarHelpers < Base
46
45
  MSG = 'Do not use legacy chef-sugar helper methods, which will not be moved into Chef Infra Client itself. For a complete set of chef-sugar helpers now shipping in Chef Infra Client itself see https://github.com/chef/chef/tree/master/chef-utils#getting-started'
47
46
  RESTRICT_ON_SEND = [:vagrant_key?, :vagrant_domain?, :vagrant_user?, :require_chef_gem, :best_ip_for, :nexus?, :ios_xr?, :ruby_20?, :ruby_19?, :includes_recipe?, :wrlinux?, :dev_null, :nexentacore_platform?, :opensolaris_platform?, :nexentacore?, :opensolaris?].freeze
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,13 +15,12 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
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
- #
24
21
  module Deprecations
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
+ #
25
24
  class Cheffile < Base
26
25
  include RangeHelp
27
26
 
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -31,7 +31,6 @@ module RuboCop
31
31
  # end
32
32
  # end
33
33
  # end
34
-
35
34
  class EOLAuditModeUsage < Base
36
35
  MSG = 'The beta Audit Mode feature in Chef Infra Client was removed in Chef Infra Client 15.0.'
37
36
  RESTRICT_ON_SEND = [:control_group].freeze
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -0,0 +1,86 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # Copyright:: Copyright (c) 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 Deprecations
22
+ # Chef Infra Client 15.3 and later include a new Unified Mode that simplies the execution of resoures by replace the traditional compile and converge phases with a single phase. Unified mode simplies writing advanced resources and avoids confusing errors that often occur when mixing ruby and Chef Infra resources. Chef Infra Client 17.0 and later will beging warning that `unified_mode true` should be set in all resources to validate that they will continue to function in Chef Infra Client 18.0 (April 2022) when Unified Mode becomes the default.
23
+ #
24
+ # @example
25
+ #
26
+ # #### incorrect
27
+ # class Chef
28
+ # class Resource
29
+ # class UlimitRule < Chef::Resource
30
+ # provides :ulimit_rule
31
+ #
32
+ # property :type, [Symbol, String], required: true
33
+ # property :item, [Symbol, String], required: true
34
+ #
35
+ # # additional resource code
36
+ # end
37
+ # end
38
+ # end
39
+ #
40
+ # #### correct
41
+ # class Chef
42
+ # class Resource
43
+ # class UlimitRule < Chef::Resource
44
+ # provides :ulimit_rule
45
+ # unified_mode true
46
+ #
47
+ # property :type, [Symbol, String], required: true
48
+ # property :item, [Symbol, String], required: true
49
+ #
50
+ # # additional resource code
51
+ # end
52
+ # end
53
+ # end
54
+ #
55
+ class HWRPWithoutUnifiedTrue < Base
56
+ extend TargetChefVersion
57
+
58
+ minimum_target_chef_version '15.3'
59
+
60
+ MSG = 'Set `unified_mode true` in Chef Infra Client 15.3+ HWRP style custom resources to ensure they work correctly in Chef Infra Client 18 (April 2022) when Unified Mode becomes the default.'
61
+
62
+ def_node_matcher :HWRP?, <<-PATTERN
63
+ (class
64
+ (const nil? :Chef) nil?
65
+ (class
66
+ (const nil? :Resource) nil?
67
+ $(class
68
+ (const nil? ... )
69
+ (const
70
+ (const nil? :Chef) :Resource)
71
+ (begin ... ))))
72
+ PATTERN
73
+
74
+ def_node_search :unified_mode?, '(send nil? :unified_mode ...)'
75
+
76
+ def on_class(node)
77
+ return if unified_mode?(processed_source.ast)
78
+ HWRP?(node) do |inherit|
79
+ add_offense(inherit, message: MSG, severity: :warning)
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -0,0 +1,84 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # Copyright:: Copyright (c) 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 Deprecations
22
+ # Chef Infra Client 15.3 and later include a new Unified Mode that simplies the execution of resoures by replace the traditional compile and converge phases with a single phase. Unified mode simplies writing advanced resources and avoids confusing errors that often occur when mixing ruby and Chef Infra resources. Chef Infra Client 17.0 and later will beging warning that `unified_mode true` should be set in all resources to validate that they will continue to function in Chef Infra Client 18.0 (April 2022) when Unified Mode becomes the default.
23
+ #
24
+ # @example
25
+ #
26
+ # #### incorrect
27
+ # resource_name :foo
28
+ # provides :foo
29
+ #
30
+ # action :create do
31
+ # # some action code
32
+ # end
33
+ #
34
+ # #### correct
35
+ # resource_name :foo
36
+ # provides :foo
37
+ # unified_mode true
38
+ #
39
+ # action :create do
40
+ # # some action code
41
+ # end
42
+ #
43
+ class ResourceWithoutUnifiedTrue < Base
44
+ include RangeHelp
45
+ extend AutoCorrector
46
+ extend TargetChefVersion
47
+
48
+ minimum_target_chef_version '15.3'
49
+
50
+ MSG = 'Set `unified_mode true` in Chef Infra Client 15.3+ custom resources to ensure they work correctly in Chef Infra Client 18 (April 2022) when Unified Mode becomes the default.'
51
+
52
+ def_node_search :unified_mode?, '(send nil? :unified_mode ...)'
53
+ def_node_search :resource_name, '(send nil? :resource_name ...)'
54
+ def_node_search :provides, '(send nil? :provides ...)'
55
+
56
+ def on_new_investigation
57
+ # Using range similar to RuboCop::Cop::Naming::Filename (file_name.rb)
58
+ return if unified_mode?(processed_source.ast)
59
+ range = source_range(processed_source.buffer, 1, 0)
60
+ add_offense(range, message: MSG, severity: :refactor) do |corrector|
61
+ insert_below_provides(corrector) || insert_below_resource_name(corrector)
62
+ end
63
+ end
64
+
65
+ def insert_below_provides(corrector)
66
+ provides_ast = provides(processed_source.ast).first
67
+ if provides_ast
68
+ corrector.insert_after(provides_ast, "\nunified_mode true")
69
+ true
70
+ end
71
+ end
72
+
73
+ def insert_below_resource_name(corrector)
74
+ resource_name_ast = resource_name(processed_source.ast).first
75
+ if resource_name_ast
76
+ corrector.insert_after(resource_name_ast, "\nunified_mode true")
77
+ true
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -42,7 +41,6 @@ module RuboCop
42
41
  # #### incorrect
43
42
  # chef_vault_item(arg, arg1)
44
43
  #
45
-
46
44
  class ChefVaultUsed < Base
47
45
  MSG = 'Chef Vault usage is not supported in the Effortless pattern'
48
46
  RESTRICT_ON_SEND = [:chef_vault_item,
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -27,7 +26,6 @@ module RuboCop
27
26
  # #### incorrect
28
27
  # depends 'chef-vault'
29
28
  #
30
-
31
29
  class DependsChefVault < Base
32
30
  MSG = 'Chef Vault usage is not supported in the Effortless pattern'
33
31
  RESTRICT_ON_SEND = [:depends].freeze
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -14,7 +14,6 @@
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
16
  #
17
-
18
17
  module RuboCop
19
18
  module Cop
20
19
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
@@ -14,7 +14,6 @@
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
16
  #
17
-
18
17
  module RuboCop
19
18
  module Cop
20
19
  module Chef
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  module RuboCop
20
19
  module Cop
21
20
  module Chef
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.11.3
4
+ version: 7.12.2
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-05-06 00:00:00.000000000 Z
12
+ date: 2021-05-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rubocop
@@ -116,6 +116,7 @@ files:
116
116
  - lib/rubocop/cop/chef/deprecation/execute_relative_creates_without_cwd.rb
117
117
  - lib/rubocop/cop/chef/deprecation/foodcritic_testing.rb
118
118
  - lib/rubocop/cop/chef/deprecation/hwrp_without_provides.rb
119
+ - lib/rubocop/cop/chef/deprecation/hwrp_without_unified_mode_true.rb
119
120
  - lib/rubocop/cop/chef/deprecation/inherits_compat_resource.rb
120
121
  - lib/rubocop/cop/chef/deprecation/launchd_deprecated_hash_property.rb
121
122
  - lib/rubocop/cop/chef/deprecation/legacy_notify_syntax.rb
@@ -140,6 +141,7 @@ files:
140
141
  - lib/rubocop/cop/chef/deprecation/resource_uses_only_resource_name.rb
141
142
  - lib/rubocop/cop/chef/deprecation/resource_uses_provider_base_method.rb
142
143
  - lib/rubocop/cop/chef/deprecation/resource_uses_updated_method.rb
144
+ - lib/rubocop/cop/chef/deprecation/resource_without_unified_mode_true.rb
143
145
  - lib/rubocop/cop/chef/deprecation/ruby_27_keyword_argument_warnings.rb
144
146
  - lib/rubocop/cop/chef/deprecation/ruby_block_create_action.rb
145
147
  - lib/rubocop/cop/chef/deprecation/run_command_helper.rb