Skip to content

Commit f01ab58

Browse files
committed
Fantomas
1 parent 8322eaa commit f01ab58

12 files changed

+69
-31
lines changed

src/Ionide.Analyzers/Ignore.fs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ open FSharp.Compiler.Text
66

77
[<RequireQualifiedAccess>]
88
module Ignore =
9-
9+
1010
/// checks there is an ignore comment on the line above the range
1111
let hasComment
12-
(magicComment : string)
13-
(comments : CommentTrivia list)
14-
(sourceText : ISourceText)
15-
(analyzerTriggeredOn : Range)
12+
(magicComment: string)
13+
(comments: CommentTrivia list)
14+
(sourceText: ISourceText)
15+
(analyzerTriggeredOn: Range)
1616
: CommentTrivia option
1717
=
1818
comments
@@ -23,6 +23,6 @@ module Ignore =
2323
if r.StartLine <> analyzerTriggeredOn.StartLine - 1 then
2424
false
2525
else
26-
let lineOfComment = sourceText.GetLineString (r.StartLine - 1) // 0-based
27-
lineOfComment.Contains (magicComment, StringComparison.OrdinalIgnoreCase)
28-
)
26+
let lineOfComment = sourceText.GetLineString(r.StartLine - 1) // 0-based
27+
lineOfComment.Contains(magicComment, StringComparison.OrdinalIgnoreCase)
28+
)

src/Ionide.Analyzers/InputOperations.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ module InputOperations =
77
let getCodeComments input =
88
match input with
99
| ParsedInput.ImplFile parsedFileInput -> parsedFileInput.Trivia.CodeComments
10-
| ParsedInput.SigFile parsedSigFileInput -> parsedSigFileInput.Trivia.CodeComments
10+
| ParsedInput.SigFile parsedSigFileInput -> parsedSigFileInput.Trivia.CodeComments

src/Ionide.Analyzers/Performance/EqualsNullAnalyzer.fs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,25 @@ let private analyze
3838
=
3939
let xs = HashSet<EqualsNullOperation>()
4040
let comments = InputOperations.getCodeComments parsedInput
41-
let hasIgnoreComment = Ignore.hasComment ignoreComment comments sourceText >> Option.isSome
41+
42+
let hasIgnoreComment =
43+
Ignore.hasComment ignoreComment comments sourceText >> Option.isSome
4244

