Skip to content

Commit 54ab0a3

Browse files
committed
Core,Tests: apply TupleParentheses rule suggestions
1 parent 27f4222 commit 54ab0a3

File tree

8 files changed

+23
-23
lines changed

8 files changed

+23
-23
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ let rec checkExpression (expression: SynExpr) (range: range) (continuation: unit
2222
| SynExpr.For (_, _, _, _, _, _, _, innerExpression, range) -> checkExpression innerExpression range returnEmptyArray
2323
| SynExpr.ForEach (_, _, _, _, _, _, innerExpression, range) -> checkExpression innerExpression range returnEmptyArray
2424
| SynExpr.Match (_, _, clauses, range, _) ->
25-
let subExpressions = clauses |> List.map (fun (SynMatchClause (_, _, clause, range, _, _)) -> clause, range)
25+
let subExpressions = clauses |> List.map (fun (SynMatchClause (_, _, clause, range, _, _)) -> (clause, range))
2626
checkMultipleExpressions subExpressions returnEmptyArray
2727
| SynExpr.Do (innerExpression, range) -> checkExpression innerExpression range returnEmptyArray
2828
| SynExpr.TryWith (tryExpression, withCases, tryRange, _, _, _) ->
2929
let subExpressions =
30-
withCases |> List.map (fun (SynMatchClause (_, _, withCase, withRange, _, _)) -> withCase, withRange)
30+
withCases |> List.map (fun (SynMatchClause (_, _, withCase, withRange, _, _)) -> (withCase, withRange))
3131
checkMultipleExpressions subExpressions (fun () -> checkExpression tryExpression tryRange returnEmptyArray)
3232
| SynExpr.TryFinally (tryExpression, finallyExpr, range, _, _, _) ->
3333
checkExpression tryExpression range (fun () -> checkExpression finallyExpr range returnEmptyArray)

src/FSharpLint.Core/Rules/Conventions/AvoidSinglePipeOperator.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ let runner (args: AstNodeRuleParams) =
4646
let suggestedFix = lazy(
4747
let maybeFuncText = ExpressionUtilities.tryFindTextOfRange outerArgExpr.Range args.FileContent
4848
let maybeArgText = ExpressionUtilities.tryFindTextOfRange argExpr.Range args.FileContent
49-
match maybeFuncText, maybeArgText with
49+
match (maybeFuncText, maybeArgText) with
5050
| Some(funcText), Some(argText) ->
5151
let replacementText = sprintf "%s %s" funcText argText
5252
Some { FromText=args.FileContent; FromRange=range; ToText=replacementText }

src/FSharpLint.Core/Rules/Conventions/CyclomaticComplexity.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ type private BindingScopeComparer() =
3232
member this.Compare(left, right) =
3333
let leftStart = left.Binding.RangeOfBindingWithoutRhs.Start
3434
let rightStart = right.Binding.RangeOfBindingWithoutRhs.Start
35-
let leftTuple : ValueTuple<int, int, int> = leftStart.Line, leftStart.Column, left.Complexity
36-
let rightTuple : ValueTuple<int, int, int> = rightStart.Line, rightStart.Column, right.Complexity
35+
let leftTuple : ValueTuple<int, int, int> = (leftStart.Line, leftStart.Column, left.Complexity)
36+
let rightTuple : ValueTuple<int, int, int> = (rightStart.Line, rightStart.Column, right.Complexity)
3737
leftTuple.CompareTo rightTuple
3838

3939
/// A two-tiered stack-like structure for containing BindingScopes.
@@ -190,7 +190,7 @@ let runner (config:Config) (args:AstNodeRuleParams) : WarningDetails[] =
190190
let fromStack = bindingStack
191191
|> Seq.sortBy (fun scope -> // sort by order of start position, for reporting
192192
let pos = scope.Binding.RangeOfBindingWithRhs.Start
193-
pos.Column, pos.Line)
193+
(pos.Column, pos.Line))
194194
|> Seq.map (fun scope -> // transform into WarningDetails
195195
let errMsg = String.Format(Resources.GetString("RulesCyclomaticComplexityError"), scope.Complexity, config.MaxComplexity)
196196
{ Range = scope.Binding.RangeOfBindingWithRhs; Message = errMsg; SuggestedFix = None; TypeChecks = List.Empty })

src/FSharpLint.Core/Rules/Conventions/EnsureTailCallDiagnosticsInRecursiveFunctions.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ let private emitWarning (func: UnneededRecKeyword.RecursiveFunctionInfo) =
1919
TypeChecks = list.Empty }
2020

