linter
linter copied to clipboard
[Proposal] Lint for 'safer' code
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.
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.
Without a more concrete description of what to report, I don't think we can act on this request.