ek9_query_complexity
Answers first: in view 'totals' the workspace-wide methodCount, averages, maxima and methodsAboveCyclomaticThreshold / methodsAboveCognitiveThreshold; in 'hotspots' hotspotNames[] then hotspots[]; in 'inputVariety' per-callable floor/ceiling (display-only).
When to use it
Which methods are too complex, or how complex is the workspace overall - one call with view:'hotspots' or view:'totals'; no anchor needed. Tune the hotspots view with complexityThreshold and metric.
When not to use it
- Analysing ONE specific method's internal control-flow structure — use
ek9_query_flow(complexity FINDS complex methods; flow ANALYSES one of them). - Test coverage (line/branch/method) — use
ek9_run_tests/ek9_run_quality_checks. - Per-test pass/fail outcomes — use
ek9_run_tests. - Compile errors/warnings, including complexity-threshold violations as diagnostics — use
ek9_query_diagnostics(this tool returns the metric VALUES, not the violations).
Details
Three views: totals (fixed industry thresholds 10 cyclomatic / 15 cognitive, echoed as cyclomaticThreshold / cognitiveThreshold), hotspots (methods with the chosen metric >= complexityThreshold, default cyclomatic >= 10, sorted descending) and inputVariety (per-callable floor/ceiling input-variation figures + confidence, plus per-type rollups - DISPLAY ONLY, never a gate or a target). fileFilter (a path substring) is honoured in every view; complexityThreshold < 1 is clamped to 1. Metrics are squirrelled at PRE_IR_CHECKS, so compilation must reach that phase (queriesReliable:true on ek9_query_build_status) — no test run needed; an empty or earlier-stalled workspace returns methodCount 0 / empty arrays.
Arguments
| Argument | Type | Required | What it is |
|---|---|---|---|
complexityThreshold | integer | Hotspots view: methods with metric >= complexityThreshold. Default 10. | |
fileFilter | string | Optional: keep only methods whose source path contains this text. | |
metric | string: cyclomatic | cognitive | Which metric to threshold on in the hotspots view. | |
view | string: totals | hotspots | inputVariety | Which view: totals (aggregate stats), hotspots (above-threshold methods), or inputVariety (per-construct input-variation figures, display-only). |
Recorded calls
Real calls, recorded against small projects and checked on every build - a changed answer fails it.
Summary shape
Request
{
"view" : "totals"
}
Response
{
"meta" : {
"serverMs" : "<timing>"
},
"totals" : {
"averageCognitive" : 0.0,
"averageCyclomatic" : 1.0,
"cognitiveThreshold" : 15,
"cyclomaticThreshold" : 10,
"maxCognitive" : 0,
"maxCyclomatic" : 1,
"methodCount" : 1,
"methodsAboveCognitiveThreshold" : 0,
"methodsAboveCyclomaticThreshold" : 0
},
"view" : "totals"
}
Hotspots shape
Request
{
"complexityThreshold" : 1,
"metric" : "cyclomatic",
"view" : "hotspots"
}
Response
{
"complexityThreshold" : 1,
"hotspotCount" : 1,
"hotspotNames" : [ "com.example.hello::Main" ],
"hotspots" : [ {
"cognitive" : 0,
"cyclomatic" : 1,
"file" : "Hello.ek9",
"fullyQualifiedName" : "com.example.hello::Main",
"line" : 5,
"method" : "Main"
} ],
"meta" : {
"serverMs" : "<timing>"
},
"metric" : "cyclomatic",
"view" : "hotspots"
}
Inputvariety shape
Request
{
"view" : "inputVariety"
}
Response
{
"constructs" : [ {
"ceiling" : 486,
"confidence" : "EXACT,EXACT,EXACT,EXACT",
"file" : "Variety.ek9",
"floor" : 36,
"fullyQualifiedName" : "com.example.variety::Point.<=>",
"line" : 22,
"method" : "public Integer <- <=>(other as Point)"
}, {
"ceiling" : 81,
"confidence" : "EXACT,EXACT",
"file" : "Variety.ek9",
"floor" : 18,
"fullyQualifiedName" : "com.example.variety::combine",
"line" : 5,
"method" : "Void <- combine(first as Integer, second as Integer)"
}, {
"ceiling" : 81,
"confidence" : "EXACT,EXACT",
"file" : "Variety.ek9",
"floor" : 18,
"fullyQualifiedName" : "com.example.variety::Point.Point",
"line" : 16,
...
Cut short here: 26 more lines. The whole recorded call.