Sha256: a72cca406823492f7fd329038149f99202082b41ff572560dc0e1f25e40ff6ce

Contents?: true

Size: 1.32 KB

Versions: 4

Compression:

Stored size: 1.32 KB

Contents

# typed: strict
# frozen_string_literal: true

module Spoom
  module Deadcode
    module Plugins
      class Rubocop < Base
        extend T::Sig

        RUBOCOP_CONSTANTS = T.let(["MSG", "RESTRICT_ON_SEND"].to_set.freeze, T::Set[String])

        ignore_classes_inheriting_from(
          /^(::)?RuboCop::Cop::Cop$/,
          /^(::)?RuboCop::Cop::Base$/,
        )

        sig { override.params(indexer: Indexer, definition: Definition).void }
        def on_define_constant(indexer, definition)
          definition.ignored! if rubocop_constant?(indexer, definition)
        end

        sig { override.params(indexer: Indexer, definition: Definition).void }
        def on_define_method(indexer, definition)
          definition.ignored! if rubocop_method?(indexer, definition)
        end

        private

        sig { params(indexer: Indexer, definition: Definition).returns(T::Boolean) }
        def rubocop_constant?(indexer, definition)
          ignored_subclass?(indexer.nesting_class_superclass_name) && RUBOCOP_CONSTANTS.include?(definition.name)
        end

        sig { params(indexer: Indexer, definition: Definition).returns(T::Boolean) }
        def rubocop_method?(indexer, definition)
          ignored_subclass?(indexer.nesting_class_superclass_name) && definition.name == "on_send"
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
spoom-1.3.2 lib/spoom/deadcode/plugins/rubocop.rb
spoom-1.3.1 lib/spoom/deadcode/plugins/rubocop.rb
spoom-1.3.0 lib/spoom/deadcode/plugins/rubocop.rb
spoom-1.2.4 lib/spoom/deadcode/plugins/rubocop.rb