fsprojects / FSharpLint

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

Add warnings for partial functions #234

Open Krzysztof-Cieslak opened 7 years ago

Krzysztof-Cieslak commented 7 years ago

Add warnings for partial functions such as List.head or Option.get

jgardella commented 4 years ago

I think this is a good addition, in my experience a lot of bugs can arise through using partial functions, and in most cases you shouldn't be using them when writing idiomatic F#.

My initial thought was that this could be achieved by adding hints, and it can to some degree, but with a dedicated rule we could also make use of typechecking information to check for instances of optionVar.Value and similar usages.

duckmatt commented 4 years ago

It would be quite cool if the hints allow you to specify the type of a variable, that would enable this to be done via hints and enable other rules like unnecessary casts etc to be done via hints