Skip to content

Commit 9226ca3

Browse files
committed
WIP: fix SelfCheck
1 parent d16cbc1 commit 9226ca3

File tree

7 files changed

+29
-29
lines changed

7 files changed

+29
-29
lines changed

src/FSharpLint.Console/Program.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,9 @@ let private lint
175175
handleLintResult lintResult
176176
with
177177
| exn ->
178-
let target = if fileType = FileType.Source then "source" else target
178+
let targetStr = if fileType = FileType.Source then "source" else target
179179
handleError
180-
$"Lint failed while analysing %s{target}.{Environment.NewLine}Failed with: %s{exn.Message}{Environment.NewLine}Stack trace: {exn.StackTrace}"
180+
$"Lint failed while analysing %s{targetStr}.{Environment.NewLine}Failed with: %s{exn.Message}{Environment.NewLine}Stack trace: {exn.StackTrace}"
181181

182182
exitCode
183183

src/FSharpLint.Core/Framework/AbstractSyntaxArray.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ module AbstractSyntaxArray =
262262
| Else(body) -> extractExtraInfo (Expression(body)) SyntaxNode.Else
263263
| _ -> node
264264

265-
traverseNode node (fun node -> left.Push (StackedNode(node, depth + 1)))
265+
traverseNode node (fun aNode -> left.Push (StackedNode(aNode, depth + 1)))
266266

267267
match astNodeToSyntaxNode node with
268268
| SyntaxNode.Other -> ()

src/FSharpLint.Core/Framework/AstInfo.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ module AstInfo =
120120
if Seq.isEmpty str then
121121
true
122122
else
123-
let operator = List.tryFind (fun (op: string) -> str.StartsWith(op)) operators
123+
let maybeOperator = List.tryFind (fun (op: string) -> str.StartsWith(op)) operators
124124

125-
match operator with
125+
match maybeOperator with
126126
| Some(operator) -> str.Substring(operator.Length) |> isSequenceOfOperators
127127
| None -> false
128128

