Skip to content

Commit 9dfcd78

Browse files
committed
Core: fix FSharpLint warning
Fixing the warning avoidSinglePipeOperator rule.
1 parent 0c82d80 commit 9dfcd78

File tree

72 files changed

+1032
-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

+1032
-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
@@ -190,16 +190,17 @@ module Lint =
190190
}
191191

192192
let indentationError =
193-
config.LineRules.IndentationRule
194-
|> Option.map (fun rule -> runLineRuleWithContext rule config.Context.IndentationRuleContext lineParams)
193+
Option.map
194+
(fun rule -> runLineRuleWithContext rule config.Context.IndentationRuleContext lineParams)
195+
config.LineRules.IndentationRule
195196

196197
let noTabCharactersError =
197-
config.LineRules.NoTabCharactersRule
198-
|> Option.map (fun rule -> runLineRuleWithContext rule config.Context.NoTabCharactersRuleContext lineParams)
198+
Option.map
199+
(fun rule -> runLineRuleWithContext rule config.Context.NoTabCharactersRuleContext lineParams)
200+
config.LineRules.NoTabCharactersRule
199201

200202
let lineErrors =
201-
config.LineRules.GenericLineRules
202-
|> Array.collect (fun rule -> runLineRule rule lineParams)
203+
Array.collect (fun rule -> runLineRule rule lineParams) config.LineRules.GenericLineRules
203204

204205
[|
205206
indentationError |> Option.toArray
@@ -473,7 +474,7 @@ module Lint =
473474
|> List.filter (not << isIgnoredFile)
474475
|> List.map (fun file -> ParseFile.parseFile file checker (Some projectOptions))
475476

476-
let failedFiles = parsedFiles |> List.choose getFailedFiles
477+
let failedFiles = List.choose getFailedFiles parsedFiles
477478

478479
if List.isEmpty failedFiles then
479480
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

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

8790
/// Operator identifiers can be made up of "op_" followed by a sequence of operators from this list.
8891
let operators =
@@ -116,7 +119,7 @@ module AstInfo =
116119
if Seq.isEmpty str then
117120
true
118121
else
119-
let operator = operators |> List.tryFind (fun op -> str.StartsWith(op))
122+
let operator = List.tryFind (fun (op: string) -> str.StartsWith(op)) operators
120123

121124
match operator with
122125
| Some(operator) -> str.Substring(operator.Length) |> isSequenceOfOperators

src/FSharpLint.Core/Framework/HintParser.fs

+14-12
Original file line numberDiff line numberDiff line change
@@ -480,16 +480,19 @@ 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+
('\'', '\'')
488+
('n', '\n')
489+
('t', '\t')
490+
('b', '\b')
491+
('r', '\r')
492+
('a', '\a')
493+
('f', '\f')
494+
('v', '\v')
495+
]
493496

494497
let private pescapechar: Parser<char, unit> =
495498
skipChar '\\'
@@ -622,8 +625,7 @@ module HintParser =
622625
let private pminus: Parser<char, unit> = pchar '-'
623626

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

628630
let private phexint: Parser<char list, unit> =
629631
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

+10-6
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,13 @@ 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+
{
70+
Name = "AsyncExceptionWithoutReturn"
71+
Identifier = Identifiers.AsyncExceptionWithoutReturn
72+
RuleConfig =
73+
{
74+
AstNodeRuleConfig.Runner = runner
75+
Cleanup = ignore
76+
}
77+
}

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

+17-10
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ 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+
{
15+
Range = range
16+
Message = String.Format(Resources.GetString("RulesAvoidSinglePipeOperator"))
17+
SuggestedFix = None
18+
TypeChecks = List.Empty
19+
}
1920

2021
let error =
2122
match args.AstNode with
@@ -47,7 +48,13 @@ let runner (args: AstNodeRuleParams) =
4748

4849

4950
let rule =
50-
{ Name = "AvoidSinglePipeOperator"
51-
Identifier = Identifiers.AvoidSinglePipeOperator
52-
RuleConfig = { AstNodeRuleConfig.Runner = runner; Cleanup = ignore } }
53-
|> AstNodeRule
51+
AstNodeRule
52+
{
53+
Name = "AvoidSinglePipeOperator"
54+
Identifier = Identifiers.AvoidSinglePipeOperator
55+
RuleConfig =
56+
{
57+
AstNodeRuleConfig.Runner = runner
58+
Cleanup = ignore
59+
}
60+
}

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

+10-6
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,13 @@ 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+
{
100+
Name = "AvoidTooShortNames"
101+
Identifier = Identifiers.AvoidTooShortNames
102+
RuleConfig =
103+
{
104+
AstNodeRuleConfig.Runner = runner
105+
Cleanup = ignore
106+
}
107+
}

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

+10-4
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ 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
34+
{
35+
Name = "FavourIgnoreOverLetWild"
36+
Identifier = Identifiers.FavourIgnoreOverLetWild
37+
RuleConfig =
38+
{
39+
AstNodeRuleConfig.Runner = runner
40+
Cleanup = ignore
41+
}
42+
}

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

+10-6
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,13 @@ 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+
{
55+
Name = "FavourTypedIgnore"
56+
Identifier = Identifiers.FavourTypedIgnore
57+
RuleConfig =
58+
{
59+
AstNodeRuleConfig.Runner = runner
60+
Cleanup = ignore
61+
}
62+
}

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

+12-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,20 @@ 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
58+
{
59+
Name = "TupleOfWildcards"
60+
Identifier = Identifiers.TupleOfWildcards
61+
RuleConfig =
62+
{
63+
AstNodeRuleConfig.Runner = runner
64+
Cleanup = ignore
65+
}
66+
}

0 commit comments

Comments
 (0)