fsprojects / FSharpLint

Lint tool for F#
https://fsprojects.github.io/FSharpLint/
MIT License
303 stars 73 forks source link

Suggest `return raise fooException` or `return failwith` instead of `raise`/`failwith` when inside async block #597

Closed knocte closed 10 months ago

knocte commented 1 year ago

If a raise or failwith is placed inside an async{} block without a return before it, then the F# compiler will demand that you return a proper value (in case function returns Async<'T> where 'T is different than unit). Because of that, the developer might add by mistake code that is actually unreachable without her realizing it.

knocte commented 1 year ago

Mmm, unfortunately, even with a return keyword, the possible subsequent LOC after it that has another return keyword might still not be flagged as unreachable by F# compiler (TODO: file bug?). So the idea here would be that this rule detects both the absence of return keyword and/or unreachable code after it.