Skip to content

args counts call-site arguments in apex (+38%): the return type is optional, so the method arm degenerates to ^IDENT(...) #2783

Closed

Description

@squid-protocol

Found by the 46-language audit in docs/args_rule_contract.md, written for #2773. Same defect
#2773 fixed in typescript and #2782 reports for groovy, in the same rule, on the same corpus
pass (2026-09-05).

The contract

args matches the parameters a callable declares. A call site consumes a parameter
surface; it does not publish one.

Measured

keyword-rosetta/data/apex, args against func_start, over the code stream:

file func_start args the extra hits
a.cls 3 5 isAccessible(value), StripInaccessible(value)
main.cls 4 7 probeBranch(argv), probeIo(argv), probeRisk(argv)
total 13 18 (+38%) 5 call sites

language-crucible/data/apex: 41 args against 41 func_start.

Every extra hit is a call, and isAccessible/StripInaccessible are probes the SPEC planted for
safety (Apex's Security.stripInaccessible CRUD/FLS surface), not for args.

The cause

"args": re.compile(
    r"^[ \t]*(?:@[\w.]+\b(?:\s*\(…\))?\s*){0,5}"
    r"(?:(?:public|private|global|protected|static|override|virtual|abstract|testMethod)\s+){0,5}"
    r"(?:(?!new\b)[a-zA-Z_][\w.]*(?:\s*<…>)?(?:\s*\[\s*\])*\s+)?"        # <-- the return type is OPTIONAL
    r"(?!(?:class|interface|enum|if|for|while|switch|catch)\b)([a-zA-Z_]\w*)\s*(\([^)]*\))|…"

The return-type group carries a trailing ?, and the annotation and modifier runs can both match
zero times, so the alternative degenerates to ^[ \t]*IDENT(...) -- equally the shape of a bare
call statement.

Unlike groovy (#2782), Apex has no def: every Apex method declaration carries an explicit
return type (void included), and a constructor carries the class name in that position. So the
? can simply come off, which is exactly what java and csharp -- the same C-family rule, same
shape -- already do (java: "Branch 1: Standard Methods MUST have a return type").

Corpus pairing

args is planted at 13 (one parameter per probe, SPEC.md). keyword-rosetta/data/apex needs no
authoring change -- the fix should land it on 13 exactly, the mechanical check that the anchor is
right and not merely narrower.

Part of #2669 (rosetta[apex] tracking issue).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcore-enginemetrics

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions