Skip to content

Commit ccedd44

Browse files
committed
Core: fix FSharpLint warning
Fixing the warning avoidSinglePipeOperator rule.
1 parent 0877d79 commit ccedd44

File tree

72 files changed

+638
-669
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+638
-669
lines changed

src/FSharpLint.Core/Application/Configuration.fs

+213-201
Large diffs are not rendered by default.

src/FSharpLint.Core/Application/Lint.fs

+8-7
Original file line numberDiff line numberDiff line change
@@ -185,16 +185,17 @@ module Lint =
185185
}
186186

187187
let indentationError =
188-
config.LineRules.IndentationRule
189-
|> Option.map (fun rule -> runLineRuleWithContext rule config.Context.IndentationRuleContext lineParams)
188+
Option.map
189+
(fun rule -> runLineRuleWithContext rule config.Context.IndentationRuleContext lineParams)
190+
config.LineRules.IndentationRule
190191

191192
let noTabCharactersError =
192-
config.LineRules.NoTabCharactersRule
193-
|> Option.map (fun rule -> runLineRuleWithContext rule config.Context.NoTabCharactersRuleContext lineParams)
193+
Option.map
194+
(fun rule -> runLineRuleWithContext rule config.Context.NoTabCharactersRuleContext lineParams)
195+
config.LineRules.NoTabCharactersRule
194196

195197
let lineErrors =
196-
config.LineRules.GenericLineRules
197-
|> Array.collect (fun rule -> runLineRule rule lineParams)
198+
Array.collect (fun rule -> runLineRule rule lineParams) config.LineRules.GenericLineRules
198199

