Skip to content

Python · maintainability

no-comment-cruft

python:no-comment-cruft

Comment repeats code, preserves dead code, or adds a decorative section marker.

Code
SARJ016
Default
error
Fix
none
Languages
python

Why

Mechanical narration and dead code obscure the constraints and rationale that comments should preserve.

Fix

Delete the cruft and keep only concise comments that explain a non-obvious reason or constraint.

Before / after

Executed by this rule’s unit tests.

Before

Dead code preserved as a comment

service.py · focus
value = load()
# return value
save(value)

After

Comment records an external constraint

service.py · focus
value = load()
# Keep this ordering because Clerk caches the first lookup.
save(value)

Limits

  • Only standalone comments are classified; trailing comments, docstrings, directives, and referenced notes are excluded.
  • Generated files, license headers, doctests, grammar illustrations, and Sphinx configuration banners are excluded.