Skip to content

Commit eb1f16f

Browse files
authored
Merge pull request #958 from nojaf/single-sarif
Run analyzers for all projects
2 parents 2bd545e + 72659b0 commit eb1f16f

File tree

11 files changed

+63
-52
lines changed

11 files changed

+63
-52
lines changed

.config/dotnet-tools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
]
1010
},
1111
"fsharp-analyzers": {
12-
"version": "0.26.0",
12+
"version": "0.32.1",
1313
"commands": [
1414
"fsharp-analyzers"
1515
]

.github/workflows/pull-requests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ jobs:
3434
uses: github/codeql-action/upload-sarif@v3
3535
if: matrix.os == 'ubuntu-latest'
3636
with:
37-
sarif_file: ./reports
37+
sarif_file: ./analysis.sarif

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@ tests/FSharp.Literate.Tests/output2/
5050
tests/FSharp.Literate.Tests/previous-next-output/
5151

5252
# Analyzer
53-
reports/
53+
analysis.sarif

Directory.Packages.props

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
<PackageVersion Include="NUnit3TestAdapter" Version="4.5.0" />
2727
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
2828
<PackageVersion Include="Ionide.KeepAChangelog.Tasks" Version="0.1.8" />
29-
<PackageVersion Include="FSharp.Analyzers.Build" Version="0.3.0" />
30-
<PackageVersion Include="G-Research.FSharp.Analyzers" Version="0.10.0" />
31-
<PackageVersion Include="Ionide.Analyzers" Version="0.11.0" />
29+
<PackageVersion Include="G-Research.FSharp.Analyzers" Version="0.18.0" />
30+
<PackageVersion Include="Ionide.Analyzers" Version="0.14.7" />
3231
</ItemGroup>
3332
</Project>

Directory.Solution.targets

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,26 @@
11
<Project>
2-
<ItemGroup>
3-
<ProjectsToAnalyze Include="src/**/*.fsproj" />
4-
</ItemGroup>
2+
<!-- Import the NuGet props file to get access to Pkg* variables -->
3+
<Import Project="src/FSharp.Formatting/obj/FSharp.Formatting.fsproj.nuget.g.props" Condition="Exists('src/FSharp.Formatting/obj/FSharp.Formatting.fsproj.nuget.g.props')" />
54

6-
<Target Name="AnalyzeSolution">
7-
<MSBuild Projects="@(ProjectsToAnalyze)" Targets="AnalyzeFSharpProject" />
8-
</Target>
9-
</Project>
5+
<ItemGroup>
6+
<ProjectsToAnalyze Include="src/**/*.fsproj" />
7+
</ItemGroup>
8+
9+
<Target Name="AnalyzeSolution" Condition="Exists('src/FSharp.Formatting/obj/FSharp.Formatting.fsproj.nuget.g.props')">
10+
<PropertyGroup>
11+
<CodeRoot>$(SolutionDir)</CodeRoot>
12+
<FSharpAnalyzersOtherFlags>--analyzers-path &quot;$(PkgG-Research_FSharp_Analyzers)/analyzers/dotnet/fs&quot;</FSharpAnalyzersOtherFlags>
13+
<FSharpAnalyzersOtherFlags>$(FSharpAnalyzersOtherFlags) --analyzers-path &quot;$(PkgIonide_Analyzers)/analyzers/dotnet/fs&quot;</FSharpAnalyzersOtherFlags>
14+
<FSharpAnalyzersOtherFlags>$(FSharpAnalyzersOtherFlags) --exclude-analyzers PartialAppAnalyzer ReturnStructPartialActivePatternAnalyzer -c Release</FSharpAnalyzersOtherFlags>
15+
<FSharpAnalyzersOtherFlags>$(FSharpAnalyzersOtherFlags) --code-root $(CodeRoot)</FSharpAnalyzersOtherFlags>
16+
<FSharpAnalyzersOtherFlags>$(FSharpAnalyzersOtherFlags) --report &quot;$(CodeRoot)/analysis.sarif&quot;</FSharpAnalyzersOtherFlags>
17+
</PropertyGroup>
18+
<Delete Files="$(SolutionDir)/analysis.sarif" Condition="Exists('$(SolutionDir)/analysis.sarif')" />
19+
20+
<!-- Execute fsharp-analyzers with all projects in a single process -->
21+
<Exec
22+
Command="dotnet fsharp-analyzers $(FSharpAnalyzersOtherFlags) @(ProjectsToAnalyze->'--project &quot;%(FullPath)&quot;', ' ')"
23+
ContinueOnError="true"
24+
/>
25+
</Target>
26+
</Project>

src/Directory.Build.props

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
<Project>
22
<Import Project="../Directory.Build.props" />
33
<ItemGroup>
4-
<PackageReference Include="FSharp.Analyzers.Build">
5-
<PrivateAssets>all</PrivateAssets>
6-
<IncludeAssets>build</IncludeAssets>
7-
</PackageReference>
84
<PackageReference Include="G-Research.FSharp.Analyzers">
95
<PrivateAssets>all</PrivateAssets>
106
<IncludeAssets>analyzers</IncludeAssets>

src/Directory.Build.targets

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/FSharp.Formatting.ApiDocs/Categorise.fs

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,28 +53,32 @@ let entities (nsIndex: int, ns: ApiDocNamespace, suppress) =
5353
// TODO: use <exclude /> to do these, or work out if there's a better way
5454
if suppress then
5555
categoryEntities
56-
57-
// Remove FSharp.Data.UnitSystems.SI from the list-of-namespaces
58-
// display - it's just so rarely used, has long names and dominates the docs.
59-
//
60-
// See https://github.com/fsharp/fsharp-core-docs/issues/57, we may rethink this
61-
|> List.filter (fun e ->
62-
(e.Symbol.Namespace <> Some "Microsoft.FSharp.Data.UnitSystems.SI.UnitSymbols"))
63-
|> List.filter (fun e ->
64-
(e.Symbol.Namespace <> Some "Microsoft.FSharp.Data.UnitSystems.SI.UnitNames"))
65-
// Don't show 'AnonymousObject' in list-of-namespaces navigation
6656
|> List.filter (fun e ->
57+
// Remove FSharp.Data.UnitSystems.SI from the list-of-namespaces
58+
// display - it's just so rarely used, has long names and dominates the docs.
59+
//
60+
// See https://github.com/fsharp/fsharp-core-docs/issues/57, we may rethink this
61+
(e.Symbol.Namespace <> Some "Microsoft.FSharp.Data.UnitSystems.SI.UnitSymbols")
62+
&& (e.Symbol.Namespace <> Some "Microsoft.FSharp.Data.UnitSystems.SI.UnitNames")
63+
64+
&&
65+
66+
// Don't show 'AnonymousObject' in list-of-namespaces navigation
6767
not (
6868
e.Symbol.Namespace = Some "Microsoft.FSharp.Linq.RuntimeHelpers"
6969
&& e.Symbol.DisplayName = "AnonymousObject"
70-
))
71-
// Don't show 'FSharp.Linq.QueryRunExtensions' in list-of-namespaces navigation
72-
|> List.filter (fun e ->
70+
)
71+
72+
&&
73+
74+
// Don't show 'FSharp.Linq.QueryRunExtensions' in list-of-namespaces navigation
7375
not (
7476
e.Symbol.Namespace = Some "Microsoft.FSharp.Linq.QueryRunExtensions"
7577
&& e.Symbol.DisplayName = "LowPriority"
76-
))
77-
|> List.filter (fun e ->
78+
)
79+
80+
&&
81+
7882
not (
7983
e.Symbol.Namespace = Some "Microsoft.FSharp.Linq.QueryRunExtensions"
8084
&& e.Symbol.DisplayName = "HighPriority"

src/FSharp.Formatting.ApiDocs/GenerateModel.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ type internal CrossReferenceResolver(root, collectionName, qualify, extensions)
870870

871871
let tryGetTypeFromMemberName (memberName: string) =
872872
let sub = removeParen memberName
873-
let lastPeriod = sub.LastIndexOf(".")
873+
let lastPeriod = sub.LastIndexOf('.')
874874

875875
if lastPeriod > 0 then
876876
Some(memberName.Substring(0, lastPeriod))
@@ -879,7 +879,7 @@ type internal CrossReferenceResolver(root, collectionName, qualify, extensions)
879879

880880
let tryGetShortMemberNameFromMemberName (memberName: string) =
881881
let sub = removeParen memberName
882-
let lastPeriod = sub.LastIndexOf(".")
882+
let lastPeriod = sub.LastIndexOf('.')
883883

884884
if lastPeriod > 0 then
885885
Some(memberName.Substring(lastPeriod + 1))

src/FSharp.Formatting.Common/YaafFSharpScripting.fs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -282,14 +282,18 @@ module internal CompilerServiceExtensions =
282282
|> Seq.filter (fun file ->
283283
let fileName = Path.GetFullPath file |> Path.GetFileName
284284

285-
dllFiles
286-
|> List.exists (fun (dllFile: string) -> Path.GetFileName dllFile =? fileName)
287-
|> not)
288-
|> Seq.filter (fun file ->
289-
if Path.GetFileName file =? "FSharp.Core.dll" then
290-
FSharpAssemblyHelper.tryCheckFsCore file |> Option.isSome
291-
else
292-
true)
285+
let dllNotAlreadyReferenced =
286+
dllFiles
287+
|> List.exists (fun (dllFile: string) -> Path.GetFileName dllFile =? fileName)
288+
|> not
289+
290+
let checkFSharpCore =
291+
if Path.GetFileName file =? "FSharp.Core.dll" then
292+
FSharpAssemblyHelper.tryCheckFsCore file |> Option.isSome
293+
else
294+
true
295+
296+
dllNotAlreadyReferenced && checkFSharpCore)
293297
|> Seq.toList
294298

295299
// See https://github.com/tpetricek/FSharp.Formatting/commit/5d14f45cd7e70c2164a7448ea50a6b9995166489
@@ -350,7 +354,6 @@ type internal FsiEvaluationException
350354
(Log.formatArgs args)
351355
(base.ToString())
352356

353-
354357
/// Exception for invalid expression types
355358
type internal FsiExpressionTypeException =
356359
val private value: obj option

0 commit comments

Comments
 (0)