Class: RuboCop::Cop::InSpecStyle::ShadowProperties

Inherits:
RuboCop::Cop
  • Object
show all
Defined in:
lib/rubocop/cop/inspecstyle/shadow_properties.rb

Overview

Shadow resource property user is deprecated in favor of ‘users`

Examples:

EnforcedStyle: InSpecStyle (default)

# Use users instead

# bad
describe shadow('/etc/my-custom-place/shadow') do
  its('user') { should eq 'user' }
end

# good
describe shadow('/etc/my-custom-place/shadow') do
  its('users') { should eq 'user' }
end

Constant Summary collapse

MSG =

TODO: Implement the cop in here.

In many cases, you can use a node matcher for matching node pattern. See github.com/rubocop-hq/rubocop-ast/blob/master/lib/rubocop/node_pattern.rb

For example

'Use `:%<modifier>ss` instead of `:%<modifier>s` as a property ' \
'for the `shadow` resource. This property will be removed in InSpec 5'

Instance Method Summary collapse

Instance Method Details

#on_block(node) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/rubocop/cop/inspecstyle/shadow_properties.rb', line 45

def on_block(node)
  return unless shadow_resource_user_property?(node) do |modifier|
    message = format(MSG, modifier: modifier)
    range = locate_range(modifier, node)
    add_offense(node, message: message, location: range)
  end
end