Skip to content

Instantly share code, notes, and snippets.

@house9
Created March 14, 2011 15:58
Show Gist options
  • Save house9/869367 to your computer and use it in GitHub Desktop.
Save house9/869367 to your computer and use it in GitHub Desktop.
powershell script to generate a TODO report
$fileName = "_2-DO_log.txt"
$max = 20
$encoding = "ASCII"
# remove previous file if exists
if(Test-Path $fileName) { Remove-Item $fileName }
# dump 2-do report to the file system
Get-ChildItem –rec –include *.config,*.cs,*.js,*.cshtml,*.css,*.aspx |
where { $_ -notmatch 'lib' } |
where { $_ -notmatch 'Test' } |
select-string TODO |
out-string -width 4096 |
out-file $fileName -encoding $encoding
# get the line count of the report
$content = Get-Content .\$fileName
$count = $content.Count.ToString()
# Write-Host "Total count is $count"
# verify we don't have too many entries
if($content.Count -gt $max)
{
$message = "TO DO comment count has been exceeded. Max Allowed is $max but found $count for the entire solution, excluding lib files and Test projects"
# prepend the message before the data
$message | out-file $fileName -encoding $encoding
$content | add-content $fileName
Throw [system.Exception]($message)
}
@jjmartin
Copy link

Thanks for a huge headstart on getting this info into my TeamCity build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment