Open MetRonnie opened 3 years ago
I would try to get rid of the comment, e.g. as:
for p in reversed(path.parents):
...
is_last_iteration = p == path.parent
if is_last_iteration and p in some_list and some_bool:
do_something()
@MetRonnie Do you have an example where getting rid of the comments would not be desirable?
Mainly my example in the OP. Your suggestion of creating a variable feels a bit inefficient to me, and I could imagine scenarios where a lengthier comment that couldn't be summarised with a variable (although admittedly I haven't run into any since opening the issue).
Desired change
if
conditions, don't flag this ruleExplanation
Sometimes it is clearer to split up logic into separate
if
conditions with comments explaining what is going on under theif
conditionsExample
This is an example where the mentioned rule(s) would currently be suboptimal:
With the current rule, I guess you can do this:
but it is less readable in my opinion.