Summary
The inline comment in format_number claims its integer fast-path matches "the JSON serializer's trailing-.0 elision", but serde_json does not elide trailing .0 from f64 values — JSON output renders whole-valued floats with the .0 intact.
Location
src/output/dump_metrics.rs:272-274
Evidence
// A safe-integer-valued float (e.g. an exact `2.0` average) prints as
// an integer, matching the JSON serializer's trailing-`.0` elision.
if float.fract() == 0.0 && float.abs() < F64_SAFE_INT_BOUND {
#[allow(clippy::cast_possible_truncation)]
return (float as i64).to_string();
}
serde_json (and serde's f64 serialization generally) always emits a decimal point for an f64: an f64 value of 2.0 serializes as 2.0, never 2. The metric JSON snapshots in this repo confirm whole-valued floats keep the .0:
src/metrics/snapshots/big_code_analysis__metrics__cognitive__tests__tcl_2_level_nesting.snap: "n": 6.0,
src/metrics/snapshots/big_code_analysis__metrics__loc__tests__php_no_zero_blank.snap: "sloc_n": 5.0,
So for a whole-valued average the dump prints 6 while the JSON output prints 6.0. The dump's behavior (printing 6) is the deliberate legibility choice documented in the module header ("float values render rounded ... whereas JSON keeps full precision"), and is fine. The problem is only the rationale: the comment asserts a JSON "trailing-.0 elision" that does not exist, which misleads a future reader into believing the two views agree on whole floats when they do not.
Expected Behavior
The comment should state the dump deliberately prints whole-valued floats without a decimal point for legibility, diverging from JSON, which keeps the .0.
Actual Behavior
The comment claims the integer fast-path matches a JSON "trailing-.0 elision" — describing JSON behavior that serde_json does not exhibit.
Impact
Documentation-only. A maintainer relying on the comment may incorrectly assume the text dump and JSON agree on whole-valued float rendering, or may "fix" a perceived JSON regression that is actually correct serde_json behavior. No runtime effect.
Resolution
Fixed in 7a41184: format_number comment now states the whole-float-as-integer rendering DIVERGES from JSON (a legibility choice), not matches it.
Summary
The inline comment in
format_numberclaims its integer fast-path matches "the JSON serializer's trailing-.0elision", but serde_json does not elide trailing.0fromf64values — JSON output renders whole-valued floats with the.0intact.Location
src/output/dump_metrics.rs:272-274Evidence
serde_json (and serde's
f64serialization generally) always emits a decimal point for anf64: anf64value of2.0serializes as2.0, never2. The metric JSON snapshots in this repo confirm whole-valued floats keep the.0:So for a whole-valued average the dump prints
6while the JSON output prints6.0. The dump's behavior (printing6) is the deliberate legibility choice documented in the module header ("float values render rounded ... whereas JSON keeps full precision"), and is fine. The problem is only the rationale: the comment asserts a JSON "trailing-.0elision" that does not exist, which misleads a future reader into believing the two views agree on whole floats when they do not.Expected Behavior
The comment should state the dump deliberately prints whole-valued floats without a decimal point for legibility, diverging from JSON, which keeps the
.0.Actual Behavior
The comment claims the integer fast-path matches a JSON "trailing-
.0elision" — describing JSON behavior that serde_json does not exhibit.Impact
Documentation-only. A maintainer relying on the comment may incorrectly assume the text dump and JSON agree on whole-valued float rendering, or may "fix" a perceived JSON regression that is actually correct serde_json behavior. No runtime effect.
Resolution
Fixed in 7a41184: format_number comment now states the whole-float-as-integer rendering DIVERGES from JSON (a legibility choice), not matches it.