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

Analyzers integration test1 via custom msbuild target #6

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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.16.0",
"commands": [
"fsharp-analyzers"
]
}
}
}
4 changes: 4 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ jobs:
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: analysis.sarif
4 changes: 2 additions & 2 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ rm -Recurse -Force -ErrorAction Ignore ./nupkg
dotnet tool restore
dotnet fantomas .
dotnet build -c Release
dotnet test -c Release
dotnet pack -c Release
dotnet test -c Release --no-build
dotnet pack -c Release --no-build
7 changes: 7 additions & 0 deletions src/Fats/AnalyzersDemo.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Fats.AnalyzersDemo

let f x y = x + y

let g x = f x

Check warning

Code scanning / Ionide.Analyzers.Cli

Warns when partial application is being used. Warning

Partial application should not be used.

Check warning

Code scanning / Ionide.Analyzers.Cli

Warns when partial application is being used. Warning

Partial application should not be used.

let h (s: string) = s.StartsWith("foo")

Check warning

Code scanning / Ionide.Analyzers.Cli

Verifies the correct usage of System.String.StartsWith Warning

The usage of String.StartsWith with a single string argument is discouraged. Signal your intention explicitly by calling an overload.

Check warning

Code scanning / Ionide.Analyzers.Cli

Verifies the correct usage of System.String.StartsWith Warning

The usage of String.StartsWith with a single string argument is discouraged. Signal your intention explicitly by calling an overload.
10 changes: 10 additions & 0 deletions src/Fats/Fats.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,22 @@
<Compile Include="Core.fs" />
<Compile Include="IO.fs" />
<Compile Include="SarifReport.fs" />
<Compile Include="AnalyzersDemo.fs" />
<Compile Include="Program.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Argu" Version="6.1.1" />
<PackageReference Include="Ionide.KeepAChangelog.Tasks" Version="0.1.8" />
<PackageReference Include="Sarif.Sdk" Version="4.3.4" />
<PackageReference Include="Spectre.Console" Version="0.47.0" />
<PackageReference Include="G-Research.FSharp.Analyzers" Version="0.1.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>build</IncludeAssets>
</PackageReference>
</ItemGroup>

<Target Name="Analyze" BeforeTargets="Build">
<Exec Command= "dotnet fsharp-analyzers --project $(MSBuildProjectFile) --analyzers-path $(PkgG-Research_FSharp_Analyzers) --verbose --report $(SolutionDir)/analysis.sarif" />
</Target>

</Project>