ek9_find_unused_code
Answers first: deadNames and deadByOwner (owner -> its dead members), complete workspace-wide - then each finding classified.
When to use it
'What can I delete' / 'which methods of X are never called' is one call, no arguments - every construct, method and constant nothing reaches, by owner.
When not to use it
- Checking usage of ONE specific symbol, not a whole-workspace scan - use
ek9_query_references. - Actually removing a construct once found unused - use
ek9_safe_delete. - You want compiler errors/warnings (incl. unused-parameter E08091/E11018), not the reachability scan - use
ek9_query_diagnostics. - You want the inventory of EXISTING constructs, not the unused subset - use
ek9_query_workspace.
Details
Covered kinds: 'construct' (dead top-level functions) + 'method' (dead methods/constructors); 'field'/'reference' return empty+note (not yet wired), 'parameter' is compiler-owned (E08091/E11018). Each finding carries reachability (dead|production-dead|test-helper|dead-test|untested-public-api), recommendation (delete|relocate-to-test|none|add-test), definedIn, reachedBy, reason and ONE nextStep (for 'delete' the literal ek9_safe_delete(symbols:[...]) call); a dead callable still called names its callers in calledOnlyFrom - each itself dead, deleted with it by that nextStep; library-aware - with no production roots (programs/service operations) the tests are the root set, while application mode adds ungroundedTests[] (@Test programs whose closure never touches production code a release runs). Requires the workspace to reach PRE_IR_CHECKS (where the call graph is built); below that the tool errors rather than guessing.
Arguments
| Argument | Type | Required | What it is |
|---|---|---|---|
among | array of string | Names to answer FOR: 'which of these ...' - the name lists shrink to these and amongUnmatched names the ones that are not in the answer. Bare names, 'mod::Type' or 'Type.member'; a MODULE name stands for every construct in it ('which in scale.m07 do not ...' = amongUnmatched). | |
excludePublic | boolean | When true, excludes public-visibility findings (intentional library API). Default false. Useful when scanning a library. | |
fileFilter | string | Optional source-file substring to scope the scan. Omit to scan all source. | |
kind | string: all | construct | method | constant | field | reference | parameter | Filter by what kind of unused code to find. Default 'all'. 'construct' = dead top-level functions; 'method' = dead members (methods/constructors); 'constant' = a 'defines constant' entry nothing references (each finding carries the ek9_safe_delete call). 'field'/'reference' are not yet covered (empty + note); 'parameter' is owned by the compiler (E08091/E11018). |
It also takes the arguments every tool takes.
Recorded calls
Real calls, recorded against small projects and checked on every build - a changed answer fails it. 3 of the 14 recorded are shown.
Scan kind parameter note
Request
{
"kind" : "parameter"
}
Response
{
"byKind" : { },
"deadByOwner" : { },
"deadNames" : [ ],
"deadNamesCover" : "every construct, method and constant no program or test reaches - workspace-wide, nothing to verify",
"findings" : [ ],
"meta" : {
"serverMs" : "<timing>"
},
"note" : "Unused parameters are already a compile error in EK9 (E08091 / E11018) — the compiler owns this; nothing for the scan to report.",
"reachabilityComplete" : true,
"scanCount" : 0,
"status" : "empty"
}
Nothing dead is empty
Request
{ }
Response
{
"actionableCount" : 0,
"byKind" : {
"constant" : 0,
"construct" : 0,
"method" : 0
},
"byReachability" : { },
"deadByOwner" : { },
"deadNames" : [ ],
"deadNamesCover" : "every construct, method and constant no program or test reaches - workspace-wide, nothing to verify",
"findings" : [ ],
"meta" : {
"serverMs" : "<timing>"
},
"reachabilityComplete" : true,
"scanCount" : 0,
"status" : "empty",
"summary" : {
"byVisibility" : {
"private" : 0,
"protected" : 0,
"public" : 0
},
...
Cut short here: 4 more lines. The whole recorded call.
Type used only as a generic argument
Request
{ }
Response
{
"actionableCount" : 0,
"byKind" : {
"constant" : 0,
"construct" : 0,
"method" : 0
},
"byReachability" : { },
"deadByOwner" : { },
"deadNames" : [ ],
"deadNamesCover" : "every construct, method and constant no program or test reaches - workspace-wide, nothing to verify",
"findings" : [ ],
"meta" : {
"serverMs" : "<timing>"
},
"reachabilityComplete" : true,
"scanCount" : 0,
"status" : "empty",
"summary" : {
"byVisibility" : {
"private" : 0,
"protected" : 0,
"public" : 0
},
...
Cut short here: 4 more lines. The whole recorded call.
See also
- Show me in the IDE: Unused Code