Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add F# Analyzers #603

Merged
merged 3 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
"commands": [
"fantomas"
]
},
"fsharp-analyzers": {
"version": "0.26.0",
"commands": [
"fsharp-analyzers"
]
}
}
}
28 changes: 27 additions & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,30 @@ jobs:
- name: Build
run: dotnet build -c Release --no-restore
- name: Test
run: dotnet test -c Release
run: dotnet test -c Release

analyzers:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
- name: Restore tools
run: dotnet tool restore
- name: Build solution
run: dotnet build -c Release Giraffe.sln

- name: Run Analyzers
run: dotnet msbuild /t:AnalyzeFSharpProject src/Giraffe/Giraffe.fsproj
# This is important, you want to continue your Action even if you found problems.
# As you always want the report to upload
continue-on-error: true
# checkout code, build, run analyzers, ...
- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v2
with:
# You can also specify the path to a folder for `sarif_file`
sarif_file: ./src/Giraffe/analysis.sarif
9 changes: 9 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project>
<PropertyGroup>
<FSharpAnalyzersOtherFlags>--analyzers-path &quot;$(PkgG-Research_FSharp_Analyzers)&quot;</FSharpAnalyzersOtherFlags>
<FSharpAnalyzersOtherFlags>$(FSharpAnalyzersOtherFlags) --analyzers-path &quot;$(PkgIonide_Analyzers)&quot;</FSharpAnalyzersOtherFlags>
<FSharpAnalyzersOtherFlags>$(FSharpAnalyzersOtherFlags) --configuration $(Configuration)</FSharpAnalyzersOtherFlags>
<FSharpAnalyzersOtherFlags>$(FSharpAnalyzersOtherFlags) --exclude-analyzers PartialAppAnalyzer</FSharpAnalyzersOtherFlags>
<FSharpAnalyzersOtherFlags>$(FSharpAnalyzersOtherFlags) --report &quot;analysis.sarif&quot;</FSharpAnalyzersOtherFlags>
</PropertyGroup>
</Project>
9 changes: 9 additions & 0 deletions Directory.Solution.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project>
<ItemGroup>
<ProjectsToAnalyze Include="src/**/*.fsproj" />
</ItemGroup>

<Target Name="AnalyzeSolution">
<MSBuild Projects="@(ProjectsToAnalyze)" Targets="AnalyzeFSharpProject" />
</Target>
</Project>
14 changes: 14 additions & 0 deletions src/Giraffe/Giraffe.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,20 @@
</ItemGroup>

<ItemGroup>
<!-- Analyzers -->
<PackageReference Include="FSharp.Analyzers.Build" Version="0.3.0">
<IncludeAssets>build</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="G-Research.FSharp.Analyzers" Version="0.10.0">
<IncludeAssets>analyzers</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Ionide.Analyzers" Version="0.11.0">
<IncludeAssets>analyzers</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>

<PackageReference Include="FSharp.Core" Version="6.0.0" />
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.*" />
<PackageReference Include="System.Text.Json" Version="8.0.*" />
Expand Down
Loading