Skip to content
Sarj Code Standards

no-discarded-validation-result

Consume a value-producing validator's result instead of relying on its exceptions.

Why

Discarding a conversion's returned value makes validation an implicit exception side effect. The caller can continue with unvalidated or unnormalized inputs even after constructing a checked replacement.

Fix

Use the checked result in the following operation, or expose a separate validation command returning None. Preserve exception behavior; do not delete the call or add a dummy assignment.

Examples

Before — flagged A checked replacement is constructed and discarded
app/counts.py
def checked_count(raw: str) -> int:
if not raw:
raise ValueError("empty count")
return int(raw)
def save(raw: str) -> None:
checked_count(raw)
After — preferred Pass the validated replacement to the next operation
app/counts.py
def checked_count(raw: str) -> int:
if not raw:
raise ValueError("empty count")
return int(raw)
def save(raw: str) -> int:
return checked_count(raw)