cookstyle 6.17.5 → 6.19.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +5 -1
  3. data/bin/cookstyle +0 -1
  4. data/config/cookstyle.yml +85 -15
  5. data/config/disable_all.yml +8 -0
  6. data/config/upstream.yml +50 -3
  7. data/cookstyle.gemspec +1 -2
  8. data/lib/cookstyle.rb +5 -5
  9. data/lib/cookstyle/version.rb +2 -2
  10. data/lib/rubocop/cop/chef/correctness/block_guard_clause_string_only.rb +1 -1
  11. data/lib/rubocop/cop/chef/correctness/chef_application_fatal.rb +2 -1
  12. data/lib/rubocop/cop/chef/correctness/conditional_ruby_shellout.rb +1 -1
  13. data/lib/rubocop/cop/chef/correctness/incorrect_library_injection.rb +24 -14
  14. data/lib/rubocop/cop/chef/correctness/invalid_platform_family_values_in_case.rb +1 -1
  15. data/lib/rubocop/cop/chef/correctness/invalid_platform_metadata.rb +2 -2
  16. data/lib/rubocop/cop/chef/correctness/invalid_platform_values_in_case.rb +2 -1
  17. data/lib/rubocop/cop/chef/correctness/invalid_version_metadata.rb +1 -0
  18. data/lib/rubocop/cop/chef/correctness/lazy_eval_node_attribute_defaults.rb +1 -1
  19. data/lib/rubocop/cop/chef/correctness/lazy_in_resource_guard.rb +67 -0
  20. data/lib/rubocop/cop/chef/correctness/macos_userdefaults_invalid_type.rb +2 -2
  21. data/lib/rubocop/cop/chef/correctness/node_normal.rb +1 -0
  22. data/lib/rubocop/cop/chef/correctness/node_normal_unless.rb +1 -0
  23. data/lib/rubocop/cop/chef/correctness/node_save.rb +1 -0
  24. data/lib/rubocop/cop/chef/correctness/notifies_action_not_symbol.rb +1 -1
  25. data/lib/rubocop/cop/chef/correctness/property_without_type.rb +59 -0
  26. data/lib/rubocop/cop/chef/correctness/resource_with_none_action.rb +1 -1
  27. data/lib/rubocop/cop/chef/correctness/scoped_file_exist.rb +1 -1
  28. data/lib/rubocop/cop/chef/correctness/supports_must_be_float.rb +2 -2
  29. data/lib/rubocop/cop/chef/deprecation/chef_handler_supports.rb +1 -1
  30. data/lib/rubocop/cop/chef/deprecation/chef_rewind.rb +2 -2
  31. data/lib/rubocop/cop/chef/deprecation/chef_shellout.rb +2 -2
  32. data/lib/rubocop/cop/chef/deprecation/chef_windows_platform_helper.rb +2 -1
  33. data/lib/rubocop/cop/chef/deprecation/chefdk_generators.rb +1 -1
  34. data/lib/rubocop/cop/chef/deprecation/chefspec_coverage_report.rb +1 -1
  35. data/lib/rubocop/cop/chef/deprecation/chefspec_legacy_runner.rb +1 -1
  36. data/lib/rubocop/cop/chef/deprecation/deprecated_chefspec_platform.rb +1 -3
  37. data/lib/rubocop/cop/chef/deprecation/deprecated_platform_methods.rb +1 -0
  38. data/lib/rubocop/cop/chef/deprecation/deprecated_yum_repository_properties.rb +1 -1
  39. data/lib/rubocop/cop/chef/deprecation/epic_fail.rb +1 -1
  40. data/lib/rubocop/cop/chef/deprecation/execute_path_property.rb +1 -1
  41. data/lib/rubocop/cop/chef/deprecation/execute_relative_creates_without_cwd.rb +1 -1
  42. data/lib/rubocop/cop/chef/deprecation/inherits_compat_resource.rb +1 -1
  43. data/lib/rubocop/cop/chef/deprecation/legacy_notify_syntax.rb +2 -2
  44. data/lib/rubocop/cop/chef/deprecation/node_deep_fetch.rb +2 -0
  45. data/lib/rubocop/cop/chef/deprecation/node_methods_not_attributes.rb +22 -27
  46. data/lib/rubocop/cop/chef/deprecation/node_set.rb +1 -0
  47. data/lib/rubocop/cop/chef/deprecation/node_set_unless.rb +1 -0
  48. data/lib/rubocop/cop/chef/deprecation/node_set_without_level.rb +1 -0
  49. data/lib/rubocop/cop/chef/deprecation/partial_search_class_usage.rb +1 -0
  50. data/lib/rubocop/cop/chef/deprecation/powershell_cookbook_helpers.rb +2 -1
  51. data/lib/rubocop/cop/chef/deprecation/resource_overrides_provides_method.rb +2 -2
  52. data/lib/rubocop/cop/chef/deprecation/ruby_27_keyword_argument_warnings.rb +2 -2
  53. data/lib/rubocop/cop/chef/deprecation/ruby_block_create_action.rb +2 -2
  54. data/lib/rubocop/cop/chef/deprecation/search_uses_positional_parameters.rb +1 -1
  55. data/lib/rubocop/cop/chef/deprecation/user_supports_property.rb +1 -1
  56. data/lib/rubocop/cop/chef/deprecation/windows_package_installer_type_string.rb +1 -1
  57. data/lib/rubocop/cop/chef/deprecation/windows_task_change_action.rb +2 -2
  58. data/lib/rubocop/cop/chef/deprecation/windows_version_helpers.rb +5 -4
  59. data/lib/rubocop/cop/chef/deprecation/xml_ruby_recipe.rb +1 -1
  60. data/lib/rubocop/cop/chef/effortless/chef_vault_used.rb +89 -0
  61. data/lib/rubocop/cop/chef/effortless/depends_chef_vault.rb +49 -0
  62. data/lib/rubocop/cop/chef/modernize/action_method_in_resource.rb +2 -2
  63. data/lib/rubocop/cop/chef/modernize/berksfile_source.rb +2 -2
  64. data/lib/rubocop/cop/chef/modernize/build_essential.rb +1 -1
  65. data/lib/rubocop/cop/chef/modernize/compile_time_resources.rb +1 -0
  66. data/lib/rubocop/cop/chef/modernize/conditional_using_test.rb +2 -2
  67. data/lib/rubocop/cop/chef/modernize/cron_manage_resource.rb +1 -1
  68. data/lib/rubocop/cop/chef/modernize/databag_helpers.rb +2 -1
  69. data/lib/rubocop/cop/chef/modernize/foodcritic_comments.rb +1 -1
  70. data/lib/rubocop/cop/chef/modernize/if_provides_default_action.rb +1 -1
  71. data/lib/rubocop/cop/chef/modernize/libarchive_file.rb +2 -2
  72. data/lib/rubocop/cop/chef/modernize/macos_user_defaults.rb +1 -1
  73. data/lib/rubocop/cop/chef/modernize/node_init_package.rb +5 -4
  74. data/lib/rubocop/cop/chef/modernize/node_roles_include.rb +2 -1
  75. data/lib/rubocop/cop/chef/modernize/openssl_rsa_key_resource.rb +1 -1
  76. data/lib/rubocop/cop/chef/modernize/openssl_x509_resource.rb +1 -1
  77. data/lib/rubocop/cop/chef/modernize/osx_config_profile_resource.rb +1 -1
  78. data/lib/rubocop/cop/chef/modernize/property_with_name_attribute.rb +1 -1
  79. data/lib/rubocop/cop/chef/modernize/respond_to_compile_time.rb +7 -4
  80. data/lib/rubocop/cop/chef/modernize/respond_to_metadata.rb +6 -6
  81. data/lib/rubocop/cop/chef/modernize/respond_to_provides.rb +10 -10
  82. data/lib/rubocop/cop/chef/modernize/respond_to_resource_name.rb +2 -2
  83. data/lib/rubocop/cop/chef/modernize/shell_out_helper.rb +2 -1
  84. data/lib/rubocop/cop/chef/modernize/simplify_apt_ppa_setup.rb +1 -1
  85. data/lib/rubocop/cop/chef/modernize/sysctl_param_resource.rb +1 -1
  86. data/lib/rubocop/cop/chef/modernize/use_multipackage_installs.rb +1 -1
  87. data/lib/rubocop/cop/chef/modernize/use_require_relative.rb +1 -1
  88. data/lib/rubocop/cop/chef/modernize/zypper_repo.rb +1 -1
  89. data/lib/rubocop/cop/chef/redundant/double_compile_time.rb +2 -1
  90. data/lib/rubocop/cop/chef/redundant/multiple_platform_checks.rb +1 -1
  91. data/lib/rubocop/cop/chef/redundant/name_property_and_required.rb +1 -0
  92. data/lib/rubocop/cop/chef/redundant/ohai_attribute_to_string.rb +2 -1
  93. data/lib/rubocop/cop/chef/redundant/property_splat_regex.rb +1 -0
  94. data/lib/rubocop/cop/chef/redundant/use_create_if_missing.rb +1 -1
  95. data/lib/rubocop/cop/chef/sharing/include_property_descriptions.rb +1 -1
  96. data/lib/rubocop/cop/chef/sharing/insecure_cookbook_url.rb +1 -1
  97. data/lib/rubocop/cop/chef/sharing/invalid_license_string.rb +1 -1
  98. data/lib/rubocop/cop/chef/style/attribute_keys.rb +2 -1
  99. data/lib/rubocop/cop/chef/style/chef_whaaat.rb +1 -1
  100. data/lib/rubocop/cop/chef/style/comment_sentence_spacing.rb +2 -2
  101. data/lib/rubocop/cop/chef/style/comments_copyright_format.rb +2 -2
  102. data/lib/rubocop/cop/chef/style/comments_default_copyright.rb +1 -1
  103. data/lib/rubocop/cop/chef/style/comments_format.rb +6 -13
  104. data/lib/rubocop/cop/chef/style/file_mode.rb +2 -2
  105. data/lib/rubocop/cop/chef/style/immediate_notification_timing.rb +2 -2
  106. data/lib/rubocop/cop/chef/style/include_recipe_with_parentheses.rb +2 -2
  107. data/lib/rubocop/cop/chef/style/negating_only_if.rb +2 -2
  108. data/lib/rubocop/cop/chef/style/overly_complex_supports_depends_metadata.rb +2 -2
  109. data/lib/rubocop/cop/chef/style/simplify_platform_major_version_check.rb +2 -1
  110. data/lib/rubocop/cop/chef/style/true_false_resource_properties.rb +2 -2
  111. data/lib/rubocop/cop/chef/style/unnecessary_os_check.rb +5 -4
  112. data/lib/rubocop/cop/chef/style/unnecessary_platform_case_statement.rb +2 -2
  113. data/lib/rubocop/cop/chef/style/use_platform_helpers.rb +7 -6
  114. metadata +8 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 76d0f2a3917c4ff1035541386d4edaa98f4cb782bd2f43a839d938b66aada708
