-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ adding maintainability json output
- Loading branch information
1 parent
ee5b056
commit 5752970
Showing
3 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"maintainability": "93.8%%" | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Delete the 'maintainability.txt' file if it exists | ||
Get-ChildItem -Path . -Recurse -Filter 'maintainability.txt' | Remove-Item -Force | ||
|
||
# Run radon to calculate the maintainability index and save the output to a log file | ||
poetry run python -m radon mi pycvcqv -s | Out-File -FilePath ".logs/maintainability.txt" -Append | ||
|
||
# Extract and calculate the maintainability score | ||
$maintainabilityScores = poetry run python -m radon mi pycvcqv -s | Select-String -Pattern '\((.*?)\)' | ForEach-Object { | ||
$_.Matches.Value.Trim('()') | ||
} | ||
|
||
# Calculate the average maintainability score | ||
$total = 0 | ||
$count = 0 | ||
|
||
foreach ($score in $maintainabilityScores) { | ||
$total += [double]$score | ||
$count++ | ||
} | ||
|
||
$averageMaintainability = if ($count -gt 0) { | ||
$average = $total / $count | ||
"{0:N1}%%" -f $average | ||
} | ||
else { | ||
"0.0%%" | ||
} | ||
|
||
# Output the maintainability score (for verification) | ||
Write-Output "maintainability: $averageMaintainability" | ||
|
||
# Create an object to store the maintainability in JSON format | ||
$jsonOutput = @{ | ||
maintainability = $averageMaintainability | ||
} | ConvertTo-Json | ||
|
||
# Save the JSON output to a file | ||
$jsonOutput | Set-Content -Path ".logs/maintainability.json" |