Query language
The syntax of inkdex q and inkdex repl: kinds, keys, values, negation.
inkdex q '<kind>? <term>*'A query is an optional kind, then terms. A term is key:value or a flag; a - in front negates it. Terms are combined with AND.
inkdex q 'fn name:*password* -param.count:0'
inkdex q 'fn entry -auth sink:sql.* churn:>3'
inkdex q 'class extends:BaseModel fields:>10'
inkdex q 'literal class:url in:app/'
inkdex q 'dep unused -scope:dev'An unknown key is an error that gives its position and the closest known key:
error: invalid query: at 4: unknown key `complexty`, did you mean `complexity`?Kinds
fn, class, symbol, file, literal, route, dep, marker, fact, secret, tag. Without a kind, the query searches symbols.
Values
| Form | Meaning | Example |
|---|---|---|
| glob | * and ?, case-insensitive | name:*login* |
| regex | between slashes | name:/^get_[a-z]+$/ |
| range | a..b | complexity:5..10 |
| comparison | >n, >=n, <n, <=n | loc:>200 |
| list | a,b (any of them) | lang:py,ts |
Keys
| Area | Keys |
|---|---|
| Naming and place | name:, qname:, fq:, lang:, in: (a directory), file: |
| Flags | exported, test, generated, entry, auth, unsanitized, direct, unused, neutralized, orphaned |
| Signature and metrics | param.name:, param.type:, param.count:, returns:, complexity:, cognitive:, loc:, nesting: |
| Calls | calls:, callee:, caller:, callers:, callees:, unresolved: |
| Security | sink:, source:, sanitizer:, dangerous:, crypto:, env:, category:, rule:, confidence: |
| Classes | extends:, implements:, methods:, fields:, decorator:, attr: |
| Files | flag: (test, generated, vendored, minified, config, doc), imports:, imported_by:, deps: |
| Literals | class:, value:, entropy:, in_fn: |
| Routes | method: (GET, POST…), path:, framework:, handler:, kind: |
| Dependencies | version:, scope:, manifest: |
| Markers | kind: (TODO, FIXME…), text:, older: |
| Secrets | provider: |
| History | changed:, since:, author:, age:, at:, churn: |
| Tags | tag:, tag.<name>:, label:, tool:, target: |
Languages for lang:: py, ts, js, rs, go, ex, java.
Output
--count prints only the number of results; --format paths prints the files of the results, one per line, for piping into other tools:
inkdex q 'fn complexity:>20' --format paths | xargs wc -l