4
- data.tar.gz: ca7aff409b3d786fd71ac630c1d23b36f51a51ba495f7c2c4761c753c5e40624
3
+ metadata.gz: f26b00de7e92bb6cd6e16e2c323c66504b95a098512d78929dda659128c0f828
4
+ data.tar.gz: ae852bc01e5b7d9e2bab25ef88778650c46a0c0fb463286bc68dc8400892c215
5
5
  SHA512:
6
- metadata.gz: 94bd535e28382dfd08776a053b8c6c9bb46e054a4dc3f10876b470de3755b3d6a78da9c71982ae3a7e0aee3856230e027ffe25457c77b8fd703df839acffeed4
7
- data.tar.gz: f80c75e882aa27d4d4d81628c996acd2c2f5b1fc0226fafcd37b2ff86b2f9dddc9aa8f84c0b5cf4c8f71b1333757e2e239699966ac612902b426cae881ca91c1
6
+ metadata.gz: 69f6664c011cd99a25a1a2695c156190eea02c952e3dfcef41de670de003d3ccfb3a927c9967c3f1ea887294a0acdbd11280b61b410382dc20231fa408abf6a8
7
+ data.tar.gz: 1a0a759425be48591153c51e14d06324a3edc240eae193e99110870f62785405043f5847c5ee112157288c11c529614ed920fa17d3b281392d8798d8679723c2
data/Gemfile CHANGED
@@ -17,8 +17,12 @@ group :docs do
17
17
  end