199200
[|
200201
indentationError |> Option.toArray
@@ -460,7 +461,7 @@ module Lint =
460461
|> List.filter (not << isIgnoredFile)
461462
|> List.map (fun file -> ParseFile.parseFile file checker (Some projectOptions))
462463

463-
let failedFiles = parsedFiles |> List.choose getFailedFiles
464+
let failedFiles = List.choose getFailedFiles parsedFiles
464465

465466
if List.isEmpty failedFiles then
466467
parsedFiles

src/FSharpLint.Core/Framework/Ast.fs

+1-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ module Ast =
4242
/// Concatenates the nested-list structure of `SynAttributes` into a `SynAttribute list` to keep other code
4343
/// mostly unchanged.
4444
let extractAttributes (attrs:SynAttributes) =
45-
attrs
46-
|> List.collect (fun attrList -> attrList.Attributes)
45+
List.collect (fun (attrList: SynAttributeList) -> attrList.Attributes) attrs
4746

4847
/// Extracts an expression from parentheses e.g. ((x + 4)) -> x + 4
4948
let rec removeParens = function

src/FSharpLint.Core/Framework/AstInfo.fs

+57-56
Original file line numberDiff line numberDiff line change
@@ -28,61 +28,62 @@ module AstInfo =
2828
| None -> Function
2929

3030
let operatorIdentifiers =
31-
[ "op_Nil"
32-
"op_ColonColon"
33-
"op_Addition"
34-
"op_Splice"
35-
"op_SpliceUntyped"
36-
"op_Increment"
37-
"op_Decrement"
38-
"op_Subtraction"
39-
"op_Multiply"
40-
"op_Exponentiation"
41-
"op_Division"
42-
"op_Append"
43-
"op_Concatenate"
44-
"op_Modulus"
45-
"op_BitwiseAnd"
46-
"op_BitwiseOr"
47-
"op_ExclusiveOr"
48-
"op_LeftShift"
49-
"op_LogicalNot"
50-
"op_RightShift"
51-
"op_UnaryPlus"
52-
"op_UnaryNegation"
53-
"op_AddressOf"
54-
"op_IntegerAddressOf"
55-
"op_BooleanAnd"
56-
"op_BooleanOr"
57-
"op_LessThanOrEqual"
58-
"op_Equality"
59-
"op_Inequality"
60-
"op_GreaterThanOrEqual"
61-
"op_LessThan"
62-
"op_GreaterThan"
63-
"op_PipeRight"
64-
"op_PipeRight2"
65-
"op_PipeRight3"
66-
"op_PipeLeft"
67-
"op_PipeLeft2"
68-
"op_PipeLeft3"
69-
"op_Dereference"
70-
"op_ComposeRight"
71-
"op_ComposeLeft"
72-
"op_TypedQuotationUnicode"
73-
"op_ChevronsBar"
74-
"op_Quotation"
75-
"op_QuotationUntyped"
76-
"op_AdditionAssignment"
77-
"op_SubtractionAssignment"
78-
"op_MultiplyAssignment"
79-
"op_DivisionAssignment"
80-
"op_Range"
81-
"op_RangeStep"
82-
"op_Dynamic"
83-
"op_DynamicAssignment"
84-
"op_ArrayLookup"
85-
"op_ArrayAssign" ] |> Set.ofList
31+
Set.ofList
32+
[ "op_Nil"
33+
"op_ColonColon"
34+
"op_Addition"
35+
"op_Splice"
36+
"op_SpliceUntyped"
37+
"op_Increment"
38+
"op_Decrement"
39+
"op_Subtraction"
40+
"op_Multiply"
41+
"op_Exponentiation"
42+
"op_Division"
43+
"op_Append"
44+
"op_Concatenate"
45+
"op_Modulus"
46+
"op_BitwiseAnd"
47+
"op_BitwiseOr"
48+
"op_ExclusiveOr"
49+
"op_LeftShift"
50+
"op_LogicalNot"
51+
"op_RightShift"
52+
"op_UnaryPlus"
53+
"op_UnaryNegation"
54+
"op_AddressOf"
55+
"op_IntegerAddressOf"
56+
"op_BooleanAnd"
57+
"op_BooleanOr"
58+
"op_LessThanOrEqual"
59+
"op_Equality"
60+
"op_Inequality"
61+
"op_GreaterThanOrEqual"
62+
"op_LessThan"
63+
"op_GreaterThan"
64+
"op_PipeRight"
65+
"op_PipeRight2"
66+
"op_PipeRight3"
67+
"op_PipeLeft"
68+
"op_PipeLeft2"
69+
"op_PipeLeft3"
70+
"op_Dereference"
71+
"op_ComposeRight"
72+
"op_ComposeLeft"
73+
"op_TypedQuotationUnicode"
74+
"op_ChevronsBar"
75+
"op_Quotation"
76+
"op_QuotationUntyped"
77+
"op_AdditionAssignment"
78+
"op_SubtractionAssignment"
79+
"op_MultiplyAssignment"
80+
"op_DivisionAssignment"
81+
"op_Range"
82+
"op_RangeStep"
83+
"op_Dynamic"
84+
"op_DynamicAssignment"
85+
"op_ArrayLookup"
86+
"op_ArrayAssign" ]
8687

8788
/// Operator identifiers can be made up of "op_" followed by a sequence of operators from this list.
8889
let operators =
@@ -116,7 +117,7 @@ module AstInfo =
116117
if Seq.isEmpty str then
117118
true
118119
else
119-
let operator = operators |> List.tryFind (fun op -> str.StartsWith(op))
120+
let operator = List.tryFind (fun (op: string) -> str.StartsWith(op)) operators
120121

121122
match operator with
122123
| Some(operator) -> str.Substring(operator.Length) |> isSequenceOfOperators

src/FSharpLint.Core/Framework/HintParser.fs

+12-12
Original file line numberDiff line numberDiff line change
@@ -480,16 +480,17 @@ module HintParser =
480480
char(System.Convert.ToInt32(dec, 10))
481481

482482
let private escapeMap =
483-
[ ('"', '\"')
484-
('\\', '\\')
485-
('\'', '\'')
486-
('n', '\n')
487-
('t', '\t')
488-
('b', '\b')
489-
('r', '\r')
490-
('a', '\a')
491-
('f', '\f')
492-
('v', '\v') ] |> Map.ofList
483+
Map.ofList
484+
[ ('"', '\"')
485+
('\\', '\\')
486+
('\'', '\'')
487+
('n', '\n')
488+
('t', '\t')
489+
('b', '\b')
490+
('r', '\r')
491+
('a', '\a')
492+
('f', '\f')
493+
('v', '\v') ]
493494

494495
let private pescapechar: Parser<char, unit> =
495496
skipChar '\\'
@@ -622,8 +623,7 @@ module HintParser =
622623
let private pminus: Parser<char, unit> = pchar '-'
623624

624625
let private minusString (minus:char option, charList) =
625-
if minus.IsSome then '-' :: charList else charList
626-
|> charListToString
626+
charListToString (if minus.IsSome then '-' :: charList else charList)
627627

628628
let private phexint: Parser<char list, unit> =
629629
skipChar '0'

src/FSharpLint.Core/Framework/Suppression.fs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ let private extractRules (rules:Set<String>) (str:string) =
2929

3030
/// Parses a given file to find lines containing rule suppressions.
3131
let parseSuppressionInfo (rules:Set<String>) (lines:string list) =
32-
let rules = rules |> Set.map (fun rule -> rule.ToLowerInvariant())
32+
let rules = Set.map (fun (rule: String) -> rule.ToLowerInvariant()) rules
3333

3434
let choose lineNum line =
3535
let matched = Regex.Match (line, ".*fsharplint:([a-z\-]+)\s*(.*)$")

src/FSharpLint.Core/Framework/Utilities.fs

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ module ExpressionUtilities =
3939
let getSymbolFromIdent (checkFile:FSharpCheckFileResults option) expr =
4040
match (checkFile, expr) with
4141
| Some(checkFile), Identifier(ident, range) ->
42-
let identNames = ident |> List.map (fun x -> x.idText)
42+
let identNames = List.map (fun (x: Ident) -> x.idText) ident
4343

4444
checkFile.GetSymbolUseAtLocation(
4545
range.StartLine,
@@ -83,7 +83,7 @@ module ExpressionUtilities =
8383

8484
/// Converts a LongIdentWithDots to a String.
8585
let longIdentWithDotsToString (lidwd: SynLongIdent) =
86-
lidwd.LongIdent |> longIdentToString
86+
longIdentToString lidwd.LongIdent
8787

8888
/// Tries to find the source code within a given range.
8989
let tryFindTextOfRange (range:Range) (text:string) =
@@ -114,7 +114,7 @@ module ExpressionUtilities =
114114

115115
/// Converts a list of type args to its string representation.
116116
let typeArgsToString (text:string) (typeArgs:SynType list) =
117-
let typeStrings = typeArgs |> List.choose (synTypeToString text)
117+
let typeStrings = List.choose (synTypeToString text) typeArgs
118118
if typeStrings.Length = typeArgs.Length
119119
then typeStrings |> String.concat "," |> Some
120120
else None

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ let runner args =
6565
| _ -> Array.empty
6666

6767
let rule =
68-
{ Name = "AsyncExceptionWithoutReturn"
69-
Identifier = Identifiers.AsyncExceptionWithoutReturn
70-
RuleConfig =
71-
{ AstNodeRuleConfig.Runner = runner
72-
Cleanup = ignore } }
73-
|> AstNodeRule
68+
AstNodeRule
69+
{ Name = "AsyncExceptionWithoutReturn"
70+
Identifier = Identifiers.AsyncExceptionWithoutReturn
71+
RuleConfig =
72+
{ AstNodeRuleConfig.Runner = runner
73+
Cleanup = ignore } }

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

+8-10
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@ open FSharpLint.Framework.Rules
1010

1111
let runner (args: AstNodeRuleParams) =
1212
let errors range =
13-
{
14-
Range = range
15-
Message = String.Format(Resources.GetString ("RulesAvoidSinglePipeOperator"))
16-
SuggestedFix = None
17-
TypeChecks = List.Empty
18-
} |> Array.singleton
13+
Array.singleton
14+
{ Range = range
15+
Message = String.Format(Resources.GetString("RulesAvoidSinglePipeOperator"))
16+
SuggestedFix = None
17+
TypeChecks = List.Empty }
1918

2019
let error =
2120
match args.AstNode with
@@ -47,7 +46,6 @@ let runner (args: AstNodeRuleParams) =
4746

4847

4948
let rule =
50-
{ Name = "AvoidSinglePipeOperator"
51-
Identifier = Identifiers.AvoidSinglePipeOperator
52-
RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } }
53-
|> AstNodeRule
49+
AstNodeRule { Name = "AvoidSinglePipeOperator"
50+
Identifier = Identifiers.AvoidSinglePipeOperator
51+
RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } }

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ let runner (args:AstNodeRuleParams) =
9595
suggestions |> Array.map (fun suggestion -> { suggestion with TypeChecks = Option.toList typeCheck }))
9696

