cookstyle 6.11.4 → 6.15.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (227) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +6 -0
  3. data/bin/cookstyle +1 -0
  4. data/bin/cookstyle-profile +31 -0
  5. data/config/cookstyle.yml +146 -38
  6. data/config/disable_all.yml +40 -4
  7. data/config/upstream.yml +153 -22
  8. data/cookstyle.gemspec +2 -0
  9. data/lib/cookstyle.rb +8 -7
  10. data/lib/cookstyle/version.rb +3 -2
  11. data/lib/rubocop/chef.rb +1 -0
  12. data/lib/rubocop/chef/autocorrect_helpers.rb +1 -0
  13. data/lib/rubocop/chef/cookbook_helpers.rb +1 -0
  14. data/lib/rubocop/chef/platform_helpers.rb +1 -0
  15. data/lib/rubocop/cop/chef/correctness/block_guard_clause_string_only.rb +2 -1
  16. data/lib/rubocop/cop/chef/correctness/cb_depends_on_self.rb +2 -1
  17. data/lib/rubocop/cop/chef/correctness/chef_application_fatal.rb +2 -1
  18. data/lib/rubocop/cop/chef/correctness/conditional_ruby_shellout.rb +2 -1
  19. data/lib/rubocop/cop/chef/correctness/dnf_package_allow_downgrades.rb +2 -1
  20. data/lib/rubocop/cop/chef/correctness/incorrect_library_injection.rb +2 -1
  21. data/lib/rubocop/cop/chef/correctness/invalid_default_action.rb +48 -0
  22. data/lib/rubocop/cop/chef/correctness/invalid_notification_timing.rb +2 -1
  23. data/lib/rubocop/cop/chef/correctness/invalid_platform_family_helper.rb +28 -4
  24. data/lib/rubocop/cop/chef/correctness/invalid_platform_family_values_in_case.rb +2 -1
  25. data/lib/rubocop/cop/chef/correctness/invalid_platform_helper.rb +2 -1
  26. data/lib/rubocop/cop/chef/correctness/invalid_platform_metadata.rb +2 -1
  27. data/lib/rubocop/cop/chef/correctness/invalid_platform_values_in_case.rb +2 -1
  28. data/lib/rubocop/cop/chef/correctness/invalid_value_for_platform_family_helper.rb +2 -1
  29. data/lib/rubocop/cop/chef/correctness/invalid_value_for_platform_helper.rb +2 -1
  30. data/lib/rubocop/cop/chef/correctness/invalid_version_metadata.rb +2 -1
  31. data/lib/rubocop/cop/chef/correctness/lazy_eval_node_attribute_defaults.rb +2 -1
  32. data/lib/rubocop/cop/chef/correctness/macos_userdefaults_invalid_type.rb +68 -0
  33. data/lib/rubocop/cop/chef/correctness/malformed_value_for_platform.rb +1 -0
  34. data/lib/rubocop/cop/chef/correctness/metadata_missing_name.rb +2 -1
  35. data/lib/rubocop/cop/chef/correctness/node_normal.rb +2 -1
  36. data/lib/rubocop/cop/chef/correctness/node_normal_unless.rb +2 -1
  37. data/lib/rubocop/cop/chef/correctness/node_save.rb +2 -1
  38. data/lib/rubocop/cop/chef/correctness/notifies_action_not_symbol.rb +6 -5
  39. data/lib/rubocop/cop/chef/correctness/openssl_password_helpers.rb +2 -1
  40. data/lib/rubocop/cop/chef/correctness/powershell_delete_file.rb +2 -1
  41. data/lib/rubocop/cop/chef/correctness/resource_sets_internal_properties.rb +2 -1
  42. data/lib/rubocop/cop/chef/correctness/resource_sets_name_property.rb +2 -1
  43. data/lib/rubocop/cop/chef/correctness/resource_with_none_action.rb +2 -1
  44. data/lib/rubocop/cop/chef/correctness/scoped_file_exist.rb +2 -1
  45. data/lib/rubocop/cop/chef/correctness/service_resource.rb +2 -1
  46. data/lib/rubocop/cop/chef/correctness/supports_must_be_float.rb +52 -0
  47. data/lib/rubocop/cop/chef/correctness/tmp_path.rb +2 -1
  48. data/lib/rubocop/cop/chef/deprecation/ use_automatic_resource_name.rb +52 -0
  49. data/lib/rubocop/cop/chef/deprecation/chef_handler_recipe.rb +55 -0
  50. data/lib/rubocop/cop/chef/deprecation/chef_handler_supports.rb +2 -1
  51. data/lib/rubocop/cop/chef/deprecation/chef_rest.rb +2 -1
  52. data/lib/rubocop/cop/chef/deprecation/chef_rewind.rb +2 -1
  53. data/lib/rubocop/cop/chef/deprecation/chef_windows_platform_helper.rb +2 -1
  54. data/lib/rubocop/cop/chef/deprecation/chefdk_generators.rb +60 -0
  55. data/lib/rubocop/cop/chef/deprecation/cheffile.rb +3 -2
  56. data/lib/rubocop/cop/chef/deprecation/chefspec_coverage_report.rb +2 -1
  57. data/lib/rubocop/cop/chef/deprecation/chefspec_legacy_runner.rb +2 -1
  58. data/lib/rubocop/cop/chef/deprecation/chocolatey_package_uninstall_action.rb +2 -1
  59. data/lib/rubocop/cop/chef/deprecation/depends_compat_resource.rb +2 -1
  60. data/lib/rubocop/cop/chef/deprecation/depends_partial_search.rb +2 -1
  61. data/lib/rubocop/cop/chef/deprecation/depends_poise.rb +2 -1
  62. data/lib/rubocop/cop/chef/deprecation/deprecated_chefspec_platform.rb +2 -1
  63. data/lib/rubocop/cop/chef/deprecation/deprecated_mixins.rb +2 -1
  64. data/lib/rubocop/cop/chef/deprecation/deprecated_platform_methods.rb +2 -1
  65. data/lib/rubocop/cop/chef/deprecation/deprecated_shellout_methods.rb +2 -1
  66. data/lib/rubocop/cop/chef/deprecation/deprecated_windows_version_check.rb +2 -1
  67. data/lib/rubocop/cop/chef/deprecation/deprecated_yum_repository_properties.rb +2 -1
  68. data/lib/rubocop/cop/chef/deprecation/easy_install.rb +2 -1
  69. data/lib/rubocop/cop/chef/deprecation/eol_audit_mode.rb +3 -2
  70. data/lib/rubocop/cop/chef/deprecation/epic_fail.rb +2 -1
  71. data/lib/rubocop/cop/chef/deprecation/erl_call.rb +2 -1
  72. data/lib/rubocop/cop/chef/deprecation/hwrp_without_provides.rb +2 -1
  73. data/lib/rubocop/cop/chef/deprecation/inherits_compat_resource.rb +2 -1
  74. data/lib/rubocop/cop/chef/deprecation/launchd_deprecated_hash_property.rb +2 -1
  75. data/lib/rubocop/cop/chef/deprecation/legacy_notify_syntax.rb +3 -2
  76. data/lib/rubocop/cop/chef/deprecation/legacy_yum_cookbook_recipes.rb +2 -1
  77. data/lib/rubocop/cop/chef/deprecation/locale_lc_all_property.rb +2 -1
  78. data/lib/rubocop/cop/chef/deprecation/log_resource_notifications.rb +2 -1
  79. data/lib/rubocop/cop/chef/deprecation/macos_userdefaults_global_property.rb +61 -0
  80. data/lib/rubocop/cop/chef/deprecation/name_property_and_default.rb +2 -1
  81. data/lib/rubocop/cop/chef/deprecation/node_deep_fetch.rb +8 -21
  82. data/lib/rubocop/cop/chef/deprecation/node_methods_not_attributes.rb +2 -1
  83. data/lib/rubocop/cop/chef/deprecation/node_set.rb +2 -1
  84. data/lib/rubocop/cop/chef/deprecation/node_set_unless.rb +2 -1
  85. data/lib/rubocop/cop/chef/deprecation/node_set_without_level.rb +2 -1
  86. data/lib/rubocop/cop/chef/deprecation/partial_search_class_usage.rb +2 -1
  87. data/lib/rubocop/cop/chef/deprecation/partial_search_helper_usage.rb +2 -1
  88. data/lib/rubocop/cop/chef/deprecation/poise_archive.rb +6 -3
  89. data/lib/rubocop/cop/chef/deprecation/powershell_cookbook_helpers.rb +2 -1
  90. data/lib/rubocop/cop/chef/deprecation/require_recipe.rb +2 -1
  91. data/lib/rubocop/cop/chef/deprecation/resource_overrides_provides_method.rb +2 -1
  92. data/lib/rubocop/cop/chef/deprecation/resource_uses_dsl_name_method.rb +2 -1
  93. data/lib/rubocop/cop/chef/deprecation/resource_uses_only_resource_name.rb +5 -4
  94. data/lib/rubocop/cop/chef/deprecation/resource_uses_provider_base_method.rb +2 -1
  95. data/lib/rubocop/cop/chef/deprecation/resource_uses_updated_method.rb +2 -1
  96. data/lib/rubocop/cop/chef/deprecation/ruby_27_keyword_argument_warnings.rb +3 -2
  97. data/lib/rubocop/cop/chef/deprecation/ruby_block_create_action.rb +2 -1
  98. data/lib/rubocop/cop/chef/deprecation/run_command_helper.rb +2 -1
  99. data/lib/rubocop/cop/chef/deprecation/search_uses_positional_parameters.rb +2 -1
  100. data/lib/rubocop/cop/chef/deprecation/use_inline_resources.rb +2 -1
  101. data/lib/rubocop/cop/chef/deprecation/user_supports_property.rb +2 -1
  102. data/lib/rubocop/cop/chef/deprecation/verify_property_file_expansion.rb +2 -1
  103. data/lib/rubocop/cop/chef/deprecation/windows_feature_servermanagercmd.rb +2 -1
  104. data/lib/rubocop/cop/chef/deprecation/windows_task_change_action.rb +2 -1
  105. data/lib/rubocop/cop/chef/deprecation/windows_version_helpers.rb +2 -1
  106. data/lib/rubocop/cop/chef/deprecation/xml_ruby_recipe.rb +2 -1
  107. data/lib/rubocop/cop/chef/deprecation/yum_dnf_compat_recipe.rb +2 -1
  108. data/lib/rubocop/cop/chef/effortless/berksfile.rb +2 -1
  109. data/lib/rubocop/cop/chef/effortless/data_bags.rb +2 -1
  110. data/lib/rubocop/cop/chef/effortless/node_environment.rb +3 -2
  111. data/lib/rubocop/cop/chef/effortless/node_policygroup.rb +2 -1
  112. data/lib/rubocop/cop/chef/effortless/node_roles.rb +5 -4
  113. data/lib/rubocop/cop/chef/effortless/search_for_environments_or_roles.rb +2 -1
  114. data/lib/rubocop/cop/chef/effortless/search_used.rb +2 -1
  115. data/lib/rubocop/cop/chef/modernize/action_method_in_resource.rb +57 -0
  116. data/lib/rubocop/cop/chef/modernize/allowed_actions_initializer.rb +4 -3
  117. data/lib/rubocop/cop/chef/modernize/apt_default_recipe.rb +2 -1
  118. data/lib/rubocop/cop/chef/modernize/berksfile_source.rb +2 -1
  119. data/lib/rubocop/cop/chef/modernize/build_essential.rb +2 -1
  120. data/lib/rubocop/cop/chef/modernize/chef_14_resources.rb +2 -1
  121. data/lib/rubocop/cop/chef/modernize/chef_gem_nokogiri.rb +2 -1
  122. data/lib/rubocop/cop/chef/modernize/compile_time_resources.rb +2 -1
  123. data/lib/rubocop/cop/chef/modernize/conditional_using_test.rb +2 -1
  124. data/lib/rubocop/cop/chef/modernize/cron_d_file_or_template.rb +88 -0
  125. data/lib/rubocop/cop/chef/modernize/cron_manage_resource.rb +2 -1
  126. data/lib/rubocop/cop/chef/modernize/databag_helpers.rb +2 -1
  127. data/lib/rubocop/cop/chef/modernize/default_action_initializer.rb +5 -4
  128. data/lib/rubocop/cop/chef/modernize/defines_chefspec_matchers.rb +2 -1
  129. data/lib/rubocop/cop/chef/modernize/definitions.rb +3 -2
  130. data/lib/rubocop/cop/chef/modernize/depends_zypper_cookbook.rb +2 -1
  131. data/lib/rubocop/cop/chef/modernize/dsl_include_in_resource.rb +2 -1
  132. data/lib/rubocop/cop/chef/modernize/empty_resource_initialize.rb +2 -1
  133. data/lib/rubocop/cop/chef/modernize/execute_apt_update.rb +3 -2
  134. data/lib/rubocop/cop/chef/modernize/execute_sc_exe.rb +2 -1
  135. data/lib/rubocop/cop/chef/modernize/execute_sleep.rb +2 -1
  136. data/lib/rubocop/cop/chef/modernize/execute_sysctl.rb +2 -1
  137. data/lib/rubocop/cop/chef/modernize/execute_tzutil.rb +2 -1
  138. data/lib/rubocop/cop/chef/modernize/foodcritic_comments.rb +2 -1
  139. data/lib/rubocop/cop/chef/modernize/if_provides_default_action.rb +2 -1
  140. data/lib/rubocop/cop/chef/modernize/includes_mixin_shellout.rb +2 -1
  141. data/lib/rubocop/cop/chef/modernize/libarchive_file.rb +2 -1
  142. data/lib/rubocop/cop/chef/modernize/macos_user_defaults.rb +2 -1
  143. data/lib/rubocop/cop/chef/modernize/minitest_handler_usage.rb +2 -1
  144. data/lib/rubocop/cop/chef/modernize/node_init_package.rb +2 -1
  145. data/lib/rubocop/cop/chef/modernize/node_roles_include.rb +2 -1
  146. data/lib/rubocop/cop/chef/modernize/ohai_default_recipe.rb +2 -1
  147. data/lib/rubocop/cop/chef/modernize/openssl_rsa_key_resource.rb +2 -1
  148. data/lib/rubocop/cop/chef/modernize/openssl_x509_resource.rb +2 -1
  149. data/lib/rubocop/cop/chef/modernize/osx_config_profile_resource.rb +2 -1
  150. data/lib/rubocop/cop/chef/modernize/powershell_expand_archive.rb +2 -1
  151. data/lib/rubocop/cop/chef/modernize/powershell_guard_interpreter.rb +2 -1
  152. data/lib/rubocop/cop/chef/modernize/powershell_install_package.rb +2 -1
  153. data/lib/rubocop/cop/chef/modernize/powershell_install_windowsfeature.rb +2 -1
  154. data/lib/rubocop/cop/chef/modernize/property_with_name_attribute.rb +2 -1
  155. data/lib/rubocop/cop/chef/modernize/provides_initializer.rb +5 -4
  156. data/lib/rubocop/cop/chef/modernize/resource_name_initializer.rb +4 -3
  157. data/lib/rubocop/cop/chef/modernize/resource_set_or_return.rb +2 -1
  158. data/lib/rubocop/cop/chef/modernize/resource_with_attributes.rb +2 -1
  159. data/lib/rubocop/cop/chef/modernize/respond_to_compile_time.rb +2 -1
  160. data/lib/rubocop/cop/chef/modernize/respond_to_metadata.rb +2 -1
  161. data/lib/rubocop/cop/chef/modernize/respond_to_provides.rb +2 -1
  162. data/lib/rubocop/cop/chef/modernize/respond_to_resource_name.rb +2 -1
  163. data/lib/rubocop/cop/chef/modernize/sc_windows_resource.rb +2 -1
  164. data/lib/rubocop/cop/chef/modernize/seven_zip_archive.rb +2 -1
  165. data/lib/rubocop/cop/chef/modernize/shell_out_helper.rb +2 -1
  166. data/lib/rubocop/cop/chef/modernize/shellouts_to_chocolatey.rb +2 -1
  167. data/lib/rubocop/cop/chef/modernize/simplify_apt_ppa_setup.rb +2 -1
  168. data/lib/rubocop/cop/chef/modernize/systctl_param_resource.rb +2 -1
  169. data/lib/rubocop/cop/chef/modernize/unnecessary_mixlib_shellout_require.rb +2 -1
  170. data/lib/rubocop/cop/chef/modernize/use_multipackage_installs.rb +4 -3
  171. data/lib/rubocop/cop/chef/modernize/use_require_relative.rb +2 -1
  172. data/lib/rubocop/cop/chef/modernize/whyrun_supported_true.rb +2 -1
  173. data/lib/rubocop/cop/chef/modernize/windows_default_recipe.rb +2 -1
  174. data/lib/rubocop/cop/chef/modernize/windows_registry_uac.rb +2 -1
  175. data/lib/rubocop/cop/chef/modernize/windows_zipfile.rb +2 -1
  176. data/lib/rubocop/cop/chef/modernize/zipfile_resource.rb +2 -1
  177. data/lib/rubocop/cop/chef/modernize/zypper_repo.rb +2 -1
  178. data/lib/rubocop/cop/chef/redundant/apt_repository_distribution_default.rb +2 -1
  179. data/lib/rubocop/cop/chef/redundant/apt_repository_notifies_apt_update.rb +2 -1
  180. data/lib/rubocop/cop/chef/redundant/attribute_metadata.rb +2 -1
  181. data/lib/rubocop/cop/chef/redundant/conflicts_metadata.rb +2 -1
  182. data/lib/rubocop/cop/chef/redundant/custom_resource_with_allowed_actions.rb +2 -1
  183. data/lib/rubocop/cop/chef/redundant/double_compile_time.rb +65 -0
  184. data/lib/rubocop/cop/chef/redundant/grouping_metadata.rb +2 -1
  185. data/lib/rubocop/cop/chef/redundant/long_description_metadata.rb +2 -1
  186. data/lib/rubocop/cop/chef/redundant/multiple_platform_checks.rb +2 -1
  187. data/lib/rubocop/cop/chef/redundant/name_property_and_required.rb +2 -1
  188. data/lib/rubocop/cop/chef/redundant/ohai_attribute_to_string.rb +5 -4
  189. data/lib/rubocop/cop/chef/redundant/property_splat_regex.rb +2 -1
  190. data/lib/rubocop/cop/chef/redundant/property_with_default_and_required.rb +2 -1
  191. data/lib/rubocop/cop/chef/redundant/provides_metadata.rb +2 -1
  192. data/lib/rubocop/cop/chef/redundant/recipe_metadata.rb +2 -1
  193. data/lib/rubocop/cop/chef/redundant/replaces_metadata.rb +2 -1
  194. data/lib/rubocop/cop/chef/redundant/resource_with_nothing_action.rb +2 -1
  195. data/lib/rubocop/cop/chef/redundant/sensitive_property_in_resource.rb +2 -1
  196. data/lib/rubocop/cop/chef/redundant/string_property_with_nil_default.rb +2 -1
  197. data/lib/rubocop/cop/chef/redundant/suggests_metadata.rb +2 -1
  198. data/lib/rubocop/cop/chef/redundant/unnecessary_desired_state.rb +2 -1
  199. data/lib/rubocop/cop/chef/redundant/unnecessary_name_property.rb +2 -1
  200. data/lib/rubocop/cop/chef/redundant/use_create_if_missing.rb +2 -1
  201. data/lib/rubocop/cop/chef/sharing/default_maintainer_metadata.rb +2 -1
  202. data/lib/rubocop/cop/chef/sharing/empty_metadata_field.rb +2 -1
  203. data/lib/rubocop/cop/chef/sharing/include_property_descriptions.rb +3 -2
  204. data/lib/rubocop/cop/chef/sharing/include_resource_descriptions.rb +3 -2
  205. data/lib/rubocop/cop/chef/sharing/include_resource_examples.rb +3 -2
  206. data/lib/rubocop/cop/chef/sharing/insecure_cookbook_url.rb +2 -1
  207. data/lib/rubocop/cop/chef/sharing/invalid_license_string.rb +2 -1
  208. data/lib/rubocop/cop/chef/style/attribute_keys.rb +2 -1
  209. data/lib/rubocop/cop/chef/style/chef_whaaat.rb +2 -1
  210. data/lib/rubocop/cop/chef/style/comment_sentence_spacing.rb +2 -1
  211. data/lib/rubocop/cop/chef/style/comments_copyright_format.rb +2 -1
  212. data/lib/rubocop/cop/chef/style/comments_default_copyright.rb +2 -1
  213. data/lib/rubocop/cop/chef/style/comments_format.rb +2 -1
  214. data/lib/rubocop/cop/chef/style/file_mode.rb +39 -19
  215. data/lib/rubocop/cop/chef/style/immediate_notification_timing.rb +2 -1
  216. data/lib/rubocop/cop/chef/style/include_recipe_with_parentheses.rb +2 -1
  217. data/lib/rubocop/cop/chef/style/negating_only_if.rb +2 -1
  218. data/lib/rubocop/cop/chef/style/overly_complex_supports_depends_metadata.rb +2 -1
  219. data/lib/rubocop/cop/chef/style/simplify_platform_major_version_check.rb +2 -1
  220. data/lib/rubocop/cop/chef/style/true_false_resource_properties.rb +2 -1
  221. data/lib/rubocop/cop/chef/style/unnecessary_os_check.rb +3 -3
  222. data/lib/rubocop/cop/chef/style/unnecessary_platform_case_statement.rb +3 -2
  223. data/lib/rubocop/cop/chef/style/use_platform_helpers.rb +3 -3
  224. data/lib/rubocop/monkey_patches/{cop.rb → base.rb} +2 -1
  225. data/lib/rubocop/monkey_patches/comment_config.rb +1 -0
  226. data/lib/rubocop/monkey_patches/registry_cop.rb +1 -0
  227. metadata +17 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4593dcbd93b8d0d668e0fe5e5551147db850c38deabcccf698b3f8ea391c281d