18
18
 
19
19
  group :profiling do
20
- gem 'stackprof'
21
20
  gem 'memory_profiler'
21
+ gem 'stackprof'
22
+ end
23
+
24
+ group :rubocop_gems do
25
+ gem 'rubocop-performance'
22
26
  end
23
27
 
24
28
  group :development do
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- # -*- encoding: utf-8 -*-
3
2
  # frozen_string_literal: true
4
3
 
5
4
  $LOAD_PATH.unshift File.join(__dir__, %w(.. lib))
@@ -451,6 +451,24 @@ ChefCorrectness/MacosUserdefaultsInvalidType:
451
451
  - '**/metadata.rb'
452
452
  - '**/Berksfile'
453
453
 
454
+ ChefCorrectness/LazyInResourceGuard:
455
+ Description: Using `lazy {}` within a resource guard (not_if/only_if) will cause failures and is unnecessary as resource guards are always lazily evaluated.
456
+ StyleGuide: '#chefcorrectnesslazyinresourceguard'
457
+ Enabled: true
458
+ VersionAdded: '6.18.0'
459
+ Exclude:
460
+ - '**/metadata.rb'
461
+ - '**/Berksfile'
462
+
463
+ ChefCorrectness/PropertyWithoutType:
464
+ Description: Custom resource properties or attributes should always define a type to help users understand the correct allowed values.
465
+ StyleGuide: '#chefcorrectnesspropertywithouttype'
466
+ Enabled: true
467
+ VersionAdded: '6.18.0'
468
+ Include:
469
+ - '**/libraries/*.rb'
470
+ - '**/resources/*.rb'
471
+
454
472
  ###############################
