linter icon indicating copy to clipboard operation
linter copied to clipboard

[Proposal] Lint for 'safer' code

Open bernaferrari opened this issue 3 years ago • 2 comments

I wish there was a lint for things frequently used that can blow up. Example:

[].firstWhere(...) // This can throw an exception when false. Use firstWhereOrNull.
[].reduce(...) // This can throw an exception when list is empty, use fold instead.
http.get // This can throw an exception, try adding try/catch to make it safe.

These are often overlooked by people, and they only find out it blows in testing. If we had a lint, it would be easier for those that don't want them.

bernaferrari avatar Jan 10 '22 03:01 bernaferrari

For reduce I don't really think a lint is going to be used much since there are lot of cases where reduce is a perfectly valid thing to use and it would get annoying really fast to ignore the lint every time using reduce just to prove that you have thought about the risk.

julemand101 avatar Jan 10 '22 10:01 julemand101

Without a more concrete description of what to report, I don't think we can act on this request.

srawlins avatar Aug 10 '22 20:08 srawlins