Class: RuboCop::Cop::Naming::InstanceVariableName

Inherits:
Cop
  • Object
show all
Defined in:
lib/rubocop/cop/naming/instance_variable_name.rb

Constant Summary collapse

MSG =
'Instance variable `%<ivar_name>s` is too short.'.freeze
DEFAULT_ACCEPTABLE_MINIMUM_LENGTH =
3.freeze

Instance Method Summary collapse

Instance Method Details

#on_ivasgn(node) ⇒ Object



10
11
12
13
14
# File 'lib/rubocop/cop/naming/instance_variable_name.rb', line 10

def on_ivasgn(node)
  ivar_name, _ = *node
  var_name = ivar_name[/^@(\w+)/, 1]
  add_offense(node, message: format(MSG, ivar_name: ivar_name)) if var_name.length < acceptable_length
end