455
473
  # ChefSharing: Issues that prevent sharing code with other teams or with the Chef community in general
456
474
  ###############################
@@ -1911,6 +1929,25 @@ ChefEffortless/CookbookUsesDatabags:
1911
1929
  Exclude:
1912
1930
  - '**/metadata.rb'
1913
1931
  - '**/Berksfile'
1932
+
1933
+ # https://github.com/chef/cookstyle/issues/346
1934
+ ChefEffortless/ChefVaultUsed:
1935
+ Description: Cookbook uses Chef Vault, which cannot be used in the Effortless Infra pattern
1936
+ StyleGuide: '#chefeffortlesscookbookuseschefvault'
1937
+ Enabled: false
1938
+ VersionAdded: '6.19'
1939
+ Exclude:
1940
+ - '**/metadata.rb'
1941
+ - '**/Berksfile'
1942
+
1943
+ # https://github.com/chef/cookstyle/issues/346
1944
+ ChefEffortless/DependsChefVault:
1945
+ Description: Cookbook depends on Chef Vault, which cannot be used in the Effortless Infra pattern
1946
+ StyleGuide: '#chefeffortlesscookbookdependschefvault'
1947
+ Enabled: false
1948
+ VersionAdded: '6.19'
1949
+ Include:
1950
+ - '**/metadata.rb'
1914
1951
 
1915
1952
  ChefEffortless/CookbookUsesEnvironments:
1916
1953
  Description: Cookbook uses environments, which cannot be used in the Effortless Infra pattern
@@ -2343,21 +2380,6 @@ Lint/UselessSetterCall:
2343
2380
  Lint/Void:
2344
2381
  Enabled: true
2345
2382
 
2346
- ##### Additional rules we enable/disable over the rubocop 0.37 rules ago #####
2347
-
2348
- Layout/AlignParameters:
2349
- Enabled: false
2350
- Style/Encoding:
2351
- Enabled: false
2352
- Style/Alias:
2353
- Enabled: false
2354
- Layout/SpaceBeforeFirstArg:
2355
- Enabled: false
2356
- Style/ClassAndModuleChildren:
2357
- Enabled: false
2358
- Style/DoubleNegation:
2359
- Enabled: false
2360
-
2361
2383
  # file names don't matter in cookbooks
2362
2384
  Naming/FileName:
2363
2385
  Enabled: false
@@ -2658,3 +2680,51 @@ Style/RedundantAssignment:
2658
2680
  # alert on invalid ruby
2659
2681
  Lint/Syntax:
