Expand description
CSV writer for FuncSpace trees.
Emits one row per space (function, class, struct, unit, etc.),
flattened depth-first from the root. Each row carries the source
path, space name and kind, line range, and every leaf metric
value. The header order is fixed by CSV_HEADER so downstream
tools (Pandas, Excel, awk) can rely on positional access.
Empty / non-finite metric values render as empty CSV cells (not
0, not NaN) — f64::NAN and f64::INFINITY mean “not
applicable for this space” in the underlying metric structs, and
we keep that signal across the format boundary.
RFC 4180 quoting (commas, double-quotes, newlines in values) is
handled by the csv crate; nothing in this module hand-rolls
escaping.
If the source path is not valid UTF-8, the writer emits the
header row only (no data rows) and warns to stderr. There is no
useful fallback for the CSV path column, mirroring the
convention established by the Checkstyle writer.
Constants§
- CSV_
EXTENSION - File extension used when writing CSV output to a file path.
- CSV_
HEADER - Fixed column order for
write_csvoutput. Asserted by tests so downstream consumers can rely on positional access. Metric column names use dotted JSON-style paths (loc.lloc,halstead.volume) so a single name addresses the metric in both JSON and CSV.
Functions§
- write_
csv - Write a CSV document for the metric tree rooted at
space. Thesource_pathis recorded in thepathcolumn of every row; if it is not valid UTF-8 the entire document is skipped (header + zero rows) and a warning is emitted to stderr — there is no useful fallback for a CSV identifier.