Sha256: d1f73568b4c941963467b108f8d584380b282b67fc4adebce5dceb3f737c3874

Contents?: true

Size: 665 Bytes

Versions: 2

Compression:

Stored size: 665 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Rake
      module Helper
        module TaskName
          extend self

          def task_name(node)
            first_arg = node.arguments[0]
            case first_arg&.type
            when :sym, :str
              return 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
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubocop-rake-0.5.0 lib/rubocop/cop/rake/helper/task_name.rb
rubocop-rake-0.4.0 lib/rubocop/cop/rake/helper/task_name.rb