Systematic code review and audit practices including automated checks, security audits, compliance verification, and review checklists.
Code Review & Audit
Purpose: Systematic validation of implementations against production guardrails. Focus: Self-review automation, manual review checklists, security audits, compliance verification.
Pre-Review Automated Checks
Run these before requesting human review or deploying.
Quick Check Script
# Run all automated checks
./scripts/pre-review-check.sh
# Or manually:
dotnet format --verify-no-changes
dotnet build --no-incremental
dotnet test --collect:"XPlat Code Coverage"
dotnet list package --vulnerable --include-transitive
PowerShell Pre-Review Script
# scripts/Pre-Review-Check.ps1
Write-Host "=== Pre-Review Automated Checks ===" -ForegroundColor Cyan
# 1. Format Check
Write-Host "`n[1/6] Checking code formatting..." -ForegroundColor Yellow
dotnet format --verify-no-changes
if ($LASTEXITCODE -ne 0) {
Write-Host "❌ Format issues found. Run 'dotnet format'" -ForegroundColor Red
exit 1
}
# 2. Build
Write-Host "`n[2/6] Building solution..." -ForegroundColor Yellow
dotnet build --no-incremental
if ($LASTEXITCODE -ne 0) {
Write-Host "❌ Build failed" -ForegroundColor Red
exit 1
}
# 3. Tests
Write-Host "`n[3/6] Running tests..." -ForegroundColor Yellow
dotnet test --no-build --verbosity minimal --collect:"XPlat Code Coverage"
if ($LASTEXITCODE -ne 0) {
Write-Host "❌ Tests failed" -ForegroundColor Red
exit 1
}
# 4. Coverage Check (requires ReportGenerator)
Write-Host "`n[4/6] Checking code coverage..." -ForegroundColor Yellow
$coverageFile = Get-ChildItem -Path "TestResults" -Filter "coverage.cobertura.xml" -Recurse | Select-Object -First 1
if ($coverageFile) {
$xml = [xml](Get-Content $coverageFile.FullName)
$coverage = [math]::Round([decimal]$xml.coverage.'line-rate' * 100, 2)
Write-Host "Coverage: $coverage%" -ForegroundColor Cyan
if ($coverage -lt 80) {
Write-Host "⚠️ Coverage below 80% threshold" -ForegroundColor Yellow
}
}
# 5. Security Vulnerabilities
Write-Host "`n[5/6] Checking for vulnerable packages..." -ForegroundColor Yellow
dotnet list package --vulnerable --include-transitive
if ($LASTEXITCODE -ne 0) {
Write-Host "❌ Vulnerable packages found" -ForegroundColor Red
exit 1
}
# 6. Static Analysis (if SonarScanner installed)
if (Get-Command "dotnet-sonarscanner" -ErrorAction SilentlyContinue) {
Write-Host "`n[6/6] Running SonarQube analysis..." -ForegroundColor Yellow
dotnet sonarscanner begin /k:"project-key"
dotnet build
dotnet sonarscanner end
}
Write-Host "`n✅ All automated checks passed!" -ForegroundColor Green
Code Review Checklist
Architecture & Design (AGENTS.md Alignment)
Research → Design → Implement workflow followed
Architecture documented (ADRs for significant decisions)
SOLID principles adhered to (especially SRP, DIP)
Design patterns used appropriately (not over-engineered)
No premature optimization (YAGNI principle)
Code Quality
Single Responsibility - Each class/method does one thing
DRY - No code duplication (extracted to methods/classes)
KISS - Simple solution, not over-complicated
Meaningful names - Self-documenting code
Functions < 50 lines - Long methods refactored
No magic numbers - Constants with clear names
No dead code - Unused code removed
No commented code - Remove or document why kept
Type Safety & Documentation
Type annotations on all parameters and return values
Nullable reference types handled correctly
XML documentation on all public APIs
Inline comments explain "why", not "what"
README updated with new features/changes
API documentation generated and accurate
Error Handling
Specific exceptions caught (not generic Exception)