Sha256: 768940b7169cc5239904b5856e5b631bd6024568d2e93a055fbf5d34efceb336

Contents?: true

Size: 688 Bytes

Versions: 6

Compression:

Stored size: 688 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Sorbet
      # Mixing for writing cops that deal with `T::Enum`s
      module TEnum
        extend RuboCop::NodePattern::Macros
        def initialize(*)
          @scopes = []
          super
        end

        # @!method t_enum?(node)
        def_node_matcher :t_enum?, <<~PATTERN
          (class (const...) (const (const nil? :T) :Enum) ...)
        PATTERN

        def on_class(node)
          @scopes.push(node)
        end

        def after_class(node)
          @scopes.pop
        end

        private

        def in_t_enum_class?
          t_enum?(@scopes&.last)
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rubocop-sorbet-0.8.7 lib/rubocop/cop/sorbet/mixin/t_enum.rb
rubocop-sorbet-0.8.6 lib/rubocop/cop/sorbet/mixin/t_enum.rb
rubocop-sorbet-0.8.5 lib/rubocop/cop/sorbet/mixin/t_enum.rb
rubocop-sorbet-0.8.4 lib/rubocop/cop/sorbet/mixin/t_enum.rb
rubocop-sorbet-0.8.3 lib/rubocop/cop/sorbet/mixin/t_enum.rb
rubocop-sorbet-0.8.2 lib/rubocop/cop/sorbet/mixin/t_enum.rb