CodeQL library for Ruby
codeql/ruby-all 4.1.2-dev (changelog, source)
Search

Predicate singletonMethodOnInstance

Holds if method is a singleton method named name, defined on expression object, where object is not likely to resolve to a module:

class C
  def self.m1; end # not included

  class << self
    def m2; end # not included
  end
end

def C.m3; end # not included

c_alias = C
def c_alias.m4; end # included (due to negative recursion limitation)

c = C.new
def c.m5; end # included

class << c
  def m6; end # included
end

module M
  def instance; end # included in `c` via `extend` call below
end
c.extend(M)

Import path

import codeql.ruby.dataflow.internal.DataFlowDispatch
predicate singletonMethodOnInstance(MethodBase method, string name, Expr object)