Created
September 14, 2018 19:29
-
-
Save Krzysztof-Cieslak/42829ce7b5dcc937bece698a5af9ff2b to your computer and use it in GitHub Desktop.
Option Analyzer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[<Analyzer>] | |
let optionValueAnalyzer : Analyzer = | |
fun ctx -> | |
let state = ResizeArray<range>() | |
let handler (range: range) (m: FSharpMemberOrFunctionOrValue) = | |
let name = String.Join(".", m.DeclaringEntity.Value.FullName, m.DisplayName) | |
if name = "Microsoft.FSharp.Core.FSharpOption`1.Value" then | |
state.Add range | |
ctx.TypedTree.Declarations |> List.iter (visitDeclaration handler) | |
state | |
|> Seq.map (fun r -> | |
{ Type = "Option.Value analyzer" | |
Message = "Option.Value shouldn't be used" | |
Code = "OV001" | |
Severity = Warning | |
Range = r | |
Fixes = []} | |
) | |
|> Seq.toList |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment