ionide / ionide-analyzers

http://ionide.io/ionide-analyzers/
MIT License
6 stars 7 forks source link

Option.get analyzer #31

Closed sheridanchris closed 9 months ago

sheridanchris commented 9 months ago

I think an analyzer for Option.get that promotes the graceful handling of the None case by using functions like Option.defaultValue or pattern matching should be added. I'd like to create a PR for this if you believe this is a useful addition.

nojaf commented 9 months ago

Hi Chris,

Thank you for this suggestion! We like it and would be happy to receive a PR for this 🥳! Don't hesitate to ask any technical questions if you have any.

dawedawe commented 9 months ago

This sample could be of help for you to get started: https://github.com/ionide/FSharp.Analyzers.SDK/blob/master/samples/OptionAnalyzer/Library.fs

Numpsy commented 9 months ago

could / should there be something similar for ValueOption ?

nojaf commented 9 months ago

Yeah, seems reasonable. Are you interested in submitting a PR?

nojaf commented 9 months ago

Would probably be nothing more than adding an OR in if mfv.FullName = "Microsoft.FSharp.Core.Option.get" && args.Length = 1 then

Numpsy commented 9 months ago

I can have a go later if no one else gets to it first

dawedawe commented 9 months ago

I think we should have the Option.Value analyzer from the SDK sample as well.