2660
2682
  Enabled: true
2683
+
2684
+ # remove extra requires like 'thread'
2685
+ Lint/RedundantRequireStatement:
2686
+ Enabled: true
2687
+
2688
+ # simplify stripping strings
2689
+ Style/Strip:
2690
+ Enabled: true
2691
+
2692
+ # simplify how you warn
2693
+ Style/StderrPuts:
2694
+ Enabled: true
2695
+
2696
+ # more code simplification
2697
+ Style/Sample:
2698
+ Enabled: true
2699
+
2700
+ # simpler returns
2701
+ Style/ReturnNil:
2702
+ Enabled: true
2703
+
2704
+ # use .sort when .sort_by isn't needed
2705
+ Style/RedundantSortBy:
2706
+ Enabled: true
2707
+
2708
+ # simplify getting min/max
2709
+ Style/RedundantSort:
2710
+ Enabled: true
2711
+
2712
+ # no need for .rb in requires
2713
+ Style/RedundantFileExtensionInRequire:
2714
+ Enabled: true
2715
+
2716
+ # more code you don't need
2717
+ Style/RedundantCondition:
2718
+ Enabled: true
2719
+
2720
+ # Ruby 2 makes these pointless
2721
+ Style/Encoding:
2722
+ Enabled: true
2723
+
2724
+ # Use __dir__ to simplify things
2725
+ Style/Dir:
2726
+ Enabled: true
2727
+
2728
+ # Use __FILE__ or __dir__ to simplify expand_paths
2729
+ Style/ExpandPathArguments:
2730
+ Enabled: true
@@ -25,6 +25,8 @@ Layout/ArrayAlignment:
25
25
  Enabled: false
26
26
  Layout/AssignmentIndentation:
27
27
  Enabled: false
28
+ Layout/BeginEndAlignment:
29
+ Enabled: false
28
30
  Layout/BlockAlignment:
29
31
  Enabled: false
30
32
  Layout/BlockEndNewline:
@@ -215,6 +217,8 @@ Lint/BooleanSymbol:
215
217
  Enabled: false
216
218
  Lint/CircularArgumentReference:
217
219
  Enabled: false
220
+ Lint/ConstantDefinitionInBlock:
221
+ Enabled: false
218
222
  Lint/ConstantResolution:
219
223
  Enabled: false
220
224
  Lint/Debugger:
@@ -267,6 +271,8 @@ Lint/FormatParameterMismatch:
267
271
  Enabled: false
268
272
  Lint/HeredocMethodCallPosition:
269
273
  Enabled: false
274
+ Lint/IdentityComparison:
275
+ Enabled: false
270
276
  Lint/ImplicitStringConcatenation:
271
277
  Enabled: false
272
278
  Lint/InheritException:
@@ -395,6 +401,8 @@ Lint/UselessMethodDefinition:
395
401
  Enabled: false
396
402
  Lint/UselessSetterCall:
397
403
  Enabled: false
404
+ Lint/UselessTimes:
405
+ Enabled: false
398
406
  Lint/Void:
399
407
  Enabled: false
400
408
  Metrics/CyclomaticComplexity:
@@ -117,6 +117,8 @@ AllCops:
117
117
  # CacheRootDirectory is ~ (nil), which it is by default, the root will be
118
118
  # taken from the environment variable `$XDG_CACHE_HOME` if it is set, or if
119
119
  # `$XDG_CACHE_HOME` is not set, it will be `$HOME/.cache/`.
120
+ # The CacheRootDirectory can be overwritten by passing the `--cache-root` command
121
+ # line option or by setting `$RUBOCOP_CACHE_ROOT` environment variable.
120
122
  CacheRootDirectory: ~
121
123
  # It is possible for a malicious user to know the location of RuboCop's cache
122
124
  # directory by looking at CacheRootDirectory, and create a symlink in its
@@ -309,6 +311,19 @@ Layout/AssignmentIndentation:
309
311
  # But it can be overridden by setting this parameter
310
312
  IndentationWidth: ~
311
313
 
