Python · maintainability
no-restated-comment
python:no-restated-comment Comment restates the statement immediately below it.
- Code
- SARJ049
- Default
- error
- Fix
- suggestion
- Languages
- python
Why
Comments that repeat code add reading cost and can become stale without explaining intent.
Fix
Delete the comment or replace it with context the statement cannot express.
Before / after
Executed by this rule’s unit tests.
Before
Comment repeats the action
def load_profile(profile_id):
# Get profile by ID
return get_profile_by_id(profile_id)
After
Comment adds operational context
def load_profile(profile_id):
# The replica may lag after signup, so read from primary.
return get_profile_by_id(profile_id)
Limits
- Detection uses conservative lexical heuristics for short standalone comments above simple actions.
- Generated files, directives, protected comments, section labels, and comments adding novel context are excluded.