cookstyle 6.19.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 (42) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +5 -1
  3. data/lib/cookstyle/version.rb +1 -1
  4. data/lib/rubocop/cop/chef/correctness/chef_application_fatal.rb +1 -0
  5. data/lib/rubocop/cop/chef/correctness/incorrect_library_injection.rb +1 -0
  6. data/lib/rubocop/cop/chef/correctness/invalid_platform_values_in_case.rb +1 -0
  7. data/lib/rubocop/cop/chef/correctness/invalid_version_metadata.rb +1 -0
  8. data/lib/rubocop/cop/chef/correctness/node_normal.rb +1 -0
  9. data/lib/rubocop/cop/chef/correctness/node_normal_unless.rb +1 -0
  10. data/lib/rubocop/cop/chef/correctness/node_save.rb +1 -0
  11. data/lib/rubocop/cop/chef/deprecation/chef_shellout.rb +1 -1
  12. data/lib/rubocop/cop/chef/deprecation/chef_windows_platform_helper.rb +1 -0
  13. data/lib/rubocop/cop/chef/deprecation/deprecated_chefspec_platform.rb +0 -2
  14. data/lib/rubocop/cop/chef/deprecation/deprecated_platform_methods.rb +1 -0
  15. data/lib/rubocop/cop/chef/deprecation/legacy_notify_syntax.rb +1 -1
  16. data/lib/rubocop/cop/chef/deprecation/node_deep_fetch.rb +2 -0
  17. data/lib/rubocop/cop/chef/deprecation/node_methods_not_attributes.rb +21 -26
  18. data/lib/rubocop/cop/chef/deprecation/node_set.rb +1 -0
  19. data/lib/rubocop/cop/chef/deprecation/node_set_unless.rb +1 -0
  20. data/lib/rubocop/cop/chef/deprecation/node_set_without_level.rb +1 -0
  21. data/lib/rubocop/cop/chef/deprecation/partial_search_class_usage.rb +1 -0
  22. data/lib/rubocop/cop/chef/deprecation/powershell_cookbook_helpers.rb +1 -0
  23. data/lib/rubocop/cop/chef/deprecation/resource_overrides_provides_method.rb +2 -2
  24. data/lib/rubocop/cop/chef/deprecation/windows_version_helpers.rb +1 -0
  25. data/lib/rubocop/cop/chef/modernize/compile_time_resources.rb +1 -0
  26. data/lib/rubocop/cop/chef/modernize/conditional_using_test.rb +1 -1
  27. data/lib/rubocop/cop/chef/modernize/databag_helpers.rb +1 -0
  28. data/lib/rubocop/cop/chef/modernize/node_init_package.rb +2 -1
  29. data/lib/rubocop/cop/chef/modernize/node_roles_include.rb +1 -0
  30. data/lib/rubocop/cop/chef/modernize/respond_to_metadata.rb +1 -1
  31. data/lib/rubocop/cop/chef/modernize/respond_to_provides.rb +9 -9
  32. data/lib/rubocop/cop/chef/modernize/respond_to_resource_name.rb +1 -1
  33. data/lib/rubocop/cop/chef/modernize/shell_out_helper.rb +1 -0
  34. data/lib/rubocop/cop/chef/redundant/double_compile_time.rb +1 -0
  35. data/lib/rubocop/cop/chef/redundant/name_property_and_required.rb +1 -0
  36. data/lib/rubocop/cop/chef/redundant/ohai_attribute_to_string.rb +1 -0
  37. data/lib/rubocop/cop/chef/redundant/property_splat_regex.rb +1 -0
  38. data/lib/rubocop/cop/chef/style/attribute_keys.rb +1 -0
  39. data/lib/rubocop/cop/chef/style/simplify_platform_major_version_check.rb +1 -0
  40. data/lib/rubocop/cop/chef/style/unnecessary_os_check.rb +1 -0
  41. data/lib/rubocop/cop/chef/style/use_platform_helpers.rb +1 -0
  42. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 47388999a2aa49c2d130f1a553e2d17efec6090b4207e39557fc78acb8c4e5a8
4
- data.tar.gz: c622b97ecf8c86b337c7bc63ff444c4b305a6a249cc40c598ea800a1ba9cae67
3
+ metadata.gz: f26b00de7e92bb6cd6e16e2c323c66504b95a098512d78929dda659128c0f828
4
+ data.tar.gz: ae852bc01e5b7d9e2bab25ef88778650c46a0c0fb463286bc68dc8400892c215
5
5
  SHA512:
6
- metadata.gz: 4b1f192f83d65beb1360ff7df9648176bbc54398b39eb7e8791f0342f5152e5361bae374514fcb60134cb6348101c78047ab53d57efcfad3cccfa60e03de2234
7
- data.tar.gz: db704725caa2dbfa226e6693bee8ced4adeaaf45d531c5665ff3c602cb7d9b3392676917d814f44b5bb4e7fb015c3c52ce94e812b6ef017fd117210d0ff35252
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,5 @@
1
1
  # frozen_string_literal: true
2
2
  module Cookstyle
3
- VERSION = "6.19.5" # rubocop: disable Style/StringLiterals
3
+ VERSION = "6.19.11" # rubocop: disable Style/StringLiterals
4
4
  RUBOCOP_VERSION = '0.92.0'
5
5
  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
@@ -37,6 +37,7 @@ module RuboCop
37
37
  extend AutoCorrector
38
38
 
39
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
40
41
 
41
42
  def_node_search :correct_injection?, <<-PATTERN
