Skip to content

Commit

Permalink
✨ adding complexity json output
Browse files Browse the repository at this point in the history
  • Loading branch information
MaaniBeigy committed Aug 11, 2024
1 parent 8c830fe commit c29bef4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .logs/complexity.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"complexity": "A"
}
Binary file modified .logs/complexity.txt
Binary file not shown.
22 changes: 22 additions & 0 deletions .shell/complexity.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Delete the 'complexity' files if it exists
Get-ChildItem -Path . -Recurse -Filter 'complexity.txt' | Remove-Item -Force
Get-ChildItem -Path . -Recurse -Filter 'complexity.json' | Remove-Item -Force

# Run radon using poetry and save the output to a log file
poetry run python -m radon cc pycvcqv -s -a | Out-File -FilePath ".logs/complexity.txt" -Append

# Extract the average complexity from the log file
$complexity = Select-String -Path ".logs/complexity.txt" -Pattern 'Average complexity:' | ForEach-Object {
$_.Line -split ' ' | Select-Object -Index 2
}

# Create an object to store the complexity in JSON format
$jsonOutput = @{
complexity = $complexity
} | ConvertTo-Json

# Save the JSON output to a file
$jsonOutput | Set-Content -Path ".logs/complexity.json"

# Output the complexity (for verification)
Write-Output "complexity: $complexity"

0 comments on commit c29bef4

Please sign in to comment.