eduaguilera/whep

validation/nourishment_axis.R: #361 guard gates on energy while the axis is protein; 4 lines over 80 chars

Aperta

#483 aperta il 4 ago 2026

 (1 commento) (0 reazioni) (0 assegnatari)R (3 fork)auto 404
area:nitrogenbuggood first issuehelp wantedmechanicalno-data-neededpriority:lowtesting

Metriche repository

Star
 (1 stella)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

Follow-up to #454 (review). Two small things in the validation script added there. Neither affects results.

1. The #361 guard gates on energy, but the classification is protein

validation/nourishment_axis.R prints the nourish classification from normalize_nourishment(supply), which defaults to protein_g_cap_day — protein is the SJOS-N axis, energy is the secondary cross-check (per R/nourishment.R and R/food_supply.R). But the warning that names #361 fires only on the energy ratio:

if (stats::median(compared$ratio_energy, na.rm = TRUE) > 1.1) {

MEASURED, 2010: energy 1.3, protein 1.2 — both over the threshold, so today the guard happens to fire. A run where protein drifts above 1.1 while energy stays below it would print Over counts for a protein axis that is off, with no warning. Gating on either ratio (or on the protein one, since that is the axis) closes it.

2. Four lines exceed the 80-character maximum

validation/nourishment_axis.R:65-68 are 94, 95, 108 and 105 characters, against CLAUDE.md's "Maximum line width is 80 characters". They are inside cli strings, so air format . cannot reflow them (MEASURED: air format --check . reports clean), and line_length_linter is disabled in the CI linter set — so nothing catches these. Hoisting the round(stats::median(...)) calls into named locals above the cli_inform() fixes it and reads better.

Acceptance criteria

  • The #361 warning fires when the protein ratio exceeds the threshold.
  • No line in validation/nourishment_axis.R exceeds 80 characters.

Guida contributor