4
- data.tar.gz: ef4557926f01a865f3ced43e0ad7a464659f597f4f6ffc8104c2f978d959324a
3
+ metadata.gz: 91b883b4825831ec4a6cd167377859fa83bf1eea994b1b0dfa85d28dcdd998e9
4
+ data.tar.gz: fe4e2c83dc76b6b6713e7f6b1ad3e50f869708eda0bf22eeb1b68a43bd5c7762
5
5
  SHA512:
6
- metadata.gz: e3d3b5ed0ccd193ae9aad8d8e44a03935010a841c3cf551ce070c557f2f27e93ba2ffa2082042741f481ccabb7abf68e83d958ed06e3c5751556b7f0528aa3ae
7
- data.tar.gz: e48e47c6d27316fe8054ecc45164aedf0385be8d8e8e1077781dd3ef9948ccb756864bb6adad422941f061232f0ca0d3c6c41679166bcf345dfa29fc71f79ed3
6
+ metadata.gz: 330ed487b5946aba1b6b532e5ab79a0875007acd9052f7637e5a275a4db02c4cd39dfab066c981b6f14c8d24fd30b66cbd8b2b23d578232ce58176d7cc3ff11c
7
+ data.tar.gz: db1991f9e874b4fbb154e0334b09a7fcbe4062bb5207d4b3c1a3f169c4365ab8caf17fec699ca914a792be5ddab56a41207a657bdf7b919634008d1263a698d6
data/Gemfile CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  source 'https://rubygems.org'
2
3
 