314
+ Layout/BeginEndAlignment:
315
+ Description: 'Align ends corresponding to begins correctly.'
316
+ Enabled: pending
317
+ VersionAdded: '0.91'
318
+ # The value `start_of_line` means that `end` should be aligned the start of the line
319
+ # where the `begin` keyword is.
320
+ # The value `begin` means that `end` should be aligned with the `begin` keyword.
321
+ EnforcedStyleAlignWith: start_of_line
322
+ SupportedStylesAlignWith:
323
+ - start_of_line
324
+ - begin
325
+ Severity: warning
326
+
312
327
  Layout/BlockAlignment:
313
328
  Description: 'Align block ends correctly.'
314
329
  Enabled: true
@@ -1380,6 +1395,12 @@ Lint/CircularArgumentReference:
1380
1395
  Enabled: true
1381
1396
  VersionAdded: '0.33'
1382
1397
 
1398
+ Lint/ConstantDefinitionInBlock:
1399
+ Description: 'Do not define constants within a block.'
1400
+ StyleGuide: '#no-constant-definition-in-block'
1401
+ Enabled: pending
1402
+ VersionAdded: '0.91'
1403
+
1383
1404
  Lint/ConstantResolution:
1384
1405
  Description: 'Check that constants are fully qualified with `::`.'
1385
1406
  Enabled: false
@@ -1533,6 +1554,12 @@ Lint/HeredocMethodCallPosition:
1533
1554
  StyleGuide: '#heredoc-method-calls'
1534
1555
  VersionAdded: '0.68'
1535
1556
 
1557
+ Lint/IdentityComparison:
1558
+ Description: 'Prefer `equal?` over `==` when comparing `object_id`.'
1559
+ Enabled: pending
1560
+ StyleGuide: '#identity-comparison'
1561
+ VersionAdded: '0.91'
1562
+
1536
1563
  Lint/ImplicitStringConcatenation:
1537
1564
  Description: >-
1538
1565
  Checks for adjacent string literals on the same line, which
@@ -1784,6 +1811,7 @@ Lint/SafeNavigationChain:
1784
1811
  - presence
1785
1812
  - try
1786
1813
  - try!
1814
+ - in?
1787
1815
 
1788
1816
  Lint/SafeNavigationConsistency:
1789
1817
  Description: >-
@@ -1861,6 +1889,7 @@ Lint/Syntax:
1861
1889
  Enabled: true
1862
1890
  VersionAdded: '0.9'
1863
1891
 
1892
+
1864
1893
  Lint/ToJSON:
1865
1894
  Description: 'Ensure #to_json includes an optional argument.'
1866
1895
  Enabled: true
@@ -1965,6 +1994,12 @@ Lint/UselessSetterCall:
1965
1994
  VersionChanged: '0.80'
1966
1995
  Safe: false
1967
1996
 
1997
+ Lint/UselessTimes:
1998
+ Description: 'Checks for useless `Integer#times` calls.'
1999
+ Enabled: pending
2000
+ VersionAdded: '0.91'
2001
+ Safe: false
2002
+
1968
2003
  Lint/Void:
1969
2004
  Description: 'Possible use of operator/literal/variable in void context.'
1970
2005
  Enabled: true
@@ -2428,7 +2463,7 @@ Style/ArrayCoercion:
2428
2463
  with a variable you want to treat as an Array, but you're not certain it's an array.
2429
2464
  StyleGuide: '#array-coercion'
2430
2465
  Safe: false
2431
- Enabled: 'pending'
2466
+ Enabled: false
2432
2467
  VersionAdded: '0.88'
2433
2468
 
2434
2469
  Style/ArrayJoin:
@@ -2828,7 +2863,8 @@ Style/DateTime:
2828
2863
  StyleGuide: '#date--time'
2829
2864
  Enabled: false
2830
2865
  VersionAdded: '0.51'
2831
- VersionChanged: '0.59'
2866
+ VersionChanged: '0.92'
2867
+ SafeAutoCorrect: false
2832
2868
  AllowCoercion: false
2833
2869
 
2834
2870
  Style/DefWithParentheses:
@@ -3073,6 +3109,7 @@ Style/GlobalStdStream:
3073
3109
  StyleGuide: '#global-stdout'
3074
3110
  Enabled: pending
3075
3111
  VersionAdded: '0.89'
3112
+ SafeAutoCorrect: false
3076
3113
 
