Skip to content

Commit

Permalink
AvoidSinglePipeOperator: cleanup
Browse files Browse the repository at this point in the history
Avoid duplicated code, add underscores to unused vars, and
remove debugging logs.
  • Loading branch information
knocte committed Dec 5, 2023
1 parent de3bd65 commit fe1dc30
Showing 1 changed file with 21 additions and 38 deletions.
59 changes: 21 additions & 38 deletions src/FSharpLint.Core/Rules/Conventions/AvoidSinglePipeOperator.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,60 +9,42 @@ open FSharpLint.Framework.Ast
open FSharpLint.Framework.Rules

let runner (args: AstNodeRuleParams) =
printfn "%A" args.AstNode
printfn "-------"

let errors range =
{
Range = range
Message = String.Format(Resources.GetString ("RulesAvoidSinglePipeOperator"))
SuggestedFix = None
TypeChecks = List.Empty
} |> Array.singleton

let error =
match args.AstNode with
| AstNode.Binding (SynBinding(synAccessOption, synBindingKind, mustInline, isMutable, synAttributeLists, preXmlDoc, synValData, headPat, synBindingReturnInfoOption, synExpr, range, debugPointAtBinding)) ->
| AstNode.Binding (SynBinding(_synAcc, _synBinding, _mustInline, _isMut, _synAttribs, _preXmlDoc, _synValData, _headPat, _synBindingRet, synExpr, _range, _debugPointAtBinding)) ->
match synExpr with
| SynExpr.App(exprAtomicFlag, isInfix, funcExpr, argExpr, range) ->
| SynExpr.App(_exprAtomicFlag, _isInfix, funcExpr, _argExpr, _range) ->
match funcExpr with
| SynExpr.App(exprAtomicFlag, isInfix, funcExpr, argExpr, range) ->
| SynExpr.App(_exprAtomicFlag, _isInfix, funcExpr, argExpr, range) ->
match funcExpr with
| SynExpr.Ident ident ->
if ident.idText = "op_PipeRight" then
match argExpr with
| SynExpr.App(exprAtomicFlag, isInfix, funcExpr, argExpr, range) ->

| SynExpr.App(_exprAtomicFlag, _isInfix, funcExpr, _argExpr, range) ->
match funcExpr with
| SynExpr.App(exprAtomicFlag, isInfix, funcExpr, argExpr, range) ->
| SynExpr.App(_exprAtomicFlag, _isInfix, funcExpr, _argExpr, range) ->
match funcExpr with
| SynExpr.Ident ident ->
if ident.idText = "op_PipeRight" then
Array.empty
else
{
Range = range
Message = String.Format(Resources.GetString ("RulesAvoidSinglePipeOperator"))
SuggestedFix = None
TypeChecks = List.Empty
} |> Array.singleton
errors range
| _ ->
{
Range = range
Message = String.Format(Resources.GetString ("RulesAvoidSinglePipeOperator"))
SuggestedFix = None
TypeChecks = List.Empty
} |> Array.singleton

| SynExpr.Ident _ ->
Array.empty

errors range
| SynExpr.Ident _ident ->
Array.empty
| _ ->
{
Range = range
Message = String.Format(Resources.GetString ("RulesAvoidSinglePipeOperator"))
SuggestedFix = None
TypeChecks = List.Empty
} |> Array.singleton
errors range
| _ ->
{
Range = range
Message = String.Format(Resources.GetString ("RulesAvoidSinglePipeOperator"))
SuggestedFix = None
TypeChecks = List.Empty
} |> Array.singleton
errors range
else
Array.empty
| _ ->
Expand All @@ -76,8 +58,9 @@ let runner (args: AstNodeRuleParams) =

error


let rule =
{ Name = "AvoidSinglePipeOperator"
Identifier = Identifiers.AvoidSinglePipeOperator
RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } }
|> AstNodeRule
|> AstNodeRule

0 comments on commit fe1dc30

Please sign in to comment.