3
4
  # Specify your gem's dependencies in cookstyle.gemspec
@@ -15,6 +16,11 @@ group :docs do
15
16
  gem 'yard'
16
17
  end
17
18
 
19
+ group :profiling do
20
+ gem 'stackprof'
21
+ gem 'memory_profiler'
22
+ end
23
+
18
24
  group :development do
19
25
  gem 'adamantium'
20
26
  gem 'anima'
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  # -*- encoding: utf-8 -*-
3
+ # frozen_string_literal: true
3
4
 
4
5
  $LOAD_PATH.unshift File.join(File.dirname(__FILE__), %w(.. lib))
5
6
 
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ if ARGV.include?('-h') || ARGV.include?('--help')
5
+ puts 'Usage: same as main `cookstyle` command but gathers profiling info'
6
+ puts 'Additional option: `--memory` to print memory usage'
7
+ exit(0)
8
+ end
9
+ with_mem = ARGV.delete('--memory')
10
+
11
+ require 'stackprof'
12
+ if with_mem
13
+ require 'memory_profiler'
14
+ MemoryProfiler.start
15
+ end
16
+ StackProf.start
17
+ start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
18
+ begin
19
+ load "#{__dir__}/cookstyle"
20
+ ensure
21
+ delta = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
22
+ puts "Finished in #{delta.round(1)} seconds"
23
+ StackProf.stop
24
+ if with_mem
25
+ puts 'Building memory report...'
26
+ report = MemoryProfiler.stop
27
+ end
28
+ Dir.mkdir('tmp') unless File.exist?('tmp')
29
+ StackProf.results('tmp/stackprof.dump')
30
+ report&.pretty_print(scale_bytes: true)
31
+ end
@@ -5,27 +5,6 @@ AllCops:
5
5
  - '/**/files/**/*'