9797
let rule =
98-
{ Name = "AvoidTooShortNames"
99-
Identifier = Identifiers.AvoidTooShortNames
100-
RuleConfig =
101-
{ AstNodeRuleConfig.Runner = runner
102-
Cleanup = ignore } }
103-
|> AstNodeRule
98+
AstNodeRule
99+
{ Name = "AvoidTooShortNames"
100+
Identifier = Identifiers.AvoidTooShortNames
101+
RuleConfig =
102+
{ AstNodeRuleConfig.Runner = runner
103+
Cleanup = ignore } }

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

+3-4
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ let private runner (args:AstNodeRuleParams) =
3030

3131
/// Checks if any code uses 'let _ = ...' and suggests to use the ignore function.
3232
let rule =
33-
{ Name = "FavourIgnoreOverLetWild"
34-
Identifier = Identifiers.FavourIgnoreOverLetWild
35-
RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } }
36-
|> AstNodeRule
33+
AstNodeRule { Name = "FavourIgnoreOverLetWild"
34+
Identifier = Identifiers.FavourIgnoreOverLetWild
35+
RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } }

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ let private runner (args: AstNodeRuleParams) =
5050

5151
/// Checks if any code uses untyped ignore
5252
let rule =
53-
{ Name = "FavourTypedIgnore"
54-
Identifier = Identifiers.FavourTypedIgnore
55-
RuleConfig =
56-
{ AstNodeRuleConfig.Runner = runner
57-
Cleanup = ignore } }
58-
|> AstNodeRule
53+
AstNodeRule
54+
{ Name = "FavourTypedIgnore"
55+
Identifier = Identifiers.FavourTypedIgnore
56+
RuleConfig =
57+
{ AstNodeRuleConfig.Runner = runner
58+
Cleanup = ignore } }

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

