class Rubocop::Cop::Style::EmptyLiteral

This cop checks for the use of a method, the result of which would be a literal, like an empty array, hash or string.

Constants

ARRAY_NODE

Empty array node

(send

(const nil :Array) :new)
ARR_MSG
HASH_MSG
HASH_NODE

Empty hash node

(send

(const nil :Hash) :new)
STR_MSG
STR_NODE

Empty string node

(send

(const nil :String) :new)

Public Instance Methods

on_send(node) click to toggle source
# File lib/rubocop/cop/style/empty_literal.rb, line 31
def on_send(node)
  case node
  when ARRAY_NODE
    add_offence(:convention,
                node.loc.expression,
                ARR_MSG)
  when HASH_NODE
    add_offence(:convention,
                node.loc.expression,
                HASH_MSG)
  when STR_NODE
    add_offence(:convention,
                node.loc.expression,
                STR_MSG)
  end
end