6
6
  - '/**/vendor/**/*'
7
7
  - Guardfile
8
- ChefAttributes:
9
- Patterns:
10
- - attributes/.*\.rb
11
- ChefDefinitions:
12
- Patterns:
13
- - definitions/.*\.rb
14
- ChefLibraries:
15
- Patterns:
16
- - libraries/.*\.rb
17
- ChefMetadata:
18
- Patterns:
19
- - metadata\.rb
20
- ChefProviders:
21
- Patterns:
22
- - providers/.*\.rb
23
- ChefRecipes:
24
- Patterns:
25
- - recipes/.*\.rb
26
- ChefResources:
27
- Patterns:
28
- - resources/.*\.rb
29
8
 
30
9
  ###############################
31
10
  # ChefStyle: Making cookbooks look better
@@ -67,7 +46,7 @@ ChefStyle/CommentFormat:
67
46
  - '**/Berksfile'
68
47
 
69
48
  ChefStyle/FileMode:
70
- Description: Use strings to represent file modes in Chef resources
49
+ Description: Use strings to represent file modes to avoid confusion between octal and base 10 integer formats.
71
50
  StyleGuide: '#chefstylefilemode'
72
51
  Enabled: true
73
52
  VersionAdded: '5.0.0'
@@ -454,6 +433,32 @@ ChefCorrectness/InvalidPlatformInCase:
454
433
  - '**/metadata.rb'
