Skip to main content

codelens_engine/call_graph/
noise.rs

1/// Resolve call graph config via the unified language registry.
2/// Only a subset of languages have call graph queries defined.
3/// Filter out common std/builtin method calls that add noise to the call graph.
4/// Covers Rust std, Python builtins, JS/TS builtins, Go builtins, and Java/Kotlin stdlib.
5pub fn is_noise_callee(name: &str) -> bool {
6    matches!(
7        name,
8        // ── cross-language common ──
9        "get" | "set" | "push" | "pop" | "len" | "from" | "into"
10            | "map" | "filter" | "collect" | "contains" | "insert" | "remove"
11            | "format" | "print" | "clone" | "default" | "next" | "read"
12            | "write" | "open" | "close" | "keys" | "values" | "sort"
13            | "reverse" | "find" | "replace" | "delete" | "add" | "clear"
14            | "of" | "size" | "copy"
15            // ── Rust std ──
16            | "is_empty" | "to_string" | "to_owned" | "as_str" | "as_ref"
17            | "unwrap" | "expect" | "ok" | "err" | "and_then" | "or_else"
18            | "unwrap_or" | "unwrap_or_else" | "unwrap_or_default"
19            | "iter" | "into_iter" | "take" | "skip"
20            | "println" | "eprintln" | "drop" | "enter" | "lock" | "cloned"
21            // ── Python builtins ──
22            | "range" | "enumerate" | "zip" | "sorted" | "reversed"
23            | "isinstance" | "issubclass" | "hasattr" | "getattr" | "setattr" | "delattr"
24            | "type" | "super" | "str" | "int" | "float" | "bool"
25            | "list" | "dict" | "tuple" | "frozenset" | "bytes" | "bytearray"
26            | "repr" | "abs" | "min" | "max" | "sum" | "any" | "all"
27            | "ord" | "chr" | "hex" | "oct" | "bin" | "hash" | "id"
28            | "input" | "vars" | "dir" | "help" | "round"
29            | "append" | "extend" | "update" | "items" | "join" | "split"
30            | "strip" | "startswith" | "endswith" | "encode" | "decode"
31            | "upper" | "lower"
32            // ── JS/TS builtins ──
33            | "log" | "warn" | "error" | "info" | "debug"
34            | "toString" | "valueOf" | "JSON" | "parse" | "stringify" | "assign"
35            | "entries" | "forEach" | "reduce" | "findIndex" | "some" | "every"
36            | "includes" | "indexOf" | "slice" | "splice" | "concat"
37            | "flat" | "flatMap" | "fill" | "isArray"
38            | "Promise" | "resolve" | "reject" | "then" | "catch" | "finally"
39            | "setTimeout" | "setInterval" | "clearTimeout" | "clearInterval"
40            | "parseInt" | "parseFloat" | "isNaN" | "isFinite" | "require"
41            // ── Go builtins ──
42            | "make" | "cap" | "panic" | "recover" | "real" | "imag" | "complex"
43            | "Println" | "Printf" | "Sprintf" | "Fprintf" | "Errorf" | "New"
44            // ── Java/Kotlin stdlib ──
45            | "equals" | "hashCode" | "compareTo" | "getClass"
46            | "notify" | "notifyAll" | "wait" | "isEmpty"
47            | "addAll" | "containsKey" | "containsValue" | "put" | "putAll"
48            | "entrySet" | "keySet" | "charAt" | "substring" | "trim"
49            | "length" | "toArray" | "stream" | "asList"
50    )
51}
52
53/// Language-aware noise filter. Rust `new` is a constructor, not noise.
54pub(crate) fn is_noise_callee_for_lang(name: &str, lang: Option<&str>) -> bool {
55    if lang == Some("rs") && name == "new" {
56        return false;
57    }
58    is_noise_callee(name)
59}