Skip to content

(call)

method calls

clojure
(call receiver? args?)

Where:

  1. receiver: method name being called (the foo in foo()) *
  2. args: arguments supplied to the call *

Matching:

  1. regular calls, e.g. foo()
  2. calls with receivers, e.g. obj.foo()
  3. calls without parentheses, e.g. foo x

Behavior

  • Receiver matching only supports identifier method names (operator methods like + are not supported).

Examples

Find shell-outs that pass string commands.

clojure
(call (id system) (arg 1 (str)))

Selects in lines { 1, 3 } but not in { 2 }:

ruby
system("ls -la")
system(cmd)
Kernel.system("whoami")

Locate puts calls that print debug strings.

clojure
(call (id puts) (arg 1 (str /^DEBUG:/)))

Selects in lines { 1 } but not in { 2, 3 }:

ruby
puts "DEBUG: start"
puts "INFO: start"
logger.info("DEBUG: start")

Find gsub calls that replace spaces with underscores.

clojure
(call (id gsub) (:and (arg 1 (str " ")) (arg 2 (str "_"))))

Selects in lines { 1 } but not in { 2, 3 }:

ruby
title.gsub(" ", "_")
title.gsub("-", "_")
name.sub(" ", "_")

Arguments

receiver

• Identifier: shorthand for (id)
• Pattern: shorthand for (id)
(:kind) (:ref) (:text) (call) (id) (num) (proc) (str) (:into) (:and) (:or) (:not) (:replace) (:capture)

args

(arg)
(:into) (:and) (:or) (:not) (:text) (:kind) (:replace) (:capture)

Copyright © 2022-present Semantic Works, Inc.