4345
let collector =
4446
{ new SyntaxCollectorBase() with
4547
override x.WalkExpr(path, synExpr) =
4648
match synExpr with
4749
| SynExpr.App(ExprAtomicFlag.NonAtomic, false, OpEquality(opIdent, argExpr), SynExpr.Null _, m)
48-
| SynExpr.App(ExprAtomicFlag.NonAtomic, false, OpEquality(opIdent, SynExpr.Null _), argExpr, m) when not <| hasIgnoreComment m ->
50+
| SynExpr.App(ExprAtomicFlag.NonAtomic, false, OpEquality(opIdent, SynExpr.Null _), argExpr, m) when
51+
not <| hasIgnoreComment m
52+
->
4953
xs.Add(EqualsNullOperation(false, argExpr.Range, opIdent, addParens argExpr, m))
5054
|> ignore
5155

5256
| SynExpr.App(ExprAtomicFlag.NonAtomic, false, OpInequality(opIdent, argExpr), SynExpr.Null _, m)
53-
| SynExpr.App(ExprAtomicFlag.NonAtomic, false, OpInequality(opIdent, SynExpr.Null _), argExpr, m) when not <| hasIgnoreComment m ->
57+
| SynExpr.App(ExprAtomicFlag.NonAtomic, false, OpInequality(opIdent, SynExpr.Null _), argExpr, m) when
58+
not <| hasIgnoreComment m
59+
->
5460
xs.Add(EqualsNullOperation(true, argExpr.Range, opIdent, addParens argExpr, m))
5561
|> ignore
5662
| _ -> ()

src/Ionide.Analyzers/Performance/ListEqualsEmptyListAnalyzer.fs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,18 @@ let private analyze
3333
=
3434
let xs = HashSet<EqualsOperation>()
3535
let comments = InputOperations.getCodeComments parsedInput
36-
let hasIgnoreComment = Ignore.hasComment ignoreComment comments sourceText >> Option.isSome
36+
37+
let hasIgnoreComment =
38+
Ignore.hasComment ignoreComment comments sourceText >> Option.isSome
3739

3840
let collector =
3941
{ new SyntaxCollectorBase() with
4042
override x.WalkExpr(path, synExpr) =
4143
match synExpr with
4244
| SynExpr.App(ExprAtomicFlag.NonAtomic, false, OpEquality(operatorIdent, argExpr), EmptyList, m)
43-
| SynExpr.App(ExprAtomicFlag.NonAtomic, false, OpEquality(operatorIdent, EmptyList), argExpr, m) when not <| hasIgnoreComment m ->
45+
| SynExpr.App(ExprAtomicFlag.NonAtomic, false, OpEquality(operatorIdent, EmptyList), argExpr, m) when
46+
not <| hasIgnoreComment m
47+
->
4448
xs.Add(EqualsOperation(operatorIdent, argExpr.Range, m)) |> ignore
4549
| _ -> ()
4650
}

src/Ionide.Analyzers/Performance/ReturnStructPartialActivePatternAnalyzer.fs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ let rec collectSomeAndNoneFromExprBody (expr: SynExpr) (finalContinuation: Ident
101101
let analyze (sourceText: ISourceText) (parsedInput: ParsedInput) (checkResults: FSharpCheckFileResults) : Message list =
102102
let idents = HashSet<FixData>()
103103
let comments = InputOperations.getCodeComments parsedInput
104-
let hasIgnoreComment = Ignore.hasComment ignoreComment comments sourceText >> Option.isSome
104+
105+
let hasIgnoreComment =
106+
Ignore.hasComment ignoreComment comments sourceText >> Option.isSome
105107

106108
let collector =
107109
{ new SyntaxCollectorBase() with

src/Ionide.Analyzers/Style/PostfixGenericsAnalyzer.fs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ let analyze (sourceText: ISourceText) (input: ParsedInput) =
1818
{ new SyntaxCollectorBase() with
1919
override x.WalkType(_, t: SynType) =
2020
match t, hasIgnoreComment t.Range with
21-
| SynType.Array _, None ->
22-
ts.Add("Prefer postfix syntax for arrays.", t.Range)
21+
| SynType.Array _, None -> ts.Add("Prefer postfix syntax for arrays.", t.Range)
2322
| SynType.App(typeName = SynType.LongIdent synLongIdent; isPostfix = false), None ->
2423
match synLongIdent.LongIdent with
2524
| [ ident ] ->
@@ -66,4 +65,4 @@ let postfixGenericsEditorAnalyzer (ctx: EditorContext) =
6665

6766
[<CliAnalyzer(name, shortDescription, helpUri)>]
6867
let postfixGenericsCliAnalyzer (ctx: CliContext) =
69-
async { return analyze ctx.SourceText ctx.ParseFileResults.ParseTree }
68+
async { return analyze ctx.SourceText ctx.ParseFileResults.ParseTree }

src/Ionide.Analyzers/Suggestion/CopyAndUpdateRecordChangesAllFieldsAnalyzer.fs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ let ignoreComment = "IGNORE: IONIDE-001"
1414

1515
let analyze sourceText parseTree (typedTree: FSharpImplementationFileContents option) =
1616
let comments = InputOperations.getCodeComments parseTree
17-
let hasIgnoreComment = Ignore.hasComment ignoreComment comments sourceText >> Option.isSome
17+
18+
let hasIgnoreComment =
19+
Ignore.hasComment ignoreComment comments sourceText >> Option.isSome
1820

1921
let untypedRecordUpdates =
2022
let xs = ResizeArray<UpdateRecord>()
@@ -23,7 +25,9 @@ let analyze sourceText parseTree (typedTree: FSharpImplementationFileContents op
2325
{ new SyntaxCollectorBase() with
2426
override x.WalkExpr(_, e: SynExpr) =
2527
match e with
26-
| SynExpr.Record(copyInfo = Some(synExpr, (withRange, _)); recordFields = fields; range = m) when not <| hasIgnoreComment m ->
28+
| SynExpr.Record(copyInfo = Some(synExpr, (withRange, _)); recordFields = fields; range = m) when
29+
not <| hasIgnoreComment m
30+
->
2731
let fixRange = Range.unionRanges synExpr.Range (Range.shiftEnd 0 1 withRange)
2832
xs.Add(fields, e.Range, fixRange)
2933
| _ -> ()
@@ -85,8 +89,10 @@ let helpUri = "https://ionide.io/ionide-analyzers/suggestion/001.html"
8589

8690
[<CliAnalyzer(name, shortDescription, helpUri)>]
8791
let copyAndUpdateRecordChangesAllFieldsCliAnalyzer: Analyzer<CliContext> =
88-
fun (context: CliContext) -> async { return analyze context.SourceText context.ParseFileResults.ParseTree context.TypedTree }
92+
fun (context: CliContext) ->
93+
async { return analyze context.SourceText context.ParseFileResults.ParseTree context.TypedTree }
8994

9095
[<EditorAnalyzer(name, shortDescription, helpUri)>]
9196
let copyAndUpdateRecordChangesAllFieldsEditorAnalyzer: Analyzer<EditorContext> =
92-
fun (context: EditorContext) -> async { return analyze context.SourceText context.ParseFileResults.ParseTree context.TypedTree }
97+
fun (context: EditorContext) ->
98+
async { return analyze context.SourceText context.ParseFileResults.ParseTree context.TypedTree }

src/Ionide.Analyzers/Suggestion/EmptyStringAnalyzer.fs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,18 @@ let helpUri = "https://ionide.io/ionide-analyzers/suggestion/005.html"
6262

6363
[<EditorAnalyzer(name, shortDescription, helpUri)>]
6464
let emptyStringEditorAnalyzer (ctx: EditorContext) =
65-
async { return ctx.TypedTree |> Option.map (analyze ctx.SourceText ctx.ParseFileResults.ParseTree) |> Option.defaultValue [] }
65+
async {
66+
return
67+
ctx.TypedTree
68+
|> Option.map (analyze ctx.SourceText ctx.ParseFileResults.ParseTree)
69+
|> Option.defaultValue []
70+
}
6671

6772
[<CliAnalyzer(name, shortDescription, helpUri)>]
6873
let emptyStringCliAnalyzer (ctx: CliContext) =
69-
async { return ctx.TypedTree |> Option.map (analyze ctx.SourceText ctx.ParseFileResults.ParseTree) |> Option.defaultValue [] }
74+
async {
75+
return
76+
ctx.TypedTree
77+
|> Option.map (analyze ctx.SourceText ctx.ParseFileResults.ParseTree)
78+
|> Option.defaultValue []
79+
}

src/Ionide.Analyzers/Suggestion/HandleOptionGracefullyAnalyzer.fs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ let shortDescription =
6464
let helpUri = "https://ionide.io/ionide-analyzers/suggestion/006.html"
6565

6666
[<CliAnalyzer(name, shortDescription, helpUri)>]
67-
let optionGetCliAnalyzer (ctx: CliContext) = async { return analyze ctx.SourceText ctx.ParseFileResults.ParseTree ctx.TypedTree }
67+
let optionGetCliAnalyzer (ctx: CliContext) =
68+
async { return analyze ctx.SourceText ctx.ParseFileResults.ParseTree ctx.TypedTree }
6869

6970
[<EditorAnalyzer(name, shortDescription, helpUri)>]
70-
let optionGetEditorAnalyzer (ctx: EditorContext) = async { return analyze ctx.SourceText ctx.ParseFileResults.ParseTree ctx.TypedTree }
71+
let optionGetEditorAnalyzer (ctx: EditorContext) =
72+
async { return analyze ctx.SourceText ctx.ParseFileResults.ParseTree ctx.TypedTree }

src/Ionide.Analyzers/Suggestion/HeadConsEmptyListPatternAnalyzer.fs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,18 @@ let message = "Replace `x :: _` with `[ x ]`"
1616
let private analyze (sourceText: ISourceText) (parsedInput: ParsedInput) =
1717
let patterns = HashSet<range * string option>()
1818
let comments = InputOperations.getCodeComments parsedInput
19-
let hasIgnoreComment = Ignore.hasComment ignoreComment comments sourceText >> Option.isSome
19+
20+
let hasIgnoreComment =
21+
Ignore.hasComment ignoreComment comments sourceText >> Option.isSome
2022

2123
let collector =
2224
{ new SyntaxCollectorBase() with
2325
override x.WalkPat(path, synPat) =
2426
match synPat with
25-
| SynPat.ListCons(lhsPat = lhsPat; rhsPat = SynPat.ArrayOrList(isArray = false; elementPats = []); range = m) when not <| hasIgnoreComment m ->
27+
| SynPat.ListCons(
28+
lhsPat = lhsPat; rhsPat = SynPat.ArrayOrList(isArray = false; elementPats = []); range = m) when
29+
not <| hasIgnoreComment m
30+
->
2631
let text =
2732
if lhsPat.Range.StartLine <> lhsPat.Range.EndLine then
2833
None

0 commit comments

Comments
 (0)