Sha256: 465f0fc4456d348865ee96217f44e80885b92f838c2af82f11cdaf73288d9a79

Contents?: true

Size: 658 Bytes

Versions: 3

Compression:

Stored size: 658 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
              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

3 entries across 3 versions & 2 rubygems

Version Path
katalyst-govuk-formbuilder-1.9.2 vendor/bundle/ruby/3.3.0/gems/rubocop-rake-0.6.0/lib/rubocop/cop/rake/helper/task_name.rb
rubocop-rake-0.6.0 lib/rubocop/cop/rake/helper/task_name.rb
rubocop-rake-0.5.1 lib/rubocop/cop/rake/helper/task_name.rb