module RuboCop::Cop::Rake::Helper::TaskName

Public Instance Methods

task_name(node) click to toggle source
# File lib/rubocop/cop/rake/helper/task_name.rb, line 10
def task_name(node)
  first_arg = node.arguments[0]
  case first_arg&.type
  when :sym, :str
    first_arg.value.to_sym
  when :hash
    return nil if first_arg.children.size != 1

    pair = first_arg.children.first
    key = pair.children.first
    case key.type
    when :sym, :str
      key.value.to_sym
    end
  end
end