Skip to content
Sarj Code Standards

no-test-comments

Express test behavior in names and assertions instead of ordinary comments.

Why

Test prose can drift from the setup and assertion it describes; executable contracts keep the explanation checked.

Fix

Remove the comment, clarify the test or helper name, or express the invariant with an assertion. Preserve legal notices and required tool directives.

Examples

Before — flagged Name the tested behavior
tests/test_save.py
def test_save():
# A stale save is rejected.
assert save_is_rejected()
After — preferred The assertion documents the behavior
tests/test_save.py
def test_stale_save_is_rejected():
assert save_is_rejected()
Before — flagged Remove only test prose proved by the existing ordered-action contract
tests/test_activation.py
def test_activation():
# Load current account profile activation settings
# Build current account profile activation response
load_current_account_profile_activation_settings()
return build_current_account_profile_activation_response()
After — preferred The exact action sequence needs no test prose
tests/test_activation.py
def test_activation():
load_current_account_profile_activation_settings()
return build_current_account_profile_activation_response()
Autofix output
tests/test_activation.py
def test_activation():
load_current_account_profile_activation_settings()
return build_current_account_profile_activation_response()