455
434
  - '**/Berksfile'
456
435
 
436
+ ChefCorrectness/InvalidDefaultAction:
437
+ Description: Default actions in resources should be a symbol or an array of symbols.
438
+ StyleGuide: '#chefcorrectnessinvaliddefaultaction'
439
+ Enabled: true
440
+ VersionAdded: '6.13.0'
441
+ Include:
442
+ - '**/libraries/*.rb'
443
+ - '**/resources/*.rb'
444
+
445
+ ChefCorrectness/SupportsMustBeFloat:
446
+ Description: Versions used in metadata.rb supports calls should be floats not integers.
447
+ StyleGuide: '#chefcorrectnesssupportsmustbefloat'
448
+ Enabled: true
449
+ VersionAdded: '6.13.0'
450
+ Include:
451
+ - '**/metadata.rb'
452
+
453
+ ChefCorrectness/MacosUserdefaultsInvalidType:
454
+ Description: The macos_userdefaults resource prior to Chef Infra Client 16.3 would silently continue if invalid types were passed resulting in unexpected behavior. Valid values are 'array', 'bool', 'dict', 'float', 'int', and 'string'.
455
+ StyleGuide: '#chefcorrectnessmacosuserdefaultsinvalidtype'
456
+ Enabled: true
457
+ VersionAdded: '6.14.0'
458
+ Exclude:
459
+ - '**/metadata.rb'
460
+ - '**/Berksfile'
461
+
457
462
  ###############################
458
463
  # ChefSharing: Issues that prevent sharing code with other teams or with the Chef community in general
459
464
  ###############################
@@ -498,7 +503,7 @@ ChefSharing/EmptyMetadataField:
498
503
  - '**/metadata.rb'
499
504
 
500
505
  ChefSharing/IncludePropertyDescriptions:
501
- Description: Properties should include description fields to allow automated documention. Requires Chef Infra Client 13.9 or later.
506
+ Description: Properties should include description fields to allow automated documentation. Requires Chef Infra Client 13.9 or later.
502
507
  StyleGuide: '#chefsharingincludepropetydescriptions'
503
508
  Enabled: false
504
509
  VersionAdded: '6.1.0'
@@ -507,7 +512,7 @@ ChefSharing/IncludePropertyDescriptions:
507
512
  - '**/resources/*.rb'
508
513
 
509
514
  ChefSharing/IncludeResourceDescriptions:
510
- Description: Resources should include description fields to allow automated documention. Requires Chef Infra Client 13.9 or later.
515
+ Description: Resources should include description fields to allow automated documentation. Requires Chef Infra Client 13.9 or later.
511
516
  StyleGuide: '#chefsharingincluderesourcedescriptions'
512
517
  Enabled: false
513
518
  VersionAdded: '6.1.0'
@@ -515,7 +520,7 @@ ChefSharing/IncludeResourceDescriptions:
515
520
  - '**/resources/*.rb'
516
521
 
517
522
  ChefSharing/IncludeResourceExamples:
518
- Description: Resources should include examples field to allow automated documention. Requires Chef Infra Client 13.9 or later.
523
+ Description: Resources should include examples field to allow automated documentation. Requires Chef Infra Client 13.9 or later.
519
524
  StyleGuide: '#chefsharingincluderesourceexamples'
520
525
  Enabled: false
521
526
  VersionAdded: '6.10.0'
@@ -1020,6 +1025,42 @@ ChefDeprecations/ResourceUsesOnlyResourceName:
1020
1025
  - '**/libraries/*.rb'
1021
1026
  - '**/resources/*.rb'