2121
let runner (args: AstNodeRuleParams) =
22-
match args.AstNode, args.CheckInfo with
22+
match (args.AstNode, args.CheckInfo) with
2323
| UnneededRecKeyword.RecursiveFunctions(funcs), Some checkInfo ->
2424
let processFunction functionInfo =
2525
if UnneededRecKeyword.functionIsCalledInOneOf checkInfo functionInfo funcs then

src/FSharpLint.Core/Rules/Conventions/RedundantNewKeyword.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ let private generateFix (text:string) range = lazy(
4444

4545

4646
let runner args =
47-
match args.AstNode, args.CheckInfo with
47+
match (args.AstNode, args.CheckInfo) with
4848
| AstNode.Expression(SynExpr.New(_, SynType.LongIdent(identifier), _, range)), Some checkInfo
4949
| AstNode.Expression(SynExpr.New(_, SynType.App(SynType.LongIdent(identifier), _, _, _, _, _, _), _, range)), Some checkInfo ->
5050
Array.singleton

src/FSharpLint.Core/Rules/Conventions/SuggestUseAutoProperty.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ let private runner (args: AstNodeRuleParams) =
101101
memberRange
102102
)
103103
) when memberFlags.IsInstance ->
104-
match expr, argPats with
104+
match (expr, argPats) with
105105
| _, SynArgPats.Pats pats when pats.Length > 0 -> // non-property member
106106
Array.empty
107107
| expression, _ when isImmutableValueExpression args expression id ->

src/FSharpLint.Core/Rules/Conventions/UnneededRecKeyword.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ let private emitWarning (func: RecursiveFunctionInfo) =
5656
TypeChecks = list.Empty }
5757

5858
let runner (args: AstNodeRuleParams) =
59-
match args.AstNode, args.CheckInfo with
59+
match (args.AstNode, args.CheckInfo) with
6060
| RecursiveFunctions(funcs), Some checkInfo ->
6161
funcs
6262
|> List.choose

tests/FSharpLint.Core.Tests/Rules/Conventions/CyclomaticComplexity.fs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -135,18 +135,18 @@ type TestConventionsCyclomaticComplexity() =
135135
static member private FailureCasesSource =
136136
seq {
137137
let num = MaxComplexity + 1
138-
let errorLocation = 2, 4
139-
yield ifElseExpressions num, errorLocation
140-
yield forExpressions num, errorLocation
141-
yield foreachExpressions num, errorLocation
142-
yield whileExpressions num, errorLocation
143-
yield matchExpression num, errorLocation
144-
yield matchExpressionWithCombinedPatterns num, errorLocation
145-
yield matchFunction num, errorLocation
146-
yield matchBang num, errorLocation
147-
yield ifThenExpressionWithMultipleAndConditionals num, errorLocation
148-
yield ifThenExpressionWithMultipleOrConditionals num, errorLocation
149-
yield whileWithBooleanOperatorsInConditionExpressions num, errorLocation
138+
let errorLocation = (2, 4)
139+
yield (ifElseExpressions num, errorLocation)
140+
yield (forExpressions num, errorLocation)
141+
yield (foreachExpressions num, errorLocation)
142+
yield (whileExpressions num, errorLocation)
143+
yield (matchExpression num, errorLocation)
144+
yield (matchExpressionWithCombinedPatterns num, errorLocation)
145+
yield (matchFunction num, errorLocation)
146+
yield (matchBang num, errorLocation)
147+
yield (ifThenExpressionWithMultipleAndConditionals num, errorLocation)
148+
yield (ifThenExpressionWithMultipleOrConditionals num, errorLocation)
149+
yield (whileWithBooleanOperatorsInConditionExpressions num, errorLocation)
150150
} |> Seq.map (fun (x, y) -> [| box x; box y |])
151151

152152
/// Verifies that no cyclomatic complexity over-maximum flags are raised on source that has cyclomatic complexity <= maxComplexity.
@@ -254,4 +254,4 @@ let f() =
254254
let f (str: string) =
255255
match str with""" + NewLine + matchClauses
256256
this.Parse code
257-
Assert.AreEqual(1, this.ErrorRanges.Length)
257+
Assert.AreEqual(1, this.ErrorRanges.Length)

0 commit comments

Comments
 (0)