+5-6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ let private checkTupleOfWildcards pattern identifier =
1414
| _ -> false
1515

1616
let constructorString numberOfWildcards =
17-
let constructorName = identifier |> String.concat "."
17+
let constructorName = String.concat "." identifier
1818
let arguments = Array.create numberOfWildcards "_" |> String.concat ", "
1919
constructorName + "(" + arguments + ")"
2020

@@ -47,14 +47,13 @@ let private runner (args:AstNodeRuleParams) =
4747
| AstNode.Pattern(SynPat.LongIdent(identifier, _, _, SynArgPats.Pats([SynPat.Paren(SynPat.Tuple(_, _, range) as pattern, _)]), _, _)) ->
4848
let breadcrumbs = args.GetParents 2
4949
if (not << isTupleMemberArgs breadcrumbs) range then
50-
let identifier = identifier.LongIdent |> List.map (fun x -> x.idText)
50+
let identifier = List.map (fun (x: Ident) -> x.idText) identifier.LongIdent
5151
checkTupleOfWildcards pattern identifier
5252
else
5353
Array.empty
5454
| _ -> Array.empty
5555

5656
let rule =
57-
{ Name = "TupleOfWildcards"
58-
Identifier = Identifiers.TupleOfWildcards
59-
RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } }
60-
|> AstNodeRule
57+
AstNodeRule { Name = "TupleOfWildcards"
58+
Identifier = Identifiers.TupleOfWildcards
59+
RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } }

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

+3-5
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ let private runner (args:AstNodeRuleParams) =
5757
Array.empty
5858

5959
let rule =
60-
{ Name = "UselessBinding"
61-
Identifier = Identifiers.UselessBinding
62-
RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } }
63-
|> AstNodeRule
64-
60+
AstNodeRule { Name = "UselessBinding"
61+
Identifier = Identifiers.UselessBinding
62+
RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } }

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

+3-5
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ let private runner (args:AstNodeRuleParams) =
2323
| _ -> Array.empty
2424

2525
let rule =
26-
{ Name = "WildcardNamedWithAsPattern"
27-
Identifier = Identifiers.WildcardNamedWithAsPattern
28-
RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } }
29-
|> AstNodeRule
30-
26+
AstNodeRule { Name = "WildcardNamedWithAsPattern"
27+
Identifier = Identifiers.WildcardNamedWithAsPattern
28+
RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } }

0 commit comments

Comments
 (0)