src/FSharpLint.Core/Framework/HintParser.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ module HintParser =
8383
[ attempt pident
8484
.>>. many (attempt (skipChar '.' >>. pident))
8585
.>>. opt (skipChar '.' >>. pidentorop)
86-
|>> (fun ((startIdent, idents), operator) ->
86+
|>> (fun ((startIdent, idents), maybeOperator) ->
8787
let identifiers = startIdent::idents
88-
match operator with
88+
match maybeOperator with
8989
| Some(operator) -> identifiers@[operator]
9090
| None -> identifiers)
9191
attempt (pidentorop |>> fun identOrOpChars -> [identOrOpChars])

src/FSharpLint.Core/Framework/Utilities.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ module ExpressionUtilities =
8787

8888
/// Tries to find the source code within a given range.
8989
let tryFindTextOfRange (range:Range) (text:string) =
90-
let startIndex = findPos range.Start text
91-
let endIndex = findPos range.End text
90+
let maybeStartIndex = findPos range.Start text
91+
let maybeEndIndex = findPos range.End text
9292

93-
match (startIndex, endIndex) with
93+
match (maybeStartIndex, maybeEndIndex) with
9494
| Some(startIndex), Some(endIndex) ->
9595
text.Substring(startIndex, endIndex - startIndex) |> Some
9696
| _ -> None

src/FSharpLint.Core/Rules/Conventions/Binding/TupleOfWildcards.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ open FSharpLint.Framework.Rules
99

1010
let private checkTupleOfWildcards fileContents pattern identifier identifierRange =
1111
let rec isWildcard = function
12-
| SynPat.Paren(pattern, _) -> isWildcard pattern
12+
| SynPat.Paren(innerPattern, _) -> isWildcard innerPattern
1313
| SynPat.Wild(_) -> true
1414
| _ -> false
1515

src/FSharpLint.Core/Rules/Smells/AsyncExceptionWithoutReturn.fs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,28 @@ let rec checkExpression (expression: SynExpr) (range: range) (continuation: unit
1717
firstExpression
1818
range
1919
(fun () -> (checkExpression secondExpression secondExpression.Range returnEmptyArray))
20-
| SynExpr.Paren (innerExpression, _, _, range) -> checkExpression innerExpression range returnEmptyArray
21-
| SynExpr.While (_, _, innerExpression, range) -> checkExpression innerExpression range returnEmptyArray
22-
| SynExpr.For (_, _, _, _, _, _, _, innerExpression, range) -> checkExpression innerExpression range returnEmptyArray
23-
| SynExpr.ForEach (_, _, _, _, _, _, innerExpression, range) -> checkExpression innerExpression range returnEmptyArray
24-
| SynExpr.Match (_, _, clauses, range, _) ->
25-
let subExpressions = clauses |> List.map (fun (SynMatchClause (_, _, clause, range, _, _)) -> (clause, range))
20+
| SynExpr.Paren (innerExpression, _, _, innerRange) -> checkExpression innerExpression innerRange returnEmptyArray
21+
| SynExpr.While (_, _, innerExpression, innerRange) -> checkExpression innerExpression innerRange returnEmptyArray
22+
| SynExpr.For (_, _, _, _, _, _, _, innerExpression, innerRange) -> checkExpression innerExpression innerRange returnEmptyArray
23+
| SynExpr.ForEach (_, _, _, _, _, _, innerExpression, innerRange) -> checkExpression innerExpression innerRange returnEmptyArray
24+
| SynExpr.Match (_, _, clauses, innerRange, _) ->
25+
let subExpressions = clauses |> List.map (fun (SynMatchClause (_, _, clause, innerRange, _, _)) -> (clause, innerRange))
2626
checkMultipleExpressions subExpressions returnEmptyArray
27-
| SynExpr.Do (innerExpression, range) -> checkExpression innerExpression range returnEmptyArray
27+
| SynExpr.Do (innerExpression, innerRange) -> checkExpression innerExpression innerRange returnEmptyArray
2828
| SynExpr.TryWith (tryExpression, withCases, tryRange, _, _, _) ->
2929
let subExpressions =
3030
withCases |> List.map (fun (SynMatchClause (_, _, withCase, withRange, _, _)) -> (withCase, withRange))
3131
checkMultipleExpressions subExpressions (fun () -> checkExpression tryExpression tryRange returnEmptyArray)
32-
| SynExpr.TryFinally (tryExpression, finallyExpr, range, _, _, _) ->
33-
checkExpression tryExpression range (fun () -> checkExpression finallyExpr range returnEmptyArray)
34-
| SynExpr.IfThenElse (_, thenExpr, elseExpr, _, _, range, _) ->
32+
| SynExpr.TryFinally (tryExpression, finallyExpr, innerRange, _, _, _) ->
33+
checkExpression tryExpression range (fun () -> checkExpression finallyExpr innerRange returnEmptyArray)
34+
| SynExpr.IfThenElse (_, thenExpr, elseExpr, _, _, innerRange, _) ->
3535
checkExpression
3636
thenExpr
37-
range
37+
innerRange
3838
(fun () ->
3939
match elseExpr with
4040
| Some elseExpression ->
41-
checkExpression elseExpression range returnEmptyArray
41+
checkExpression elseExpression innerRange returnEmptyArray
4242
| None -> Array.empty)
4343

4444
| SynExpr.App (_, _, SynExpr.Ident failwithId, _, _) when
@@ -53,18 +53,18 @@ let rec checkExpression (expression: SynExpr) (range: range) (continuation: unit
5353
SuggestedFix = None
5454
TypeChecks = List.Empty
5555
}
56-
| SynExpr.App (_, _, funcExpr, _, range) ->
57-
checkExpression funcExpr range returnEmptyArray
58-
| SynExpr.LetOrUse (_, _, _, body, range, _) ->
59-
checkExpression body range returnEmptyArray
56+
| SynExpr.App (_, _, funcExpr, _, innerRange) ->
57+
checkExpression funcExpr innerRange returnEmptyArray
58+
| SynExpr.LetOrUse (_, _, _, body, innerRange, _) ->
59+
checkExpression body innerRange returnEmptyArray
6060
| _ -> Array.empty)
6161
(continuation ())
6262
and [<TailCall>] checkMultipleExpressions (expressions: list<SynExpr * range>) (continuation: unit -> array<WarningDetails>) =
6363
match expressions with
64-
| (expression, range) :: tail ->
64+
| (expression, innerRange) :: tail ->
6565
checkExpression
6666
expression
67-
range
67+
innerRange
6868
(fun () ->
6969
checkMultipleExpressions
7070
tail

0 commit comments

Comments
 (0)