-
-
Notifications
You must be signed in to change notification settings - Fork 159
/
inspectcode.ps1
27 lines (20 loc) · 1.19 KB
/
inspectcode.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#Requires -Version 7.0
# This script runs code inspection and opens the results in a web browser.
dotnet tool restore
if ($LastExitCode -ne 0) {
throw "Tool restore failed with exit code $LastExitCode"
}
$outputPath = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), 'jetbrains-inspectcode-results.xml')
$resultPath = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), 'jetbrains-inspectcode-results.html')
dotnet jb inspectcode JsonApiDotNetCore.sln --dotnetcoresdk=$(dotnet --version) --build --output="$outputPath" --format="xml" --profile=WarningSeverities.DotSettings --properties:Configuration=Release --properties:RunAnalyzers=false --severity=WARNING --verbosity=WARN -dsl=GlobalAll -dsl=GlobalPerProduct -dsl=SolutionPersonal -dsl=ProjectPersonal
if ($LastExitCode -ne 0) {
throw "Code inspection failed with exit code $LastExitCode"
}
[xml]$xml = Get-Content "$outputPath"
if ($xml.report.Issues -and $xml.report.Issues.Project) {
$xslt = new-object System.Xml.Xsl.XslCompiledTransform;
$xslt.Load("$pwd/JetBrainsInspectCodeTransform.xslt");
$xslt.Transform($outputPath, $resultPath);
Write-Output "Opening results in browser"
Invoke-Item "$resultPath"
}