Skip to content

Commit f5084cd

Browse files
committed
Added fsharp-analyzers to fbuild & vscode IDE
1 parent edc9ae0 commit f5084cd

File tree

5 files changed

+81
-28
lines changed

5 files changed

+81
-28
lines changed

.config/dotnet-tools.json

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,41 @@
11
{
2-
"version": 1,
3-
"isRoot": true,
4-
"tools": {
5-
"paket": {
6-
"version": "8.0.3",
7-
"commands": [
8-
"paket"
9-
]
10-
},
11-
"fable": {
12-
"version": "4.4.0",
13-
"commands": [
14-
"fable"
15-
]
16-
},
17-
"fantomas": {
18-
"version": "6.0.0-alpha-010",
19-
"commands": [
20-
"fantomas"
21-
]
22-
},
23-
"femto": {
24-
"version": "0.19.0",
25-
"commands": [
26-
"femto"
27-
]
28-
}
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {
5+
"paket": {
6+
"version": "8.0.3",
7+
"commands": [
8+
"paket"
9+
],
10+
"rollForward": false
11+
},
12+
"fable": {
13+
"version": "4.4.0",
14+
"commands": [
15+
"fable"
16+
],
17+
"rollForward": false
18+
},
19+
"fantomas": {
20+
"version": "6.0.0-alpha-010",
21+
"commands": [
22+
"fantomas"
23+
],
24+
"rollForward": false
25+
},
26+
"femto": {
27+
"version": "0.19.0",
28+
"commands": [
29+
"femto"
30+
],
31+
"rollForward": false
32+
},
33+
"fsharp-analyzers": {
34+
"version": "0.28.0",
35+
"commands": [
36+
"fsharp-analyzers"
37+
],
38+
"rollForward": false
2939
}
40+
}
3041
}

.vscode/settings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@
77
"BoundModel.TypeCheck",
88
"BackgroundCompiler."
99
],
10-
"FSharp.fsac.parallelReferenceResolution": false
10+
"FSharp.fsac.parallelReferenceResolution": false,
11+
"FSharp.enableAnalyzers": true,
12+
"FSharp.analyzersPath": ["packages/analyzers"]
1113
}

build/build.fs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,37 @@ module dotnet =
136136

137137
let fantomas args = DotNet.exec id "fantomas" args
138138

139+
let analyzers args = DotNet.exec id "fsharp-analyzers" args
140+
139141

140142
let formatCode _ =
141143
let result = dotnet.fantomas "."
142144

143145
if not result.OK then
144146
Trace.traceErrorfn "Errors while formatting all files: %A" result.Messages
145147

148+
let analyze _ =
149+
let analyzerPaths = !! "packages/analyzers/**/analyzers/dotnet/fs"
150+
151+
let createArgsForProject project analyzerPaths =
152+
[
153+
yield "--project"
154+
yield project
155+
yield "--analyzers-path"
156+
yield! analyzerPaths
157+
]
158+
|> String.concat " "
159+
160+
!! "src/**/*.fsproj"
161+
|> Seq.iter (fun fsproj ->
162+
let result =
163+
createArgsForProject fsproj analyzerPaths
164+
|> dotnet.analyzers
165+
166+
result.Errors
167+
|> Seq.iter Trace.traceError
168+
)
169+
146170

147171
let checkFormatCode _ =
148172
let result = dotnet.fantomas "--check ."
@@ -443,6 +467,7 @@ let initTargets () =
443467
Target.create "DotnetPack" dotnetPack
444468
Target.create "FormatCode" formatCode
445469
Target.create "CheckFormatCode" checkFormatCode
470+
Target.create "Analyzers" analyze
446471
Target.create "PublishToNuGet" publishNuget
447472
Target.create "GitRelease" gitRelease
448473
Target.create "GitHubRelease" githubRelease
@@ -466,6 +491,9 @@ let initTargets () =
466491
"DotnetRestore"
467492
==>! "CheckFormatCode"
468493

494+
"DotnetRestore"
495+
==>! "Analyzers"
496+
469497
//*** Dotnet Build ***//
470498
"DotnetRestore"
471499
==>! "Build"

paket.dependencies

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,9 @@ group Build
5656
nuget Nuget.Common >= 6.6.1
5757
nuget NuGet.Protocol >= 6.6.1
5858
nuget System.Security.Cryptography.Pkcs >= 7.0.2
59+
60+
group analyzers
61+
source https://api.nuget.org/v3/index.json
62+
63+
nuget Ionide.Analyzers
64+
nuget G-Research.FSharp.Analyzers

paket.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ NUGET
2424
System.Threading.Tasks.Extensions (4.5.4) - restriction: == netstandard2.0
2525
System.Runtime.CompilerServices.Unsafe (>= 4.5.3) - restriction: || (&& (< monoandroid) (< monotouch) (< net45) (>= netstandard1.0) (< netstandard2.0) (< win8) (< wpa81) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (< netstandard1.0) (>= portable-net45+win8+wp8+wpa81) (< win8)) (&& (>= net45) (< netstandard2.0)) (&& (< net45) (< netcoreapp2.1) (>= netstandard2.0) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (>= net461) (&& (< netstandard1.0) (>= win8)) (&& (< netstandard2.0) (>= wpa81)) (>= wp8)
2626

27+
GROUP analyzers
28+
NUGET
29+
remote: https://api.nuget.org/v3/index.json
30+
G-Research.FSharp.Analyzers (0.12)
31+
Ionide.Analyzers (0.13)
32+
2733
GROUP Benchmarks
2834
STORAGE: NONE
2935
NUGET

0 commit comments

Comments
 (0)