3077
3114
  Style/GlobalVars:
3078
3115
  Description: 'Do not introduce global variables.'
@@ -3247,11 +3284,16 @@ Style/IpAddresses:
3247
3284
  Description: "Don't include literal IP addresses in code."
3248
3285
  Enabled: false
3249
3286
  VersionAdded: '0.58'
3250
- VersionChanged: '0.77'
3287
+ VersionChanged: '0.91'
3251
3288
  # Allow addresses to be permitted
3252
3289
  AllowedAddresses:
3253
3290
  - "::"
3254
3291
  # :: is a valid IPv6 address, but could potentially be legitimately in code
3292
+ Exclude:
3293
+ - '**/*.gemfile'
3294
+ - '**/Gemfile'
3295
+ - '**/gems.rb'
3296
+ - '**/*.gemspec'
3255
3297
 
3256
3298
  Style/KeywordParametersOrder:
3257
3299
  Description: 'Enforces that optional keyword parameters are placed at the end of the parameters list.'
@@ -3684,6 +3726,8 @@ Style/OptionalBooleanParameter:
3684
3726
  Enabled: pending
3685
3727
  Safe: false
3686
3728
  VersionAdded: '0.89'
3729
+ AllowedMethods:
3730
+ - respond_to_missing?
3687
3731
 
3688
3732
  Style/OrAssignment:
3689
3733
  Description: 'Recommend usage of double pipe equals (||=) where applicable.'
@@ -3952,6 +3996,8 @@ Style/SafeNavigation:
3952
3996
  This cop transforms usages of a method call safeguarded by
3953
3997
  a check for the existence of the object to
3954
3998
  safe navigation (`&.`).
3999
+ Auto-correction is unsafe as it assumes the object will
4000
+ be `nil` or truthy, but never `false`.
3955
4001
  Enabled: true
3956
4002
  VersionAdded: '0.43'
3957
4003
  VersionChanged: '0.77'
@@ -3964,6 +4010,7 @@ Style/SafeNavigation:
3964
4010
  - presence
3965
4011
  - try
3966
4012
  - try!
4013
+ SafeAutoCorrect: false
3967
4014
 
3968
4015
  Style/Sample:
3969
4016
  Description: >-
@@ -1,6 +1,5 @@
1
- # coding: utf-8
2
1
  # frozen_string_literal: true
3
- lib = File.expand_path('../lib', __FILE__)
2
+ lib = File.expand_path('lib', __dir__)
4
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
4
  require 'cookstyle/version'
6
5
 
@@ -7,13 +7,13 @@ require 'yaml' unless defined?(YAML)
7
7
  # ensure the desired target version of RuboCop is gem activated
8
8
  gem 'rubocop', "= #{Cookstyle::RUBOCOP_VERSION}"
9
9
  require 'rubocop'
10
- require_relative 'rubocop/monkey_patches/comment_config.rb'
10
+ require_relative 'rubocop/monkey_patches/comment_config'
11
11
 
12
12
  # monkey patches needed for the TargetChefVersion config option
13
- require_relative 'rubocop/monkey_patches/config.rb'
14
- require_relative 'rubocop/monkey_patches/base.rb'
15
- require_relative 'rubocop/monkey_patches/team.rb'
16
- require_relative 'rubocop/monkey_patches/registry_cop.rb'
13
+ require_relative 'rubocop/monkey_patches/config'
14
+ require_relative 'rubocop/monkey_patches/base'
15
+ require_relative 'rubocop/monkey_patches/team'
16
+ require_relative 'rubocop/monkey_patches/registry_cop'
17
17
 
18
18
  module RuboCop
19
19
  class ConfigLoader
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  module Cookstyle
3
- VERSION = "6.17.5" # rubocop: disable Style/StringLiterals
4
- RUBOCOP_VERSION = '0.90.0'
3
+ VERSION = "6.19.11" # rubocop: disable Style/StringLiterals
4
+ RUBOCOP_VERSION = '0.92.0'
5
5
  end
@@ -50,7 +50,7 @@ module RuboCop
50
50
  block_guard_with_only_string?(node) do
51
51
  add_offense(node, message: MSG, severity: :refactor) do |corrector|
52
52
  new_val = "#{node.method_name} #{node.body.source}"
