Class: RuboCop::Cop::InSpecStyle::MSSQLSessionPass

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

Overview

Examples:

EnforcedStyle: InSpecStyle (default)

# Description of the `bar` style.

# bad
sql = mssql_session(user: 'my_user', pass: 'password')

# good
sql = mssql_session(user: 'my_user', password: 'password

Constant Summary collapse

MSG =
'Use `:password` instead of `:pass`. This will be removed in '\
'InSpec 5'

Instance Method Summary collapse

Instance Method Details

#autocorrect(node) ⇒ Object



39
40
41
42
43
# File 'lib/rubocop/cop/inspecstyle/mssql_session_pass.rb', line 39

def autocorrect(node)
  lambda do |corrector|
    corrector.replace(offense_range(node), preferred_replacement)
  end
end

#on_send(node) ⇒ Object

Getting location was a bit tricky on this one, looking at docs perhaps convention does allow highlighting an entire line.



34
35
36
37
# File 'lib/rubocop/cop/inspecstyle/mssql_session_pass.rb', line 34

def on_send(node)
  return unless result = mssql_session_pass?(node)
  add_offense(node, message: MSG)
end