class RuboCop::Cop::Sorbet::ForbidIncludeConstLiteral

“‘
include Polaris::Engine.helpers
“`ruby
or
“`
include Rails.application.routes.url_helpers
“`ruby
Multiple occurences of this can be found in Shopify’s code base like:
“‘
end
include send_expr
class MyClass
“`ruby
following form:
Sorbet, the static checker, is not (yet) able to support constructs on the
Correct `send` expressions in include statements by constant literals.

def neither_const_nor_self?(node)

def neither_const_nor_self?(node)
  !node.const_type? && !node.self_type?
end

def on_send(node)

def on_send(node)
  dynamic_inclusion?(node) do |inclusion_method, included|
    return unless within_onymous_module?(node)
    add_offense(node, message: format(MSG, inclusion_method: inclusion_method)) do |corrector|
      corrector.replace(node, "T.unsafe(self).#{inclusion_method} #{included.source}")
    end
  end
end

def within_onymous_module?(node)

Returns true if the node is within a module declaration that is not anonymous.
def within_onymous_module?(node)
  parent = node.parent
  parent = parent.parent while parent&.begin_type? || parent&.block_type?
  parent && (parent.module_type? || parent.class_type? || parent.sclass_type?)
end