1022
1027
 
1028
+ ChefDeprecations/ChefDKGenerators:
1029
+ Description: Chef Workstation 0.8 and later renamed the ChefDK module used when writing custom cookbook generators from ChefDK to ChefCLI. For compatibility with the latest Chef Workstation releases you'll need to reference the new class names.
1030
+ StyleGuide: '#chefdeprecationschefdkgenerators'
1031
+ Enabled: true
1032
+ VersionAdded: '6.12.0'
1033
+ Exclude:
1034
+ - '**/metadata.rb'
1035
+ - '**/Berksfile'
1036
+
1037
+ ChefDeprecations/ChefHandlerRecipe:
1038
+ Description: There is no need to include the empty and deprecated chef_handler::default recipe in order to use the chef_handler resource.
1039
+ StyleGuide: '#chefdeprecationschefhandlerrecipe'
1040
+ Enabled: true
1041
+ VersionAdded: '6.12.0'
1042
+ Exclude:
1043
+ - '**/metadata.rb'
1044
+ - '**/Berksfile'
1045
+
1046
+ ChefDeprecations/UseAutomaticResourceName:
1047
+ Description: The use_automatic_resource_name method was removed in Chef Infra Client 16. The resource name/provides should be set explicitly instead.
1048
+ StyleGuide: '#chefdeprecationsuseautomaticresourcename'
1049
+ Enabled: true
1050
+ VersionAdded: '6.12.0'
1051
+ Include:
1052
+ - '**/libraries/*.rb'
1053
+ - '**/resources/*.rb'
1054
+
1055
+ ChefDeprecations/MacosUserdefaultsGlobalProperty:
1056
+ Description: The `global` property in the macos_userdefaults resource was deprecated in Chef Infra Client 16.3. Omitting the `domain` property will now set global defaults.
1057
+ StyleGuide: '#chefdeprecationsmacosuserdefaultsglobalproperty'
1058
+ Enabled: true
1059
+ VersionAdded: '6.14.0'
1060
+ Exclude:
1061
+ - '**/metadata.rb'
1062
+ - '**/Berksfile'
1063
+
1023
1064
  ###############################
1024
1065
  # ChefModernize: Cleaning up legacy code and using new built-in resources
1025
1066
  ###############################
@@ -1496,7 +1537,7 @@ ChefModernize/WindowsRegistryUAC:
1496
1537
  - '**/Berksfile'
1497
1538
 
1498
1539
  ChefModernize/UseMultipackageInstalls:
1499
- Description: Pass an array of packages to package resources instead of interating over an array of packages when using multi-package capable package subystem such as apt, yum, chocolatey, dnf, or zypper. Multipackage installs are faster and simplify logs.
1540
+ Description: Pass an array of packages to package resources instead of iterating over an array of packages when using multi-package capable package subsystem such as apt, yum, chocolatey, dnf, or zypper. Multi-package installs are faster and simplify logs.
1500
1541
  StyleGuide: '#chefmodernizeusemultipackageinstalls'
1501
1542
  Enabled: true
1502
1543
  VersionAdded: '6.0.0'
@@ -1554,7 +1595,7 @@ ChefModernize/ShellOutHelper:
1554
1595
 
1555
1596
  ChefModernize/ConditionalUsingTest:
1556
1597
  Description: Use ::File.exist?('/foo/bar') instead of the slower 'test -f /foo/bar' which requires shelling out.
1557
- StyleGuide: '#conditionalusingtest'
1598
+ StyleGuide: '#chefmodernizeconditionalusingtest'
1558
1599
  Enabled: true
1559
1600
  VersionAdded: '6.11.0'
1560
1601
  Exclude:
@@ -1562,6 +1603,26 @@ ChefModernize/ConditionalUsingTest:
1562
1603
  - '**/Berksfile'
1563
1604
  - '**/attributes/*.rb'
1564
1605
 
1606
+ ChefModernize/CronDFileOrTemplate:
1607
+ Description: Use the cron_d resource that ships with Chef Infra Client 14.4+ instead of manually creating the file with template, file, or cookbook_file resources
1608
+ StyleGuide: '#chefmodernizecrondfileortemplate'
1609
+ Enabled: true
1610
+ VersionAdded: '6.13.0'
1611
+ Exclude:
1612
+ - '**/metadata.rb'
1613
+ - '**/Berksfile'
1614
+ - '**/attributes/*.rb'
1615
+
1616
+ ChefModernize/ActionMethodInResource:
1617
+ Description: Use the custom resource language's `action :my_action` blocks instead of creating actions with methods.
1618
+ StyleGuide: '#chefmodernizeactionmethodinresource'
1619
+ Enabled: true
1620
+ VersionAdded: '6.13.0'
1621
+ Include:
1622
+ - '**/resources/*.rb'
1623
+ - '**/providers/*.rb'
1624
+ - '**/libraries/*.rb'
1625
+
1565
1626
  ###############################
1566
1627
  # ChefRedundantCode: Cleanup unnecessary code in your cookbooks regardless of Chef Infra Client release
1567
1628
  ###############################
@@ -1758,7 +1819,7 @@ ChefRedundantCode/UseCreateIfMissing:
1758
1819
 
1759
1820
  ChefRedundantCode/OhaiAttributeToString:
1760
1821
  Description: Many Ohai node attributes are already strings and don't need to be cast to strings again
1761
- StyleGuide: '#ohaiattributetostring'
1822
+ StyleGuide: '#chefredundantcodeohaiattributetostring'
1762
1823
  Enabled: true
1763
1824
  VersionAdded: '6.10.0'
1764
1825
  Exclude:
@@ -1767,13 +1828,23 @@ ChefRedundantCode/OhaiAttributeToString:
1767
1828
 
1768
1829
  ChefRedundantCode/MultiplePlatformChecks:
1769
1830
  Description: You can pass multiple values to the platform? and platform_family? helpers instead of calling the helpers multiple times.
1770
- StyleGuide: '#multipleplatformchecks'
1831
+ StyleGuide: '#chefredundantcodemultipleplatformchecks'
1771
1832
  Enabled: true
1772
1833
  VersionAdded: '6.10.0'
