Created
March 2, 2011 12:43
-
-
Save RhysC/850863 to your computer and use it in GitHub Desktop.
Recursively Gets the code quality details from the csroj files
This file contains hidden or 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
$projectSummarys = @{} | |
Get-ChildItem -exclude '*Test*' -Recurse -Include *.csproj | | |
Where-Object {$_.Attributes -ne "Directory"} | | |
%{ | |
$filename = $_.FullName | |
$proj = [xml](get-Content $filename); | |
$projectSummarys[$filename] = ($proj.Project.PropertyGroup)|select -Skip 1 -First 1 | | |
select WarningLevel, CodeAnalysisRuleSet, RunCodeAnalysis, TreatWarningsAsErrors | |
} | |
$WarningLevelNotvalid = @{} | |
$CodeAnalysisRuleSetNotvalid = @{} | |
$RunCodeAnalysis = @{} | |
$TreatWarningsAsErrors = @{} | |
$projectSummarys.GetEnumerator() | | |
%{ | |
if($_.Value.WarningLevel -ne 4) | |
{ | |
$WarningLevelNotvalid[$_.Name] = $_.Value.WarningLevel | |
} | |
if($_.Value.CodeAnalysisRuleSet -eq $null -or $_.Value.CodeAnalysisRuleSet.Contains("Alpha.ruleset") -eq $false) | |
{ | |
$CodeAnalysisRuleSetNotvalid[$_.Name] = $_.Value.CodeAnalysisRuleSet | |
} | |
if($_.Value.RunCodeAnalysis -eq $null -or $_.Value.RunCodeAnalysis.Contains("true") -eq $false) | |
{ | |
$RunCodeAnalysis[$_.Name] = $_.Value.RunCodeAnalysis | |
} | |
if($_.Value.TreatWarningsAsErrors -eq $null -or $_.Value.TreatWarningsAsErrors.Contains("true") -eq $false) | |
{ | |
$TreatWarningsAsErrors[$_.Name] = $_.Value.TreatWarningsAsErrors | |
} | |
} | |
#report results | |
Write-Host "Projects without warning level at 4" -ForegroundColor Yellow | |
$WarningLevelNotvalid.GetEnumerator() | % {Write-Host $_.Name} | |
Write-Host "Projects with incorrect CodeAnalysisRuleSet" -ForegroundColor Yellow | |
$CodeAnalysisRuleSetNotvalid.GetEnumerator() | % {Write-Host $_.Name} | |
Write-Host "Projects without RunCodeAnalysis" -ForegroundColor Yellow | |
$RunCodeAnalysis.GetEnumerator() | % {Write-Host $_.Name} | |
Write-Host "Projects without TreatWarningsAsErrors" -ForegroundColor Yellow | |
$TreatWarningsAsErrors.GetEnumerator() | % {Write-Host $_.Name} | |
$reportfile = "report.txt" | |
"Projects without warning level at 4" > $reportfile | |
$WarningLevelNotvalid.GetEnumerator() | % {$_.Name >> $reportfile} | |
"`r`nProjects with incorrect CodeAnalysisRuleSet" >> $reportfile | |
$CodeAnalysisRuleSetNotvalid.GetEnumerator() | % {$_.Name >> $reportfile} | |
"`r`nProjects without RunCodeAnalysis" >> $reportfile | |
$RunCodeAnalysis.GetEnumerator() | % {$_.Name >> $reportfile} | |
"`r`nProjects without TreatWarningsAsErrors" >> $reportfile | |
$TreatWarningsAsErrors.GetEnumerator() | % {$_.Name >> $reportfile} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment