cookstyle 6.2.5 → 6.2.9

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3d1707e36ea2cbbcb24bf4fa6c8e4f79fed7ea64fdce34b7776c1888f6ee0871
4
- data.tar.gz: faa3b6376f8d0022291709084b240ab98ec86f18106a6bb3f2271c5291064635
3
+ metadata.gz: 0e4a34f5dc3234aeb3febf3019211d19e70b32538dfe55a13150ba45086767b2
4
+ data.tar.gz: 6825981876e3882b87e5699c0e9127cf0c0512201771086bc1ad5948cfb9b71f
5
5
  SHA512:
6
- metadata.gz: 886ec87ae9bc65b2ddcbc061fda82c55755fe48ca5131574a3291ecf518a273b051a4977642feb8802051aa3e1def3c85e79fc6df4af8756e9e16fa5eccaa51d
7
- data.tar.gz: 1089873dec1ec43f88eb2b8e9d0a4a059a80a26757b1f6a97b92619aad25f7a3761bdd7e01dd5a389534778ad4c9a03140e83d3828c2643e5c4ff13869f0edc9
6
+ metadata.gz: 31bb85b95815744e511f172d62e83c21624c2192d15cd8e766b4b5a960165f5367bcbd289cb0df8db25d842f826889f1e1b9b6f5dfedc1f2fe2bd82dbd428e95
7
+ data.tar.gz: 4d5ea06716a8559835225d596594deb81e40a61ab38141b0f9ea3e65bfec8460fd53b45a64eea036de136cf56fcec1ade258160d8d74e7f48fc1f1137e9f19e7
@@ -1,4 +1,4 @@
1
1
  module Cookstyle
2
- VERSION = "6.2.5".freeze # rubocop: disable Style/StringLiterals
2
+ VERSION = "6.2.9".freeze # rubocop: disable Style/StringLiterals
3
3
  RUBOCOP_VERSION = '0.81.0'.freeze
4
4
  end
@@ -19,7 +19,7 @@ module RuboCop
19
19
  module Cop
20
20
  module Chef
21
21
  module ChefDeprecations
22
- # In Chef Infra Client 16 the log resource no longer notifies when logging so notifications should not be triggered from log resources. See the notify_group functionality for a potential replacement.
22
+ # In Chef Infra Client 16 the log resource no longer notifies when logging so notifications should not be triggered from log resources. Use the notify_group resource introduced in Chef Infra Client 15.8 instead to aggregate notifications.
23
23
  #
24
24
  # @example
25
25
  #
@@ -45,8 +45,11 @@ module RuboCop
45
45
  #
46
46
  class LogResourceNotifications < Cop
47
47
  include RuboCop::Chef::CookbookHelpers
48
+ extend TargetChefVersion
48
49
 
49
- MSG = 'In Chef Infra Client 16 the log resource no longer notifies when logging so notifications should not be triggered from log resources. Use the notify_group resource instead to aggregate notifications.'.freeze
50
+ minimum_target_chef_version '15.8'
51
+
52
+ MSG = 'In Chef Infra Client 16 the log resource no longer notifies when logging so notifications should not be triggered from log resources. Use the notify_group resource introduced in Chef Infra Client 15.8 instead to aggregate notifications.'.freeze
50
53
 
51
54
  def on_block(node)
52
55
  match_property_in_resource?(:log, 'notifies', node) do |prop_node|
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: 2019, Chef Software Inc.
2
+ # Copyright:: 2019-2020, Chef Software Inc.
3
3
  # Author:: Tim Smith (<tsmith@chef.io>)
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -35,8 +35,15 @@ module RuboCop
35
35
 
36
36
  MSG = 'whyrun_supported? no longer needs to be set to true as it is the default in Chef Infra Client 13+'.freeze
37
37
 
38
+ # match on both whyrun_supported? and the typo form why_run_supported?
39
+ def_node_matcher :whyrun_true?, <<-PATTERN
40
+ (def {:whyrun_supported? :why_run_supported?}
41
+ (args)
42
+ (true))
43
+ PATTERN
44
+
38
45
  def on_def(node)
39
- if node.method_name == :whyrun_supported? && node.body == s(:true) # rubocop: disable Lint/BooleanSymbol
46
+ whyrun_true?(node) do
40
47
  add_offense(node, location: :expression, message: MSG, severity: :refactor)
41
48
  end
42
49
  end
@@ -26,7 +26,6 @@ module RuboCop
26
26
  # # bad
27
27
  # grouping 'windows_log_rotate', title: 'Demonstration cookbook with code to switch loggers'
28
28
  #
29
- #
30
29
  class GroupingMetadata < Cop
31
30
  include RangeHelp
32
31
  include RuboCop::Chef::AutocorrectHelpers
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright 2019, Chef Software Inc.
2
+ # Copyright:: Copyright 2019-2020, Chef Software Inc.
3
3
  # Author:: Tim Smith (<tsmith@chef.io>)
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,13 +18,13 @@ module RuboCop
18
18
  module Cop
19
19
  module Chef
20
20
  module ChefRedundantCode
21
- # Every Chef Infra resources already include a sensitive property with a default value of false.
21
+ # Every Chef Infra resource already includes a sensitive property with a default value of false.
22
22
  #
23
23
  # # bad
24
24
  # property :sensitive, [true, false], default: false
25
25
  #
26
26
  class SensitivePropertyInResource < Cop
27
- MSG = 'Every Chef Infra resources already include a sensitive property with a default value of false.'.freeze
27
+ MSG = 'Every Chef Infra resource already includes a sensitive property with a default value of false.'.freeze
28
28
 
29
29
  def_node_matcher :sensitive_property?, <<-PATTERN
30
30
  (send nil? {:property :attribute} (sym :sensitive) ... (hash (pair (sym :default) (false))))
@@ -18,7 +18,7 @@ module RuboCop
18
18
  module Cop
19
19
  module Chef
20
20
  module ChefStyle
21
- # Use not_if instead of only_if that negates the Ruby statement with a !
21
+ # Instead of using only_if conditionals with ! to negate the returned value, use not_if which is easier to read
22
22
  #
23
23
  # @example
24
24
  #
@@ -33,7 +33,7 @@ module RuboCop
33
33
  # end
34
34
  #
35
35
  class NegatingOnlyIf < Cop
36
- MSG = 'Use not_if instead of only_if that negates the Ruby statement with a !'.freeze
36
+ MSG = 'Instead of using only_if conditionals with ! to negate the returned value, use not_if which is easier to read'.freeze
37
37
 
38
38
  def_node_matcher :negated_only_if?, <<-PATTERN
39
39
  (block
@@ -45,8 +45,13 @@ module RuboCop
45
45
 
46
46
  def on_block(node)
47
47
  negated_only_if?(node) do |_only_if, code|
48
+ # skip inspec controls where we don't have not_if
49
+ return if node.parent&.parent&.block_type? &&
50
+ node.parent&.parent&.method_name == :control
51
+
48
52
  # the value was double negated to work around types: ex: !!systemd?
49
- return if code.descendants.first.negation_method?
53
+ return if code.descendants.first.send_type? &&
54
+ code.descendants.first.negation_method?
50
55
 
51
56
  add_offense(node, location: :expression, message: MSG, severity: :refactor)
52
57
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cookstyle
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.2.5
4
+ version: 6.2.9
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-04-03 00:00:00.000000000 Z
12
+ date: 2020-04-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rubocop