1773
1834
  Exclude:
1774
1835
  - '**/metadata.rb'
1775
1836
  - '**/Berksfile'
1776
1837
 
1838
+ ChefRedundantCode/DoubleCompileTime:
1839
+ Description: If a resource includes the `compile_time` property there's no need to also use `.run_action(:some_action)` on the resource block
1840
+ StyleGuide: '#chefredundantcodedoublecompiletime'
1841
+ Enabled: true
1842
+ VersionAdded: '6.13.0'
1843
+ Exclude:
1844
+ - '**/metadata.rb'
1845
+ - '**/attributes/*.rb'
1846
+ - '**/Berksfile'
1847
+
1777
1848
  ###############################
1778
1849
  # ChefEffortless: Migrating to new patterns
1779
1850
  ###############################
@@ -1799,7 +1870,7 @@ ChefEffortless/CookbookUsesDatabags:
1799
1870
  - '**/metadata.rb'
1800
1871
  - '**/Berksfile'
1801
1872
 
1802
- ChefEffortless/CookbookUsesEnvironmments:
1873
+ ChefEffortless/CookbookUsesEnvironments:
1803
1874
  Description: Cookbook uses environments, which cannot be used in the Effortless Infra pattern
1804
1875
  StyleGuide: '#chefeffortlesscookbookusesenvironments'
1805
1876
  Enabled: false
@@ -2135,10 +2206,6 @@ Style/WordArray:
2135
2206
  Enabled: true
2136
2207
  Style/ZeroLengthPredicate:
2137
2208
  Enabled: true
2138
- Metrics/BlockNesting:
2139
- Enabled: true
2140
- Metrics/ParameterLists:
2141
- Enabled: true
2142
2209
  Lint/AmbiguousOperator:
2143
2210
  Enabled: true
2144
2211
  Lint/AssignmentInCondition:
@@ -2270,16 +2337,16 @@ Metrics/CyclomaticComplexity:
2270
2337
  Enabled: false
2271
2338
  Metrics/PerceivedComplexity:
2272
2339
  Enabled: false
2273
-
2274
- #### COPS FOR THE NEXT MAJOR RELEASE
2340
+ Metrics/BlockNesting:
2341
+ Enabled: false
2342
+ Metrics/ParameterLists:
2343
+ Enabled: false
2275
2344
 
2276
2345
  # This updates how we send helpers into the Chef recipe/resource classes and makes WAY more sense
2277
2346
  # Chef::Recipe.send(:include, ::Apt::Helpers) -> Chef::Recipe.include ::Apt::Helpers
2278
2347
  Lint/SendWithMixinArgument:
2279
2348
  Enabled: true
2280
2349
 
2281
- #### END COPS FOR THE NEXT MAJOR RELEASE
2282
-
2283
2350
  # this migrates old # rubocop: comments to use the latest namespaces, which prevents a ton of spam during cookstyle runs
2284
2351
  Migration/DepartmentName:
2285
2352
  Enabled: true
@@ -2504,3 +2571,44 @@ Style/HashEachMethods:
2504
2571
  # We want to catch this deprecation in cookbooks
2505
2572
  Lint/DeprecatedOpenSSLConstant:
2506
2573
  Enabled: true
2574
+
2575
+ # This just isn't a big deal in the context of a cookbook
2576
+ Naming/AccessorMethodName:
2577
+ Enabled: false
2578
+
2579
+ # Rescuing a particular exception twice isn't going to work
2580
+ Lint/DuplicateRescueException:
2581
+ Enabled: true
2582
+
2583
+ # if b == 0 && b == 0 is invalid and we should flag it
2584
+ Lint/BinaryOperatorWithIdenticalOperands:
2585
+ Enabled: true
2586
+
2587
+ # returning at the top level with an arg is invalid
2588
+ # @TODO we can enable this once this is fixed: https://github.com/rubocop-hq/rubocop/issues/8462
2589
+ # Lint/TopLevelReturnWithArgument:
2590
+ # Enabled: true
2591
+
2592
+ # simplify hash acccess that doesn't actually need .dig
2593
+ Style/SingleArgumentDig:
2594
+ Enabled: true
2595
+
2596
+ # trying to access $2 when there is no $2 will always return nil
2597
+ Lint/OutOfRangeRegexpRef:
2598
+ Enabled: true
2599
+
2600
+ # simplify how people coerce arrays
2601
+ Style/ArrayCoercion:
2602
+ Enabled: true
2603
+
2604
+ # if your elseif is the same as your if you're gonna have a bad day
2605
+ Lint/DuplicateElsifCondition:
2606
+ Enabled: true
2607
+
2608
+ # simplify attr_reader and attr_write into attr_accessor
2609
+ Style/BisectedAttrAccessor:
2610
+ Enabled: true
2611
+
2612
+ # avoid assignments that aren't needed
2613
+ Style/RedundantAssignment:
2614
+ Enabled: true
@@ -207,6 +207,8 @@ Lint/AssignmentInCondition:
207
207
  Enabled: false
208
208
  Lint/BigDecimalNew:
209
209
  Enabled: false
210
+ Lint/BinaryOperatorWithIdenticalOperands:
211
+ Enabled: false
210
212
  Lint/BooleanSymbol:
211
213
  Enabled: false
212
214
  Lint/CircularArgumentReference:
@@ -223,14 +225,20 @@ Lint/DisjunctiveAssignmentInConstructor:
223
225
  Enabled: false
224
226
  Lint/DuplicateCaseCondition:
225
227
  Enabled: false
228
+ Lint/DuplicateElsifCondition:
229
+ Enabled: false
226
230
  Lint/DuplicateHashKey:
227
231
  Enabled: false
228
232
  Lint/DuplicateMethods:
229
233
  Enabled: false
234
+ Lint/DuplicateRescueException:
235
+ Enabled: false
230
236
  Lint/EachWithObjectArgument:
231
237
  Enabled: false
232
238
  Lint/ElseLayout:
233
239
  Enabled: false
240
+ Lint/EmptyConditionalBody:
241
+ Enabled: false
234
242
  Lint/EmptyEnsure:
235
243
  Enabled: false
236
244
  Lint/EmptyExpression:
