From 73ad48f814a5cddb58df646b6be0e96f67a69e42 Mon Sep 17 00:00:00 2001 From: Mehrshad Date: Fri, 22 Dec 2023 15:08:48 +0330 Subject: [PATCH] Core: fix FSharpLint warning Fixing the warning for maxNumberOfFunctionParameters rule. --- src/FSharpLint.Core/Application/Lint.fs | 88 +++++++++++------ src/FSharpLint.Core/Application/Lint.fsi | 21 +++- .../Rules/Formatting/TypePrefixing.fs | 48 +++++---- .../Rules/Hints/HintMatcher.fs | 97 +++++++++++++++---- .../Rules/TestAstNodeRule.fs | 13 ++- .../Rules/TestHintMatcherBase.fs | 11 ++- .../Rules/TestIndentationRule.fs | 18 +++- .../Rules/TestLineRule.fs | 18 +++- .../Rules/TestNoTabCharactersRule.fs | 18 +++- 9 files changed, 255 insertions(+), 77 deletions(-) diff --git a/src/FSharpLint.Core/Application/Lint.fs b/src/FSharpLint.Core/Application/Lint.fs index d16214107..53e30a4cc 100644 --- a/src/FSharpLint.Core/Application/Lint.fs +++ b/src/FSharpLint.Core/Application/Lint.fs @@ -118,34 +118,43 @@ module Lint = { IndentationRuleContext:Map NoTabCharactersRuleContext:(string * Range) list } - let runAstNodeRules (rules:RuleMetadata []) (globalConfig:Rules.GlobalRuleConfig) typeCheckResults (filePath:string) (fileContent:string) (lines:string []) syntaxArray = + type RunAstNodeRulesConfig = + { Rules: RuleMetadata [] + GlobalConfig: Rules.GlobalRuleConfig + TypeCheckResults: FSharpCheckFileResults option + FilePath: string + FileContent: string + Lines: string [] + SyntaxArray: AbstractSyntaxArray.Node array } + + let runAstNodeRules (config: RunAstNodeRulesConfig) = let mutable indentationRuleState = Map.empty let mutable noTabCharactersRuleState = List.empty let collect index (astNode: AbstractSyntaxArray.Node) = - let getParents (depth:int) = AbstractSyntaxArray.getBreadcrumbs depth syntaxArray index + let getParents (depth:int) = AbstractSyntaxArray.getBreadcrumbs depth config.SyntaxArray index let astNodeParams = { AstNode = astNode.Actual NodeHashcode = astNode.Hashcode NodeIndex = index - SyntaxArray = syntaxArray + SyntaxArray = config.SyntaxArray GetParents = getParents - FilePath = filePath - FileContent = fileContent - Lines = lines - CheckInfo = typeCheckResults - GlobalConfig = globalConfig } + FilePath = config.FilePath + FileContent = config.FileContent + Lines = config.Lines + CheckInfo = config.TypeCheckResults + GlobalConfig = config.GlobalConfig } // Build state for rules with context. indentationRuleState <- Indentation.ContextBuilder.builder indentationRuleState astNode.Actual noTabCharactersRuleState <- NoTabCharacters.ContextBuilder.builder noTabCharactersRuleState astNode.Actual - rules + config.Rules |> Array.collect (fun rule -> runAstNodeRule rule astNodeParams) // Collect suggestions for AstNode rules, and build context for following rules. let astNodeSuggestions = - syntaxArray + config.SyntaxArray |> Array.mapi (fun index astNode -> (index, astNode)) |> Array.collect (fun (index, astNode) -> collect index astNode) @@ -153,32 +162,37 @@ module Lint = { IndentationRuleContext = indentationRuleState NoTabCharactersRuleContext = noTabCharactersRuleState } - rules |> Array.iter (fun rule -> rule.RuleConfig.Cleanup()) + config.Rules |> Array.iter (fun rule -> rule.RuleConfig.Cleanup()) (astNodeSuggestions, context) - let runLineRules (lineRules:Configuration.LineRules) (globalConfig:Rules.GlobalRuleConfig) (filePath:string) (fileContent:string) (lines:string []) (context:Context) = + type RunLineRulesConfig = + { LineRules: Configuration.LineRules + GlobalConfig: Rules.GlobalRuleConfig + FilePath: string + FileContent: string + Lines: string[] + Context: Context } + let runLineRules (config: RunLineRulesConfig) = let collectErrors (line: string) (lineNumber: int) (isLastLine: bool) = let lineParams = - { - LineRuleParams.Line = line - LineNumber = lineNumber + 1 - IsLastLine = isLastLine - FilePath = filePath - FileContent = fileContent - Lines = lines - GlobalConfig = globalConfig - } + { LineRuleParams.Line = line + LineNumber = lineNumber + 1 + IsLastLine = isLastLine + FilePath = config.FilePath + FileContent = config.FileContent + Lines = config.Lines + GlobalConfig = config.GlobalConfig } let indentationError = - lineRules.IndentationRule - |> Option.map (fun rule -> runLineRuleWithContext rule context.IndentationRuleContext lineParams) + config.LineRules.IndentationRule + |> Option.map (fun rule -> runLineRuleWithContext rule config.Context.IndentationRuleContext lineParams) let noTabCharactersError = - lineRules.NoTabCharactersRule - |> Option.map (fun rule -> runLineRuleWithContext rule context.NoTabCharactersRuleContext lineParams) + config.LineRules.NoTabCharactersRule + |> Option.map (fun rule -> runLineRuleWithContext rule config.Context.NoTabCharactersRuleContext lineParams) let lineErrors = - lineRules.GenericLineRules + config.LineRules.GenericLineRules |> Array.collect (fun rule -> runLineRule rule lineParams) [| @@ -187,7 +201,7 @@ module Lint = lineErrors |> Array.singleton |] - fileContent + config.FileContent |> String.toLines |> Array.collect (fun (line, lineNumber, isLastLine) -> collectErrors line lineNumber isLastLine) |> Array.concat @@ -230,8 +244,24 @@ module Lint = let syntaxArray = AbstractSyntaxArray.astToArray fileInfo.Ast // Collect suggestions for AstNode rules - let (astNodeSuggestions, context) = runAstNodeRules enabledRules.AstNodeRules enabledRules.GlobalConfig fileInfo.TypeCheckResults fileInfo.File fileInfo.Text lines syntaxArray - let lineSuggestions = runLineRules enabledRules.LineRules enabledRules.GlobalConfig fileInfo.File fileInfo.Text lines context + let (astNodeSuggestions, context) = + runAstNodeRules + { Rules = enabledRules.AstNodeRules + GlobalConfig = enabledRules.GlobalConfig + TypeCheckResults = fileInfo.TypeCheckResults + FilePath = fileInfo.File + FileContent = fileInfo.Text + Lines = lines + SyntaxArray = syntaxArray } + + let lineSuggestions = + runLineRules + { LineRules = enabledRules.LineRules + GlobalConfig = enabledRules.GlobalConfig + FilePath = fileInfo.File + FileContent = fileInfo.Text + Lines = lines + Context = context } [| lineSuggestions; astNodeSuggestions |] |> Array.concat diff --git a/src/FSharpLint.Core/Application/Lint.fsi b/src/FSharpLint.Core/Application/Lint.fsi index 655c184b4..43e042489 100644 --- a/src/FSharpLint.Core/Application/Lint.fsi +++ b/src/FSharpLint.Core/Application/Lint.fsi @@ -119,11 +119,28 @@ module Lint = member TryGetSuccess : byref -> bool member TryGetFailure : byref -> bool + type RunAstNodeRulesConfig = + { Rules: RuleMetadata [] + GlobalConfig: Rules.GlobalRuleConfig + TypeCheckResults: FSharpCheckFileResults option + FilePath: string + FileContent: string + Lines: string [] + SyntaxArray: AbstractSyntaxArray.Node array } + /// Runs all rules which take a node of the AST as input. - val runAstNodeRules : RuleMetadata [] -> Rules.GlobalRuleConfig -> FSharpCheckFileResults option -> string -> string -> string [] -> AbstractSyntaxArray.Node [] -> Suggestion.LintWarning [] * Context + val runAstNodeRules : RunAstNodeRulesConfig -> Suggestion.LintWarning [] * Context + + type RunLineRulesConfig = + { LineRules: Configuration.LineRules + GlobalConfig: Rules.GlobalRuleConfig + FilePath: string + FileContent: string + Lines: string[] + Context: Context } /// Runs all rules which take a line of text as input. - val runLineRules : LineRules -> Rules.GlobalRuleConfig -> string -> string -> string [] -> Context -> Suggestion.LintWarning [] + val runLineRules : RunLineRulesConfig -> Suggestion.LintWarning [] /// Lints an entire F# solution by linting all projects specified in the `.sln` file. val lintSolution : optionalParams:OptionalLintParameters -> solutionFilePath:string -> toolsPath:Ionide.ProjInfo.Types.ToolsPath -> LintResult diff --git a/src/FSharpLint.Core/Rules/Formatting/TypePrefixing.fs b/src/FSharpLint.Core/Rules/Formatting/TypePrefixing.fs index f9b15e5f2..6bdc7942d 100644 --- a/src/FSharpLint.Core/Rules/Formatting/TypePrefixing.fs +++ b/src/FSharpLint.Core/Rules/Formatting/TypePrefixing.fs @@ -16,15 +16,23 @@ type Mode = [] type Config = { Mode: Mode } -let checkTypePrefixing (config:Config) (args:AstNodeRuleParams) range typeName typeArgs isPostfix = +type CheckTypePrefixingConfig = + { Config: Config + Args: AstNodeRuleParams + Range: FSharp.Compiler.Text.Range + TypeName: SynType + TypeArgs: string option + IsPostfix: bool } + +let checkTypePrefixing (typePrefixingConfig: CheckTypePrefixingConfig) = let recommendPostfixErrMsg = lazy(Resources.GetString("RulesFormattingF#PostfixGenericError")) - match typeName with + match typePrefixingConfig.TypeName with | SynType.LongIdent lid -> let prefixSuggestion typeName = let suggestedFix = lazy( - (ExpressionUtilities.tryFindTextOfRange range args.FileContent, typeArgs) - ||> Option.map2 (fun fromText typeArgs -> { FromText = fromText; FromRange = range; ToText = typeName + "<" + typeArgs + ">" })) - { Range = range + (ExpressionUtilities.tryFindTextOfRange typePrefixingConfig.Range typePrefixingConfig.Args.FileContent, typePrefixingConfig.TypeArgs) + ||> Option.map2 (fun fromText typeArgs -> { FromText = fromText; FromRange = typePrefixingConfig.Range; ToText = typeName + "<" + typeArgs + ">" })) + { Range = typePrefixingConfig.Range Message = Resources.GetString("RulesFormattingGenericPrefixError") SuggestedFix = Some suggestedFix TypeChecks = [] } |> Some @@ -38,39 +46,39 @@ let checkTypePrefixing (config:Config) (args:AstNodeRuleParams) range typeName t | "Ref" as typeName -> // Prefer postfix. - if not isPostfix && config.Mode <> Mode.Always + if not typePrefixingConfig.IsPostfix && typePrefixingConfig.Config.Mode <> Mode.Always then let suggestedFix = lazy( - (ExpressionUtilities.tryFindTextOfRange range args.FileContent, typeArgs) - ||> Option.map2 (fun fromText typeArgs -> { FromText = fromText; FromRange = range; ToText = typeArgs + " " + typeName })) - { Range = range + (ExpressionUtilities.tryFindTextOfRange typePrefixingConfig.Range typePrefixingConfig.Args.FileContent, typePrefixingConfig.TypeArgs) + ||> Option.map2 (fun fromText typeArgs -> { FromText = fromText; FromRange = typePrefixingConfig.Range; ToText = typeArgs + " " + typeName })) + { Range = typePrefixingConfig.Range Message = String.Format(recommendPostfixErrMsg.Value, typeName) SuggestedFix = Some suggestedFix TypeChecks = [] } |> Some else - if isPostfix && config.Mode = Mode.Always then + if typePrefixingConfig.IsPostfix && typePrefixingConfig.Config.Mode = Mode.Always then prefixSuggestion typeName else None - | "array" when config.Mode <> Mode.Always -> + | "array" when typePrefixingConfig.Config.Mode <> Mode.Always -> // Prefer special postfix (e.g. int []). let suggestedFix = lazy( - (ExpressionUtilities.tryFindTextOfRange range args.FileContent, typeArgs) - ||> Option.map2 (fun fromText typeArgs -> { FromText = fromText; FromRange = range; ToText = typeArgs + " []" })) - { Range = range + (ExpressionUtilities.tryFindTextOfRange typePrefixingConfig.Range typePrefixingConfig.Args.FileContent, typePrefixingConfig.TypeArgs) + ||> Option.map2 (fun fromText typeArgs -> { FromText = fromText; FromRange = typePrefixingConfig.Range; ToText = typeArgs + " []" })) + { Range = typePrefixingConfig.Range Message = Resources.GetString("RulesFormattingF#ArrayPostfixError") SuggestedFix = Some suggestedFix TypeChecks = [] } |> Some | typeName -> - match (isPostfix, config.Mode) with + match (typePrefixingConfig.IsPostfix, typePrefixingConfig.Config.Mode) with | true, Mode.Never -> None | true, _ -> prefixSuggestion typeName | false, Mode.Never -> - { Range = range + { Range = typePrefixingConfig.Range Message = String.Format(recommendPostfixErrMsg.Value, typeName) // TODO SuggestedFix = None @@ -84,7 +92,13 @@ let runner (config:Config) args = match args.AstNode with | AstNode.Type (SynType.App (typeName, _, typeArgs, _, _, isPostfix, range)) -> let typeArgs = typeArgsToString args.FileContent typeArgs - checkTypePrefixing config args range typeName typeArgs isPostfix + checkTypePrefixing + { Config = config + Args = args + Range = range + TypeName = typeName + TypeArgs = typeArgs + IsPostfix = isPostfix } |> Option.toArray | AstNode.Type (SynType.Array (1, _elementType, range)) when config.Mode = Mode.Always -> { Range = range diff --git a/src/FSharpLint.Core/Rules/Hints/HintMatcher.fs b/src/FSharpLint.Core/Rules/Hints/HintMatcher.fs index 982487db2..d67073d82 100644 --- a/src/FSharpLint.Core/Rules/Hints/HintMatcher.fs +++ b/src/FSharpLint.Core/Rules/Hints/HintMatcher.fs @@ -13,6 +13,14 @@ open FSharpLint.Framework.ExpressionUtilities open FSharpLint.Framework.HintParser open FSharpLint.Framework.Rules +type ToStringConfig = + { Replace: bool + ParentAstNode: AstNode option + Args: AstNodeRuleParams + MatchedVariables: Dictionary + ParentHintNode: option + HintNode: HintNode } + type Config = { HintTrie:MergeSyntaxTrees.Edges } @@ -503,15 +511,22 @@ module private FormatHint = Debug.Assert(false, "Expected operator to be an expression identifier, but was " + expression.ToString()) String.Empty - let rec toString replace parentAstNode (args:AstNodeRuleParams) (matchedVariables:Dictionary<_, SynExpr>) parentHintNode hintNode = - let toString = toString replace parentAstNode args matchedVariables (Some hintNode) + let rec toString (config: ToStringConfig) = + let toString hintNode = + toString + { Replace = config.Replace + ParentAstNode = config.ParentAstNode + Args = config.Args + MatchedVariables = config.MatchedVariables + ParentHintNode = (Some config.HintNode) + HintNode = hintNode } let str = - match hintNode with - | HintExpr(Expression.Variable(varChar)) when replace -> - match matchedVariables.TryGetValue varChar with + match config.HintNode with + | HintExpr(Expression.Variable(varChar)) when config.Replace -> + match config.MatchedVariables.TryGetValue varChar with | true, expr -> - match ExpressionUtilities.tryFindTextOfRange expr.Range args.FileContent with + match ExpressionUtilities.tryFindTextOfRange expr.Range config.Args.FileContent with | Some(replacement) -> replacement | _ -> varChar.ToString() | _ -> varChar.ToString() @@ -547,7 +562,7 @@ module private FormatHint = | HintPat(Pattern.Parentheses(hint)) -> "(" + toString (HintPat hint) + ")" | HintExpr(Expression.Lambda(arguments, LambdaBody(body))) -> "fun " - + lambdaArgumentsToString replace parentAstNode args matchedVariables arguments + + lambdaArgumentsToString config.Replace config.ParentAstNode config.Args config.MatchedVariables arguments + " -> " + toString (HintExpr body) | HintExpr(Expression.LambdaArg(argument)) -> toString (HintExpr argument) @@ -573,33 +588,61 @@ module private FormatHint = "else " + toString (HintExpr expr) | HintExpr(Expression.Null) | HintPat(Pattern.Null) -> "null" - if replace && Precedence.requiresParenthesis matchedVariables hintNode parentAstNode parentHintNode then "(" + str + ")" + if config.Replace && Precedence.requiresParenthesis config.MatchedVariables config.HintNode config.ParentAstNode config.ParentHintNode then "(" + str + ")" else str and private lambdaArgumentsToString replace parentAstNode args matchedVariables (arguments:LambdaArg list) = arguments - |> List.map (fun (LambdaArg expr) -> toString replace parentAstNode args matchedVariables None (HintExpr expr)) + |> List.map (fun (LambdaArg expr) -> + toString + { Replace = replace + ParentAstNode = parentAstNode + Args = args + MatchedVariables = matchedVariables + ParentHintNode = None + HintNode = (HintExpr expr) }) |> String.concat " " -let private hintError typeChecks hint (args:AstNodeRuleParams) range matchedVariables parentAstNode = - let matched = FormatHint.toString false None args matchedVariables None hint.MatchedNode - - match hint.Suggestion with +type HintErrorConfig = + { TypeChecks: (unit -> bool) list + Hint: Hint + Args: AstNodeRuleParams + Range: FSharp.Compiler.Text.Range + MatchedVariables: Dictionary + ParentAstNode: AstNode option } + +let private hintError (config: HintErrorConfig) = + let toStringConfig = + { ToStringConfig.Replace = false + ToStringConfig.ParentAstNode = None + ToStringConfig.Args = config.Args + ToStringConfig.MatchedVariables = config.MatchedVariables + ToStringConfig.ParentHintNode = None + ToStringConfig.HintNode = config.Hint.MatchedNode } + + let matched = FormatHint.toString toStringConfig + + match config.Hint.Suggestion with | Suggestion.Expr(expr) -> - let suggestion = FormatHint.toString false None args matchedVariables None (HintExpr expr) + let suggestion = FormatHint.toString { toStringConfig with HintNode = (HintExpr expr) } let errorFormatString = Resources.GetString("RulesHintRefactor") let error = System.String.Format(errorFormatString, matched, suggestion) - let toText = FormatHint.toString true parentAstNode args matchedVariables None (HintExpr expr) + let toText = + FormatHint.toString + { toStringConfig with + Replace = true + ParentAstNode = config.ParentAstNode + HintNode = (HintExpr expr) } let suggestedFix = lazy( - ExpressionUtilities.tryFindTextOfRange range args.FileContent - |> Option.map (fun fromText -> { FromText = fromText; FromRange = range; ToText = toText })) + ExpressionUtilities.tryFindTextOfRange config.Range config.Args.FileContent + |> Option.map (fun fromText -> { FromText = fromText; FromRange = config.Range; ToText = toText })) - { Range = range; Message = error; SuggestedFix = Some suggestedFix; TypeChecks = typeChecks } + { Range = config.Range; Message = error; SuggestedFix = Some suggestedFix; TypeChecks = config.TypeChecks } | Suggestion.Message(message) -> let errorFormatString = Resources.GetString("RulesHintSuggestion") let error = System.String.Format(errorFormatString, matched, message) - { Range = range; Message = error; SuggestedFix = None; TypeChecks = typeChecks } + { Range = config.Range; Message = error; SuggestedFix = None; TypeChecks = config.TypeChecks } let private getMethodParameters (checkFile:FSharpCheckFileResults) (methodIdent: SynLongIdent) = let symbol = @@ -655,7 +698,13 @@ let private confirmFuzzyMatch (args:AstNodeRuleParams) (hint:HintParser.Hint) = | AstNode.Expression(SynExpr.Paren(_)), HintExpr(_) | AstNode.Pattern(SynPat.Paren(_)), HintPat(_) -> () | AstNode.Pattern(pattern), HintPat(hintPattern) when MatchPattern.matchHintPattern (pattern, hintPattern) -> - hintError List.Empty hint args pattern.Range (Dictionary<_, _>()) None + hintError + { TypeChecks = List.Empty + Hint = hint + Args = args + Range = pattern.Range + MatchedVariables = (Dictionary<_, _>()) + ParentAstNode = None } |> suggestions.Add | AstNode.Expression(expr), HintExpr(hintExpr) -> let arguments = @@ -669,7 +718,13 @@ let private confirmFuzzyMatch (args:AstNodeRuleParams) (hint:HintParser.Hint) = match MatchExpression.matchHintExpr arguments with | MatchExpression.Match(typeChecks) -> let suggest checks = - hintError checks hint args expr.Range arguments.MatchedVariables (List.tryHead breadcrumbs) + hintError + { TypeChecks = checks + Hint = hint + Args = args + Range = expr.Range + MatchedVariables = arguments.MatchedVariables + ParentAstNode = (List.tryHead breadcrumbs) } |> suggestions.Add match (hint.MatchedNode, hint.Suggestion) with diff --git a/tests/FSharpLint.Core.Tests/Rules/TestAstNodeRule.fs b/tests/FSharpLint.Core.Tests/Rules/TestAstNodeRule.fs index 1e5dd5152..de4d63f2f 100644 --- a/tests/FSharpLint.Core.Tests/Rules/TestAstNodeRule.fs +++ b/tests/FSharpLint.Core.Tests/Rules/TestAstNodeRule.fs @@ -34,7 +34,18 @@ type TestAstNodeRuleBase (rule:Rule) = match checkFile with | Some false -> None | _ -> parseInfo.TypeCheckResults - let suggestions = runAstNodeRules (Array.singleton rule) globalConfig checkResult (Option.defaultValue "" fileName) input (input.Split("\n")) syntaxArray |> fst + + let suggestions = + runAstNodeRules + { Rules = Array.singleton rule + GlobalConfig = globalConfig + TypeCheckResults = checkResult + FilePath = (Option.defaultValue "" fileName) + FileContent = input + Lines = (input.Split("\n")) + SyntaxArray = syntaxArray } + |> fst + rule.RuleConfig.Cleanup() suggestions |> Array.iter this.PostSuggestion diff --git a/tests/FSharpLint.Core.Tests/Rules/TestHintMatcherBase.fs b/tests/FSharpLint.Core.Tests/Rules/TestHintMatcherBase.fs index 28e2a933c..5afb55dd4 100644 --- a/tests/FSharpLint.Core.Tests/Rules/TestHintMatcherBase.fs +++ b/tests/FSharpLint.Core.Tests/Rules/TestHintMatcherBase.fs @@ -57,7 +57,16 @@ type TestHintMatcherBase () = match checkFile with | Some false -> None | _ -> parseInfo.TypeCheckResults - let suggestions = runAstNodeRules (Array.singleton rule) globalConfig checkResult (Option.defaultValue "" fileName) input (input.Split "\n") syntaxArray |> fst + let suggestions = + runAstNodeRules + { Rules = Array.singleton rule + GlobalConfig = globalConfig + TypeCheckResults = checkResult + FilePath = (Option.defaultValue "" fileName) + FileContent = input + Lines = (input.Split("\n")) + SyntaxArray = syntaxArray } + |> fst suggestions |> Array.iter this.PostSuggestion | _ -> failwithf "Failed to parse" \ No newline at end of file diff --git a/tests/FSharpLint.Core.Tests/Rules/TestIndentationRule.fs b/tests/FSharpLint.Core.Tests/Rules/TestIndentationRule.fs index 032a71bdc..eebbeb494 100644 --- a/tests/FSharpLint.Core.Tests/Rules/TestIndentationRule.fs +++ b/tests/FSharpLint.Core.Tests/Rules/TestIndentationRule.fs @@ -31,8 +31,22 @@ type TestIndentationRuleBase (rule:Rule) = let lines = input.Split "\n" let syntaxArray = AbstractSyntaxArray.astToArray parseResults.ParseTree - let (_, context) = runAstNodeRules Array.empty globalConfig None fileName input lines syntaxArray + let (_, context) = + runAstNodeRules + { Rules = Array.empty + GlobalConfig = globalConfig + TypeCheckResults = None + FilePath = fileName + FileContent = input + Lines = lines + SyntaxArray = syntaxArray } let lineRules = { LineRules.IndentationRule = Some rule; NoTabCharactersRule = None; GenericLineRules = [||] } - runLineRules lineRules globalConfig fileName input lines context + runLineRules + { LineRules = lineRules + GlobalConfig = globalConfig + FilePath = fileName + FileContent = input + Lines = lines + Context = context } |> Array.iter this.PostSuggestion \ No newline at end of file diff --git a/tests/FSharpLint.Core.Tests/Rules/TestLineRule.fs b/tests/FSharpLint.Core.Tests/Rules/TestLineRule.fs index 71c14f6f7..65b81986a 100644 --- a/tests/FSharpLint.Core.Tests/Rules/TestLineRule.fs +++ b/tests/FSharpLint.Core.Tests/Rules/TestLineRule.fs @@ -31,8 +31,22 @@ type TestLineRuleBase (rule:Rule) = let lines = input.Split "\n" let syntaxArray = AbstractSyntaxArray.astToArray parseResults.ParseTree - let (_, context) = runAstNodeRules Array.empty globalConfig None fileName input lines syntaxArray + let (_, context) = + runAstNodeRules + { Rules = Array.empty + GlobalConfig = globalConfig + TypeCheckResults = None + FilePath = fileName + FileContent = input + Lines = lines + SyntaxArray = syntaxArray } let lineRules = { LineRules.IndentationRule = None; NoTabCharactersRule = None; GenericLineRules = [|rule|] } - runLineRules lineRules globalConfig fileName input lines context + runLineRules + { LineRules = lineRules + GlobalConfig = globalConfig + FilePath = fileName + FileContent = input + Lines = lines + Context = context } |> Array.iter this.PostSuggestion \ No newline at end of file diff --git a/tests/FSharpLint.Core.Tests/Rules/TestNoTabCharactersRule.fs b/tests/FSharpLint.Core.Tests/Rules/TestNoTabCharactersRule.fs index 35de346e8..6eed4baff 100644 --- a/tests/FSharpLint.Core.Tests/Rules/TestNoTabCharactersRule.fs +++ b/tests/FSharpLint.Core.Tests/Rules/TestNoTabCharactersRule.fs @@ -31,8 +31,22 @@ type TestNoTabCharactersRuleBase (rule:Rule) = let lines = input.Split "\n" let syntaxArray = AbstractSyntaxArray.astToArray parseResults.ParseTree - let (_, context) = runAstNodeRules Array.empty globalConfig None fileName input lines syntaxArray + let (_, context) = + runAstNodeRules + { Rules = Array.empty + GlobalConfig = globalConfig + TypeCheckResults = None + FilePath = fileName + FileContent = input + Lines = lines + SyntaxArray = syntaxArray } let lineRules = { LineRules.IndentationRule = None; NoTabCharactersRule = Some rule; GenericLineRules = [||] } - runLineRules lineRules globalConfig fileName input lines context + runLineRules + { LineRules = lineRules + GlobalConfig = globalConfig + FilePath = fileName + FileContent = input + Lines = lines + Context = context } |> Array.iter this.PostSuggestion \ No newline at end of file