Skip to content

Commit

Permalink
Fix false positive in AvoidSinglePipeOperator (fsprojects#640)
Browse files Browse the repository at this point in the history
We already had a test for this scenario, but with one parameter.
This adds a testcase with two parameters.
  • Loading branch information
webwarrior-ws committed Dec 20, 2023
1 parent 44dbf24 commit 96c4e36
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
17 changes: 2 additions & 15 deletions src/FSharpLint.Core/Rules/Conventions/AvoidSinglePipeOperator.fs
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,8 @@ let runner (args: AstNodeRuleParams) =
| SynExpr.Ident ident ->
if ident.idText = "op_PipeRight" then
match argExpr with
| SynExpr.App(_exprAtomicFlag, _isInfix, funcExpr, _argExpr, range) ->
match funcExpr with
| SynExpr.App(_exprAtomicFlag, _isInfix, funcExpr, _argExpr, range) ->
match funcExpr with
| SynExpr.Ident ident ->
if ident.idText = "op_PipeRight" then
Array.empty
else
errors range
| _ ->
errors range
| SynExpr.Ident _ident ->
Array.empty
| _ ->
errors range
| SynExpr.App(_exprAtomicFlag, _isInfix, _funcExpr, _argExpr, _range) ->
Array.empty
| _ ->
errors range
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,13 @@ let someFunc someParam =
"""

Assert.IsFalse this.ErrorsExist


[<Test>]
member this.``Use pipe operator once to avoid parenthesis on expression with function application``() =
this.Parse """
let someFunc someParam =
someOtherFunc1 someParam someParam2 |> someOtherFunc3
"""

Assert.IsFalse this.ErrorsExist

0 comments on commit 96c4e36

Please sign in to comment.