Open asashour opened 3 years ago
I am not sure if a lint exists, or should it be part of unnecessary_statements?
I don't believe there is currently such a lint. Do you have an estimate for how often this occurs? I personally don't remember ever seeing it in a code review, but that doesn't prove anything.
I believe that the primary purpose of 'unnecessary_statements' is to find places that are likely to be bugs because of missing code. This kind of error doesn't really qualify as a bug. But if we think it's worth adding support for it we might consider adding it to the 'dead_code' support.
Actually, two unneeded return
s are currently in master
and were detected (and removed) in #2800.
I've seen a couple of times such return statements while reviewing inexperienced developers and was quite surprised, such return statements are in fact just garbage.
I don't think that this occurs very often, but such lint would be nice to have.
Description Some
return
statements are redundant, and can safely be removed, if they are not followed by other statements.This is specially true for
void
functions.I am not sure if a lint exists, or should it be part of unnecessary_statements?
Examples