53
- corrector.replace(node.loc.expression, new_val)
53
+ corrector.replace(node, new_val)
54
54
  end
55
55
  end
56
56
  end
@@ -33,6 +33,7 @@ module RuboCop
33
33
  extend AutoCorrector
34
34
 
35
35
  MSG = 'Use raise to force Chef Infra Client to fail instead of using Chef::Application.fatal'
36
+ RESTRICT_ON_SEND = [:fatal!].freeze
36
37
 
37
38
  def_node_matcher :application_fatal?, <<-PATTERN
38
39
  (send
@@ -44,7 +45,7 @@ module RuboCop
44
45
  def on_send(node)
45
46
  application_fatal?(node) do |val|
46
47
  add_offense(node, message: MSG, severity: :refactor) do |corrector|
47
- corrector.replace(node.loc.expression, "raise(#{val.source})")
48
+ corrector.replace(node, "raise(#{val.source})")
48
49
  end
49
50
  end
50
51
  end
@@ -58,7 +58,7 @@ module RuboCop
58
58
  def on_block(node)
59
59
  conditional_shellout?(node) do |type, val|
60
60
  add_offense(node, message: MSG, severity: :refactor) do |corrector|
61
- corrector.replace(node.loc.expression, "#{type} #{val.source}")
61
+ corrector.replace(node, "#{type} #{val.source}")
62
62
  end
63
63
  end
64
64
  end
@@ -33,30 +33,40 @@ module RuboCop
33
33
  # ::Chef::DSL::Recipe.send(:include, Filebeat::Helpers) # covers previous Recipe & Provider classes
34
34
  #
35
35
  class IncorrectLibraryInjection < Base
36
+ include RangeHelp
36
37
  extend AutoCorrector
37
38
 
38
39
  MSG = 'Libraries should be injected into the Chef::DSL::Recipe class and not Chef::Recipe or Chef::Provider classes directly.'
40
+ RESTRICT_ON_SEND = [:send, :include].freeze
39
41
 
40
- def_node_matcher :legacy_class_sends?, <<-PATTERN
41
- (send (const (const (cbase) :Chef) {:Recipe :Provider}) :send (sym :include) ... )
42
+ def_node_search :correct_injection?, <<-PATTERN
43
+ {(send
44
+ (const
45
+ (const
46
+ (const {cbase nil?} :Chef) :DSL) :Recipe) :send
47
+ (sym :include)
48
+ ... )
49
+ (send
50
+ (const
51
+ (const
52
+ (const {cbase nil?} :Chef) :DSL) :Recipe) :include
53
+ ... )}
42
54
  PATTERN
43
55
 
44
- def_node_matcher :legacy_class_includes?, <<-PATTERN
45
- (send (const (const (cbase) :Chef) {:Recipe :Provider}) :include ... )
56
+ def_node_matcher :legacy_injection?, <<-PATTERN
57
+ {(send (const (const {cbase nil?} :Chef) {:Recipe :Provider}) :send (sym :include) ... )
58
+ (send (const (const {cbase nil?} :Chef) {:Recipe :Provider}) :include ... )}
46
59
  PATTERN
47
60
 
48
61
  def on_send(node)
49
- legacy_class_sends?(node) do
62
+ legacy_injection?(node) do
50
63
  add_offense(node, message: MSG, severity: :refactor) do |corrector|
51
- corrector.replace(node.loc.expression,
52
- node.source.gsub(/Chef::(Provider|Recipe)/, 'Chef::DSL::Recipe'))
53
- end
54
- end
55
-
56
- legacy_class_includes?(node) do
57
- add_offense(node, message: MSG, severity: :refactor) do |corrector|
58
- corrector.replace(node.loc.expression,
59
- node.source.gsub(/Chef::(Provider|Recipe)/, 'Chef::DSL::Recipe'))
64
+ if node.parent && correct_injection?(node.parent)
65
+ corrector.remove(range_with_surrounding_space(range: node.loc.expression, side: :left))
66
+ else
67
+ corrector.replace(node,
68
+ node.source.gsub(/Chef::(Provider|Recipe)/, 'Chef::DSL::Recipe'))
69
+ end
60
70
  end
61
71
  end
62
72
  end