You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|> List.sortByDescending (fun scope -> scope.Complexity)// sort in descending order by complexity
70
+
|> List.distinctBy (fun scope -> scope.Binding.RangeOfBindingWithRhs.Start)// throw away any extraneous elements with the same start position but a lower complexity
increaseComplexity(1+ countBooleanOperators condition)// include the number of boolean operators in the while condition
178
+
bindingStack.IncrComplexityOfCurrentScope(1+ countBooleanOperators condition)// include the number of boolean operators in the while condition
143
179
| SynExpr.IfThenElse(condition,_,_,_,_,_,_)->
144
-
increaseComplexity(1+ countBooleanOperators condition)// include the number of boolean operators in the condition
180
+
bindingStack.IncrComplexityOfCurrentScope(1+ countBooleanOperators condition)// include the number of boolean operators in the condition
145
181
| SynExpr.MatchBang(_,_, clauses,_)
146
182
| SynExpr.MatchLambda(_,_, clauses,_,_)
147
183
| SynExpr.Match(_,_, clauses,_)->
148
184
letnumCases= clauses |> List.sumBy countCasesInMatchClause // determine the number of cases in the match expression
149
-
increaseComplexity(numCases + countBooleanOperators expression)// include the number of boolean operators in any when expressions, if applicable
185
+
bindingStack.IncrComplexityOfCurrentScope(numCases + countBooleanOperators expression)// include the number of boolean operators in any when expressions, if applicable
150
186
|_->()
151
187
|_->()
152
188
153
189
// if the last node to be processed, pop everything off the stack
154
190
if args.NodeIndex >= args.SyntaxArray.Length-1then
155
-
seq{
156
-
match warningDetails with
157
-
| Some x ->yield x
158
-
| None ->()
159
-
whilenot BindingStack.IsEmpty do
160
-
match popOffBindingStack()with
161
-
| Some x ->yield x
162
-
| None ->()
163
-
}|> Seq.toArray
191
+
letfromStack= bindingStack
192
+
|> Seq.sortBy (fun scope ->// sort by order of start position, for reporting
193
+
letpos= scope.Binding.RangeOfBindingWithRhs.Start
194
+
pos.Column, pos.Line)
195
+
|> Seq.map (fun scope ->// transform into WarningDetails
/// Verifies that the cyclomatic complexity is calculated on functions independently by checking that a function that comes after a function with a cyclomatic complexity that is flagged as too high need not be flagged.
202
201
[<Test>]
@@ -221,7 +220,7 @@ let f() =
221
220
{makeMatchSnippet MaxComplexity |> indent 8}
222
221
()"""
223
222
this.Parse code
224
-
Assert.AreEqual(0, this.ErrorRanges.Length)
223
+
Assert.IsTrue this.NoErrorsExist
225
224
226
225
227
226
/// Verifies that the cyclomatic complexity is calculated on nested functions independently by checking that a nested function that comes after another nested function with a cyclomatic complexity that is flagged as too high need not be flagged.
0 commit comments