This cop makes sure that all variables use the configured style, snake_case or camelCase, for their names.
# File lib/rubocop/cop/style/variable_name.rb, line 37 def message(style) format('Use %s for variables.', style) end
# File lib/rubocop/cop/style/variable_name.rb, line 29 def name_of_setter(send_node) receiver, method_name = *send_node return unless receiver && receiver.type == :self return unless method_name.to_s.end_with?('=') after_dot(send_node, method_name.length - '='.length, Regexp.escape(receiver.loc.expression.source)) end
# File lib/rubocop/cop/style/variable_name.rb, line 22 def name_of_variable(vasgn_node) expr = vasgn_node.loc.expression name = vasgn_node.children.first Parser::Source::Range.new(expr.source_buffer, expr.begin_pos, expr.begin_pos + name.length) end
# File lib/rubocop/cop/style/variable_name.rb, line 14 def on_ivasgn(node) check(node, name_of_variable(node)) end
Generated with the Darkfish Rdoc Generator 2.