dart-lang / linter

Linter for Dart.
https://dart.dev/tools/linter-rules
BSD 3-Clause "New" or "Revised" License
628 stars 170 forks source link

proposal: `avoid_unnecessary_return` #3804

Open fzyzcjy opened 1 year ago

fzyzcjy commented 1 year ago

avoid_unnecessary_return

Description

As mentioned in https://github.com/flutter/flutter/pull/114290#issuecomment-1297514968, it would be great to have a linter to catch:

void f() {
  ...
  return; // LINT this is unnecessary!
}

Realworld example: https://github.com/flutter/flutter/pull/114290

Details

see above

Kind

style?

Good Examples

see above

Bad Examples

see above

Discussion

Add any other motivation or useful context here.

Discussion checklist

srawlins commented 1 year ago

I don't see a lot of win here. It has 0 false positives, but it's not very exciting. I don't think this would be worth the maintenance cost or performance cost.