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
value = load()
# return value
save(value)
After
Comment records an external constraint
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.