@@ -245,6 +253,8 @@ Lint/ErbNewArguments:
245
253
  Enabled: false
246
254
  Lint/FlipFlop:
247
255
  Enabled: false
256
+ Lint/FloatComparison:
257
+ Enabled: false
248
258
  Lint/FloatOutOfRange:
249
259
  Enabled: false
250
260
  Lint/FormatParameterMismatch:
@@ -267,6 +277,8 @@ Lint/Loop:
267
277
  Enabled: false
268
278
  Lint/MissingCopEnableDirective:
269
279
  Enabled: false
280
+ Lint/MissingSuper:
281
+ Enabled: false
270
282
  Lint/MixedRegexpCaptureTypes:
271
283
  Enabled: false
272
284
  Lint/MultipleComparison:
@@ -285,6 +297,8 @@ Lint/NumberConversion:
285
297
  Enabled: false
286
298
  Lint/OrderedMagicComments:
287
299
  Enabled: false
300
+ Lint/OutOfRangeRegexpRef:
301
+ Enabled: false
288
302
  Lint/ParenthesesAsGroupedExpression:
289
303
  Enabled: false
290
304
  Lint/PercentStringArray:
@@ -327,6 +341,8 @@ Lint/SafeNavigationWithEmpty:
327
341
  Enabled: false
328
342
  Lint/ScriptPermission:
329
343
  Enabled: false
344
+ Lint/SelfAssignment:
345
+ Enabled: false
330
346
  Lint/SendWithMixinArgument:
331
347
  Enabled: false
332
348
  Lint/ShadowedArgument:
@@ -343,12 +359,16 @@ Lint/Syntax:
343
359
  Enabled: false
344
360
  Lint/ToJSON:
345
361
  Enabled: false
362
+ Lint/TopLevelReturnWithArgument:
363
+ Enabled: false
346
364
  Lint/UnderscorePrefixedVariableName:
347
365
  Enabled: false
348
366
  Lint/UnifiedInteger:
349
367
  Enabled: false
350
368
  Lint/UnreachableCode:
351
369
  Enabled: false
370
+ Lint/UnreachableLoop:
371
+ Enabled: false
352
372
  Lint/UnusedBlockArgument:
353
373
  Enabled: false
354
374
  Lint/UnusedMethodArgument:
@@ -361,8 +381,6 @@ Lint/UselessAccessModifier:
361
381
  Enabled: false
362
382
  Lint/UselessAssignment:
363
383
  Enabled: false
364
- Lint/UselessComparison:
365
- Enabled: false
366
384
  Lint/UselessElseWithoutRescue:
367
385
  Enabled: false
368
386
  Lint/UselessSetterCall:
@@ -427,6 +445,8 @@ Style/Alias:
427
445
  Enabled: false
428
446
  Style/AndOr:
429
447
  Enabled: false
448
+ Style/ArrayCoercion:
449
+ Enabled: false
430
450
  Style/ArrayJoin:
431
451
  Enabled: false
432
452
  Style/AsciiComments:
@@ -447,6 +467,8 @@ Style/BlockDelimiters:
447
467
  Enabled: false
448
468
  Style/CaseEquality:
449
469
  Enabled: false
470
+ Style/CaseLikeIf:
471
+ Enabled: false
450
472
  Style/CharacterLiteral:
451
473
  Enabled: false
452
474
  Style/ClassAndModuleChildren:
@@ -517,6 +539,8 @@ Style/EvenOdd:
517
539
  Enabled: false
518
540
  Style/ExpandPathArguments:
519
541
  Enabled: false
542
+ Style/ExplicitBlockArgument:
543
+ Enabled: false
520
544
  Style/ExponentialNotation:
521
545
  Enabled: false
522
546
  Style/FloatDivision:
@@ -529,12 +553,18 @@ Style/FormatStringToken:
529
553
  Enabled: false
530
554
  Style/FrozenStringLiteralComment:
531
555
  Enabled: false
556
+ Style/GlobalStdStream:
557
+ Enabled: false
532
558
  Style/GlobalVars:
533
559
  Enabled: false
534
560
  Style/GuardClause:
535
561
  Enabled: false
562
+ Style/HashAsLastArrayItem:
563
+ Enabled: false
536
564
  Style/HashEachMethods:
537
565
  Enabled: false
566
+ Style/HashLikeCase:
567
+ Enabled: false
538
568
  Style/HashSyntax:
539
569
  Enabled: false
540
570
  Style/HashTransformKeys:
@@ -575,12 +605,12 @@ Style/RedundantAssignment:
575
605
  Enabled: false
576
606
  Style/RedundantFetchBlock:
577
607
  Enabled: false
608
+ Style/RedundantFileExtensionInRequire:
609
+ Enabled: false
578
610
  Style/MethodCalledOnDoEndBlock:
579
611
  Enabled: false
580
612
  Style/MethodDefParentheses:
581
613
  Enabled: false
582
- Style/MethodMissingSuper:
583
- Enabled: false
584
614
  Style/MinMax:
585
615
  Enabled: false
586
616
  Style/MissingElse:
@@ -645,6 +675,8 @@ Style/OptionHash:
645
675
  Enabled: false
646
676
  Style/OptionalArguments:
647
677
  Enabled: false
678
+ Style/OptionalBooleanParameter:
679
+ Enabled: false
648
680
  Style/ParallelAssignment:
649
681
  Enabled: false
650
682
  Style/ParenthesesAroundCondition:
@@ -713,6 +745,8 @@ Style/Send:
713
745
  Enabled: false
714
746
  Style/SignalException:
715
747
  Enabled: false
748
+ Style/SingleArgumentDig:
749
+ Enabled: false
716
750
  Style/SingleLineBlockParams:
717
751
  Enabled: false
718
752
  Style/SingleLineMethods:
@@ -725,6 +759,8 @@ Style/StabbyLambdaParentheses:
725
759
  Enabled: false
726
760
  Style/StderrPuts:
727
761
  Enabled: false
762
+ Style/StringConcatenation:
763
+ Enabled: false
728
764
  Style/StringHashKeys:
729
765
  Enabled: false
730
766
  Style/StringLiterals: