mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-16 17:48:05 +00:00
doc headers
This commit is contained in:
+26
-27
@@ -28,7 +28,7 @@ if (-not (Test-Path $NDBadgePath)) {
|
||||
|
||||
if (-not (Test-Path $XmlPath)) {
|
||||
Write-Error "NDepend trend data XML not found at: $XmlPath"
|
||||
Write-Host "Please run ndepend.ps1 first to generate analysis data" -ForegroundColor Yellow
|
||||
Write-Information "Please run ndepend.ps1 first to generate analysis data"
|
||||
exit 1
|
||||
}
|
||||
|
||||
@@ -40,54 +40,53 @@ if (-not (Test-Path $OutputDir)) {
|
||||
New-Item -ItemType Directory -Path $OutputDir -Force | Out-Null
|
||||
}
|
||||
|
||||
Write-Host "=== Generating QuanTAlib Quality Badges ===" -ForegroundColor Cyan
|
||||
Write-Host "Output directory: $OutputDir`n" -ForegroundColor Gray
|
||||
Write-Information "=== Generating QuanTAlib Quality Badges ==="
|
||||
Write-Information "Output directory: $OutputDir`n"
|
||||
|
||||
# Selected badges for QuanTAlib README
|
||||
Write-Host "Generating QuanTAlib badges..." -ForegroundColor Green
|
||||
Write-Information "Generating QuanTAlib badges..."
|
||||
|
||||
$HighValueBadges = @(
|
||||
@{
|
||||
Metric = "# Lines of Code"
|
||||
Output = "loc.svg"
|
||||
Metric = "# Lines of Code"
|
||||
Output = "loc.svg"
|
||||
Description = "Total lines of code"
|
||||
},
|
||||
@{
|
||||
Metric = "# Source Files"
|
||||
Output = "files.svg"
|
||||
Metric = "# Source Files"
|
||||
Output = "files.svg"
|
||||
Description = "Source files"
|
||||
},
|
||||
@{
|
||||
Metric = "# Classes"
|
||||
Output = "classes.svg"
|
||||
Metric = "# Classes"
|
||||
Output = "classes.svg"
|
||||
Description = "Classes"
|
||||
},
|
||||
@{
|
||||
Metric = "# Methods"
|
||||
Output = "methods.svg"
|
||||
Metric = "# Methods"
|
||||
Output = "methods.svg"
|
||||
Description = "Methods"
|
||||
},
|
||||
@{
|
||||
Metric = "# Public Types"
|
||||
Output = "public-api.svg"
|
||||
Metric = "# Public Types"
|
||||
Output = "public-api.svg"
|
||||
Description = "Public API surface"
|
||||
},
|
||||
@{
|
||||
Metric = "Percentage of Comments"
|
||||
Output = "comments.svg"
|
||||
Metric = "Percentage of Comments"
|
||||
Output = "comments.svg"
|
||||
Description = "Comment percentage"
|
||||
},
|
||||
@{
|
||||
Metric = "Average Cyclomatic Complexity for Methods"
|
||||
Output = "complexity.svg"
|
||||
Metric = "Average Cyclomatic Complexity for Methods"
|
||||
Output = "complexity.svg"
|
||||
Description = "Average complexity"
|
||||
}
|
||||
)
|
||||
|
||||
foreach ($badge in $HighValueBadges) {
|
||||
$outputPath = Join-Path $OutputDir $badge.Output
|
||||
Write-Host " [$($badge.Output)]" -ForegroundColor Cyan -NoNewline
|
||||
Write-Host " $($badge.Description)" -ForegroundColor Gray
|
||||
Write-Information " [$($badge.Output)] $($badge.Description)"
|
||||
|
||||
& $NDBadgePath --xml $XmlPath --metric $badge.Metric --output $outputPath
|
||||
|
||||
@@ -98,17 +97,17 @@ foreach ($badge in $HighValueBadges) {
|
||||
|
||||
|
||||
# Generate summary
|
||||
Write-Host "`n=== Badge Generation Complete ===" -ForegroundColor Green
|
||||
Write-Information "`n=== Badge Generation Complete ==="
|
||||
$generatedBadges = Get-ChildItem -Path $OutputDir -Filter "*.svg"
|
||||
Write-Host "Generated $($generatedBadges.Count) badges in: $OutputDir"
|
||||
Write-Information "Generated $($generatedBadges.Count) badges in: $OutputDir"
|
||||
|
||||
Write-Host "`nGenerated badges:" -ForegroundColor Green
|
||||
Write-Information "`nGenerated badges:"
|
||||
$HighValueBadges | ForEach-Object {
|
||||
Write-Host " - $($_.Output.PadRight(20)) : $($_.Description)" -ForegroundColor Gray
|
||||
Write-Information " - $($_.Output.PadRight(20)) : $($_.Description)"
|
||||
}
|
||||
|
||||
Write-Host "`nMarkdown snippet for README.md:" -ForegroundColor Cyan
|
||||
Write-Host @"
|
||||
Write-Information "`nMarkdown snippet for README.md:"
|
||||
Write-Information @"
|
||||
|
||||
## Quality Metrics
|
||||
|
||||
@@ -120,4 +119,4 @@ Write-Host @"
|
||||
[]()
|
||||
[]()
|
||||
|
||||
"@ -ForegroundColor Gray
|
||||
"@
|
||||
|
||||
+41
-31
@@ -46,7 +46,7 @@ if (-not (Test-Path $SolutionFile)) {
|
||||
# Helper function for section headers
|
||||
function Write-Section {
|
||||
param([string]$Message)
|
||||
Write-Host "`n=== $Message ===" -ForegroundColor Cyan
|
||||
Write-Information "`n=== $Message ==="
|
||||
}
|
||||
|
||||
# Track analysis failure
|
||||
@@ -58,25 +58,25 @@ try {
|
||||
if (-not (Test-Path $SarifDir)) {
|
||||
New-Item -ItemType Directory -Path $SarifDir -Force | Out-Null
|
||||
}
|
||||
Write-Host "SARIF directory: $SarifDir"
|
||||
Write-Information "SARIF directory: $SarifDir"
|
||||
|
||||
# Restore, clean, and build
|
||||
Write-Section "Cleaning and building solution (generates SARIF files)"
|
||||
|
||||
Write-Host "Restoring packages..." -ForegroundColor Gray
|
||||
Write-Information "Restoring packages..."
|
||||
dotnet restore $SolutionFile -v q
|
||||
if ($LASTEXITCODE -ne 0) { throw "Restore failed with exit code $LASTEXITCODE" }
|
||||
|
||||
Write-Host "Cleaning solution..." -ForegroundColor Gray
|
||||
Write-Information "Cleaning solution..."
|
||||
dotnet clean $SolutionFile -v q
|
||||
if ($LASTEXITCODE -ne 0) { throw "Clean failed with exit code $LASTEXITCODE" }
|
||||
|
||||
Write-Host "Removing old coverage data..." -ForegroundColor Gray
|
||||
Write-Information "Removing old coverage data..."
|
||||
if (Test-Path $CoverageDir) {
|
||||
Remove-Item -Path $CoverageDir -Recurse -Force
|
||||
}
|
||||
|
||||
Write-Host "Building solution..." -ForegroundColor Gray
|
||||
Write-Information "Building solution..."
|
||||
dotnet build $SolutionFile -c Debug --no-incremental
|
||||
if ($LASTEXITCODE -ne 0) { throw "Build failed with exit code $LASTEXITCODE" }
|
||||
|
||||
@@ -103,15 +103,16 @@ try {
|
||||
if ($LASTEXITCODE -ne 0) { throw "Tests failed for Quantower.Tests with exit code $LASTEXITCODE" }
|
||||
|
||||
# Find coverage files
|
||||
Write-Host "`nSearching for coverage files..." -ForegroundColor Gray
|
||||
Write-Information "`nSearching for coverage files..."
|
||||
$CoverageFiles = Get-ChildItem -Path $CoverageDir -Filter "coverage.opencover.xml" -Recurse -File |
|
||||
Select-Object -ExpandProperty FullName
|
||||
Select-Object -ExpandProperty FullName
|
||||
|
||||
if (-not $CoverageFiles) {
|
||||
Write-Warning "No coverage files found in $CoverageDir"
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$CoverageFiles | ForEach-Object {
|
||||
Write-Host "Coverage file: $_" -ForegroundColor Green
|
||||
Write-Information "Coverage file: $_"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,16 +121,18 @@ try {
|
||||
$InspectCodeOutput = Join-Path $SarifDir "resharper.sarif.json"
|
||||
$jbPath = Get-Command "jb" -ErrorAction SilentlyContinue
|
||||
if ($jbPath) {
|
||||
Write-Host "Running InspectCode analysis..." -ForegroundColor Gray
|
||||
Write-Information "Running InspectCode analysis..."
|
||||
jb inspectcode $SolutionFile --output=$InspectCodeOutput --format=Sarif --no-build
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Warning "InspectCode completed with exit code $LASTEXITCODE"
|
||||
} else {
|
||||
Write-Host "InspectCode SARIF saved to: $InspectCodeOutput" -ForegroundColor Green
|
||||
}
|
||||
} else {
|
||||
else {
|
||||
Write-Information "InspectCode SARIF saved to: $InspectCodeOutput"
|
||||
}
|
||||
}
|
||||
else {
|
||||
Write-Warning "JetBrains CLI (jb) not found. Skipping InspectCode analysis."
|
||||
Write-Host " Install with: dotnet tool install -g JetBrains.ReSharper.GlobalTools" -ForegroundColor Gray
|
||||
Write-Information " Install with: dotnet tool install -g JetBrains.ReSharper.GlobalTools"
|
||||
}
|
||||
|
||||
# List SARIF files
|
||||
@@ -137,10 +140,11 @@ try {
|
||||
$SarifFiles = Get-ChildItem -Path $SarifDir -Filter "*.json" -ErrorAction SilentlyContinue
|
||||
if ($SarifFiles) {
|
||||
$SarifFiles | ForEach-Object {
|
||||
Write-Host " $($_.Name) ($([math]::Round($_.Length / 1KB, 2)) KB)" -ForegroundColor Gray
|
||||
Write-Information " $($_.Name) ($([math]::Round($_.Length / 1KB, 2)) KB)"
|
||||
}
|
||||
} else {
|
||||
Write-Host "No SARIF files found" -ForegroundColor Yellow
|
||||
}
|
||||
else {
|
||||
Write-Information "No SARIF files found"
|
||||
}
|
||||
|
||||
# Activate NDepend license
|
||||
@@ -148,7 +152,8 @@ try {
|
||||
if (-not [string]::IsNullOrWhiteSpace($NdependLicense)) {
|
||||
dotnet $NdependDll --RegLic $NdependLicense
|
||||
if ($LASTEXITCODE -ne 0) { Write-Warning "License activation returned exit code $LASTEXITCODE" }
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Write-Warning "Skipping license activation (no license provided)"
|
||||
}
|
||||
|
||||
@@ -168,17 +173,20 @@ try {
|
||||
$AnalysisFailed = $true
|
||||
}
|
||||
|
||||
} catch {
|
||||
}
|
||||
catch {
|
||||
Write-Error "Script failed: $_"
|
||||
$AnalysisFailed = $true
|
||||
} finally {
|
||||
}
|
||||
finally {
|
||||
# Always deactivate license
|
||||
Write-Section "Deactivating NDepend license"
|
||||
if (-not [string]::IsNullOrWhiteSpace($NdependLicense)) {
|
||||
dotnet $NdependDll --UnregLic
|
||||
if ($LASTEXITCODE -ne 0) { Write-Warning "License deactivation returned exit code $LASTEXITCODE" }
|
||||
} else {
|
||||
Write-Host "Skipping license deactivation (no license provided)" -ForegroundColor Gray
|
||||
}
|
||||
else {
|
||||
Write-Information "Skipping license deactivation (no license provided)"
|
||||
}
|
||||
|
||||
# Generate badges from NDepend trend data
|
||||
@@ -188,9 +196,10 @@ try {
|
||||
$TrendMetricsDir = Join-Path $ScriptDir "NDependOut\TrendMetrics"
|
||||
$TrendXml = if (Test-Path $TrendMetricsDir) {
|
||||
Get-ChildItem -Path $TrendMetricsDir -Filter "NDependTrendData*.xml" -File |
|
||||
Sort-Object Name -Descending |
|
||||
Select-Object -First 1 -ExpandProperty FullName
|
||||
} else { $null }
|
||||
Sort-Object Name -Descending |
|
||||
Select-Object -First 1 -ExpandProperty FullName
|
||||
}
|
||||
else { $null }
|
||||
$BadgeDir = Join-Path $ScriptDir "badges"
|
||||
|
||||
if ((Test-Path $NDBadgePath) -and $TrendXml -and (Test-Path $TrendXml)) {
|
||||
@@ -212,18 +221,19 @@ try {
|
||||
$outputPath = Join-Path $BadgeDir $badge.Output
|
||||
& $NDBadgePath --xml $TrendXml --metric $badge.Metric --output $outputPath 2>$null
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Host " Generated: $($badge.Output)" -ForegroundColor Gray
|
||||
Write-Information " Generated: $($badge.Output)"
|
||||
}
|
||||
}
|
||||
Write-Host "Badges saved to: $BadgeDir" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "Skipping badge generation (NDBadge.exe or trend data not found)" -ForegroundColor Yellow
|
||||
Write-Information "Badges saved to: $BadgeDir"
|
||||
}
|
||||
else {
|
||||
Write-Information "Skipping badge generation (NDBadge.exe or trend data not found)"
|
||||
}
|
||||
|
||||
Write-Section "Done"
|
||||
|
||||
if ($AnalysisFailed) {
|
||||
Write-Host "Note: Analysis completed with quality gate failures" -ForegroundColor Yellow
|
||||
Write-Information "Note: Analysis completed with quality gate failures"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user