42
43
  {(send
@@ -35,6 +35,7 @@ module RuboCop
35
35
  include ::RuboCop::Chef::PlatformHelpers
36
36
 
37
37
  MSG = 'Use valid platform values in case statements.'
38
+ RESTRICT_ON_SEND = [:[]].freeze
38
39
 
39
40
  def_node_matcher :node_platform?, <<-PATTERN
40
41
  (send (send nil? :node) :[] (str "platform") )
@@ -32,6 +32,7 @@ module RuboCop
32
32
  #
33
33
  class InvalidVersionMetadata < Base
34
34
  MSG = 'Cookbook metadata.rb version field should follow X.Y.Z version format.'
35
+ RESTRICT_ON_SEND = [:version].freeze
35
36
 
36
37
  def_node_matcher :version?, '(send nil? :version $str ...)'
37
38
 
@@ -39,6 +39,7 @@ module RuboCop
39
39
  #
40
40
  class NodeNormal < Base
41
41
  MSG = 'Do not use node.normal. Replace with default/override/force_default/force_override attribute levels.'
42
+ RESTRICT_ON_SEND = [:normal].freeze
42
43
 
43
44
  def_node_matcher :node_normal?, <<-PATTERN
44
45
  (send (send _ :node) :normal)
@@ -39,6 +39,7 @@ module RuboCop
39
39
  #
40
40
  class NodeNormalUnless < Base
41
41
  MSG = 'Do not use node.normal_unless. Replace with default/override/force_default/force_override attribute levels.'
42
+ RESTRICT_ON_SEND = [:normal_unless].freeze
42
43
 
43
44
  def_node_matcher :node_normal_unless?, <<-PATTERN
44
45
  (send (send _ :node) :normal_unless)
@@ -30,6 +30,7 @@ module RuboCop
30
30
  #
31
31
  class CookbookUsesNodeSave < Base
32
32
  MSG = "Don't use node.save to save partial node data to the Chef Infra Server mid-run unless it's absolutely necessary. Node.save can result in failed Chef Infra runs appearing in search and increases load on the Chef Infra Server."
33
+ RESTRICT_ON_SEND = [:save].freeze
33
34
 
34
35
  def_node_matcher :node_save?, <<-PATTERN
35
36
  (send (send nil? :node) :save)
@@ -41,7 +41,7 @@ module RuboCop
41
41
  extend AutoCorrector
42
42
 
43
43
  MSG = "Don't use deprecated Chef::ShellOut which was removed in Chef Infra Client 13. Use Mixlib::ShellOut instead, which behaves identically."
44
- # RESTRICT_ON_SEND = [:new, :require, :include].freeze
44
+ RESTRICT_ON_SEND = [:new, :require, :include].freeze
45
45
 
46
46
  def_node_matcher :include_shellout?, <<-PATTERN
47
47
  (send nil? :include
@@ -33,6 +33,7 @@ module RuboCop
33
33
  class ChefWindowsPlatformHelper < Base
34
34
  extend AutoCorrector
35
35
  MSG = "Use `platform?('windows')` instead of the legacy `Chef::Platform.windows?` helper."
36
+ RESTRICT_ON_SEND = [:windows?].freeze
36
37
 
37
38
  def_node_matcher :chef_platform_windows?, <<-PATTERN
38
39
  (send
@@ -32,8 +32,6 @@ module RuboCop
32
32
 
33
33
  MSG = "Use currently supported platforms in ChefSpec listed at https://github.com/chefspec/fauxhai/blob/master/PLATFORMS.md. Fauxhai / ChefSpec will perform fuzzy matching on platform version so it's always best to be less specific ie. 10 instead of 10.3"
34
34
 
35
- Gem::Dependency.new('', ['~> 1.4.5', '>= 1.4.6']).match?('', '1.4.6')
36
-
37
35
  DEPRECATED_MAPPING = {
38
36
  'amazon' => {
39
37
  '2017.12' => '2',
@@ -44,6 +44,7 @@ module RuboCop
44
44
 
45
45
  class DeprecatedPlatformMethods < Base
46
46
  MSG = 'Use provider_for_action or provides instead of the deprecated Chef::Platform methods in resources, which were removed in Chef Infra Client 13.'
47
+ RESTRICT_ON_SEND = [:provider_for_resource, :find_provider, :find_provider_for_node, :set].freeze
47
48
 
48
49
  def_node_matcher :platform_method?, <<-PATTERN
49
50
  (send (const (const nil? :Chef) :Platform) {:provider_for_resource :find_provider :find_provider_for_node :set} ... )
@@ -78,7 +78,7 @@ module RuboCop
78
78
  else
79
79
  "\"#{type.source}[\#{#{name.source}}]\""
80
80
  end
81
- new_val = "#{notify_type} #{action.source}, #{service_value}".dup
81
+ new_val = +"#{notify_type} #{action.source}, #{service_value}"
82
82
  new_val << ", #{timing.first.source}" unless timing.empty?
83
83
  corrector.replace(node, new_val)
84
84
  end
@@ -37,6 +37,8 @@ module RuboCop
37
37
  class NodeDeepFetch < Base
38
38
  extend RuboCop::Cop::AutoCorrector
39
39
 
40
+ RESTRICT_ON_SEND = [:deep_fetch, :deep_fetch!].freeze
41
+
40
42
  def_node_matcher :node_deep_fetch?, <<-PATTERN
41
43
  (send (send _ :node) ${:deep_fetch :deep_fetch!} _)
42
44
  PATTERN
@@ -41,9 +41,29 @@ module RuboCop
41
41
  extend AutoCorrector
42
42
 
43
43
  MSG = 'Use node attributes to access Ohai data instead of node methods, which were deprecated in Chef Infra Client 13.'
44
+ RESTRICT_ON_SEND = %i(
45
+ current_user
46
+ domain
47
+ fqdn
48
+ hostname
49
+ ip6address
50
+ ipaddress
51
+ macaddress
52
+ machinename
53
+ ohai_time
54
+ os
55
+ os_version
56
+ platform
57
+ platform_build
58
+ platform_family
59
+ platform_version
60
+ root_group
61
+ shard_seed
62
+ uptime
63
+ uptime_seconds).freeze
44
64
 
45
65
  def_node_matcher :node_ohai_methods?, <<-PATTERN
46
- (send (send nil? :node) #non_nested_ohai_attribute?)
66
+ (send (send nil? :node) _)
47
67
  PATTERN
48
68
 
49
69
  def on_send(node)
@@ -53,31 +73,6 @@ module RuboCop
53
73
  end
54
74
  end
55
75
  end
56
-
57
- private
58
-
59
- def non_nested_ohai_attribute?(attribute)
60
- %i(
61
- current_user
62
- domain
63
- fqdn
64
- hostname
65
- ip6address
66
- ipaddress
67
- macaddress
68
- machinename
69
- ohai_time
70
- os
71
- os_version
72
- platform
73
- platform_build
74
- platform_family
75
- platform_version
76
- root_group
77
- shard_seed
78
- uptime
79
- uptime_seconds).include?(attribute)
80
- end
81
76
  end
82
77
  end
83
78
  end
@@ -34,6 +34,7 @@ module RuboCop
34
34
  extend AutoCorrector
35
35
 
36
36
  MSG = 'Do not use node.set. Replace with node.normal to keep identical behavior.'
37
+ RESTRICT_ON_SEND = [:set].freeze
37
38
 
38
39
  def_node_matcher :node_set?, <<-PATTERN
39
40
  (send (send _ :node) $:set)
@@ -34,6 +34,7 @@ module RuboCop
34
34
  extend AutoCorrector
35
35
 
36
36
  MSG = 'Do not use node.set_unless. Replace with node.normal_unless to keep identical behavior.'
37
+ RESTRICT_ON_SEND = [:set_unless].freeze
37
38
 
38
39
  def_node_matcher :node_set_unless?, <<-PATTERN
39
40
  (send (send _ :node) $:set_unless)
@@ -36,6 +36,7 @@ module RuboCop
36
36
  #
37
37
  class NodeSetWithoutLevel < Base
38
38
  MSG = 'When setting a node attribute in Chef Infra Client 11 and later you must specify the precedence level.'
39
+ RESTRICT_ON_SEND = [:[]=, :<<].freeze
39
40
 
40
41
  def on_op_asgn(node)
41
42
  # make sure it was a += or -=
@@ -49,6 +49,7 @@ module RuboCop
49
49
  #
50
50
  class PartialSearchClassUsage < Base
51
51
  MSG = 'Legacy Chef::PartialSearch class usage should be updated to use the search helper instead with the filter_result key.'
52
+ RESTRICT_ON_SEND = [:new].freeze
52
53
 
53
54
  def_node_matcher :partial_search_class?, <<-PATTERN
54
55
  (send (const (const ... :Chef) :PartialSearch) :new)
@@ -36,6 +36,7 @@ module RuboCop
36
36
  extend AutoCorrector
37
37
 
38
38
  MSG = "Use node['powershell']['version'] or the new powershell_version helper available in Chef Infra Client 15.8+ instead of the deprecated PowerShell cookbook helpers."
39
+ RESTRICT_ON_SEND = [:powershell_version?].freeze
39
40
 
40
41
  def_node_matcher :ps_cb_helper?, <<-PATTERN
41
42
  (send
@@ -34,12 +34,12 @@ module RuboCop
34
34
  class ResourceOverridesProvidesMethod < Base
35
35
  MSG = "Don't override the provides? method in a resource provider. Use provides :SOME_PROVIDER_NAME instead. This will cause failures in Chef Infra Client 13 and later."
36
36
 
37
- def_node_search :provides, '(send nil? :provides ...)'
37
+ def_node_search :calls_provides?, '(send nil? :provides ...)'
38
38
 
39
39
  def on_def(node)
40
40
  return unless node.method_name == :provides?
41
41
 
42
- add_offense(node, message: MSG, severity: :warning) if provides(processed_source.ast).count == 0
42
+ add_offense(node, message: MSG, severity: :warning) unless calls_provides?(processed_source.ast)
43
43
  end
44
44
  end
45
45
  end
@@ -42,6 +42,7 @@ module RuboCop
42
42
  minimum_target_chef_version '14.0'
43
43
 
44
44
  MSG = "Use node['platform_version'] and node['kernel'] data introduced in Chef Infra Client 14 instead of the deprecated Windows::VersionHelper helpers from the Windows cookbook."
45
+ RESTRICT_ON_SEND = [:nt_version, :server_version?, :core_version?, :workstation_version?].freeze
45
46
 
46
47
  def_node_matcher :windows_helper?, <<-PATTERN
47
48
  (send ( const ( const {nil? cbase} :Windows ) :VersionHelper ) $_ )
@@ -35,6 +35,7 @@ module RuboCop
35
35
  #
36
36
  class ResourceForcingCompileTime < Base
37
37
  MSG = "Set 'compile_time true' in resources when available instead of forcing resources to run at compile time by setting an action on the block."
38
+ RESTRICT_ON_SEND = [:run_action].freeze
38
39
 
39
40
  def_node_matcher :compile_time_resource?, <<-PATTERN
40
41
  (send (block (send nil? {:build_essential :chef_gem :hostname :ohai_hint} (...)) (args) (...)) $:run_action (sym ...))
@@ -36,7 +36,7 @@ module RuboCop
36
36
  RESTRICT_ON_SEND = [:not_if, :only_if].freeze
37
37
 
38
38
  def_node_matcher :resource_conditional?, <<~PATTERN
39
- (send nil? {:not_if :only_if} $str )
39
+ (send nil? {:not_if :only_if} $str )
40
40
  PATTERN
41
41
 
42
42
  def on_send(node)
@@ -35,6 +35,7 @@ module RuboCop
35
35
  extend AutoCorrector
36
36
 
37
37
  MSG = 'Use the `data_bag_item` helper instead of `Chef::DataBagItem.load` or `Chef::EncryptedDataBagItem.load`.'
38
+ RESTRICT_ON_SEND = [:load].freeze
38
39
 
39
40
  def_node_matcher :data_bag_class_load?, <<-PATTERN
40
41
  (send
@@ -43,6 +43,7 @@ module RuboCop
43
43
  extend RuboCop::Cop::AutoCorrector
44
44
 
45
45
  MSG = "Use node['init_package'] to check for systemd instead of reading the contents of '/proc/1/comm'"
46
+ RESTRICT_ON_SEND = [:open, :read, :exist?, :==, :not_if, :only_if].freeze
46
47
 
47
48
  def_node_matcher :file_reads_proc_1_comm?, <<-PATTERN
48
49
  (send (const {(cbase) nil?} {:File :IO}) {:open :read} (str "/proc/1/comm"))
@@ -62,7 +63,7 @@ module RuboCop
62
63
  PATTERN
63
64
 
64
65
  def_node_matcher :file_systemd_conditional?, <<~PATTERN
65
- (send nil? {:not_if :only_if} $(str "test -f /bin/systemctl && /bin/systemctl"))
66
+ (send nil? {:not_if :only_if} $(str "test -f /bin/systemctl && /bin/systemctl"))
66
67
  PATTERN
67
68
 
68
69
  def on_send(node)
@@ -33,6 +33,7 @@ module RuboCop
33
33
  extend AutoCorrector
34
34
 
35
35
  MSG = "Use `node.role?('foo')` to check if a node includes a role instead of `node['roles'].include?('foo')`."
36
+ RESTRICT_ON_SEND = [:include?].freeze
36
37
 
37
38
  def_node_matcher :node_role_include?, <<-PATTERN
38
39
  (send
@@ -69,7 +69,7 @@ module RuboCop
69
69
  end
70
70
 
71
71
  def_node_matcher :if_respond_to?, <<~PATTERN
72
- (if (send nil? :respond_to? _ ) ... )
72
+ (if (send nil? :respond_to? _ ) ... )
73
73
  PATTERN
74
74
  end
75
75
  end
@@ -45,16 +45,16 @@ module RuboCop
45
45
  end
46
46
 
47
47
  def_node_matcher :if_respond_to_provides?, <<~PATTERN
48
- (if
49
- {
50
- (send nil? :respond_to?
51
- (sym :provides))
48
+ (if
49
+ {
50
+ (send nil? :respond_to?
51
+ (sym :provides))
52
52
 
53
- (:defined?
54
- (send nil? :provides))
55
- }
56
- (send nil? :provides
57
- (sym _)) ... )
53
+ (:defined?
54
+ (send nil? :provides))
55
+ }
56
+ (send nil? :provides
57
+ (sym _)) ... )
58
58
  PATTERN
59
59
  end
60
60
  end
@@ -43,7 +43,7 @@ module RuboCop
43
43
  end
44
44
 
45
45
  def_node_matcher :if_respond_to_resource_name?, <<~PATTERN
46
- (if (send nil? :respond_to? ( :sym :resource_name ) ) ... )
46
+ (if (send nil? :respond_to? ( :sym :resource_name ) ) ... )
47
47
  PATTERN
48
48
  end
49
49
  end
@@ -37,6 +37,7 @@ module RuboCop
37
37
  minimum_target_chef_version '12.11'
38
38
 
39
39
  MSG = "Use the built-in `shell_out` helper available in Chef Infra Client 12.11+ instead of calling `Mixlib::ShellOut.new('foo').run_command`."
40
+ RESTRICT_ON_SEND = [:run_command].freeze
40
41
 
41
42
  def_node_matcher :mixlib_shellout_run_cmd?, <<-PATTERN
42
43
  (send
@@ -37,6 +37,7 @@ module RuboCop
37
37
  extend RuboCop::Cop::AutoCorrector
38
38
 
39
39
  MSG = "If a resource includes the `compile_time` property there's no need to also use `.run_action(:some_action)` on the resource block."
40
+ RESTRICT_ON_SEND = [:run_action].freeze
40
41
 
41
42
  def_node_matcher :compile_time_and_run_action?, <<-PATTERN
42
43
  (send
@@ -61,6 +61,7 @@ module RuboCop
61
61
  #
62
62
  class NamePropertyIsRequired < Base
63
63
  MSG = 'Resource properties marked as name properties should not also be required properties'
64
+ RESTRICT_ON_SEND = [:property, :attribute].freeze
64
65
 
65
66
  # match on a property or attribute that has any name and any type and a hash that
66
67
  # contains name_property: true and required: true. These are wrapped in <> which means
@@ -46,6 +46,7 @@ module RuboCop
46
46
  extend AutoCorrector
47
47
 
48
48
  MSG = "This Ohai node attribute is already a string and doesn't need to be converted"
49
+ RESTRICT_ON_SEND = [:to_s].freeze
49
50
 
50
51
  def_node_matcher :attribute_to_s?, <<-PATTERN
51
52
  (send (send (send nil? :node) :[] $(str {"platform" "platform_family" "platform_version" "fqdn" "hostname" "os" "name"}) ) :to_s )
@@ -36,6 +36,7 @@ module RuboCop
36
36
  extend AutoCorrector
37
37
 
38
38
  MSG = 'There is no need to validate the input of properties in resources using a regex value that will always pass.'
39
+ RESTRICT_ON_SEND = [:property, :attribute].freeze
39
40
 
40
41
  def_node_matcher :property_with_regex_splat?, <<-PATTERN
41
42
  (send nil? {:property :attribute} (sym _) ... (hash <$(pair (sym :regex) (regexp (str ".*") (regopt))) ...>))
@@ -45,6 +45,7 @@ module RuboCop
45
45
  include RuboCop::Cop::ConfigurableEnforcedStyle
46
46
 
47
47
  MSG = 'Use %s to access node attributes'
48
+ RESTRICT_ON_SEND = [:[]].freeze
48
49
 
49
50
  def_node_matcher :node_attribute_access?, <<-PATTERN
50
51
  (send (send _ :node) :[] _)
@@ -38,6 +38,7 @@ module RuboCop
38
38
  extend AutoCorrector
39
39
 
40
40
  MSG = "Use node['platform_version'].to_i instead of node['platform_version'].split('.').first or node['platform_version'].split('.')[0]"
41
+ RESTRICT_ON_SEND = [:split].freeze
41
42
 
42
43
  def_node_matcher :platform_version_check?, <<-PATTERN
43
44
  (send (send (send nil? :node) :[] (str "platform_version") ) :split (str ".") )
@@ -39,6 +39,7 @@ module RuboCop
39
39
  extend AutoCorrector
40
40
 
41
41
  MSG = "Use the platform_family?() helpers instead of node['os] == 'foo' for platform_families that match 1:1 with OS values."
42
+ RESTRICT_ON_SEND = [:==, :!=, :eql?, :include?].freeze
42
43
 
43
44
  # sorted list of all the os values that match 1:1 with a platform_family
44
45
  UNNECESSARY_OS_VALUES = %w(aix darwin dragonflybsd freebsd netbsd openbsd solaris2 windows).freeze
@@ -42,6 +42,7 @@ module RuboCop
42
42
  extend AutoCorrector
43
43
 
44
44
  MSG = "Use platform? and platform_family? helpers to check a node's platform"
45
+ RESTRICT_ON_SEND = [:==, :!=, :eql?, :include?].freeze
45
46
 
46
47
  def_node_matcher :platform_equals?, <<-PATTERN
47
48
  (send (send (send nil? :node) :[] $(str {"platform" "platform_family"}) ) ${:== :!=} $str )
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: 6.19.5
4
+ version: 6.19.11
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: 2020-09-28 00:00:00.000000000 Z
12
+ date: 2020-10-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rubocop